mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-25 16:43:28 +00:00
stm32-l053r8-em9304: expect active state entered event, debug #0 indidcates wait for RDY
This commit is contained in:
parent
6e78c2056a
commit
19f11e8d8b
@ -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<status[1];i++){
|
||||
printf("%02x ", event[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
printf("EVT: Done\n");
|
||||
}
|
||||
|
||||
void port_main(void){
|
||||
HAL_GPIO_WritePin(SPI1_CSN_GPIO_Port, SPI1_CSN_Pin, GPIO_PIN_SET);
|
||||
uint8_t status[2];
|
||||
uint8_t event[10];
|
||||
|
||||
while (1){
|
||||
|
||||
@ -79,16 +113,17 @@ void port_main(void){
|
||||
HAL_Delay(10);
|
||||
HAL_GPIO_WritePin(EN_GPIO_Port, EN_Pin, GPIO_PIN_SET);
|
||||
|
||||
printf("CMD: Select\n");
|
||||
// HAL_GPIO_WritePin( GPIOB, GPIO_PIN_6, GPIO_PIN_RESET );
|
||||
// HAL_GPIO_WritePin( GPIOB, GPIO_PIN_6, GPIO_PIN_SET );
|
||||
read_event();
|
||||
|
||||
// chip select
|
||||
printf("CMD: Select\n");
|
||||
HAL_GPIO_WritePin(SPI1_CSN_GPIO_Port, SPI1_CSN_Pin, GPIO_PIN_RESET);
|
||||
|
||||
// wait for RDY
|
||||
printf("CMD: Wait for ready\n");
|
||||
HAL_GPIO_WritePin(DEBUG_0_GPIO_Port, DEBUG_0_Pin, GPIO_PIN_SET);
|
||||
// printf("CMD: 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);
|
||||
|
||||
printf("CMD: Send write request\n");
|
||||
|
||||
@ -105,7 +140,7 @@ void port_main(void){
|
||||
// check size
|
||||
if (status[1] < sizeof(hci_reset)) continue;
|
||||
|
||||
printf("CMD: Enough buffer, send\n");
|
||||
printf("CMD: Enough buffer, send HCI Reset\n");
|
||||
|
||||
// send command
|
||||
HAL_SPI_Transmit(&hspi1, (uint8_t*) hci_reset, sizeof(hci_reset), HAL_MAX_DELAY);
|
||||
@ -115,33 +150,6 @@ void port_main(void){
|
||||
|
||||
printf("CMD: Done\n");
|
||||
|
||||
// wait for RDY
|
||||
printf("EVT: Wait for ready\n");
|
||||
while (HAL_GPIO_ReadPin(SPI1_RDY_GPIO_Port, SPI1_RDY_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<status[1];i++){
|
||||
printf("%02x ", event[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
printf("EVT: Done\n");
|
||||
|
||||
read_event();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user