Skip to content

Commit

Permalink
fix(PeriphDrivers): Resolve incorrect DMA request in DMA-based SPI tr…
Browse files Browse the repository at this point in the history
…ansactions for all parts (#1059)
  • Loading branch information
JeonChangmin authored Jul 2, 2024
1 parent 4495706 commit 796e710
Show file tree
Hide file tree
Showing 13 changed files with 382 additions and 813 deletions.
81 changes: 25 additions & 56 deletions Libraries/PeriphDrivers/Source/SPI/spi_ai87.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,34 +403,19 @@ int MXC_SPI_MasterTransactionDMA(mxc_spi_req_t *req)
spi_num = MXC_SPI_GET_IDX(req->spi);
MXC_ASSERT(spi_num >= 0);

if (req->txData != NULL) {
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI1TX;
break;

case 1:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
break;

default:
return E_BAD_PARAM;
}
}

if (req->rxData != NULL) {
switch (spi_num) {
case 0:
reqselRx = MXC_DMA_REQUEST_SPI1RX;
break;

case 1:
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

default:
return E_BAD_PARAM;
}
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

case 1:
reqselTx = MXC_DMA_REQUEST_SPI1TX;
reqselRx = MXC_DMA_REQUEST_SPI1RX;
break;

default:
return E_BAD_PARAM;
}

return MXC_SPI_RevA1_MasterTransactionDMA((mxc_spi_reva_req_t *)req, reqselTx, reqselRx,
Expand All @@ -457,36 +442,20 @@ int MXC_SPI_SlaveTransactionDMA(mxc_spi_req_t *req)
spi_num = MXC_SPI_GET_IDX(req->spi);
MXC_ASSERT(spi_num >= 0);

if (req->txData != NULL) {
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI1TX;
break;

case 1:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
break;
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

default:
return E_BAD_PARAM;
break;
}
}
case 1:
reqselTx = MXC_DMA_REQUEST_SPI1TX;
reqselRx = MXC_DMA_REQUEST_SPI1RX;
break;

if (req->rxData != NULL) {
switch (spi_num) {
case 0:
reqselRx = MXC_DMA_REQUEST_SPI1RX;
break;

case 1:
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

default:
return E_BAD_PARAM;
break;
}
default:
return E_BAD_PARAM;
break;
}

return MXC_SPI_RevA1_SlaveTransactionDMA((mxc_spi_reva_req_t *)req, reqselTx, reqselRx,
Expand Down
79 changes: 24 additions & 55 deletions Libraries/PeriphDrivers/Source/SPI/spi_es17.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,35 +252,19 @@ int MXC_SPI_MasterTransactionDMA(mxc_spi_req_t *req)
spi_num = MXC_SPI_GET_IDX(req->spi);
MXC_ASSERT(spi_num >= 0);

if (req->txData != NULL) {
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
break;

case 1:
reqselTx = MXC_DMA_REQUEST_SPI1TX;
break;

default:
return E_BAD_PARAM;
}
}

//tx
if (req->rxData != NULL) {
switch (spi_num) {
case 0:
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

case 1:
reqselRx = MXC_DMA_REQUEST_SPI1RX;
break;

default:
return E_BAD_PARAM;
}
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

case 1:
reqselTx = MXC_DMA_REQUEST_SPI1TX;
reqselRx = MXC_DMA_REQUEST_SPI1RX;
break;

default:
return E_BAD_PARAM;
}

return MXC_SPI_RevA1_MasterTransactionDMA((mxc_spi_reva_req_t *)req, reqselTx, reqselRx,
Expand All @@ -307,34 +291,19 @@ int MXC_SPI_SlaveTransactionDMA(mxc_spi_req_t *req)
spi_num = MXC_SPI_GET_IDX(req->spi);
MXC_ASSERT(spi_num >= 0);

if (req->txData != NULL) {
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
break;
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

case 1:
reqselTx = MXC_DMA_REQUEST_SPI1TX;
break;
case 1:
reqselTx = MXC_DMA_REQUEST_SPI1TX;
reqselRx = MXC_DMA_REQUEST_SPI1RX;
break;

default:
return E_BAD_PARAM;
}
}

if (req->rxData != NULL) {
switch (spi_num) {
case 0:
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

case 1:
reqselRx = MXC_DMA_REQUEST_SPI1RX;
break;

default:
return E_BAD_PARAM;
}
default:
return E_BAD_PARAM;
}

