I had a little SPI (test)program running under ChibiOs 2.6.1 on STM32F30x and now I'm trying to get it running on STM32F4xx.
Mosi and Clock lines are working good but CS remains always low level. I tried with 'Software slave management disabled' and 'enabled in the SPI_CR1 register.
Here is my little test code and perhaps somebody sees an error immediatly?
Code: Select all
static const SPIConfig spi1cfg = {
NULL,
/* HW dependent part.*/
GPIOA,
4,
0b0000101000010100 //or 0b0000100000010100 for NSS hard?
};
/*
* Gyroscope (SPI1) Startup code
* See documentation
*/
static uint16_t txbuf[7]={42784,1313,34,4131,36,168,143};
static uint16_t rxbuf[7];
void write_read_buffer_spi_gyroscope (uint16_t *transmit,uint16_t *receive){
spiSelect(&SPID1); /* Slave Select assertion. */
spiExchange(&SPID1, 1*2,
transmit, receive); /* Atomic transfer operations. */
spiUnselect(&SPID1); /* Slave Select de-assertion. */
}
/*
* Application entry point.
*/
int main(void) {
halInit();
chSysInit();
spiStart(&SPID1, &spi1cfg); /* Setup transfer parameters. */
write_read_buffer_spi_gyroscope(&txbuf[0],&rxbuf[0]);
write_read_buffer_spi_gyroscope(&txbuf[1],&rxbuf[1]);
write_read_buffer_spi_gyroscope(&txbuf[2],&rxbuf[2]);
write_read_buffer_spi_gyroscope(&txbuf[3],&rxbuf[3]);
write_read_buffer_spi_gyroscope(&txbuf[4],&rxbuf[4]);
write_read_buffer_spi_gyroscope(&txbuf[5],&rxbuf[5]);
write_read_buffer_spi_gyroscope(&txbuf[6],&rxbuf[6]);
...
Thank you!!!