Skip to content

Commit

Permalink
[rtl872x] SPI and UART HAL minor fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
XuGuohui committed Mar 13, 2024
1 parent 5bf4c98 commit c595a2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hal/src/rtl872x/spi_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ class Spi {
// When the RX buffer is not supplied, we may lose some TX data due to the false SPI completion.
// Hence, we add the SSI_Busy() check here.
bool isBusy() const {
return status_.transmitting || status_.receiving || SSI_Busy(SPI_DEV_TABLE[rtlSpiIndex_].SPIx);
return status_.transmitting || status_.receiving || ((config_.spiMode == SPI_MODE_MASTER) && SSI_Busy(SPI_DEV_TABLE[rtlSpiIndex_].SPIx));
}

bool isSuspended() const {
Expand Down
10 changes: 8 additions & 2 deletions hal/src/rtl872x/usart_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,17 @@ class Usart {
void* txBuf = conf.tx_buffer;
size_t txBufSize = conf.tx_buffer_size;
if (((uintptr_t)rxBuf & portBYTE_ALIGNMENT_MASK) != 0) {
rxBuf = std::align(portBYTE_ALIGNMENT, conf.rx_buffer_size, rxBuf, rxBufSize);
if (conf.rx_buffer_size < portBYTE_ALIGNMENT) {
return SYSTEM_ERROR_NOT_ENOUGH_DATA;
}
rxBuf = std::align(portBYTE_ALIGNMENT, conf.rx_buffer_size - portBYTE_ALIGNMENT, rxBuf, rxBufSize);
rxBufSize = (rxBufSize / portBYTE_ALIGNMENT) * portBYTE_ALIGNMENT;
}
if (((uintptr_t)txBuf & portBYTE_ALIGNMENT_MASK) != 0) {
txBuf = std::align(portBYTE_ALIGNMENT, conf.tx_buffer_size, txBuf, txBufSize);
if (conf.tx_buffer_size < portBYTE_ALIGNMENT) {
return SYSTEM_ERROR_NOT_ENOUGH_DATA;
}
txBuf = std::align(portBYTE_ALIGNMENT, conf.tx_buffer_size - portBYTE_ALIGNMENT, txBuf, txBufSize);
txBufSize = (txBufSize / portBYTE_ALIGNMENT) * portBYTE_ALIGNMENT;
}
CHECK_TRUE(rxBuf, SYSTEM_ERROR_NOT_ENOUGH_DATA);
Expand Down

0 comments on commit c595a2a

Please sign in to comment.