boards: adapt stm32f3 based boards to new I2C api
This commit is contained in:
parent
c95ee04b23
commit
634d9f6d68
@ -194,47 +194,37 @@ static const spi_conf_t spi_config[] = {
|
|||||||
* @name I2C configuration
|
* @name I2C configuration
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define I2C_NUMOF (2U)
|
static const i2c_conf_t i2c_config[] = {
|
||||||
#define I2C_0_EN 1
|
{
|
||||||
#define I2C_1_EN 1
|
.dev = I2C1,
|
||||||
#define I2C_IRQ_PRIO 1
|
.speed = I2C_SPEED_NORMAL,
|
||||||
#define I2C_APBCLK (36000000U)
|
.scl_pin = GPIO_PIN(PORT_B, 8),
|
||||||
|
.sda_pin = GPIO_PIN(PORT_B, 9),
|
||||||
|
.scl_af = GPIO_AF4,
|
||||||
|
.sda_af = GPIO_AF4,
|
||||||
|
.bus = APB1,
|
||||||
|
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
||||||
|
.rcc_sw_mask = RCC_CFGR3_I2C1SW,
|
||||||
|
.irqn = I2C1_ER_IRQn
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.dev = I2C3,
|
||||||
|
.speed = I2C_SPEED_NORMAL,
|
||||||
|
.scl_pin = GPIO_PIN(PORT_A, 8),
|
||||||
|
.sda_pin = GPIO_PIN(PORT_A, 5),
|
||||||
|
.scl_af = GPIO_AF5,
|
||||||
|
.sda_af = GPIO_AF8,
|
||||||
|
.bus = APB1,
|
||||||
|
.rcc_mask = RCC_APB1ENR_I2C3EN,
|
||||||
|
.rcc_sw_mask = RCC_CFGR3_I2C3SW,
|
||||||
|
.irqn = I2C3_ER_IRQn
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* I2C 0 device configuration */
|
#define I2C_0_ISR isr_i2c1_er
|
||||||
#define I2C_0_DEV I2C1
|
#define I2C_1_ISR isr_i2c3_er
|
||||||
#define I2C_0_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C1EN))
|
|
||||||
#define I2C_0_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C1EN))
|
|
||||||
#define I2C_0_EVT_IRQ I2C1_EV_IRQn
|
|
||||||
#define I2C_0_EVT_ISR isr_i2c1_ev
|
|
||||||
#define I2C_0_ERR_IRQ I2C1_ER_IRQn
|
|
||||||
#define I2C_0_ERR_ISR isr_i2c1_er
|
|
||||||
/* I2C 0 pin configuration */
|
|
||||||
#define I2C_0_SCL_PORT GPIOB
|
|
||||||
#define I2C_0_SCL_PIN 8
|
|
||||||
#define I2C_0_SCL_AF 4
|
|
||||||
#define I2C_0_SCL_CLKEN() (periph_clk_en(AHB, RCC_AHBENR_GPIOBEN))
|
|
||||||
#define I2C_0_SDA_PORT GPIOB
|
|
||||||
#define I2C_0_SDA_PIN 9
|
|
||||||
#define I2C_0_SDA_AF 4
|
|
||||||
#define I2C_0_SDA_CLKEN() (periph_clk_en(AHB, RCC_AHBENR_GPIOBEN))
|
|
||||||
|
|
||||||
/* I2C 1 device configuration */
|
#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0]))
|
||||||
#define I2C_1_DEV I2C3
|
|
||||||
#define I2C_1_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C3EN))
|
|
||||||
#define I2C_1_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C3EN))
|
|
||||||
#define I2C_1_EVT_IRQ I2C3_EV_IRQn
|
|
||||||
#define I2C_1_EVT_ISR isr_i2c3_ev
|
|
||||||
#define I2C_1_ERR_IRQ I2C3_ER_IRQn
|
|
||||||
#define I2C_1_ERR_ISR isr_i2c3_er
|
|
||||||
/* I2C 1 pin configuration */
|
|
||||||
#define I2C_1_SCL_PORT GPIOA
|
|
||||||
#define I2C_1_SCL_PIN 8
|
|
||||||
#define I2C_1_SCL_AF 3
|
|
||||||
#define I2C_1_SCL_CLKEN() (periph_clk_en(AHB, RCC_AHBENR_GPIOAEN))
|
|
||||||
#define I2C_1_SDA_PORT GPIOB
|
|
||||||
#define I2C_1_SDA_PIN 5
|
|
||||||
#define I2C_1_SDA_AF 8
|
|
||||||
#define I2C_1_SDA_CLKEN() (periph_clk_en(AHB, RCC_AHBENR_GPIOBEN))
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@ -195,47 +195,37 @@ static const spi_conf_t spi_config[] = {
|
|||||||
* @name I2C configuration
|
* @name I2C configuration
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define I2C_NUMOF (2U)
|
static const i2c_conf_t i2c_config[] = {
|
||||||
#define I2C_0_EN 1
|
{
|
||||||
#define I2C_1_EN 1
|
.dev = I2C1,
|
||||||
#define I2C_IRQ_PRIO 1
|
.speed = I2C_SPEED_NORMAL,
|
||||||
#define I2C_APBCLK (CLOCK_APB1)
|
.scl_pin = GPIO_PIN(PORT_B, 8),
|
||||||
|
.sda_pin = GPIO_PIN(PORT_B, 9),
|
||||||
|
.scl_af = GPIO_AF4,
|
||||||
|
.sda_af = GPIO_AF4,
|
||||||
|
.bus = APB1,
|
||||||
|
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
||||||
|
.rcc_sw_mask = RCC_CFGR3_I2C1SW,
|
||||||
|
.irqn = I2C1_ER_IRQn
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.dev = I2C3,
|
||||||
|
.speed = I2C_SPEED_NORMAL,
|
||||||
|
.scl_pin = GPIO_PIN(PORT_A, 8),
|
||||||
|
.sda_pin = GPIO_PIN(PORT_A, 5),
|
||||||
|
.scl_af = GPIO_AF5,
|
||||||
|
.sda_af = GPIO_AF8,
|
||||||
|
.bus = APB1,
|
||||||
|
.rcc_mask = RCC_APB1ENR_I2C3EN,
|
||||||
|
.rcc_sw_mask = RCC_CFGR3_I2C3SW,
|
||||||
|
.irqn = I2C3_ER_IRQn
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* I2C 0 device configuration */
|
#define I2C_0_ISR isr_i2c1_er
|
||||||
#define I2C_0_DEV I2C1
|
#define I2C_1_ISR isr_i2c3_er
|
||||||
#define I2C_0_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C1EN))
|
|
||||||
#define I2C_0_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C1EN))
|
|
||||||
#define I2C_0_EVT_IRQ I2C1_EV_IRQn
|
|
||||||
#define I2C_0_EVT_ISR isr_i2c1_ev
|
|
||||||
#define I2C_0_ERR_IRQ I2C1_ER_IRQn
|
|
||||||
#define I2C_0_ERR_ISR isr_i2c1_er
|
|
||||||
/* I2C 0 pin configuration */
|
|
||||||
#define I2C_0_SCL_PORT GPIOB
|
|
||||||
#define I2C_0_SCL_PIN 8
|
|
||||||
#define I2C_0_SCL_AF 4
|
|
||||||
#define I2C_0_SCL_CLKEN() (periph_clk_en(AHB, RCC_AHBENR_GPIOBEN))
|
|
||||||
#define I2C_0_SDA_PORT GPIOB
|
|
||||||
#define I2C_0_SDA_PIN 9
|
|
||||||
#define I2C_0_SDA_AF 4
|
|
||||||
#define I2C_0_SDA_CLKEN() (periph_clk_en(AHB, RCC_AHBENR_GPIOBEN))
|
|
||||||
|
|
||||||
/* I2C 1 device configuration */
|
#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0]))
|
||||||
#define I2C_1_DEV I2C3
|
|
||||||
#define I2C_1_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C3EN))
|
|
||||||
#define I2C_1_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C3EN))
|
|
||||||
#define I2C_1_EVT_IRQ I2C3_EV_IRQn
|
|
||||||
#define I2C_1_EVT_ISR isr_i2c3_ev
|
|
||||||
#define I2C_1_ERR_IRQ I2C3_ER_IRQn
|
|
||||||
#define I2C_1_ERR_ISR isr_i2c3_er
|
|
||||||
/* I2C 1 pin configuration */
|
|
||||||
#define I2C_1_SCL_PORT GPIOA
|
|
||||||
#define I2C_1_SCL_PIN 8
|
|
||||||
#define I2C_1_SCL_AF 3
|
|
||||||
#define I2C_1_SCL_CLKEN() (periph_clk_en(AHB, RCC_AHBENR_GPIOAEN))
|
|
||||||
#define I2C_1_SDA_PORT GPIOB
|
|
||||||
#define I2C_1_SDA_PIN 5
|
|
||||||
#define I2C_1_SDA_AF 8
|
|
||||||
#define I2C_1_SDA_CLKEN() (periph_clk_en(AHB, RCC_AHBENR_GPIOBEN))
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@ -209,47 +209,37 @@ static const spi_conf_t spi_config[] = {
|
|||||||
* @name I2C configuration
|
* @name I2C configuration
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define I2C_NUMOF (2U)
|
static const i2c_conf_t i2c_config[] = {
|
||||||
#define I2C_0_EN 1
|
{
|
||||||
#define I2C_1_EN 1
|
.dev = I2C1,
|
||||||
#define I2C_IRQ_PRIO 1
|
.speed = I2C_SPEED_NORMAL,
|
||||||
#define I2C_APBCLK (CLOCK_APB1)
|
.scl_pin = GPIO_PIN(PORT_B, 6),
|
||||||
|
.sda_pin = GPIO_PIN(PORT_B, 7),
|
||||||
|
.scl_af = GPIO_AF4,
|
||||||
|
.sda_af = GPIO_AF4,
|
||||||
|
.bus = APB1,
|
||||||
|
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
||||||
|
.rcc_sw_mask = RCC_CFGR3_I2C1SW,
|
||||||
|
.irqn = I2C1_ER_IRQn
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.dev = I2C2,
|
||||||
|
.speed = I2C_SPEED_NORMAL,
|
||||||
|
.scl_pin = GPIO_PIN(PORT_F, 1),
|
||||||
|
.sda_pin = GPIO_PIN(PORT_F, 0),
|
||||||
|
.scl_af = GPIO_AF4,
|
||||||
|
.sda_af = GPIO_AF4,
|
||||||
|
.bus = APB1,
|
||||||
|
.rcc_mask = RCC_APB1ENR_I2C2EN,
|
||||||
|
.rcc_sw_mask = RCC_CFGR3_I2C2SW,
|
||||||
|
.irqn = I2C2_ER_IRQn
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* I2C 0 device configuration */
|
#define I2C_0_ISR isr_i2c1_er
|
||||||
#define I2C_0_DEV I2C1
|
#define I2C_1_ISR isr_i2c2_er
|
||||||
#define I2C_0_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C1EN))
|
|
||||||
#define I2C_0_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C1EN))
|
|
||||||
#define I2C_0_EVT_IRQ I2C1_EV_IRQn
|
|
||||||
#define I2C_0_EVT_ISR isr_i2c1_ev
|
|
||||||
#define I2C_0_ERR_IRQ I2C1_ER_IRQn
|
|
||||||
#define I2C_0_ERR_ISR isr_i2c1_er
|
|
||||||
/* I2C 0 pin configuration */
|
|
||||||
#define I2C_0_SCL_PORT GPIOB
|
|
||||||
#define I2C_0_SCL_PIN 6
|
|
||||||
#define I2C_0_SCL_AF 4
|
|
||||||
#define I2C_0_SCL_CLKEN() (periph_clk_en(AHB, RCC_AHBENR_GPIOBEN))
|
|
||||||
#define I2C_0_SDA_PORT GPIOB
|
|
||||||
#define I2C_0_SDA_PIN 7
|
|
||||||
#define I2C_0_SDA_AF 4
|
|
||||||
#define I2C_0_SDA_CLKEN() (periph_clk_en(AHB, RCC_AHBENR_GPIOBEN))
|
|
||||||
|
|
||||||
/* I2C 1 device configuration */
|
#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0]))
|
||||||
#define I2C_1_DEV I2C2
|
|
||||||
#define I2C_1_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C2EN))
|
|
||||||
#define I2C_1_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C2EN))
|
|
||||||
#define I2C_1_EVT_IRQ I2C2_EV_IRQn
|
|
||||||
#define I2C_1_EVT_ISR isr_i2c2_ev
|
|
||||||
#define I2C_1_ERR_IRQ I2C2_ER_IRQn
|
|
||||||
#define I2C_1_ERR_ISR isr_i2c2_er
|
|
||||||
/* I2C 1 pin configuration */
|
|
||||||
#define I2C_1_SCL_PORT GPIOF
|
|
||||||
#define I2C_1_SCL_PIN 1
|
|
||||||
#define I2C_1_SCL_AF 4
|
|
||||||
#define I2C_1_SCL_CLKEN() (periph_clk_en(AHB, RCC_AHBENR_GPIOFEN))
|
|
||||||
#define I2C_1_SDA_PORT GPIOF
|
|
||||||
#define I2C_1_SDA_PIN 0
|
|
||||||
#define I2C_1_SDA_AF 4
|
|
||||||
#define I2C_1_SDA_CLKEN() (periph_clk_en(AHB, RCC_AHBENR_GPIOFEN))
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user