Skip to content

Commit 488cc1e

Browse files
ZhaoxiangJinmmahadevan108
authored andcommitted
sdk_ng: Roll back the SAI driver version to 2.4.3
The 2.4.4 SAI driver from the 24.12.00 release will cause FRDM-MCXN947 i2s speed exmaple run fail, currently roll back it to 2.4.3 version. Signed-off-by: Zhaoxiang Jin <[email protected]>
1 parent 9904e33 commit 488cc1e

File tree

2 files changed

+87
-54
lines changed

2 files changed

+87
-54
lines changed

mcux/mcux-sdk-ng/drivers/sai/fsl_sai.c

Lines changed: 58 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,16 @@ static uint32_t SAI_GetInstance(I2S_Type *base)
277277
}
278278
}
279279

280-
assert(instance < ARRAY_SIZE(s_saiBases));
280+
if (instance == ARRAY_SIZE(s_saiBases)) {
281+
assert(false);
282+
/* asserts may not always be enabled. As such, return NULL here to
283+
* avoid compilation warnings complaining about a possible out-of-bounds
284+
* access. If the user decides to disable the asserts, it is up to them
285+
* to debug in case of out-of-bounds access as SAI_GetInstance() will
286+
* return a valid instance.
287+
*/
288+
return 0;
289+
}
281290

