STM32F4 hangs on _spi_wait_s
Posted: Sat Aug 25, 2012 10:10 pm
Hi ALL!
This is my 1st post on this forum so first of all let me thank you for great job making Chibios/RT even better each day.
I am a newbie with Chibios/RT and I am trying to use it with nRF24l01+ transceiver.
My code is simple:
Unfortunately code hangs on "_spi_wait_s" inside "spiSend".
I have spent 2 days on it w/o success.
Please note, that i've tested it with following versions: 2.4.1, 2.4.2, today's trunk.
Thanks in advance.
Piotr
This is my 1st post on this forum so first of all let me thank you for great job making Chibios/RT even better each day.
I am a newbie with Chibios/RT and I am trying to use it with nRF24l01+ transceiver.
My code is simple:
Code: Select all
SPIConfig hs_spicfg = {
NULL,
GPIOB,
12,
0
};
#define NRF_BUF_SIZE 128
static uint8_t txbuf[NRF_BUF_SIZE] = {0};
static uint8_t rxbuf[NRF_BUF_SIZE] = {0};
int main(void) {
halInit(); //hal must be initialized before kernel
chSysInit(); //kernel init
palSetPadMode(GPIOB, 12, PAL_MODE_ALTERNATE(5) | PAL_STM32_OSPEED_HIGHEST); /* NSS. */
palSetPadMode(GPIOB, 13, PAL_MODE_ALTERNATE(5) | PAL_STM32_OSPEED_HIGHEST); /* SCK. */
palSetPadMode(GPIOB, 14, PAL_MODE_ALTERNATE(5)); /* MISO.*/
palSetPadMode(GPIOB, 15, PAL_MODE_ALTERNATE(5) | PAL_STM32_OSPEED_HIGHEST); /* MOSI.*/
palSetPad(GPIOB, 12);
spiAcquireBus(&SPID2); /* Acquire ownership of the bus. */
/* Write Config */
spiStart(&SPID2, &hs_spicfg); /* Setup transfer parameters. */
spiSelect(&SPID2); /* Slave Select assertion. */
txbuf[0] = 0b00100000;
txbuf[1] = 0b00001110;
spiSend(&SPID2, 2, txbuf); /* Atomic transfer operations. */
spiUnselect(&SPID2); /* Slave Select de-assertion. */
/* Read Config */
txbuf[0] = 0b00000000;
spiSelect(&SPID2); /* Slave Select assertion. */
spiExchange(&SPID2, 1, txbuf, rxbuf); /* Atomic transfer operations. */
spiUnselect(&SPID2); /* Slave Select de-assertion. */
spiReleaseBus(&SPID2); /* Ownership release. */
}
Unfortunately code hangs on "_spi_wait_s" inside "spiSend".
I have spent 2 days on it w/o success.
Please note, that i've tested it with following versions: 2.4.1, 2.4.2, today's trunk.
Thanks in advance.
Piotr