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 6, 2019
1 parent 26613ee commit 23cc987
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 @@ -128,6 +128,30 @@ static const gpio_t adc_channels[] = ADC_GPIOS;
* @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 @@ -136,7 +160,7 @@ static const gpio_t adc_channels[] = ADC_GPIOS;
*
* @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 23cc987

Please sign in to comment.