27 #ifndef LPC17XX_SSP_H_
28 #define LPC17XX_SSP_H_
49 #define SSP_CPHA_FIRST ((uint32_t)(0))
50 #define SSP_CPHA_SECOND SSP_CR0_CPHA_SECOND
60 #define SSP_CPOL_HI ((uint32_t)(0))
61 #define SSP_CPOL_LO SSP_CR0_CPOL_HI
64 #define SSP_SLAVE_MODE SSP_CR1_SLAVE_EN
65 #define SSP_MASTER_MODE ((uint32_t)(0))
68 #define SSP_DATABIT_4 SSP_CR0_DSS(4)
69 #define SSP_DATABIT_5 SSP_CR0_DSS(5)
70 #define SSP_DATABIT_6 SSP_CR0_DSS(6)
71 #define SSP_DATABIT_7 SSP_CR0_DSS(7)
72 #define SSP_DATABIT_8 SSP_CR0_DSS(8)
73 #define SSP_DATABIT_9 SSP_CR0_DSS(9)
74 #define SSP_DATABIT_10 SSP_CR0_DSS(10)
75 #define SSP_DATABIT_11 SSP_CR0_DSS(11)
76 #define SSP_DATABIT_12 SSP_CR0_DSS(12)
77 #define SSP_DATABIT_13 SSP_CR0_DSS(13)
78 #define SSP_DATABIT_14 SSP_CR0_DSS(14)
79 #define SSP_DATABIT_15 SSP_CR0_DSS(15)
80 #define SSP_DATABIT_16 SSP_CR0_DSS(16)
84 #define SSP_FRAME_SPI SSP_CR0_FRF_SPI
86 #define SSP_FRAME_TI SSP_CR0_FRF_TI
88 #define SSP_FRAME_MICROWIRE SSP_CR0_FRF_MICROWIRE
94 #define SSP_STAT_TXFIFO_EMPTY SSP_SR_TFE
96 #define SSP_STAT_TXFIFO_NOTFULL SSP_SR_TNF
98 #define SSP_STAT_RXFIFO_NOTEMPTY SSP_SR_RNE
100 #define SSP_STAT_RXFIFO_FULL SSP_SR_RFF
102 #define SSP_STAT_BUSY SSP_SR_BSY
108 #define SSP_INTCFG_ROR SSP_IMSC_ROR
110 #define SSP_INTCFG_RT SSP_IMSC_RT
112 #define SSP_INTCFG_RX SSP_IMSC_RX
114 #define SSP_INTCFG_TX SSP_IMSC_TX
120 #define SSP_INTSTAT_ROR SSP_MIS_ROR
122 #define SSP_INTSTAT_RT SSP_MIS_RT
124 #define SSP_INTSTAT_RX SSP_MIS_RX
126 #define SSP_INTSTAT_TX SSP_MIS_TX
132 #define SSP_INTSTAT_RAW_ROR SSP_RIS_ROR
134 #define SSP_INTSTAT_RAW_RT SSP_RIS_RT
136 #define SSP_INTSTAT_RAW_RX SSP_RIS_RX
138 #define SSP_INTSTAT_RAW_TX SSP_RIS_TX
145 #define SSP_INTCLR_ROR SSP_ICR_ROR
148 #define SSP_INTCLR_RT SSP_ICR_RT
154 #define SSP_DMA_RX SSP_DMA_RXDMA_EN
156 #define SSP_DMA_TX SSP_DMA_TXDMA_EN
159 #define SSP_STAT_DONE (1UL<<8)
160 #define SSP_STAT_ERROR (1UL<<9)
176 #define SSP_CR0_DSS(n) ((uint32_t)((n-1)&0xF))
178 #define SSP_CR0_FRF_SPI ((uint32_t)(0<<4))
180 #define SSP_CR0_FRF_TI ((uint32_t)(1<<4))
182 #define SSP_CR0_FRF_MICROWIRE ((uint32_t)(2<<4))
185 #define SSP_CR0_CPOL_HI ((uint32_t)(1<<6))
188 #define SSP_CR0_CPHA_SECOND ((uint32_t)(1<<7))
191 #define SSP_CR0_SCR(n) ((uint32_t)((n&0xFF)<<8))
193 #define SSP_CR0_BITMASK ((uint32_t)(0xFFFF))
199 #define SSP_CR1_LBM_EN ((uint32_t)(1<<0))
201 #define SSP_CR1_SSP_EN ((uint32_t)(1<<1))
203 #define SSP_CR1_SLAVE_EN ((uint32_t)(1<<2))
206 #define SSP_CR1_SO_DISABLE ((uint32_t)(1<<3))
208 #define SSP_CR1_BITMASK ((uint32_t)(0x0F))
214 #define SSP_DR_BITMASK(n) ((n)&0xFFFF)
220 #define SSP_SR_TFE ((uint32_t)(1<<0))
222 #define SSP_SR_TNF ((uint32_t)(1<<1))
224 #define SSP_SR_RNE ((uint32_t)(1<<2))
226 #define SSP_SR_RFF ((uint32_t)(1<<3))
228 #define SSP_SR_BSY ((uint32_t)(1<<4))
230 #define SSP_SR_BITMASK ((uint32_t)(0x1F))
236 #define SSP_CPSR_CPDVSR(n) ((uint32_t)(n&0xFF))
238 #define SSP_CPSR_BITMASK ((uint32_t)(0xFF))
244 #define SSP_IMSC_ROR ((uint32_t)(1<<0))
246 #define SSP_IMSC_RT ((uint32_t)(1<<1))
248 #define SSP_IMSC_RX ((uint32_t)(1<<2))
250 #define SSP_IMSC_TX ((uint32_t)(1<<3))
252 #define SSP_IMSC_BITMASK ((uint32_t)(0x0F))
258 #define SSP_RIS_ROR ((uint32_t)(1<<0))
260 #define SSP_RIS_RT ((uint32_t)(1<<1))
262 #define SSP_RIS_RX ((uint32_t)(1<<2))
264 #define SSP_RIS_TX ((uint32_t)(1<<3))
266 #define SSP_RIS_BITMASK ((uint32_t)(0x0F))
272 #define SSP_MIS_ROR ((uint32_t)(1<<0))
274 #define SSP_MIS_RT ((uint32_t)(1<<1))
276 #define SSP_MIS_RX ((uint32_t)(1<<2))
278 #define SSP_MIS_TX ((uint32_t)(1<<3))
280 #define SSP_MIS_BITMASK ((uint32_t)(0x0F))
287 #define SSP_ICR_ROR ((uint32_t)(1<<0))
290 #define SSP_ICR_RT ((uint32_t)(1<<1))
292 #define SSP_ICR_BITMASK ((uint32_t)(0x03))
298 #define SSP_DMA_RXDMA_EN ((uint32_t)(1<<0))
300 #define SSP_DMA_TXDMA_EN ((uint32_t)(1<<1))
302 #define SSP_DMA_BITMASK ((uint32_t)(0x03))
307 #define PARAM_SSPx(n) ((((uint32_t *)n)==((uint32_t *)LPC_SSP0)) \
308 || (((uint32_t *)n)==((uint32_t *)LPC_SSP1)))
311 #define PARAM_SSP_CPHA(n) ((n==SSP_CPHA_FIRST) || (n==SSP_CPHA_SECOND))
314 #define PARAM_SSP_CPOL(n) ((n==SSP_CPOL_HI) || (n==SSP_CPOL_LO))
317 #define PARAM_SSP_MODE(n) ((n==SSP_SLAVE_MODE) || (n==SSP_MASTER_MODE))
320 #define PARAM_SSP_DATABIT(n) ((n==SSP_DATABIT_4) || (n==SSP_DATABIT_5) \
321 || (n==SSP_DATABIT_6) || (n==SSP_DATABIT_16) \
322 || (n==SSP_DATABIT_7) || (n==SSP_DATABIT_8) \
323 || (n==SSP_DATABIT_9) || (n==SSP_DATABIT_10) \
324 || (n==SSP_DATABIT_11) || (n==SSP_DATABIT_12) \
325 || (n==SSP_DATABIT_13) || (n==SSP_DATABIT_14) \
326 || (n==SSP_DATABIT_15))
329 #define PARAM_SSP_FRAME(n) ((n==SSP_FRAME_SPI) || (n==SSP_FRAME_TI)\
330 || (n==SSP_FRAME_MICROWIRE))
333 #define PARAM_SSP_STAT(n) ((n==SSP_STAT_TXFIFO_EMPTY) || (n==SSP_STAT_TXFIFO_NOTFULL) \
334 || (n==SSP_STAT_RXFIFO_NOTEMPTY) || (n==SSP_STAT_RXFIFO_FULL) \
335 || (n==SSP_STAT_BUSY))
338 #define PARAM_SSP_INTCFG(n) ((n==SSP_INTCFG_ROR) || (n==SSP_INTCFG_RT) \
339 || (n==SSP_INTCFG_RX) || (n==SSP_INTCFG_TX))
342 #define PARAM_SSP_INTSTAT(n) ((n==SSP_INTSTAT_ROR) || (n==SSP_INTSTAT_RT) \
343 || (n==SSP_INTSTAT_RX) || (n==SSP_INTSTAT_TX))
346 #define PARAM_SSP_INTSTAT_RAW(n) ((n==SSP_INTSTAT_RAW_ROR) || (n==SSP_INTSTAT_RAW_RT) \
347 || (n==SSP_INTSTAT_RAW_RX) || (n==SSP_INTSTAT_RAW_TX))
350 #define PARAM_SSP_INTCLR(n) ((n==SSP_INTCLR_ROR) || (n==SSP_INTCLR_RT))
353 #define PARAM_SSP_DMA(n) ((n==SSP_DMA_TX) || (n==SSP_DMA_RX))