Skip to content

Commit

Permalink
Merge pull request #7132 from Marc-Aurele/ws-integration
Browse files Browse the repository at this point in the history
cpu/stm32l0: add i2c driver
  • Loading branch information
aabadie committed Jun 8, 2017
2 parents f5a1e82 + 2a27cb2 commit 1934ae1
Show file tree
Hide file tree
Showing 4 changed files with 517 additions and 0 deletions.
1 change: 1 addition & 0 deletions boards/nucleo-l073/Makefile.features
Expand Up @@ -2,6 +2,7 @@
FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_gpio
FEATURES_PROVIDED += periph_hwrng
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_pwm
FEATURES_PROVIDED += periph_rtc
FEATURES_PROVIDED += periph_spi
Expand Down
45 changes: 45 additions & 0 deletions boards/nucleo-l073/include/periph_conf.h
Expand Up @@ -189,6 +189,51 @@ static const spi_conf_t spi_config[] = {
#define DAC_NUMOF (0)
/** @} */

/**
* @name I2C configuration
* @{
*/
#define I2C_0_EN 1
#define I2C_1_EN 1
#define I2C_NUMOF (I2C_0_EN + I2C_1_EN)
#define I2C_IRQ_PRIO 1
#define I2C_APBCLK (CLOCK_APB1)

/* I2C 0 device configuration */
#define I2C_0_DEV I2C1
#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_IRQn
#define I2C_0_EVT_ISR isr_i2c1
/* I2C 0 pin configuration */
#define I2C_0_SCL_PORT PORT_B
#define I2C_0_SCL_PIN 8
#define I2C_0_SCL_AF 4
#define I2C_0_SCL_CLKEN() (periph_clk_en(AHB, RCC_IOPENR_GPIOBEN))
#define I2C_0_SDA_PORT PORT_B
#define I2C_0_SDA_PIN 9
#define I2C_0_SDA_AF 4
#define I2C_0_SDA_CLKEN() (periph_clk_en(AHB, RCC_IOPENR_GPIOBEN))

/* I2C 1 device configuration */
#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_IRQn
#define I2C_1_EVT_ISR isr_i2c3
/* I2C 1 pin configuration */
#define I2C_1_SCL_PORT PORT_A
#define I2C_1_SCL_PIN 8
#define I2C_1_SCL_AF 3
#define I2C_1_SCL_CLKEN() (periph_clk_en(AHB, RCC_IOPENR_GPIOAEN))
#define I2C_1_SDA_PORT PORT_B
#define I2C_1_SDA_PIN 5
#define I2C_1_SDA_AF 8
#define I2C_1_SDA_CLKEN() (periph_clk_en(AHB, RCC_IOPENR_GPIOBEN))
/** @} */

/** @} */

/**
* @name RTC configuration
* @{
Expand Down
12 changes: 12 additions & 0 deletions cpu/stm32l0/include/periph_cpu.h
Expand Up @@ -73,6 +73,18 @@ typedef struct {
uint8_t chan; /**< DAC device used for this line */
} dac_conf_t;

/**
* @brief I2C configuration data structure
*/
typedef struct {
I2C_TypeDef *dev; /**< i2c device */
gpio_t scl; /**< scl pin number */
gpio_t sda; /**< sda pin number */
gpio_mode_t pin_mode; /**< with or without pull resistor */
gpio_af_t af; /**< I2C alternate function value */
uint8_t ev_irqn; /**< event IRQ */
} i2c_conf_t;

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 1934ae1

Please sign in to comment.