[riot-devel] SPI automatic interface configuration inside of cpu.c/periph_init(();

Hauke Petersen hauke.petersen at fu-berlin.de
Tue May 2 09:43:34 CEST 2017


Hi Neo,

the global/automatic SPI initialization might not be ideal, but the 
benefits are greater than the drawbacks. One of the major design issues 
this is solving is the handling of shared peripherals (as in SPI/I2C): 
when doing the initialization somewhere in the driver code, different 
driver will re-initialize the same peripheral, potentially with 
contradicting settings...

For your specific problem: if you only use one specific SPI and use pins 
configured to another SPI dev for other purposes, then the other SPI 
should not be configured, so you should use an application specific 
`periph_conf.h` file. This should fix your issues.

Cheers,
Hauke


On 29.04.2017 14:56, Neo wrote:
> Dear RIOT developers,
>
> I think it is not a good idea to initilialize the SPI interface 
> automatically via the periph_init() function because it is not as 
> static as mentioned.
>
> In my application I have 2 SPI interfaces defined in the periph_conf.h 
> file - but I wanted only to configure the second one of these interfaces.
>
> I the older days everything went well, but when I pulled in the new 
> sources I was wondering why now the spi_init() function was invoked 3 
> times....2 times automatically by the periph_init() function 
> (initializing all defined interfaces) and one time by my own 
> (initializing only the second interface).....and it took some time to 
> find out what was going wrong.
>
> For my opinion interface initialization should be under control of the 
> application which interface is set up.
>
> Best regards,
>
> Neo
>
> _______________________________________________
> devel mailing list
> devel at riot-os.org
> https://lists.riot-os.org/mailman/listinfo/devel



More information about the devel mailing list