Skip to content

Commit a85f082

Browse files
committed
MCUXpresso: Update EDMA drivers to fix warnings
Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent a184a86 commit a85f082

18 files changed

+879
-317
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/drivers/fsl_flexio_camera_edma.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ status_t FLEXIO_CAMERA_TransferReceiveEDMA(FLEXIO_CAMERA_Type *base,
170170
EDMA_PrepareTransfer(&xferConfig, (void *)FLEXIO_CAMERA_GetRxBufferAddress(base), 32, (void *)xfer->dataAddress,
171171
32, 32, xfer->dataNum, kEDMA_PeripheralToMemory);
172172

173+
/* Store the initially configured eDMA minor byte transfer count into the FLEXIO CAMERA handle */
174+
handle->nbytes = 32;
175+
173176
/* Submit transfer. */
174177
EDMA_SubmitTransfer(handle->rxEdmaHandle, &xferConfig);
175178
EDMA_StartTransfer(handle->rxEdmaHandle);
@@ -207,7 +210,9 @@ status_t FLEXIO_CAMERA_TransferGetReceiveCountEDMA(FLEXIO_CAMERA_Type *base,
207210

208211
if (kFLEXIO_CAMERA_RxBusy == handle->rxState)
209212
{
210-
*count = (handle->rxSize - EDMA_GetRemainingBytes(handle->rxEdmaHandle->base, handle->rxEdmaHandle->channel));
213+
*count = (handle->rxSize -
214+
(uint32_t)handle->nbytes *
215+
EDMA_GetRemainingMajorLoopCount(handle->rxEdmaHandle->base, handle->rxEdmaHandle->channel));
211216
}
212217
else
213218
{

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/drivers/fsl_flexio_camera_edma.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,29 @@
3939
* @{
4040
*/
4141

42-
4342
/*******************************************************************************
4443
* Definitions
4544
******************************************************************************/
4645

4746
/*! @brief Forward declaration of the handle typedef. */
4847
typedef struct _flexio_camera_edma_handle flexio_camera_edma_handle_t;
4948

50-
/*! @brief CAMERA transfer callback function. */
49+
/*! @brief Camera transfer callback function. */
5150
typedef void (*flexio_camera_edma_transfer_callback_t)(FLEXIO_CAMERA_Type *base,
5251
flexio_camera_edma_handle_t *handle,
5352
status_t status,
5453
void *userData);
5554

5655
/*!
57-
* @brief CAMERA eDMA handle
56+
* @brief Camera eDMA handle
5857
*/
5958
struct _flexio_camera_edma_handle
6059
{
6160
flexio_camera_edma_transfer_callback_t callback; /*!< Callback function. */
62-
void *userData; /*!< CAMERA callback function parameter.*/
61+
void *userData; /*!< Camera callback function parameter.*/
6362
size_t rxSize; /*!< Total bytes to be received. */
6463
edma_handle_t *rxEdmaHandle; /*!< The eDMA RX channel used. */
64+
uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
6565
volatile uint8_t rxState; /*!< RX transfer state */
6666
};
6767

@@ -79,15 +79,15 @@ extern "C" {
7979
*/
8080

8181
/*!
82-
* @brief Initializes the camera handle, which is used in transactional functions.
82+
* @brief Initializes the Camera handle, which is used in transactional functions.
8383
*
84-
* @param base pointer to FLEXIO_CAMERA_Type.
84+
* @param base Pointer to the FLEXIO_CAMERA_Type.
8585
* @param handle Pointer to flexio_camera_edma_handle_t structure.
8686
* @param callback The callback function.
8787
* @param userData The parameter of the callback function.
8888
* @param rxEdmaHandle User requested DMA handle for RX DMA transfer.
8989
* @retval kStatus_Success Successfully create the handle.
90-
* @retval kStatus_OutOfRange The FlexIO camera eDMA type/handle table out of range.
90+
* @retval kStatus_OutOfRange The FlexIO Camera eDMA type/handle table out of range.
9191
*/
9292
status_t FLEXIO_CAMERA_TransferCreateHandleEDMA(FLEXIO_CAMERA_Type *base,
9393
flexio_camera_edma_handle_t *handle,
@@ -103,7 +103,7 @@ status_t FLEXIO_CAMERA_TransferCreateHandleEDMA(FLEXIO_CAMERA_Type *base,
103103
*
104104
* @param base Pointer to the FLEXIO_CAMERA_Type.
105105
* @param handle Pointer to the flexio_camera_edma_handle_t structure.
106-
* @param xfer CAMERA eDMA transfer structure, see #flexio_camera_transfer_t.
106+
* @param xfer Camera eDMA transfer structure, see #flexio_camera_transfer_t.
107107
* @retval kStatus_Success if succeeded, others failed.
108108
* @retval kStatus_CAMERA_RxBusy Previous transfer on going.
109109
*/

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/drivers/fsl_flexio_i2s_edma.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ status_t FLEXIO_I2S_TransferSendEDMA(FLEXIO_I2S_Type *base,
225225
EDMA_PrepareTransfer(&config, xfer->data, handle->bytesPerFrame, (void *)destAddr, handle->bytesPerFrame,
226226
handle->bytesPerFrame, xfer->dataSize, kEDMA_MemoryToPeripheral);
227227

228+
/* Store the initially configured eDMA minor byte transfer count into the FLEXIO I2S handle */
229+
handle->nbytes = handle->bytesPerFrame;
230+
228231
EDMA_SubmitTransfer(handle->dmaHandle, &config);
229232

230233
/* Start DMA transfer */
@@ -272,6 +275,9 @@ status_t FLEXIO_I2S_TransferReceiveEDMA(FLEXIO_I2S_Type *base,
272275
EDMA_PrepareTransfer(&config, (void *)srcAddr, handle->bytesPerFrame, xfer->data, handle->bytesPerFrame,
273276
handle->bytesPerFrame, xfer->dataSize, kEDMA_PeripheralToMemory);
274277

278+
/* Store the initially configured eDMA minor byte transfer count into the FLEXIO I2S handle */
279+
handle->nbytes = handle->bytesPerFrame;
280+
275281
EDMA_SubmitTransfer(handle->dmaHandle, &config);
276282

277283
/* Start DMA transfer */
@@ -327,7 +333,8 @@ status_t FLEXIO_I2S_TransferGetSendCountEDMA(FLEXIO_I2S_Type *base, flexio_i2s_e
327333
else
328334
{
329335
*count = handle->transferSize[handle->queueDriver] -
330-
EDMA_GetRemainingBytes(handle->dmaHandle->base, handle->dmaHandle->channel);
336+
(uint32_t)handle->nbytes *
337+
EDMA_GetRemainingMajorLoopCount(handle->dmaHandle->base, handle->dmaHandle->channel);
331338
}
332339

333340
return status;
@@ -346,7 +353,8 @@ status_t FLEXIO_I2S_TransferGetReceiveCountEDMA(FLEXIO_I2S_Type *base, flexio_i2
346353
else
347354
{
348355
*count = handle->transferSize[handle->queueDriver] -
349-
EDMA_GetRemainingBytes(handle->dmaHandle->base, handle->dmaHandle->channel);
356+
(uint32_t)handle->nbytes *
357+
EDMA_GetRemainingMajorLoopCount(handle->dmaHandle->base, handle->dmaHandle->channel);
350358
}
351359

352360
return status;

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/drivers/fsl_flexio_i2s_edma.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
* @{
3939
*/
4040

41-
4241
/*******************************************************************************
4342
* Definitions
4443
******************************************************************************/
@@ -56,6 +55,7 @@ struct _flexio_i2s_edma_handle
5655
{
5756
edma_handle_t *dmaHandle; /*!< DMA handler for FlexIO I2S send */
5857
uint8_t bytesPerFrame; /*!< Bytes in a frame */
58+
uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
5959
uint32_t state; /*!< Internal state for FlexIO I2S eDMA transfer */
6060
flexio_i2s_edma_callback_t callback; /*!< Callback for users while transfer finish or error occurred */
6161
void *userData; /*!< User callback parameter */
@@ -83,13 +83,13 @@ extern "C" {
8383
*
8484
* This function initializes the FlexIO I2S master DMA handle which can be used for other FlexIO I2S master
8585
* transactional APIs.
86-
* Usually, for a specified FlexIO I2S instance, user need only call this API once to get the initialized handle.
86+
* Usually, for a specified FlexIO I2S instance, call this API once to get the initialized handle.
8787
*
8888
* @param base FlexIO I2S peripheral base address.
8989
* @param handle FlexIO I2S eDMA handle pointer.
9090
* @param callback FlexIO I2S eDMA callback function called while finished a block.
9191
* @param userData User parameter for callback.
92-
* @param dmaHandle eDMA handle for FlexIO I2S. This handle shall be a static value allocated by users.
92+
* @param dmaHandle eDMA handle for FlexIO I2S. This handle is a static value allocated by users.
9393
*/
9494
void FLEXIO_I2S_TransferTxCreateHandleEDMA(FLEXIO_I2S_Type *base,
9595
flexio_i2s_edma_handle_t *handle,
@@ -102,13 +102,13 @@ void FLEXIO_I2S_TransferTxCreateHandleEDMA(FLEXIO_I2S_Type *base,
102102
*
103103
* This function initializes the FlexIO I2S slave DMA handle which can be used for other FlexIO I2S master transactional
104104
* APIs.
105-
* Usually, for a specified FlexIO I2S instance, user need only call this API once to get the initialized handle.
105+
* Usually, for a specified FlexIO I2S instance, call this API once to get the initialized handle.
106106
*
107107
* @param base FlexIO I2S peripheral base address.
108108
* @param handle FlexIO I2S eDMA handle pointer.
109109
* @param callback FlexIO I2S eDMA callback function called while finished a block.
110110
* @param userData User parameter for callback.
111-
* @param dmaHandle eDMA handle for FlexIO I2S. This handle shall be a static value allocated by users.
111+
* @param dmaHandle eDMA handle for FlexIO I2S. This handle is a static value allocated by users.
112112
*/
113113
void FLEXIO_I2S_TransferRxCreateHandleEDMA(FLEXIO_I2S_Type *base,
114114
flexio_i2s_edma_handle_t *handle,
@@ -120,7 +120,7 @@ void FLEXIO_I2S_TransferRxCreateHandleEDMA(FLEXIO_I2S_Type *base,
120120
* @brief Configures the FlexIO I2S Tx audio format.
121121
*
122122
* Audio format can be changed in run-time of FlexIO I2S. This function configures the sample rate and audio data
123-
* format to be transferred. This function also sets eDMA parameter according to format.
123+
* format to be transferred. This function also sets the eDMA parameter according to format.
124124
*
125125
* @param base FlexIO I2S peripheral base address.
126126
* @param handle FlexIO I2S eDMA handle pointer
@@ -137,8 +137,8 @@ void FLEXIO_I2S_TransferSetFormatEDMA(FLEXIO_I2S_Type *base,
137137
/*!
138138
* @brief Performs a non-blocking FlexIO I2S transfer using DMA.
139139
*
140-
* @note This interface returned immediately after transfer initiates, users should call
141-
* FLEXIO_I2S_GetTransferStatus to poll the transfer status to check whether FlexIO I2S transfer finished.
140+
* @note This interface returned immediately after transfer initiates. Users should call
141+
* FLEXIO_I2S_GetTransferStatus to poll the transfer status and check whether the FlexIO I2S transfer is finished.
142142
*
143143
* @param base FlexIO I2S peripheral base address.
144144
* @param handle FlexIO I2S DMA handle pointer.
@@ -154,8 +154,8 @@ status_t FLEXIO_I2S_TransferSendEDMA(FLEXIO_I2S_Type *base,
154154
/*!
155155
* @brief Performs a non-blocking FlexIO I2S receive using eDMA.
156156
*
157-
* @note This interface returned immediately after transfer initiates, users should call
158-
* FLEXIO_I2S_GetReceiveRemainingBytes to poll the transfer status to check whether FlexIO I2S transfer finished.
157+
* @note This interface returned immediately after transfer initiates. Users should call
158+
* FLEXIO_I2S_GetReceiveRemainingBytes to poll the transfer status and check whether the FlexIO I2S transfer is finished.
159159
*
160160
* @param base FlexIO I2S peripheral base address.
161161
* @param handle FlexIO I2S DMA handle pointer.

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/drivers/fsl_flexio_spi_edma.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static void FLEXIO_SPI_EDMAConfig(FLEXIO_SPI_Type *base,
198198
/* Configure DMA channel. */
199199
if (xfer->txData)
200200
{
201-
xferConfig.srcOffset = 1;
201+
xferConfig.srcOffset = bytesPerFrame;
202202
xferConfig.srcAddr = (uint32_t)(xfer->txData);
203203
}
204204
else
@@ -210,6 +210,9 @@ static void FLEXIO_SPI_EDMAConfig(FLEXIO_SPI_Type *base,
210210

211211
xferConfig.majorLoopCounts = (xfer->dataSize / xferConfig.minorLoopBytes);
212212

213+
/* Store the initially configured eDMA minor byte transfer count into the FLEXIO SPI handle */
214+
handle->nbytes = xferConfig.minorLoopBytes;
215+
213216
if (handle->txHandle)
214217
{
215218
EDMA_SubmitTransfer(handle->txHandle, &xferConfig);
@@ -219,9 +222,16 @@ static void FLEXIO_SPI_EDMAConfig(FLEXIO_SPI_Type *base,
219222
if (xfer->rxData)
220223
{
221224
xferConfig.srcAddr = FLEXIO_SPI_GetRxDataRegisterAddress(base, direction);
225+
if (bytesPerFrame == 2U)
226+
{
227+
if (direction == kFLEXIO_SPI_LsbFirst)
228+
{
229+
xferConfig.srcAddr -= 1U;
230+
}
231+
}
222232
xferConfig.srcOffset = 0;
223233
xferConfig.destAddr = (uint32_t)(xfer->rxData);
224-
xferConfig.destOffset = 1;
234+
xferConfig.destOffset = bytesPerFrame;
225235
EDMA_SubmitTransfer(handle->rxHandle, &xferConfig);
226236
handle->rxInProgress = true;
227237
FLEXIO_SPI_EnableDMA(base, kFLEXIO_SPI_RxDmaEnable, true);
@@ -349,11 +359,15 @@ status_t FLEXIO_SPI_MasterTransferGetCountEDMA(FLEXIO_SPI_Type *base,
349359

350360
if (handle->rxInProgress)
351361
{
352-
*count = (handle->transferSize - EDMA_GetRemainingBytes(handle->rxHandle->base, handle->rxHandle->channel));
362+
*count = (handle->transferSize -
363+
(uint32_t)handle->nbytes *
364+
EDMA_GetRemainingMajorLoopCount(handle->rxHandle->base, handle->rxHandle->channel));
353365
}
354366
else
355367
{
356-
*count = (handle->transferSize - EDMA_GetRemainingBytes(handle->txHandle->base, handle->txHandle->channel));
368+
*count = (handle->transferSize -
369+
(uint32_t)handle->nbytes *
370+
EDMA_GetRemainingMajorLoopCount(handle->txHandle->base, handle->txHandle->channel));
357371
}
358372

359373
return kStatus_Success;

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/drivers/fsl_flexio_spi_edma.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
* @{
3939
*/
4040

41-
4241
/*******************************************************************************
4342
* Definitions
4443
******************************************************************************/
@@ -65,6 +64,7 @@ typedef void (*flexio_spi_slave_edma_transfer_callback_t)(FLEXIO_SPI_Type *base,
6564
struct _flexio_spi_master_edma_handle
6665
{
6766
size_t transferSize; /*!< Total bytes to be transferred. */
67+
uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
6868
bool txInProgress; /*!< Send transfer in progress */
6969
bool rxInProgress; /*!< Receive transfer in progress */
7070
edma_handle_t *txHandle; /*!< DMA handler for SPI send */
@@ -86,14 +86,14 @@ extern "C" {
8686
*/
8787

8888
/*!
89-
* @brief Initializes the FLEXO SPI master eDMA handle.
89+
* @brief Initializes the FlexIO SPI master eDMA handle.
9090
*
91-
* This function initializes the FLEXO SPI master eDMA handle which can be used for other FLEXO SPI master transactional
91+
* This function initializes the FlexIO SPI master eDMA handle which can be used for other FlexIO SPI master transactional
9292
* APIs.
93-
* For a specified FLEXO SPI instance, call this API once to get the initialized handle.
93+
* For a specified FlexIO SPI instance, call this API once to get the initialized handle.
9494
*
95-
* @param base pointer to FLEXIO_SPI_Type structure.
96-
* @param handle pointer to flexio_spi_master_edma_handle_t structure to store the transfer state.
95+
* @param base Pointer to FLEXIO_SPI_Type structure.
96+
* @param handle Pointer to flexio_spi_master_edma_handle_t structure to store the transfer state.
9797
* @param callback SPI callback, NULL means no callback.
9898
* @param userData callback function parameter.
9999
* @param txHandle User requested eDMA handle for FlexIO SPI RX eDMA transfer.
@@ -112,11 +112,11 @@ status_t FLEXIO_SPI_MasterTransferCreateHandleEDMA(FLEXIO_SPI_Type *base,
112112
* @brief Performs a non-blocking FlexIO SPI transfer using eDMA.
113113
*
114114
* @note This interface returns immediately after transfer initiates. Call
115-
* FLEXIO_SPI_MasterGetTransferCountEDMA to poll the transfer status to check
116-
* whether FlexIO SPI transfer finished.
115+
* FLEXIO_SPI_MasterGetTransferCountEDMA to poll the transfer status and check
116+
* whether the FlexIO SPI transfer is finished.
117117
*
118-
* @param base pointer to FLEXIO_SPI_Type structure.
119-
* @param handle pointer to flexio_spi_master_edma_handle_t structure to store the transfer state.
118+
* @param base Pointer to FLEXIO_SPI_Type structure.
119+
* @param handle Pointer to flexio_spi_master_edma_handle_t structure to store the transfer state.
120120
* @param xfer Pointer to FlexIO SPI transfer structure.
121121
* @retval kStatus_Success Successfully start a transfer.
122122
* @retval kStatus_InvalidArgument Input argument is invalid.
@@ -129,15 +129,15 @@ status_t FLEXIO_SPI_MasterTransferEDMA(FLEXIO_SPI_Type *base,
129129
/*!
130130
* @brief Aborts a FlexIO SPI transfer using eDMA.
131131
*
132-
* @param base pointer to FLEXIO_SPI_Type structure.
132+
* @param base Pointer to FLEXIO_SPI_Type structure.
133133
* @param handle FlexIO SPI eDMA handle pointer.
134134
*/
135135
void FLEXIO_SPI_MasterTransferAbortEDMA(FLEXIO_SPI_Type *base, flexio_spi_master_edma_handle_t *handle);
136136

137137
/*!
138138
* @brief Gets the remaining bytes for FlexIO SPI eDMA transfer.
139139
*
140-
* @param base pointer to FLEXIO_SPI_Type structure.
140+
* @param base Pointer to FLEXIO_SPI_Type structure.
141141
* @param handle FlexIO SPI eDMA handle pointer.
142142
* @param count Number of bytes transferred so far by the non-blocking transaction.
143143
*/
@@ -150,8 +150,8 @@ status_t FLEXIO_SPI_MasterTransferGetCountEDMA(FLEXIO_SPI_Type *base,
150150
*
151151
* This function initializes the FlexIO SPI slave eDMA handle.
152152
*
153-
* @param base pointer to FLEXIO_SPI_Type structure.
154-
* @param handle pointer to flexio_spi_slave_edma_handle_t structure to store the transfer state.
153+
* @param base Pointer to FLEXIO_SPI_Type structure.
154+
* @param handle Pointer to flexio_spi_slave_edma_handle_t structure to store the transfer state.
155155
* @param callback SPI callback, NULL means no callback.
156156
* @param userData callback function parameter.
157157
* @param txHandle User requested eDMA handle for FlexIO SPI TX eDMA transfer.
@@ -171,11 +171,11 @@ static inline void FLEXIO_SPI_SlaveTransferCreateHandleEDMA(FLEXIO_SPI_Type *bas
171171
* @brief Performs a non-blocking FlexIO SPI transfer using eDMA.
172172
*
173173
* @note This interface returns immediately after transfer initiates. Call
174-
* FLEXIO_SPI_SlaveGetTransferCountEDMA to poll the transfer status to
175-
* check whether FlexIO SPI transfer finished.
174+
* FLEXIO_SPI_SlaveGetTransferCountEDMA to poll the transfer status and
175+
* check whether the FlexIO SPI transfer is finished.
176176
*
177-
* @param base pointer to FLEXIO_SPI_Type structure.
178-
* @param handle pointer to flexio_spi_slave_edma_handle_t structure to store the transfer state.
177+
* @param base Pointer to FLEXIO_SPI_Type structure.
178+
* @param handle Pointer to flexio_spi_slave_edma_handle_t structure to store the transfer state.
179179
* @param xfer Pointer to FlexIO SPI transfer structure.
180180
* @retval kStatus_Success Successfully start a transfer.
181181
* @retval kStatus_InvalidArgument Input argument is invalid.
@@ -188,8 +188,8 @@ status_t FLEXIO_SPI_SlaveTransferEDMA(FLEXIO_SPI_Type *base,
188188
/*!
189189
* @brief Aborts a FlexIO SPI transfer using eDMA.
190190
*
191-
* @param base pointer to FLEXIO_SPI_Type structure.
192-
* @param handle pointer to flexio_spi_slave_edma_handle_t structure to store the transfer state.
191+
* @param base Pointer to FLEXIO_SPI_Type structure.
192+
* @param handle Pointer to flexio_spi_slave_edma_handle_t structure to store the transfer state.
193193
*/
194194
static inline void FLEXIO_SPI_SlaveTransferAbortEDMA(FLEXIO_SPI_Type *base, flexio_spi_slave_edma_handle_t *handle)
195195
{
@@ -199,7 +199,7 @@ static inline void FLEXIO_SPI_SlaveTransferAbortEDMA(FLEXIO_SPI_Type *base, flex
199199
/*!
200200
* @brief Gets the remaining bytes to be transferred for FlexIO SPI eDMA.
201201
*
202-
* @param base pointer to FLEXIO_SPI_Type structure.
202+
* @param base Pointer to FLEXIO_SPI_Type structure.
203203
* @param handle FlexIO SPI eDMA handle pointer.
204204
* @param count Number of bytes transferred so far by the non-blocking transaction.
205205
*/

0 commit comments

Comments
 (0)