diff --git a/port/stm32-l053r8-em9304/port.c b/port/stm32-l053r8-em9304/port.c index bc0cda64f..32aad5f70 100644 --- a/port/stm32-l053r8-em9304/port.c +++ b/port/stm32-l053r8-em9304/port.c @@ -67,10 +67,44 @@ static const uint8_t read_command[] = { const uint8_t hci_reset[] = { 0x01, 0x03, 0x0c, 0x00 }; +void read_event(void){ + uint8_t status[2]; + uint8_t event[10]; + + // wait for RDY + HAL_GPIO_WritePin(DEBUG_0_GPIO_Port, DEBUG_0_Pin, GPIO_PIN_SET); + // printf("EVT: Wait for ready\n"); + while (HAL_GPIO_ReadPin(SPI1_RDY_GPIO_Port, SPI1_RDY_Pin) == GPIO_PIN_RESET){}; + HAL_GPIO_WritePin(DEBUG_0_GPIO_Port, DEBUG_0_Pin, GPIO_PIN_RESET); + + // chip select + printf("EVT: Select\n"); + HAL_GPIO_WritePin(SPI1_CSN_GPIO_Port, SPI1_CSN_Pin, GPIO_PIN_RESET); + + // send read command + printf("EVT: Send read request\n"); + HAL_SPI_TransmitReceive(&hspi1, (uint8_t*) read_command, status, sizeof(read_command), HAL_MAX_DELAY); + + printf("EVT: STS1 0x%02X, STS2 0x%02X\n", status[0], status[1]); + + // read all data + HAL_SPI_Receive(&hspi1, &event[0], status[1], HAL_MAX_DELAY); + + HAL_GPIO_WritePin(SPI1_CSN_GPIO_Port, SPI1_CSN_Pin, GPIO_PIN_SET); + + // dump + int i; + for (i=0;i