| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
spi_8xx.h
Go to the documentation of this file.
1 /*
2 * @brief LPC8xx SPI inclusion file
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 __SPI_8XX_H_
33 #define __SPI_8XX_H_
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
47 typedef IP_SPI_CONFIG_T SPI_CONFIG_T;
48 typedef IP_SPI_DELAY_CONFIG_T SPI_DELAY_CONFIG_T;
49
53 typedef struct {
54 uint16_t *pTx;
55 uint32_t TxCnt;/* Transmit Counter */
56 uint16_t *pRx;
57 uint32_t RxCnt;/* Transmit Counter */
58 uint32_t Length;
59 uint16_t DataSize;
60 } CHIP_SPI_DATA_SETUP_T;
61
68 void Chip_SPI_Init(LPC_SPI_T *pSPI, SPI_CONFIG_T *pConfig);
69
76 uint32_t Chip_SPI_CalClkRateDivider(LPC_SPI_T *pSPI, uint32_t bitRate);
77
85 STATIC INLINE void Chip_SPI_DelayConfig(LPC_SPI_T *pSPI, SPI_DELAY_CONFIG_T *pConfig)
86 {
87 IP_SPI_DelayConfig(pSPI, pConfig);
88 }
89
96 void Chip_SPI_DeInit(LPC_SPI_T *pSPI);
97
105 void Chip_SPI_Int_Cmd(LPC_SPI_T *pSPI, uint32_t IntMask, FunctionalState NewState);
106
112 STATIC INLINE void Chip_SPI_Enable(IP_SPI_002_T *pSPI)
113 {
114 IP_SPI_Enable(pSPI);
115 }
116
122 STATIC INLINE void Chip_SPI_Disable(IP_SPI_002_T *pSPI)
123 {
124 IP_SPI_Disable(pSPI);
125 }
126
134 STATIC INLINE void Chip_SPI_EnableLoopBack(LPC_SPI_T *pSPI)
135 {
136 IP_SPI_EnableLoopBack(pSPI);
137 }
138
146 STATIC INLINE void Chip_SPI_DisableLoopBack(LPC_SPI_T *pSPI)
147 {
148 IP_SPI_DisableLoopBack(pSPI);
149 }
150
156 STATIC INLINE uint32_t Chip_SPI_GetStatus(LPC_SPI_T *pSPI)
157 {
158 return IP_SPI_GetStatus(pSPI);
159 }
160
168 STATIC INLINE void Chip_SPI_SendFirstFrame_RxIgnore(LPC_SPI_T *pSPI, uint16_t Data, uint8_t DataSize)
169 {
170 IP_SPI_SendFrameAndControl(pSPI,
171 Data,
172 DataSize,
173 SPI_TXDATCTL_ASSERT_SSEL | SPI_TXDATCTL_EOF | SPI_TXDATCTL_RXIGNORE);
174 }
175
183 STATIC INLINE void Chip_SPI_SendFirstFrame(LPC_SPI_T *pSPI, uint16_t Data, uint8_t DataSize)
184 {
185 IP_SPI_SendFrameAndControl(pSPI, Data, DataSize, SPI_TXDATCTL_ASSERT_SSEL | SPI_TXDATCTL_EOF);
186 }
187
194 STATIC INLINE void Chip_SPI_SendMidFrame(LPC_SPI_T *pSPI, uint16_t Data)
195 {
196 IP_SPI_SendFrame(pSPI, Data);
197 }
198
206 STATIC INLINE void Chip_SPI_SendLastFrame_RxIgnore(LPC_SPI_T *pSPI, uint16_t Data, uint8_t DataSize)
207 {
208 IP_SPI_SendFrameAndControl(pSPI,
209 Data,
210 DataSize,
211 SPI_TXDATCTL_ASSERT_SSEL | SPI_TXDATCTL_EOF | SPI_TXDATCTL_EOT | SPI_TXDATCTL_RXIGNORE);
212 }
213
221 STATIC INLINE void Chip_SPI_SendLastFrame(LPC_SPI_T *pSPI, uint16_t Data, uint8_t DataSize)
222 {
223 IP_SPI_SendFrameAndControl(pSPI, Data, DataSize, SPI_TXDATCTL_ASSERT_SSEL | SPI_TXDATCTL_EOF | SPI_TXDATCTL_EOT);
224 }
225
231 STATIC INLINE uint16_t Chip_SPI_ReceiveFrame(LPC_SPI_T *pSPI)
232 {
233 return IP_SPI_ReceiveFrame(pSPI);
234 }
235
243 Status Chip_SPI_Int_RWFrames(LPC_SPI_T *pSPI, CHIP_SPI_DATA_SETUP_T *xf_setup);
244
256 uint32_t Chip_SPI_RWFrames_Blocking(LPC_SPI_T *pSPI, CHIP_SPI_DATA_SETUP_T *pXfSetup);
257
268 uint32_t Chip_SPI_WriteFrames_Blocking(LPC_SPI_T *pSPI, CHIP_SPI_DATA_SETUP_T *pXfSetup);
269
280 uint32_t Chip_SPI_ReadFrames_Blocking(LPC_SPI_T *pSPI, CHIP_SPI_DATA_SETUP_T *pXfSetup);
281
286 #ifdef __cplusplus
287 }
288 #endif
289
290 #endif /* __SPI_8XX_H_ */