analogdevicesinc / msdk

Software Development Kit for Analog Device's MAX-series microcontrollers
Apache License 2.0
61 stars 81 forks source link

In uart_reva.c, MXC_UART_RevA_Init does not initialize unused UARTs states #998

Closed aniktash closed 3 months ago

aniktash commented 5 months ago

MXC_UART_RevA_Init only initializes the selected state's structure: // Initialize state struct unsigned int i = MXC_UART_GET_IDX((mxc_uart_regs_t *)uart); states[i].channelRx = -1; states[i].channelTx = -1; states[i].tx_req = NULL; states[i].rx_req = NULL; states[i].auto_dma_handlers = false; Unused UART state's structures are not initiated. The problem happens in MXC_UART_RevA_DMACallback when checking the channelTx: for (int i = 0; i < MXC_UART_INSTANCES; i++) { if (states[i].channelTx == ch) { If it is not initialized, it thinks it is a valid state of a used UART and proceeds with checking the callback, which is also not initialized, and breaks from the loop, without iterating to the next UART instance. This results in not receiving the callbacks if UART1 is used (tested on MAX32665).