AM275 FreeRTOS SDK  11.01.00
aasrc_ch.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2025 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
48 #ifndef AASRC_CH_H_
49 #define AASRC_CH_H_
50 
51 /* ========================================================================== */
52 /* Include Files */
53 /* ========================================================================== */
56 
57 /* None */
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 /* ========================================================================== */
64 /* Macros & Typedefs */
65 /* ========================================================================== */
66 
68 #define AASRC_DEFAULT_IN_FIFO_THRESHOLD (16U)
69 
70 #define AASRC_DEFAULT_OUT_FIFO_THRESHOLD (16U)
71 
73 #define AASRC_MAX_IN_FIFO_THRESHOLD (32U)
74 
75 #define AASRC_MAX_OUT_FIFO_THRESHOLD (16U)
76 
86 #define AASRC_CHANNEL_0 (0U)
87 #define AASRC_CHANNEL_1 (1U)
88 #define AASRC_CHANNEL_2 (2U)
89 #define AASRC_CHANNEL_3 (3U)
90 #define AASRC_CHANNEL_4 (4U)
91 #define AASRC_CHANNEL_5 (5U)
92 #define AASRC_CHANNEL_6 (6U)
93 #define AASRC_CHANNEL_7 (7U)
94 
105 #define AASRC_GROUP0 (0U)
106 #define AASRC_GROUP1 (1U)
107 #define AASRC_GROUP2 (2U)
108 #define AASRC_GROUP3 (3U)
109 
119 #define AASRC_SAMPLE_WORD_LENGTH_24 (24U)
120 #define AASRC_SAMPLE_WORD_LENGTH_20 (20U)
121 #define AASRC_SAMPLE_WORD_LENGTH_18 (18U)
122 #define AASRC_SAMPLE_WORD_LENGTH_16 (16U)
123 
134 #define AASRC_GROUP_DELAY_64 (64U)
135 #define AASRC_GROUP_DELAY_32 (32U)
136 #define AASRC_GROUP_DELAY_16 (16U)
137 #define AASRC_GROUP_DELAY_8 (8U)
138 
141 #define AASRC_MAX_ATTENUATION (255U)
142 
144 #define AASRC_MAX_DEEMPHASIS_MODES (4U)
145 
147 #define AASRC_SRC_FIFO_CONTROL_REG_OFFSET (0x00000010U)
148 
149 #define AASRC_SRC_FIFO_CONTROL(x) ((uint32_t) CSL_AASRC_CFG_SRC_FIFO_CONTROL_0 + \
150  (uint32_t) ((uint32_t) AASRC_SRC_FIFO_CONTROL_REG_OFFSET * \
151  (uint32_t) (x)))
152 
154 #define AASRC_SRC_CONTROL_REG_OFFSET (0x00000010U)
155 
156 #define AASRC_SRC_CONTROL(x) ((uint32_t) CSL_AASRC_CFG_SRC_CONTROL_0 + \
157  (uint32_t) ((uint32_t) AASRC_SRC_CONTROL_REG_OFFSET * \
158  (uint32_t) (x)))
159 
160 #define AASRC_SRC_STATUS_REG_OFFSET (0x00000010U)
161 
162 #define AASRC_SRC_STATUS(x) ((uint32_t) CSL_AASRC_CFG_SRC_STATUS_0 + \
163  (uint32_t) ((uint32_t) AASRC_SRC_STATUS_REG_OFFSET * \
164  (uint32_t) (x)))
165 
167 #define AASRC_GROUP_FIFO_CONTROL_REG_OFFSET (0x00000008U)
168 
169 #define AASRC_GROUP_FIFO_CONTROL(x) ((uint32_t) CSL_AASRC_CFG_GROUP_FIFO_CONTROL_0 + \
170  (uint32_t) ((uint32_t) AASRC_GROUP_FIFO_CONTROL_REG_OFFSET * \
171  (uint32_t) (x)))
172 
174 #define AASRC_GROUP_SRC_CONTROL_REG_OFFSET (0x00000008U)
175 
176 #define AASRC_GROUP_SRC_CONTROL(x) ((uint32_t) CSL_AASRC_CFG_GROUP_SRC_CONTROL_0 + \
177  (uint32_t) ((uint32_t) AASRC_GROUP_SRC_CONTROL_REG_OFFSET * \
178  (uint32_t) (x)))
179 
181 #define AASRC_GROUP_SELECT_REG_OFFSET (0x00000004U)
182 
183 #define AASRC_INPUT_GROUP_SELECT(x) ((uint32_t) CSL_AASRC_CFG_INPUT_GROUP_0_SELECT + \
184  (uint32_t) ((uint32_t) AASRC_GROUP_SELECT_REG_OFFSET * \
185  (uint32_t) (x)))
186 
187 #define AASRC_OUTPUT_GROUP_SELECT(x) ((uint32_t) CSL_AASRC_CFG_OUTPUT_GROUP_0_SELECT + \
188  (uint32_t) ((uint32_t) AASRC_GROUP_SELECT_REG_OFFSET * \
189  (uint32_t) (x)))
190 
191 /* ========================================================================== */
192 /* Structure Declarations */
193 /* ========================================================================== */
197 typedef struct
198 {
199  void *lock;
204 
208 typedef struct
209 {
210  uint32_t inFifoThreshold;
216 } AASRC_FifoCfg;
217 
221 typedef struct
222 {
232 
236 typedef struct
237 {
238  uint32_t rateRatio;
240  uint32_t upsample;
244 
256 typedef struct
257 {
258  /*
259  * Primary user configs
260  */
261  uint32_t chType;
263  uint32_t chCount;
266  /*
267  * Secondary user configs
268  */
271  uint8_t inClkZone;
273  uint8_t outClkZone;
275  uint32_t inWordLen;
277  uint32_t ditherEnable;
279  uint32_t mute;
284  uint32_t attenuation;
286  uint32_t deEmphasisMode;
288  uint32_t groupDelay;
290  uint32_t outWordLen;
294 } AASRC_ChCfg;
295 
300 typedef struct
301 {
302  uint32_t clkZoneDiv;
306  uint8_t syncPin;
308  uint32_t extClkSrc;
314 
315 
320  typedef struct
321  {
326  } AASRC_ChClkCfg;
327 
328 
332 typedef struct
333 {
334  /*
335  * Linker variables
336  */
340  /*
341  * State variables
342  */
343  bool isOpen;
345  AASRC_ChState *chState;
347  /* User MUST not change this!*/
348 
349  /*
350  * Channel Configuration variables
351  */
353 
354 
360  /*
361  * Data transfer variables
362  */
367  /*
368  * lock semaphore Obj
369  */
372  /*
373  * Data holding queues
374  */
384  /*
385  * Status variables
386  */
394  /*
395  * Error call back function
396  */
403  uint32_t lastPlayed;
405  uint32_t lastFilled;
407  uint32_t lastReceived;
409  uint32_t lastRecQueued;
417 } AASRC_ChObj;
418 
421 
424 
425 /* ========================================================================== */
426 /* API Function Declarations */
427 /* ========================================================================== */
428 
441 AASRC_ChHandle AASRC_chOpen(uint8_t chIdx, AASRC_Handle drvHandle);
442 
453 AASRC_ChHandle AASRC_getChHandle(uint8_t instIdx, uint8_t chIdx);
454 
465 
475 int32_t AASRC_chConfig(AASRC_ChHandle chHandle);
476 
487 int32_t AASRC_chEnable(AASRC_ChHandle chHandle);
488 
499 int32_t AASRC_chDisable(AASRC_ChHandle chHandle);
500 
513 int32_t AASRC_isChEnabled(AASRC_ChHandle chHandle, uint32_t *isEnabled);
514 
525 int32_t AASRC_chClose(AASRC_ChHandle chHandle);
526 
527 /* ========================================================================== */
528 /* Static Function Definitions */
529 /* ========================================================================== */
530 
531 /* None */
532 
533 
534 
535 #ifdef __cplusplus
536 }
537 #endif
538 
539 #endif /* #ifndef AASRC_CH_H_ */
540 
AASRC_ChObj::reqQueueHandleRx
QueueP_Handle reqQueueHandleRx
Definition: aasrc_ch.h:379
AASRC_ChLockObj::lockObj
SemaphoreP_Object lockObj
Definition: aasrc_ch.h:201
AASRC_ChObj::chState
AASRC_ChState * chState
Definition: aasrc_ch.h:345
AASRC_chConfig
int32_t AASRC_chConfig(AASRC_ChHandle chHandle)
Function to configure ASRC channels.
AASRC_ChObj::reqQueueObjTx
QueueP_Object reqQueueObjTx
Definition: aasrc_ch.h:377
AASRC_ChObj::xmtObj
AASRC_TransferObj xmtObj
Definition: aasrc_ch.h:365
AASRC_FifoCfg::outFifoThreshold
uint32_t outFifoThreshold
Definition: aasrc_ch.h:213
AASRC_ChObj::drvHandle
AASRC_Handle drvHandle
Definition: aasrc_ch.h:337
AASRC_ChCfg::attenuation
uint32_t attenuation
Definition: aasrc_ch.h:284
AASRC_ChObj::isOpen
bool isOpen
Definition: aasrc_ch.h:343
AASRC_ChObj::outFifoErrorStatus
AASRC_FifoErrorStatus outFifoErrorStatus
Definition: aasrc_ch.h:391
AASRC_chClose
int32_t AASRC_chClose(AASRC_ChHandle chHandle)
AASRC channel close.
AASRC_ChCfg::fifoControl
AASRC_FifoCfg fifoControl
Definition: aasrc_ch.h:269
AASRC_ChHandle
void * AASRC_ChHandle
AASRC channel handle which points to AASRC channnel status and configs.
Definition: aasrc_types.h:71
AASRC_chDisable
int32_t AASRC_chDisable(AASRC_ChHandle chHandle)
AASRC channel disable.
aasrc_transactions.h
AASRC transactions, transfer objects and parameters.
AASRC_FifoCfg::inFifoThreshold
uint32_t inFifoThreshold
Definition: aasrc_ch.h:210
AASRC_ChObj::chStatus
AASRC_ChStatus chStatus
Definition: aasrc_ch.h:387
AASRC_FifoErrorStatus
Hardware FIFO setup structure.
Definition: aasrc_ch.h:222
AASRC_DmaIcnt
Definition: aasrc_dma.h:140
AASRC_ChObj::reqQueueHandleTx
QueueP_Handle reqQueueHandleTx
Definition: aasrc_ch.h:381
AASRC_ChClkCfg
AASRC Channel Clock Config.
Definition: aasrc_ch.h:321
AASRC_ChObj::lastFilled
uint32_t lastFilled
Definition: aasrc_ch.h:405
AASRC_ClockZoneConfig::clkZoneDiv
uint32_t clkZoneDiv
Definition: aasrc_ch.h:302
AASRC_chEnable
int32_t AASRC_chEnable(AASRC_ChHandle chHandle)
AASRC channel enable.
AASRC_ChObj
AASRC Channel object.
Definition: aasrc_ch.h:333
AASRC_ChObj::errCbFxn
AASRC_ChErrorCallbackFxn errCbFxn
Definition: aasrc_ch.h:397
AASRC_ChCfg::mute
uint32_t mute
Definition: aasrc_ch.h:279
AASRC_ChObj::lastReceived
uint32_t lastReceived
Definition: aasrc_ch.h:407
AASRC_ChCfg::outClkZone
uint8_t outClkZone
Definition: aasrc_ch.h:273
AASRC_ChObj::chCfg
AASRC_ChCfg chCfg
Definition: aasrc_ch.h:352
AASRC_DmaChCfg
Data structure used to store DMA channel configuration.
Definition: aasrc_dma.h:108
AASRC_ChCfg
AASRC configuration parameters for the channel.
Definition: aasrc_ch.h:257
AASRC_ChErrorCallbackFxn
void(* AASRC_ChErrorCallbackFxn)(AASRC_ChHandle chHandle, AASRC_Transaction *transactionRx, AASRC_Transaction *transactionTx)
The definition of a channel error callback function used by the AASRC driver when used in Callback Mo...
Definition: aasrc_transactions.h:166
AASRC_ChObj::rcvObj
AASRC_TransferObj rcvObj
Definition: aasrc_ch.h:363
AASRC_ChClkCfg::rxClkZoneCfg
AASRC_ClockZoneConfig rxClkZoneCfg
Definition: aasrc_ch.h:322
AASRC_Handle
void * AASRC_Handle
A handle that is returned from a AASRC_open() call.
Definition: aasrc_types.h:65
AASRC_FifoErrorStatus::lChannelOverflow
uint8_t lChannelOverflow
Definition: aasrc_ch.h:223
AASRC_ChCfg::inClkZone
uint8_t inClkZone
Definition: aasrc_ch.h:271
AASRC_FifoErrorStatus::lChannelUnderflow
uint8_t lChannelUnderflow
Definition: aasrc_ch.h:227
AASRC_ChObj::inFifoErrorStatus
AASRC_FifoErrorStatus inFifoErrorStatus
Definition: aasrc_ch.h:389
AASRC_ChCfg::deEmphasisMode
uint32_t deEmphasisMode
Definition: aasrc_ch.h:286
AASRC_ChObj::transferSemObj
SemaphoreP_Object transferSemObj
Definition: aasrc_ch.h:370
AASRC_ChObj::rxDmaIcnt
AASRC_DmaIcnt rxDmaIcnt
Definition: aasrc_ch.h:414
AASRC_TransferObj
AASRC Transfer Data structure stored in Channel object.
Definition: aasrc_transactions.h:173
AASRC_ChCfg::groupDelay
uint32_t groupDelay
Definition: aasrc_ch.h:288
AASRC_ChStatus
AASRC channel status register.
Definition: aasrc_ch.h:237
gConfigAasrcChObj
AASRC_ChObj * gConfigAasrcChObj[]
Externally defined driver configuration array.
AASRC_getChHandle
AASRC_ChHandle AASRC_getChHandle(uint8_t instIdx, uint8_t chIdx)
This function returns the handle of an open AASRC Channel from the instance index & channel index.
AASRC_ChObj::dmaChCfg
AASRC_DmaChCfg * dmaChCfg
Definition: aasrc_ch.h:357
AASRC_ChStatus::upsample
uint32_t upsample
Definition: aasrc_ch.h:240
gAasrcChLockObj
AASRC_ChLockObj gAasrcChLockObj
AASRC Channel lock object.
Definition: aasrc_ch.h:423
QueueP_Object
Opaque task object used with the task APIs.
Definition: QueueP.h:92
AASRC_ChCfg::chType
uint32_t chType
Definition: aasrc_ch.h:261
QueueP_Handle
void * QueueP_Handle
Opaque client reference to an instance of a QueueP.
Definition: QueueP.h:68
AASRC_FifoCfg
Hardware FIFO setup structure.
Definition: aasrc_ch.h:209
AASRC_FifoErrorStatus::rChannelUnderflow
uint8_t rChannelUnderflow
Definition: aasrc_ch.h:229
AASRC_chConfigInit
int32_t AASRC_chConfigInit(AASRC_ChHandle chHandle)
Function initialize AASRC_ChCfg.
AASRC_ClockZoneConfig::overrideClkSettle
bool overrideClkSettle
Definition: aasrc_ch.h:311
AASRC_ChObj::lastPlayed
uint32_t lastPlayed
Definition: aasrc_ch.h:403
AASRC_ChLockObj
AASRC Channel lock semaphore structure.
Definition: aasrc_ch.h:198
AASRC_ClockZoneConfig::isClkZoneDivEnable
bool isClkZoneDivEnable
Definition: aasrc_ch.h:304
AASRC_ChObj::lastRecQueued
uint32_t lastRecQueued
Definition: aasrc_ch.h:409
AASRC_ChLockObj::lock
void * lock
Definition: aasrc_ch.h:199
AASRC_ChObj::reqQueueObjRx
QueueP_Object reqQueueObjRx
Definition: aasrc_ch.h:375
AASRC_isChEnabled
int32_t AASRC_isChEnabled(AASRC_ChHandle chHandle, uint32_t *isEnabled)
is ASRC channel enabled
AASRC_FifoErrorStatus::rChannelOverflow
uint8_t rChannelOverflow
Definition: aasrc_ch.h:225
SemaphoreP_Object
Opaque semaphore object used with the semaphore APIs.
Definition: SemaphoreP.h:59
AASRC_ClockZoneConfig
Hardware setup clock zones.
Definition: aasrc_ch.h:301
AASRC_ChCfg::ditherEnable
uint32_t ditherEnable
Definition: aasrc_ch.h:277
AASRC_ClockZoneConfig::extClkSrc
uint32_t extClkSrc
Definition: aasrc_ch.h:308
AASRC_ChCfg::outWordLen
uint32_t outWordLen
Definition: aasrc_ch.h:290
AASRC_ChCfg::chCount
uint32_t chCount
Definition: aasrc_ch.h:263
AASRC_ChObj::txDmaIcnt
AASRC_DmaIcnt txDmaIcnt
Definition: aasrc_ch.h:412
AASRC_ChCfg::directDownSample
uint32_t directDownSample
Definition: aasrc_ch.h:281
AASRC_chOpen
AASRC_ChHandle AASRC_chOpen(uint8_t chIdx, AASRC_Handle drvHandle)
Function to allocate a required ASRC channel.
AASRC_ChClkCfg::txClkZoneCfg
AASRC_ClockZoneConfig txClkZoneCfg
Definition: aasrc_ch.h:324
AASRC_ChCfg::inWordLen
uint32_t inWordLen
Definition: aasrc_ch.h:275
aasrc_dma.h
AASRC dma related parameters and APIs.
AASRC_ChStatus::rateRatio
uint32_t rateRatio
Definition: aasrc_ch.h:238
AASRC_ClockZoneConfig::syncPin
uint8_t syncPin
Definition: aasrc_ch.h:306