return MXC_SPI_RevA1_SlaveTransactionDMA((mxc_spi_reva_req_t *)req, reqselTx, reqselRx,
Expand Down
78 changes: 24 additions & 54 deletions Libraries/PeriphDrivers/Source/SPI/spi_me11.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,34 +250,19 @@ int MXC_SPI_MasterTransactionDMA(mxc_spi_req_t *req)
spi_num = MXC_SPI_GET_IDX(req->spi);
MXC_ASSERT(spi_num >= 0);

if (req->txData != NULL) {
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
break;

case 1:
reqselTx = MXC_DMA_REQUEST_SPIMSSTX;
break;

default:
return E_BAD_PARAM;
}
}

if (req->rxData != NULL) {
switch (spi_num) {
case 0:
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

case 1:
reqselTx = MXC_DMA_REQUEST_SPIMSSRX;
break;

default:
return E_BAD_PARAM;
}
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

case 1:
reqselTx = MXC_DMA_REQUEST_SPIMSSTX;
reqselRx = MXC_DMA_REQUEST_SPIMSSRX;
break;

default:
return E_BAD_PARAM;
}

return MXC_SPI_RevA1_MasterTransactionDMA((mxc_spi_reva_req_t *)req, reqselTx, reqselRx,
Expand All @@ -304,34 +289,19 @@ int MXC_SPI_SlaveTransactionDMA(mxc_spi_req_t *req)
spi_num = MXC_SPI_GET_IDX(req->spi);
MXC_ASSERT(spi_num >= 0);

if (req->txData != NULL) {
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
break;
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

case 1:
reqselTx = MXC_DMA_REQUEST_SPIMSSTX;
break;
case 1:
reqselTx = MXC_DMA_REQUEST_SPIMSSTX;
reqselRx = MXC_DMA_REQUEST_SPIMSSRX;
break;

default:
return E_BAD_PARAM;
}
}

if (req->rxData != NULL) {
switch (spi_num) {
case 0:
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

case 1:
reqselRx = MXC_DMA_REQUEST_SPIMSSRX;
break;

default:
return E_BAD_PARAM;
}
default:
return E_BAD_PARAM;
}

return MXC_SPI_RevA1_SlaveTransactionDMA((mxc_spi_reva_req_t *)req, reqselTx, reqselRx,
Expand Down
81 changes: 25 additions & 56 deletions Libraries/PeriphDrivers/Source/SPI/spi_me12.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,34 +359,19 @@ int MXC_SPI_MasterTransactionDMA(mxc_spi_req_t *req)
spi_num = MXC_SPI_GET_IDX(req->spi);
MXC_ASSERT(spi_num >= 0);

if (req->txData != NULL) {
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
break;

case 1:
reqselTx = MXC_DMA_REQUEST_SPI1TX;
break;

default:
return E_BAD_PARAM;
}
}

if (req->rxData != NULL) {
switch (spi_num) {
case 0:
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

case 1:
reqselRx = MXC_DMA_REQUEST_SPI1RX;
break;

default:
return E_BAD_PARAM;
}
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

case 1:
reqselTx = MXC_DMA_REQUEST_SPI1TX;
reqselRx = MXC_DMA_REQUEST_SPI1RX;
break;

default:
return E_BAD_PARAM;
}

return MXC_SPI_RevA1_MasterTransactionDMA((mxc_spi_reva_req_t *)req, reqselTx, reqselRx,
Expand All @@ -413,36 +398,20 @@ int MXC_SPI_SlaveTransactionDMA(mxc_spi_req_t *req)
spi_num = MXC_SPI_GET_IDX(req->spi);
MXC_ASSERT(spi_num >= 0);

if (req->txData != NULL) {
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI1TX;
break;

case 1:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
break;

default:
return E_BAD_PARAM;
break;
}
}

if (req->rxData != NULL) {
switch (spi_num) {
case 0:
reqselRx = MXC_DMA_REQUEST_SPI1RX;
break;
switch (spi_num) {
case 0:
reqselTx = MXC_DMA_REQUEST_SPI0TX;
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;

case 1:
reqselRx = MXC_DMA_REQUEST_SPI0RX;
break;
case 1:
reqselTx = MXC_DMA_REQUEST_SPI1TX;
reqselRx = MXC_DMA_REQUEST_SPI1RX;
break;

default:
return E_BAD_PARAM;
break;
}
default:
return E_BAD_PARAM;
break;
}

return MXC_SPI_RevA1_SlaveTransactionDMA((mxc_spi_reva_req_t *)req, reqselTx, reqselRx,
Expand Down
Loading

0 comments on commit 796e710

Please sign in to comment.