ADuCM302x Device Drivers API Reference Manual  Release 3.1.2.0
adi_sport.h
1 
45 #ifndef ADI_SPORT_H
46 #define ADI_SPORT_H
47 
48 /*============= I N C L U D E S =============*/
49 
50 #include <adi_processor.h>
51 #include <rtos_map/adi_rtos_map.h>
52 #include <drivers/dma/adi_dma.h>
53 #include <adi_callback.h>
54 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif /* __cplusplus */
62 
63 
64 /*============== D E F I N E S ===============*/
65 
71 #define ADI_SPORT_MEMORY_SIZE (76u + ADI_SEM_SIZE)
72 
73 typedef void* ADI_SPORT_HANDLE;
78 typedef enum
79 {
83 
87 typedef enum
88 {
92 
96 typedef enum
97 {
99  ADI_SPORT_8BIT_PACKING = ENUM_SPORT_CTL_A_CTL_PACK_8BIT,
100  ADI_SPORT_16BIT_PACKING = ENUM_SPORT_CTL_A_CTL_PACK_16BIT
102 
106  typedef enum
107 {
120 
121 
125 typedef enum
126 {
141 
142 /*============= P U B L I C F U N C T I O N S =============*/
143 
144 /* Opens a SPORT device */
145 ADI_SPORT_RESULT adi_sport_Open(
146  const uint32_t nDevNum,
147  const ADI_SPORT_CHANNEL eChannel,
148  const ADI_SPORT_DIRECTION eDirection,
149  void *pMemory,
150  const uint32_t nMemSize,
151  ADI_SPORT_HANDLE * const phDevice
152  );
153 
154 /* Closes a SPORT device */
155 ADI_SPORT_RESULT adi_sport_Close(
156  ADI_SPORT_HANDLE const hDevice
157  );
158 
159 /* Submits a buffer to the driver */
160 ADI_SPORT_RESULT adi_sport_SubmitBuffer(
161  ADI_SPORT_HANDLE const hDevice,
162  void * const pBuffer,
163  uint32_t const nNumBytes,
164  bool const bDMA
165  );
166 
167 /* Get the processed buffer from the driver */
168 ADI_SPORT_RESULT adi_sport_GetBuffer(
169  ADI_SPORT_HANDLE const hDevice,
170  void ** const ppBuffer,
171  uint32_t * pHwError
172  );
173 
174 /* Peek function to know whether an processed buffer is avilable */
175 ADI_SPORT_RESULT adi_sport_IsBufferAvailable(
176  ADI_SPORT_HANDLE const hDevice,
177  bool * const pbAvailable
178  );
179 
180 /* To register the callback function */
181 ADI_SPORT_RESULT adi_sport_RegisterCallback(
182  ADI_SPORT_HANDLE const hDevice,
183  const ADI_CALLBACK pfCallback,
184  void * const pCBparam
185  );
186 
187 /* Configure the data */
188 ADI_SPORT_RESULT adi_sport_ConfigData(
189  ADI_SPORT_HANDLE const hDevice,
190  const uint8_t nWordLength,
191  const ADI_SPORT_PACKING_MODE ePackMode,
192  const bool bLSBFirst
193  );
194 
195 /* Configure the clock */
196 ADI_SPORT_RESULT adi_sport_ConfigClock(
197  ADI_SPORT_HANDLE const hDevice,
198  const uint16_t nClockRatio,
199  const bool bUseIntlClock,
200  const bool bRisingEdge,
201  const bool bGatedClk
202  );
203 
204 /* Configure the frame sync */
205 ADI_SPORT_RESULT adi_sport_ConfigFrameSync(
206  ADI_SPORT_HANDLE const hDevice,
207  const uint16_t nFsDivisor,
208  const bool bFSRequired,
209  const bool bInternalFS,
210  const bool bDataFS,
211  const bool bActiveLowFS,
212  const bool bLateFS,
213  const bool bFSErrorOperation
214  );
215 
216 /* To mux the half-SPORT; this makes the device to use FS and Clock from other half-SPORT */
217 ADI_SPORT_RESULT adi_sport_MultiplexSportSignal(
218  ADI_SPORT_HANDLE const hDevice,
219  const bool bUseOtherFS,
220  const bool bUseOtherClk
221  );
222 
223 /* To configure the SPORT in timer mode */
224 ADI_SPORT_RESULT adi_sport_ConfigTimerMode(
225  ADI_SPORT_HANDLE const hDevice,
226  const uint8_t nFSDuration,
227  const uint8_t nWidth,
228  const bool bActiveLow
229  );
230 
231 #ifdef __cplusplus
232 }
233 #endif /* __cplusplus */
234 
235 #endif /* ADI_SPORT_H */
236 
ADI_SPORT_DIRECTION
Definition: adi_sport.h:87
ADI_SPORT_RESULT adi_sport_MultiplexSportSignal(ADI_SPORT_HANDLE const hDevice, const bool bUseOtherFS, const bool bUseOtherClk)
Configure the SPORT use the Clocks and Frame Sync of other Half-Sport.
Definition: adi_sport.c:1289
void * ADI_SPORT_HANDLE
Definition: adi_sport.h:73
ADI_SPORT_CHANNEL
Definition: adi_sport.h:78
ADI_SPORT_RESULT adi_sport_ConfigData(ADI_SPORT_HANDLE const hDevice, const uint8_t nWordLength, const ADI_SPORT_PACKING_MODE ePackMode, const bool bLSBFirst)
Sets data format for the specified SPORT device.
Definition: adi_sport.c:930
ADI_SPORT_RESULT adi_sport_SubmitBuffer(ADI_SPORT_HANDLE const hDevice, void *const pBuffer, uint32_t const nNumBytes, bool const bDMA)
Submit the buffer for transmitting/receiving the data. This function can be used to submit the buffer...
Definition: adi_sport.c:379
ADI_SPORT_RESULT adi_sport_ConfigTimerMode(ADI_SPORT_HANDLE const hDevice, const uint8_t nFSDuration, const uint8_t nWidth, const bool bActiveLow)
Configure the SPORT use the Clocks and Frame Sync of other Half-Sport.
Definition: adi_sport.c:1353
ADI_SPORT_RESULT adi_sport_Close(ADI_SPORT_HANDLE const hDevice)
Closes the operation of specified SPORT device.
Definition: adi_sport.c:324
ADI_SPORT_RESULT adi_sport_ConfigClock(ADI_SPORT_HANDLE const hDevice, const uint16_t nClockRatio, const bool bUseIntlClock, const bool bRisingEdge, const bool bGatedClk)
Configure the clock for the specified SPORT device.
Definition: adi_sport.c:1062
ADI_SPORT_RESULT adi_sport_IsBufferAvailable(ADI_SPORT_HANDLE const hDevice, bool *const pbAvailable)
Peek function to know whether an empty/filled buffer is available. Call to this function is valid onl...
Definition: adi_sport.c:809
ADI_SPORT_PACKING_MODE
Definition: adi_sport.h:96
ADI_SPORT_RESULT adi_sport_Open(const uint32_t nDevNum, const ADI_SPORT_CHANNEL eChannel, const ADI_SPORT_DIRECTION eDirection, void *pMemory, const uint32_t nMemSize, ADI_SPORT_HANDLE *const phDevice)
Initialization function for SPORT device.
Definition: adi_sport.c:224
ADI_SPORT_RESULT
Definition: adi_sport.h:125
ADI_SPORT_RESULT adi_sport_RegisterCallback(ADI_SPORT_HANDLE const hDevice, const ADI_CALLBACK pfCallback, void *const pCBparam)
Register and unregister a Callback function with the SPORT device driver. A registered call back func...
Definition: adi_sport.c:867
ADI_SPORT_RESULT adi_sport_GetBuffer(ADI_SPORT_HANDLE const hDevice, void **const ppBuffer, uint32_t *pHwError)
This function returns the address of a processed buffer. This is a blocking function: it waits until ...
Definition: adi_sport.c:748
ADI_SPORT_EVENT
Definition: adi_sport.h:106
ADI_SPORT_RESULT adi_sport_ConfigFrameSync(ADI_SPORT_HANDLE const hDevice, const uint16_t nFsDivisor, const bool bFSRequired, const bool bInternalFS, const bool bDataFS, const bool bActiveLowFS, const bool bLateFS, const bool bFSErrorOperation)
Frame Sync(FS) configuration for the specified SPORT.
Definition: adi_sport.c:1193