fix: harden ch390 rx protocol handling
This commit is contained in:
@@ -283,25 +283,16 @@ uint8_t ch390_read_reg(uint8_t reg)
|
||||
|
||||
static uint8_t ch390_read_rx_reg(uint8_t reg)
|
||||
{
|
||||
uint8_t tx_buf[3];
|
||||
uint8_t rx_buf[3];
|
||||
|
||||
tx_buf[0] = OPC_MEM_DMY_R;
|
||||
tx_buf[1] = reg;
|
||||
tx_buf[2] = 0x00u;
|
||||
uint8_t value;
|
||||
|
||||
CH390_SPI_ATOMIC_ENTER();
|
||||
ch390_cs(0);
|
||||
if (HAL_SPI_TransmitReceive(&hspi1, tx_buf, rx_buf, 3, SPI_TIMEOUT) != HAL_OK)
|
||||
{
|
||||
ch390_cs(1);
|
||||
CH390_SPI_ATOMIC_EXIT();
|
||||
return 0u;
|
||||
}
|
||||
ch390_spi_exchange_byte(reg | OPC_REG_R);
|
||||
value = ch390_spi_dummy_read();
|
||||
ch390_cs(1);
|
||||
CH390_SPI_ATOMIC_EXIT();
|
||||
|
||||
return rx_buf[2];
|
||||
return value;
|
||||
}
|
||||
|
||||
uint8_t ch390_read_mrcmdx(void)
|
||||
|
||||
Reference in New Issue
Block a user