mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
boards/common/gd32v: cleanup default I2C and SPI config
This commit includes the following cleanups: - The macros `I2C_DEV_1_USED` and `SPI_DEV_1_USED` are now used with the values 0 and 1. This allows to enable but also to disable the second interface even if the board definition enables it by default. - The second I2C device `I2C_DEV(1)` and the second SPI device `SPI_DEV(1)` are now disabled by default. - The second SPI device `SPI_DEV(1)` now uses PB5 as default CS signal instead of PA4 to keep PA4 free for ADC or DAC even if `SPI_DEV(1)` is used, for example for the TFT display.
This commit is contained in:
parent
4591cebeef
commit
89846f8cea
@ -33,11 +33,16 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable the second I2C device `I2C_DEV(1)` by default
|
||||
* @brief Disable the second I2C device `I2C_DEV(1)` by default
|
||||
*
|
||||
* The second I2C device `I2C_DEV(1)` is only defined if `I2C_DEV_1_USED`
|
||||
* is set to 1 by the board.
|
||||
* This allows to use the default configuration with one or two I2C devices
|
||||
* depending on whether other peripherals are enabled that would collide with
|
||||
* the I2C devices.
|
||||
*/
|
||||
#ifndef I2C_DEV_1_USED
|
||||
#define I2C_DEV_1_USED
|
||||
#define I2C_DEV_1_USED 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -46,7 +51,7 @@ extern "C" {
|
||||
* The default I2C device configuration allows to define up to two I2C devices
|
||||
* `I2C_DEV(0)` and `I2C_DEV(1)`. `I2C_DEV(0)` is always defined if the I2C
|
||||
* peripheral is enabled by the module `periph_spi`. The second I2C device
|
||||
* `I2C_DEV(1)` is only defined if `I2C_DEV_1_USED` is defined by the board.
|
||||
* `I2C_DEV(1)` is only defined if `I2C_DEV_1_USED` is set to 1 by the board.
|
||||
* This allows to use the default configuration with one or two I2C devices
|
||||
* depending on whether other peripherals are enabled that would collide with
|
||||
* the I2C devices.
|
||||
@ -60,6 +65,7 @@ static const i2c_conf_t i2c_config[] = {
|
||||
.rcu_mask = RCU_APB1EN_I2C0EN_Msk,
|
||||
.irqn = I2C0_EV_IRQn,
|
||||
},
|
||||
#if I2C_DEV_1_USED
|
||||
{
|
||||
.dev = I2C1,
|
||||
.speed = I2C_SPEED_NORMAL,
|
||||
@ -68,6 +74,7 @@ static const i2c_conf_t i2c_config[] = {
|
||||
.rcu_mask = RCU_APB1EN_I2C1EN_Msk,
|
||||
.irqn = I2C1_EV_IRQn,
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#define I2C_NUMOF ARRAY_SIZE(i2c_config)
|
||||
|
@ -33,11 +33,16 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable the second SPI device `SPI_DEV(1)` by default
|
||||
* @brief Disable the second SPI device `SPI_DEV(1)` by default
|
||||
*
|
||||
* The second SPI device `SPI_DEV(1)` is only defined if `SPI_DEV_1_USED`
|
||||
* is set to 1 by the board.
|
||||
* This allows to use the default configuration with one or two SPI devices
|
||||
* depending on whether other peripherals are enabled that would collide with
|
||||
* the SPI devices.
|
||||
*/
|
||||
#ifndef SPI_DEV_1_USED
|
||||
#define SPI_DEV_1_USED
|
||||
#define SPI_DEV_1_USED 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -57,7 +62,7 @@ extern "C" {
|
||||
* the default CS signal is connected to an unused hardware.
|
||||
*/
|
||||
#ifndef SPI_DEV_1_CS
|
||||
#define SPI_DEV_1_CS GPIO_PIN(PORT_A, 4)
|
||||
#define SPI_DEV_1_CS GPIO_PIN(PORT_B, 5)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -66,7 +71,7 @@ extern "C" {
|
||||
* The default SPI device configuration allows to define up to two SPI devices
|
||||
* `SPI_DEV(0)` and `SPI_DEV(1)`. `SPI_DEV(0)` is always defined if the SPI
|
||||
* peripheral is enabled by the module `periph_spi`. The second SPI device
|
||||
* `SPI_DEV(1)` is only defined if `SPI_DEV_1_USED` is defined by the board.
|
||||
* `SPI_DEV(1)` is only defined if `SPI_DEV_1_USED` is set to 1 by the board.
|
||||
* This allows to use the default configuration with one or two SPI devices
|
||||
* depending on whether other peripherals are enabled that would collide with
|
||||
* the SPI devices.
|
||||
@ -81,7 +86,7 @@ static const spi_conf_t spi_config[] = {
|
||||
.rcumask = RCU_APB1EN_SPI1EN_Msk,
|
||||
.apbbus = APB1,
|
||||
},
|
||||
#ifdef SPI_DEV_1_USED
|
||||
#if SPI_DEV_1_USED
|
||||
{
|
||||
.dev = SPI0,
|
||||
.mosi_pin = GPIO_PIN(PORT_A, 7),
|
||||
|
Loading…
Reference in New Issue
Block a user