* ````c static void acc_hal_integration_sensor_transfer(acc_sensor_id_t sensor_id, uint8_t *buffer, size_t buffer_size) { if ((sensor_id == 0) || (sensor_id > SENSOR_COUNT)) { Error_Handler(); } spi_select(sensor_id); const uint32_t SPI_TRANSMIT_RECEIVE_TIMEOUT = 5000; HAL_GPIO_WritePin(A121_SPI_SS_GPIO_Port, A121_SPI_SS_Pin, GPIO_PIN_RESET); #ifdef STM32_USE_SPI_DMA spi_transfer_complete = false; HAL_StatusTypeDef status = HAL_SPI_TransmitReceive_DMA(&A121_SPI_HANDLE, spi_buffer, spi_buffer, buffer_size); if (status != HAL_OK) { Error_Handler(); } uint32_t start = HAL_GetTick(); while (!spi_transfer_complete && (HAL_GetTick() - start) < SPI_TRANSMIT_RECEIVE_TIMEOUT) { // Turn off interrupts disable_interrupts(); // Check once more so that the interrupt have not occurred if (!spi_transfer_complete) { __WFI(); } // Enable interrupt again, the ISR will execute directly after this enable_interrupts(); } #else HAL_SPI_TransmitReceive(&A121_SPI_HANDLE, buffer, buffer, buffer_size, SPI_TRANSMIT_RECEIVE_TIMEOUT); #endif HAL_GPIO_WritePin(A121_SPI_SS_GPIO_Port, A121_SPI_SS_Pin, GPIO_PIN_SET); } ````