Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rtl872x] SPI and UART HAL minor fix. #2757

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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