From 19f11e8d8bf7ffed368870a60d09ced3320345f4 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sun, 25 Jun 2017 11:45:13 +0200 Subject: [PATCH] stm32-l053r8-em9304: expect active state entered event, debug #0 indidcates wait for RDY --- port/stm32-l053r8-em9304/port.c | 76 ++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 34 deletions(-) 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