stm32-l053r8-em9304: send '0's when reading SPI data

This commit is contained in:
Matthias Ringwald 2017-07-01 18:36:58 +02:00
parent f77378dfec
commit c3163ee6f5

View File

@ -161,10 +161,13 @@ static volatile enum {
} hal_spi_em9304_state;
#define SPI_EM9304_RX_BUFFER_SIZE 64
#define SPI_EM9304_TX_BUFFER_SIZE 64
#define SPI_EM9304_RING_BUFFER_SIZE 128
static uint8_t hal_spi_em9304_slave_status[2];
static const uint8_t hal_spi_em9304_zeros[SPI_EM9304_TX_BUFFER_SIZE];
static uint8_t hal_spi_em9304_rx_buffer[SPI_EM9304_RX_BUFFER_SIZE];
static uint16_t hal_spi_em9304_rx_request_len;
static uint16_t hal_spi_em9304_tx_request_len;
@ -206,6 +209,10 @@ void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi){
hal_spi_em9304_state = SPI_EM9304_TX_WRITE_COMMAND_SENT;
hal_spi_em9304_trigger_run_loop();
break;
case SPI_EM9304_RX_W4_DATA_RECEIVED:
hal_spi_em9304_state = SPI_EM9304_RX_DATA_RECEIVED;
hal_spi_em9304_trigger_run_loop();
break;
default:
break;
}
@ -303,10 +310,10 @@ static void hal_spi_em9304_process(btstack_data_source_t *ds, btstack_data_sourc
break;
}
// read all data
// read data and send '0's
hal_spi_em9304_state = SPI_EM9304_RX_W4_DATA_RECEIVED;
hal_spi_em9304_rx_request_len = hal_spi_em9304_slave_status[1];
HAL_SPI_Receive_DMA(&hspi1, &hal_spi_em9304_rx_buffer[0], hal_spi_em9304_rx_request_len);
HAL_SPI_TransmitReceive_DMA(&hspi1, (uint8_t*) hal_spi_em9304_zeros, &hal_spi_em9304_rx_buffer[0], hal_spi_em9304_rx_request_len);
break;
case SPI_EM9304_RX_DATA_RECEIVED: