简体   繁体   中英

Bluenrg-ms/stm32F4 : Hci packet through spi

I am working on a project to developp a ble communication but i'm having some trouble to initialize and comprehend the return frame from ble.

After lowering the cs, testing the header (0x0A,0x00,0x00,0x00,0x00) and sending directly after hci_reset (0x01,0x03,0x0C,0x00) with HAL_SPI_TransmitReceive, I want to read the return value from ble.

So lowering the cs one more time, test header (0x0B,0x00,0x00,0x00,0x00) and sending dummies data with HAL_SPI_TransmitReceive. I obtain this frame: 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00.

But from what I have understood this far I should obtain something like:0x04,0x0E,0x04,0x01,0x03,0x0C,0x00.

Can someone point out where I am wrong?

Almost resolved.

Actually I changed some points in my code and finally retrieved the data from ble corresponding to what I was waiting for.

What I was doing before was closing the frame after receiving right header from ble. Then sending header to write command followed by the command.

That is the procedure I applied: Information communication spi (write): • open CS ◦ send header_master[5]={0x0a,0,0,0,0} in TransmitReceive ▪ if header_slave[0]=0x02 and header_slave[1]>0 • send commands • close CS ▪ else • close CS • goto open CS

Information communication spi (read): • wait for exti from ble ◦ Open CS ▪ send header_master[5]={0x0b,0,0,0,0} in TransmitReceive • if header_slave[0]=0x02 and header_slave[3]>0 ◦ send (header_slave[3]) dummies ◦ close CS • else ◦ close CS ◦ goto open CS

Hope that can help some people.

Now i'm facing an other issue. I don't receive the interrupt after sending the command so I do polling up to catching the frame I need. Any solution?

You must always start to reset the bluenrg first: this will cause the bluenrg to trigger an interrupt. It is unclear what the behaviour is without the hard reset.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM