Skip to content

Commit

Permalink
boards/esp32: SPI configuration approach changed
Browse files Browse the repository at this point in the history
SPI devices are now configured using static array in header files instead of static variables in implementation to be able to define SPI_NUMOF using the size of the array instead of a variable.
  • Loading branch information
gschorcht committed May 2, 2019
1 parent d1e159b commit 2666723
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion boards/common/esp32/include/periph_conf_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,30 @@ extern "C" {
* @name SPI configuration
*/

/**
* @brief Static array with configuration for declared I2C devices
*/
static const spi_conf_t spi_config[] = {
#ifdef SPI0_CTRL
{
.ctrl = SPI0_CTRL,
.sck = SPI0_SCK,
.mosi = SPI0_MOSI,
.miso = SPI0_MISO,
.cs = SPI0_CS0,
},
#endif
#ifdef SPI1_CTRL
{
.ctrl = SPI1_CTRL,
.sck = SPI1_SCK,
.mosi = SPI1_MOSI,
.miso = SPI1_MISO,
.cs = SPI1_CS0,
},
#endif
};

/**
* @brief Number of SPI interfaces
*
Expand All @@ -131,7 +155,7 @@ extern "C" {
*
* @note SPI_NUMOF definition must not be changed.
*/
#define SPI_NUMOF (spi_bus_num)
#define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))

/** @} */

Expand Down

0 comments on commit 2666723

Please sign in to comment.