[AT91SAM7X] PAL config in SPI driver

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
Post Reply
Florian
Posts: 18
Joined: Fri Sep 09, 2011 3:19 pm

[AT91SAM7X] PAL config in SPI driver

Post by Florian »

Hi Giovanni,
I tried to use the SPI_LLD driver for the AT91SAM7X µC. As I see, the slave select lines are not set by the hardware SPI controller but by the software driver using the PAL module. I wondered where the PAL configuration is done for that lines and indeed the CS didn't work instantly.
When I insert the following line to spi_lld_start, it runs properly.

Code: Select all

void spi_lld_start(SPIDriver *spip) {
// ... (below the #endif)
  /* configure SS line as output */
  palSetPadMode(spip->config->ssport, spip->config->sspad, PAL_MODE_OUTPUT_PUSHPULL);
  /* Configuration.*/
// ...
}

Maybe you wanna add this to the SAM7 SPI_LLD driver, too? Or did I maybe missconfigure something?

Regards,
Florian
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: [AT91SAM7X] PAL config in SPI driver

Post by Giovanni »

Hi,

The configuration is assumed to be done outside the driver, usually it is done statically in your board.h file. If your board assigns several pins as CS then you want them configured immediately not when the SPI driver is started, also, they have to be configured regardless the driver is started or not.

Giovanni
Florian
Posts: 18
Joined: Fri Sep 09, 2011 3:19 pm

Re: [AT91SAM7X] PAL config in SPI driver

Post by Florian »

well, that's true of course. Then I will do that in board.h or board.c as well.
Post Reply