Warm greetings, I have been trying to use the SPI hal driver to interact with ICM20948 interfaced to SPI1 in custom board that i have made.
Following is the SPI configuration which i am using,
Code: Select all
static const SPIConfig spid1_cfg = {
false, //circular mode
NULL, //complete callback
SPI_SOCKET_1_CS_PORT,
SPI_SOCKET_1_CS_PIN,
SPI_CR1_CPHA | SPI_CR1_CPOL | SPI_CR1_BR_1 | SPI_CR1_MSTR | SPI_CR1_SSM | SPI_CR1_SSI
};
I am trying to use the following,
1. Configure GPIO,
Code: Select all
/*
* SPI1 I/O pins setup.
*/
palSetPad(SPI_SOCKET_1_CS_PORT, SPI_SOCKET_1_CS_PIN);
palSetPadMode(SPI_SOCKET_1_CS_PORT, SPI_SOCKET_1_CS_PIN,
PAL_MODE_OUTPUT_PUSHPULL |
PAL_STM32_OSPEED_LOWEST); /* CS */
palSetPadMode(SPI_SOCKET_1_GPIO, SPI_SOCKET_1_SCK,
PAL_MODE_ALTERNATE(SPI_SOCKET_1_AF) |
PAL_STM32_OSPEED_HIGHEST); /* SCK. */
palSetPadMode(SPI_SOCKET_1_GPIO, SPI_SOCKET_1_MISO,
PAL_MODE_ALTERNATE(SPI_SOCKET_1_AF)); /* MISO. */
palSetPadMode(SPI_SOCKET_1_GPIO, SPI_SOCKET_1_MOSI,
PAL_MODE_ALTERNATE(SPI_SOCKET_1_AF) |
PAL_STM32_OSPEED_HIGHEST); /* MOSI. */
2. spiStart(SPID, &spid1_cfg);
3. read one byte WHOAMI from the ICM20948
Code: Select all
/* Slave selection and data send.*/
spiSelect(SPID);
spiExchange(SPID, len, (void *)buf_tx, (void *)buf_rx);
spiUnselect(SPID);
On debugging, I find the call reaches spiStartExchangeI then osalThreadSuspendS suspends and thread is never wokenup, probably by an interrupt.
Kindly let me know what could i be missing or not configured. I had enable debugging and there is no issues there.