LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ssp_13xx.h
Go to the documentation of this file.
1 /*
2  * @brief LPC13xx SSP driver
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * All rights reserved.
7  *
8  * @par
9  * Software that is described herein is for illustrative purposes only
10  * which provides customers with programming information regarding the
11  * LPC products. This software is supplied "AS IS" without any warranties of
12  * any kind, and NXP Semiconductors and its licensor disclaim any and
13  * all warranties, express or implied, including all implied warranties of
14  * merchantability, fitness for a particular purpose and non-infringement of
15  * intellectual property rights. NXP Semiconductors assumes no responsibility
16  * or liability for the use of the software, conveys no license or rights under any
17  * patent, copyright, mask work right, or any other intellectual property rights in
18  * or to any products. NXP Semiconductors reserves the right to make changes
19  * in the software without notification. NXP Semiconductors also makes no
20  * representation or warranty that such application will be suitable for the
21  * specified use without further testing or modification.
22  *
23  * @par
24  * Permission to use, copy, modify, and distribute this software and its
25  * documentation is hereby granted, under NXP Semiconductors' and its
26  * licensor's relevant copyrights in the software, without fee, provided that it
27  * is used in conjunction with NXP Semiconductors microcontrollers. This
28  * copyright, permission, and disclaimer notice must appear in all copies of
29  * this code.
30  */
31 
32 #ifndef __SSP_13XX_H_
33 #define __SSP_13XX_H_
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
44 /*
45  * @brief SSP clock format
46  */
47 typedef enum CHIP_SSP_CLOCK_FORMAT {
48  SSP_CLOCK_CPHA0_CPOL0 = (0 << 6),
49  SSP_CLOCK_CPHA0_CPOL1 = (1u << 6),
50  SSP_CLOCK_CPHA1_CPOL0 = (2u << 6),
51  SSP_CLOCK_CPHA1_CPOL1 = (3u << 6),
57 
58 /*
59  * @brief SSP frame format
60  */
61 typedef enum CHIP_SSP_FRAME_FORMAT {
62  SSP_FRAMEFORMAT_SPI = (0 << 4),
66 
67 /*
68  * @brief Number of bits per frame
69  */
70 typedef enum CHIP_SSP_BITS {
71  SSP_BITS_4 = (3u << 0),
72  SSP_BITS_5 = (4u << 0),
73  SSP_BITS_6 = (5u << 0),
74  SSP_BITS_7 = (6u << 0),
75  SSP_BITS_8 = (7u << 0),
76  SSP_BITS_9 = (8u << 0),
77  SSP_BITS_10 = (9u << 0),
78  SSP_BITS_11 = (10u << 0),
79  SSP_BITS_12 = (11u << 0),
80  SSP_BITS_13 = (12u << 0),
81  SSP_BITS_14 = (13u << 0),
82  SSP_BITS_15 = (14u << 0),
83  SSP_BITS_16 = (15u << 0),
85 
86 /*
87  * @brief SSP config format
88  */
89 typedef struct SSP_ConfigFormat {
94 
95 /*
96  * @brief SSP mode
97  */
98 typedef enum CHIP_SSP_MODE {
99  SSP_MODE_MASTER = (0 << 2),
100  SSP_MODE_SLAVE = (1u << 2),
102 
103 /*
104  * @brief SPI address
105  */
106 typedef struct {
107  uint8_t port;
108  uint8_t pin;
109 } SPI_Address_t;
110 
111 /*
112  * @brief SSP data setup structure
113  */
114 typedef struct {
115  void *tx_data;
116  uint32_t tx_cnt;
117  void *rx_data;
118  uint32_t rx_cnt;
119  uint32_t length;
121 
124 #define SSP_CPHA_FIRST SSP_CR0_CPHA_FIRST
125 #define SSP_CPHA_SECOND SSP_CR0_CPHA_SECOND
126 
128 /* There's no bug here!!!
129  * - If bit[6] in SSPnCR0 is 0: SSP controller maintains the bus clock low between frames.
130  * That means the active clock is in HI state.
131  * - If bit[6] in SSPnCR0 is 1 (SSP_CR0_CPOL_HI): SSP controller maintains the bus clock
132  * high between frames. That means the active clock is in LO state.
133  */
134 #define SSP_CPOL_HI SSP_CR0_CPOL_LO
135 #define SSP_CPOL_LO SSP_CR0_CPOL_HI
136 
138 #define SSP_SLAVE_MODE SSP_CR1_SLAVE_EN
139 #define SSP_MASTER_MODE SSP_CR1_MASTER_EN
140 
153 {
154  return IP_SSP_GetStatus(pSSP, Stat);
155 }
156 
163 {
164  IP_SSP_Enable(pSSP);
165 }
166 
173 {
174  IP_SSP_Disable(pSSP);
175 }
176 
185 {
186  IP_SSP_EnableLoopBack(pSSP);
187 }
188 
197 {
199 }
200 
207 
216 
225 
238 
249 uint32_t Chip_SSP_WriteFrames_Blocking(LPC_SSP_T *pSSP, uint8_t *buffer, uint32_t buffer_len);
250 
261 uint32_t Chip_SSP_ReadFrames_Blocking(LPC_SSP_T *pSSP, uint8_t *buffer, uint32_t buffer_len);
262 
268 void Chip_SSP_Init(LPC_SSP_T *pSSP);
269 
275 void Chip_SSP_DeInit(LPC_SSP_T *pSSP);
276 
283 void Chip_SSP_SetMaster(LPC_SSP_T *pSSP, bool master);
284 
291 void Chip_SSP_SetBitRate(LPC_SSP_T *pSSP, uint32_t bitRate);
292 
300 {
301  IP_SSP_SetFormat(pSSP, format->bits, format->frameFormat, format->clockMode);
302 }
303 
310 {
312 }
313 
320 {
322 }
323 
328 #ifdef __cplusplus
329 }
330 #endif
331 
332 #endif /* __SSP_13XX_H_ */