paparazzi/paparazzi — pull request #301 by gtoonstra (2012-10-09 16:38:38+00:00)
Title: Finish spi driver

This pull request is generated to show where things are going and to receive some additional comments on where issues do and may arise. This is not intended to be a finished piece of work, only intermediate. So consider this as something you could have a look into and possibly contribute, if you have more experience in SPI programming on the stm32 than me (and libopencm3). I'll continue to debug from here to see if I get things working.

Some feedback and insight is requested on point 1.

It does compile, but does not yet work.
Issues are:

1 phase, polarity selection not yet implemented <- probably requires some ideas on how to do that. It's a chicken/egg problem where mcu.c pre-initializes all SPI's, but where a module/peripheral may require a different configuration. This should then either lead to reinitialization of that bus or the make system should somehow allow flags/selectors for all SPI buses.

2 Only Aspirin2.1 was ported to use this new interface. Are there others? I did not change plane configuration to check. I did notice that it isn't necessarily really difficult to port at that level.

3 The processor hangs at IMU configuration:
static inline void mpu_wait_slave4_ready(void) {
...
spi_submit(&spi2,&aspirin2_mpu60x0);
// FIXME: no busy waiting! if really needed add a timeout!!!!
while(aspirin2_mpu60x0.status != SPITransSuccess);

because the DMA1 ch.4 IRQ is never triggered. Could be SPI config problem or the config of irq's
or something related to timing.

4 A bit of further cleanup would be good. spi.h, which basically should act as a high-level interface now defines functions that appear in spi_arch.c within the architecture / processor branches.

5 I don't have a logic analyzer here, so can't see anything going on. Probably wouldn't be able to, since this board is soldered onto the bottom.

6 I've not verified the code that was there, except for proper use of pins and other defines. Afaik as I know, it's correct, but I'm not sure if more stuff is needed to configure for example the NVIC.

7 I'm not an embedded driver developer, this is my first try at this. So if you see something strange, it's probably not supposed to be that way. The code is certainly not there because of my ninja skills :).