282291
return instance;
283292
}
@@ -940,8 +949,8 @@ void SAI_TxSetFifoConfig(I2S_Type *base, sai_fifo_t *config)
940949
{
941950
assert(config != NULL);
942951
#if defined(FSL_FEATURE_SAI_HAS_FIFO) && (FSL_FEATURE_SAI_HAS_FIFO)
943-
if ((config->fifoWatermark == 0U) ||
944-
(config->fifoWatermark > (uint8_t)((uint32_t)FSL_FEATURE_SAI_FIFO_COUNTn(base))))
952+
if (config->fifoWatermark > (uint8_t)((uint32_t)FSL_FEATURE_SAI_FIFO_COUNTn(base)) ||
953+
(!MCUX_SDK_SAI_ALLOW_NULL_FIFO_WATERMARK && config->fifoWatermark == 0U))
945954
{
946955
config->fifoWatermark = (uint8_t)((uint32_t)FSL_FEATURE_SAI_FIFO_COUNTn(base) / 2U);
947956
}
@@ -986,8 +995,8 @@ void SAI_RxSetFifoConfig(I2S_Type *base, sai_fifo_t *config)
986995
{
987996
assert(config != NULL);
988997
#if defined(FSL_FEATURE_SAI_HAS_FIFO) && (FSL_FEATURE_SAI_HAS_FIFO)
989-
if ((config->fifoWatermark == 0U) ||
990-
(config->fifoWatermark > (uint8_t)((uint32_t)FSL_FEATURE_SAI_FIFO_COUNTn(base))))
998+
if (config->fifoWatermark > (uint8_t)((uint32_t)FSL_FEATURE_SAI_FIFO_COUNTn(base)) ||
999+
(!MCUX_SDK_SAI_ALLOW_NULL_FIFO_WATERMARK && config->fifoWatermark == 0U))
9911000
{
9921001
config->fifoWatermark = (uint8_t)((uint32_t)FSL_FEATURE_SAI_FIFO_COUNTn(base) / 2U);
9931002
}
@@ -1131,24 +1140,15 @@ void SAI_RxSetSerialDataConfig(I2S_Type *base, sai_serial_data_t *config)
11311140
base->RCR4 = rcr4;
11321141
}
11331142

1134-
/*!
1135-
* brief SAI transmitter configurations.
1136-
*
1137-
* param base SAI base pointer.
1138-
* param config transmitter configurations.
1139-
*/
1140-
void SAI_TxSetConfig(I2S_Type *base, sai_transceiver_t *config)
1143+
#if !MCUX_SDK_SAI_DISABLE_IMPLICIT_CHAN_CONFIG
1144+
static void SAI_ComputeChannelConfig(I2S_Type *base, sai_transceiver_t *config)
11411145
{
11421146
assert(config != NULL);
11431147
assert(FSL_FEATURE_SAI_CHANNEL_COUNTn(base) != -1);
11441148

11451149
uint8_t i = 0U;
1146-
uint32_t val = 0U;
11471150
uint8_t channelNums = 0U;
11481151

1149-
/* reset transmitter */
1150-
SAI_TxReset(base);
1151-
11521152
/* if channel mask is not set, then format->channel must be set,
11531153
use it to get channel mask value */
11541154
if (config->channelMask == 0U)
@@ -1175,6 +1175,35 @@ void SAI_TxSetConfig(I2S_Type *base, sai_transceiver_t *config)
11751175
}
11761176

11771177
config->channelNums = channelNums;
1178+
}
1179+
#endif /* MCUX_SDK_SAI_DISABLE_IMPLICIT_CHAN_CONFIG */
1180+
1181+
/*!
1182+
* brief SAI transmitter configurations.
1183+
*
1184+
* param base SAI base pointer.
1185+
* param config transmitter configurations.
1186+
*/
1187+
void SAI_TxSetConfig(I2S_Type *base, sai_transceiver_t *config)
1188+
{
1189+
uint32_t val = 0U;
1190+
1191+
/* reset transmitter */
1192+
SAI_TxReset(base);
1193+
1194+
#if !MCUX_SDK_SAI_DISABLE_IMPLICIT_CHAN_CONFIG
1195+
/* sometimes, the user of the SAI driver may want to
1196+
* set the channel configuration (i.e: the startChannel,
1197+
* channelMask, endChannel, and channelNums fields of
1198+
* sai_transceiver_t) before calling SAI_TxSetConfig().
1199+
* As such, if the user wants to do this, they can define
1200+
* FSL_FEATURE_SAI_DISABLE_IMPLICIT_CHAN_CONFIG which will
1201+
* stop SAI_TxSetConfig() from implicitly computing those
1202+
* values.
1203+
*/
1204+
SAI_ComputeChannelConfig(base, config);
1205+
#endif /* MCUX_SDK_SAI_DISABLE_IMPLICIT_CHAN_CONFIG */
1206+
11781207
#if defined(FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE) && (FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE)
11791208
/* make sure combine mode disabled while multipe channel is used */
11801209
if (config->channelNums > 1U)
@@ -1273,42 +1302,24 @@ void SAI_TransferTxSetConfig(I2S_Type *base, sai_handle_t *handle, sai_transceiv
12731302
*/
12741303
void SAI_RxSetConfig(I2S_Type *base, sai_transceiver_t *config)
12751304
{
1276-
assert(config != NULL);
1277-
assert(FSL_FEATURE_SAI_CHANNEL_COUNTn(base) != -1);
1278-
1279-
uint8_t i = 0U;
1280-
uint32_t val = 0U;
1281-
uint8_t channelNums = 0U;
1305+
uint32_t val = 0U;
12821306

12831307
/* reset receiver */
12841308
SAI_RxReset(base);
12851309

1286-
/* if channel mask is not set, then format->channel must be set,
1287-
use it to get channel mask value */
1288-
if (config->channelMask == 0U)
1289-
{
1290-
config->channelMask = 1U << config->startChannel;
1291-
}
1292-
1293-
for (i = 0U; i < (uint32_t)FSL_FEATURE_SAI_CHANNEL_COUNTn(base); i++)
1294-
{
1295-
if (IS_SAI_FLAG_SET((1UL << i), config->channelMask))
1296-
{
1297-
channelNums++;
1298-
config->endChannel = i;
1299-
}
1300-
}
1301-
1302-
for (i = 0U; i < (uint32_t)FSL_FEATURE_SAI_CHANNEL_COUNTn(base); i++)
1303-
{
1304-
if (IS_SAI_FLAG_SET((1UL << i), config->channelMask))
1305-
{
1306-
config->startChannel = i;
1307-
break;
1308-
}
1309-
}
1310+
#if !MCUX_SDK_SAI_DISABLE_IMPLICIT_CHAN_CONFIG
1311+
/* sometimes, the user of the SAI driver may want to
1312+
* set the channel configuration (i.e: the startChannel,
1313+
* channelMask, endChannel, and channelNums fields of
1314+
* sai_transceiver_t) before calling SAI_RxSetConfig().
1315+
* As such, if the user wants to do this, they can define
1316+
* FSL_FEATURE_SAI_DISABLE_IMPLICIT_CHAN_CONFIG which will
1317+
* stop SAI_RxSetConfig() from implicitly computing those
1318+
* values.
1319+
*/
1320+
SAI_ComputeChannelConfig(base, config);
1321+
#endif /* MCUX_SDK_SAI_DISABLE_IMPLICIT_CHAN_CONFIG */
13101322

1311-
config->channelNums = channelNums;
13121323
#if defined(FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE) && (FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE)
13131324
/* make sure combine mode disabled while multipe channel is used */
13141325
if (config->channelNums > 1U)

mcux/mcux-sdk-ng/drivers/sai/fsl_sai.h

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,33 @@
2020
* Definitions
2121
******************************************************************************/
2222

23+
/*! @brief Used to control whether SAI_RxSetFifoConfig()/SAI_TxSetFifoConfig()
24+
* allows a NULL FIFO watermark.
25+
*
26+
* If this macro is set to 0 then SAI_RxSetFifoConfig()/SAI_TxSetFifoConfig()
27+
* will set the watermark to half of the FIFO's depth if passed a NULL
28+
* watermark.
29+
*/
30+
#ifndef MCUX_SDK_SAI_ALLOW_NULL_FIFO_WATERMARK
31+
#define MCUX_SDK_SAI_ALLOW_NULL_FIFO_WATERMARK 0
32+
#endif /* MCUX_SDK_SAI_ALLOW_NULL_FIFO_WATERMARK */
33+
34+
/*! @brief Disable implicit channel data configuration within SAI_TxSetConfig()/SAI_RxSetConfig().
35+
*
36+
* Use this macro to control whether SAI_RxSetConfig()/SAI_TxSetConfig() will
37+
* attempt to implicitly configure the channel data. By channel data we mean
38+
* the startChannel, channelMask, endChannel, and channelNums fields from the
39+
* sai_transciever_t structure. By default, SAI_TxSetConfig()/SAI_RxSetConfig()
40+
* will attempt to compute these fields, which may not be desired in cases where
41+
* the user wants to set them before the call to said functions.
42+
*/
43+
#ifndef MCUX_SDK_SAI_DISABLE_IMPLICIT_CHAN_CONFIG
44+
#define MCUX_SDK_SAI_DISABLE_IMPLICIT_CHAN_CONFIG 0
45+
#endif /* MCUX_SDK_SAI_DISABLE_IMPLICIT_CHAN_CONFIG */
46+
2347
/*! @name Driver version */
2448
/*! @{ */
25-
#define FSL_SAI_DRIVER_VERSION (MAKE_VERSION(2, 4, 4)) /*!< Version 2.4.4 */
49+
#define FSL_SAI_DRIVER_VERSION (MAKE_VERSION(2, 4, 3)) /*!< Version 2.4.3 */
2650
/*! @} */
2751

2852
/*! @brief _sai_status_t, SAI return status.*/
@@ -245,12 +269,10 @@ typedef enum _sai_data_pin_state
245269
/*! @brief sai fifo combine mode definition */
246270
typedef enum _sai_fifo_combine
247271
{
248-
kSAI_FifoCombineDisabled = 0U, /*!< sai TX/RX fifo combine mode disabled */
249-
kSAI_FifoCombineModeEnabledOnRead = 1U, /*!< sai TX fifo combine mode enabled on FIFO reads */
250-
kSAI_FifoCombineModeEnabledOnWrite = 2U, /*!< sai TX fifo combine mode enabled on FIFO write */
251-
kSAI_RxFifoCombineModeEnabledOnWrite = 1U, /*!< sai RX fifo combine mode enabled on FIFO write */
252-
kSAI_RXFifoCombineModeEnabledOnRead = 2U, /*!< sai RX fifo combine mode enabled on FIFO reads */
253-
kSAI_FifoCombineModeEnabledOnReadWrite = 3U, /*!< sai TX/RX fifo combined mode enabled on FIFO read/writes */
272+
kSAI_FifoCombineDisabled = 0U, /*!< sai fifo combine mode disabled */
273+
kSAI_FifoCombineModeEnabledOnWrite, /*!< sai fifo combine mode enabled on FIFO write */
274+
kSAI_FifoCombineModeEnabledOnRead, /*!< sai fifo combine mode enabled on FIFO reads */
275+
kSAI_FifoCombineModeEnabledOnReadWrite, /*!< sai fifo combined mode enabled on FIFO read/writes */
254276
} sai_fifo_combine_t;
255277
#endif
256278

0 commit comments

Comments
 (0)