Skip to content

Commit

Permalink
Fix UART RevB Driver not cleaning up Async Transactions
Browse files Browse the repository at this point in the history
Currently, the private AsyncTxRequests and AsyncRxRequests arrays are used to track transactions in progress for uart_revb.c.
The Tx/Rx Async Callbacks check for a callback function before clearing the Requests:

```C
mxc_uart_req_t *req = (mxc_uart_req_t *)AsyncTxRequests[uart_num];
if ((req != NULL) && (req->callback != NULL)) {
    AsyncTxRequests[uart_num] = NULL;
    req->callback(req, retVal);
}
```

This means that if the user does not supply an explicit callback function, a transaction never gets cleared, causing problems after just one transaction.

This commit resolves this by moving the cleanup of this important struct outside of the conditional check for a callback function.

```C
mxc_uart_req_t *req = (mxc_uart_req_t *)AsyncTxRequests[uart_num];
if ((req != NULL) && (req->callback != NULL)) {
    req->callback(req, retVal);
}

// Cleanup Async Transaction
AsyncTxRequests[uart_num] = NULL;
```

Signed-off-by: Brandon Hurst <brandon.hurst@analog.com>
  • Loading branch information
Brandon-Hurst committed Feb 4, 2025
1 parent bacab6b commit 035164a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Libraries/PeriphDrivers/Source/UART/uart_revb.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,10 +749,12 @@ int MXC_UART_RevB_AsyncTxCallback(mxc_uart_revb_regs_t *uart, int retVal)

mxc_uart_req_t *req = (mxc_uart_req_t *)AsyncTxRequests[uart_num];
if ((req != NULL) && (req->callback != NULL)) {
AsyncTxRequests[uart_num] = NULL;
req->callback(req, retVal);
}

// Cleanup Async Transaction
AsyncTxRequests[uart_num] = NULL;

return E_NO_ERROR;
}

Expand All @@ -762,10 +764,12 @@ int MXC_UART_RevB_AsyncRxCallback(mxc_uart_revb_regs_t *uart, int retVal)

mxc_uart_req_t *req = (mxc_uart_req_t *)AsyncRxRequests[uart_num];
if ((req != NULL) && (req->callback != NULL)) {
AsyncRxRequests[uart_num] = NULL;
req->callback(req, retVal);
}

// Cleanup Async Transaction
AsyncRxRequests[uart_num] = NULL;

return E_NO_ERROR;
}

Expand Down

0 comments on commit 035164a

Please sign in to comment.