ADuCM4x50 Device Drivers API Reference Manual  Release 4.0.0.0
adi_spi.h
1 
15 #ifndef ADI_SPI_H__
16 #define ADI_SPI_H__
17 
18 #include <adi_processor.h>
19 #include <rtos_map/adi_rtos_map.h>
20 #include <adi_spi_config.h>
21 
27 #include <adi_spi_config.h>
28 #include <adi_callback.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33 
34 
41 #define ADI_SPI_MEMORY_SIZE (40u + ADI_SEM_SIZE)
42 
43 
53 typedef enum
54 {
88 
97 typedef enum
98 {
118 
120 
134 typedef enum
135 {
147 
148 
150 typedef struct __ADI_SPI_DEV_DATA_TYPE* ADI_SPI_HANDLE;
152 typedef const struct __ADI_SPI_DEV_DATA_TYPE* ADI_SPI_CONST_HANDLE;
153 
154 
212 typedef struct
213 {
215  uint8_t* pTransmitter;
217  uint8_t* pReceiver;
221  uint16_t ReceiverBytes;
223  uint8_t nTxIncrement;
225  uint8_t nRxIncrement;
227  bool bDMA;
229  bool bRD_CTL;
230 
232 
233 
234 
235 /******************************************************************************
236  * SPI Device External API function prototypes
237  *****************************************************************************/
238 
239 /* Device Initialization and Uninitialization Interfaces */
241  uint32_t nDeviceNum,
242  void *pDevMemory,
243  uint32_t nMemorySize,
244  ADI_SPI_HANDLE* const phDevice
245  );
246 
248  ADI_SPI_HANDLE const hDevice
249  );
250 
251 /******************************************************************
252  * Eliminatable functions that may be optimized out by the linker *
253  *****************************************************************/
254 
256  ADI_SPI_HANDLE const hDevice,
257  const ADI_SPI_TRANSCEIVER* const pXfr
258  );
259 
260 
262  ADI_SPI_CONST_HANDLE const hDevice,
263  const bool bFlag
264  );
265 
266 /* Slave Mode APIs */
268  ADI_SPI_HANDLE const hDevice,
269  const ADI_SPI_TRANSCEIVER* const pXfr
270  );
271 
272 /* Command/Data transceiver API */
274  ADI_SPI_HANDLE const hDevice,
275  const ADI_SPI_TRANSCEIVER* const pXfr
276  );
277 
279  ADI_SPI_HANDLE const hDevice,
280  const ADI_SPI_TRANSCEIVER*
281  const pXfr
282  );
283 
285  ADI_SPI_HANDLE const hDevice,
286  ADI_CALLBACK const pfCallback,
287  void *const pCBParam
288  );
289 
290 
291 /* Turn a non-blocking call into a blocking call. Wait for the transaction to complete */
293  ADI_SPI_HANDLE const hDevice,
294  uint32_t * const pHWErrors
295  );
296 
297 /* Hardware Configuration Interface */
299  ADI_SPI_HANDLE const hDevice,
300  const bool bFlag
301  );
302 
304  ADI_SPI_HANDLE const hDevice,
305  const bool bFlag
306  );
307 
308 /* Query function for the data transfer completion */
310  ADI_SPI_CONST_HANDLE const hDevice,
311  bool* const bComplete
312  );
313 
314 
315 
317  ADI_SPI_CONST_HANDLE const hDevice,
318  const bool bFlag
319  );
320 
321 
323  ADI_SPI_CONST_HANDLE const hDevice,
324  const bool bFlag
325  );
326 
328  ADI_SPI_CONST_HANDLE const hDevice,
329  const uint8_t nMode);
330 
332  ADI_SPI_CONST_HANDLE const hDevice,
333  const bool bFlag
334  );
335 
337  ADI_SPI_CONST_HANDLE const hDevice,
338  const bool bFlag
339  );
340 
341 /* Mode Configuration Interface */
343  ADI_SPI_CONST_HANDLE const hDevice,
344  const uint32_t Hertz
345  );
347  ADI_SPI_HANDLE const hDevice,
348  const ADI_SPI_CHIP_SELECT eChipSelect
349  );
350 
352  ADI_SPI_CONST_HANDLE const hDevice,
353  uint32_t* const pnBitrate
354  );
355 
356 
357 #ifdef __cplusplus
358 }
359 #endif
360 
361 
365 #endif /* ADI_SPI_H__ */
366 
ADI_SPI_RESULT adi_spi_SetTransmitUnderflow(ADI_SPI_CONST_HANDLE const hDevice, const bool bFlag)
Set the SPI transmit FIFO underflow mode.
Definition: adi_spi.c:527
ADI_SPI_RESULT adi_spi_GetBuffer(ADI_SPI_HANDLE const hDevice, uint32_t *const pHWErrors)
Block until the SPI transaction is complete.
Definition: adi_spi.c:1213
ADI_SPI_RESULT adi_spi_SlaveReadWrite(ADI_SPI_HANDLE const hDevice, const ADI_SPI_TRANSCEIVER *const pXfr)
Submit data buffers for SPI Slave-Mode transaction in "Blocking mode".This function returns only af...
Definition: adi_spi.c:1536
uint16_t TransmitterBytes
Definition: adi_spi.h:219
uint8_t * pReceiver
Definition: adi_spi.h:217
uint8_t * pTransmitter
Definition: adi_spi.h:215
ADI_SPI_RESULT
Definition: adi_spi.h:53
ADI_SPI_RESULT adi_spi_SetClockPhase(ADI_SPI_HANDLE const hDevice, const bool bFlag)
Set the clock phase.
Definition: adi_spi.c:759
ADI_SPI_RESULT adi_spi_SetContinuousMode(ADI_SPI_CONST_HANDLE const hDevice, const bool bFlag)
Set the continuous transfer mode.
Definition: adi_spi.c:377
ADI_SPI_RESULT adi_spi_Open(uint32_t nDeviceNum, void *pDevMemory, uint32_t nMemorySize, ADI_SPI_HANDLE *const phDevice)
Initialize and allocate an SPI device for use in Master Mode.
Definition: adi_spi.c:154
ADI_SPI_RESULT adi_spi_Close(ADI_SPI_HANDLE const hDevice)
Uninitialize and deallocate an SPI device.
Definition: adi_spi.c:250
ADI_SPI_RESULT adi_spi_isBufferAvailable(ADI_SPI_CONST_HANDLE const hDevice, bool *const bComplete)
Get the SPI transaction completion status.
Definition: adi_spi.c:1248
ADI_SPI_RESULT adi_spi_SetChipSelect(ADI_SPI_HANDLE const hDevice, const ADI_SPI_CHIP_SELECT eChipSelect)
Set the chip select.
Definition: adi_spi.c:715
uint8_t nRxIncrement
Definition: adi_spi.h:225
ADI_SPI_RESULT adi_spi_SetLoopback(ADI_SPI_CONST_HANDLE const hDevice, const bool bFlag)
Set the internal loopback mode.
Definition: adi_spi.c:411
ADI_SPI_RESULT adi_spi_GetBitrate(ADI_SPI_CONST_HANDLE const hDevice, uint32_t *const pnBitrate)
Get the SPI serial clock frequency.
Definition: adi_spi.c:626
ADI_SPI_RESULT adi_spi_RegisterCallback(ADI_SPI_HANDLE const hDevice, ADI_CALLBACK const pfCallback, void *const pCBParam)
Register or unregister the callback.
Definition: adi_spi.c:289
ADI_SPI_RESULT adi_spi_SetClockPolarity(ADI_SPI_HANDLE const hDevice, const bool bFlag)
Set the clock polarity.
Definition: adi_spi.c:680
ADI_SPI_RESULT adi_spi_SetIrqmode(ADI_SPI_CONST_HANDLE const hDevice, const uint8_t nMode)
Set the IRQ mode.
Definition: adi_spi.c:337
ADI_SPI_RESULT adi_spi_SetReceiveOverflow(ADI_SPI_CONST_HANDLE const hDevice, const bool bFlag)
Set the SPI receive FIFO overflow mode.
Definition: adi_spi.c:489
ADI_SPI_HW_ERRORS
Definition: adi_spi.h:97
ADI_SPI_RESULT adi_spi_MasterReadWrite(ADI_SPI_HANDLE const hDevice, const ADI_SPI_TRANSCEIVER *const pXfr)
Submit data buffers for SPI Master-Mode transaction in "Blocking mode".This function returns only a...
Definition: adi_spi.c:804
struct __ADI_SPI_DEV_DATA_TYPE * ADI_SPI_HANDLE
Definition: adi_spi.h:150
uint16_t ReceiverBytes
Definition: adi_spi.h:221
ADI_SPI_RESULT adi_spi_SetMasterMode(ADI_SPI_CONST_HANDLE const hDevice, const bool bFlag)
Set SPI Master-Mode operation.
Definition: adi_spi.c:446
ADI_SPI_CHIP_SELECT
Definition: adi_spi.h:134
const struct __ADI_SPI_DEV_DATA_TYPE * ADI_SPI_CONST_HANDLE
Definition: adi_spi.h:152
uint8_t nTxIncrement
Definition: adi_spi.h:223
ADI_SPI_RESULT adi_spi_SlaveSubmitBuffer(ADI_SPI_HANDLE const hDevice, const ADI_SPI_TRANSCEIVER *const pXfr)
Submit data buffers for SPI Slave-Mode transaction.
Definition: adi_spi.c:1291
ADI_SPI_RESULT adi_spi_SetBitrate(ADI_SPI_CONST_HANDLE const hDevice, const uint32_t Hertz)
Set the SPI serial clock frequency.
Definition: adi_spi.c:569
ADI_SPI_RESULT adi_spi_MasterSubmitBuffer(ADI_SPI_HANDLE const hDevice, const ADI_SPI_TRANSCEIVER *const pXfr)
Submit data buffers for SPI Master-Mode transaction.
Definition: adi_spi.c:844