mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/esp32: port periph/i2c_hw to ESP-IDF i2c HAL
This commit is contained in:
parent
dd806ce72e
commit
c0becd2819
@ -100,24 +100,48 @@ static const gpio_t dac_channels[] = DAC_GPIOS;
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined(I2C0_SCL) && !defined(I2C0_SCL_PULLUP)
|
||||||
|
/** Define SCL pullup enabled by default */
|
||||||
|
#define I2C0_SCL_PULLUP true
|
||||||
|
#endif
|
||||||
|
#if defined(I2C0_SDA) && !defined(I2C0_SDA_PULLUP)
|
||||||
|
/** Define SDA pullup enabled by default */
|
||||||
|
#define I2C0_SDA_PULLUP true
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(I2C1_SCL) && !defined(I2C1_SCL_PULLUP)
|
||||||
|
/** Define SCL pullup enabled by default */
|
||||||
|
#define I2C1_SCL_PULLUP true
|
||||||
|
#endif
|
||||||
|
#if defined(I2C1_SDA) && !defined(I2C1_SDA_PULLUP)
|
||||||
|
/** Define SDA pullup enabled by default */
|
||||||
|
#define I2C1_SDA_PULLUP true
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Static array with configuration for declared I2C devices
|
* @brief Static array with configuration for declared I2C devices
|
||||||
*/
|
*/
|
||||||
static const i2c_conf_t i2c_config[] = {
|
static const i2c_conf_t i2c_config[] = {
|
||||||
#if defined(I2C0_SCL) && defined(I2C0_SDA) && defined(I2C0_SPEED)
|
#if defined(I2C0_SCL) && defined(I2C0_SDA) && defined(I2C0_SPEED)
|
||||||
{
|
{
|
||||||
|
.module = PERIPH_I2C0_MODULE,
|
||||||
.speed = I2C0_SPEED,
|
.speed = I2C0_SPEED,
|
||||||
.scl = I2C0_SCL,
|
.scl = I2C0_SCL,
|
||||||
.sda = I2C0_SDA,
|
.sda = I2C0_SDA,
|
||||||
|
.scl_pullup = I2C0_SCL_PULLUP,
|
||||||
|
.sda_pullup = I2C0_SCL_PULLUP,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
#if defined(I2C1_SCL) && defined(I2C1_SDA) && defined(I2C1_SPEED)
|
#if defined(I2C1_SCL) && defined(I2C1_SDA) && defined(I2C1_SPEED)
|
||||||
{
|
{
|
||||||
|
.module = PERIPH_I2C1_MODULE,
|
||||||
.speed = I2C1_SPEED,
|
.speed = I2C1_SPEED,
|
||||||
.scl = I2C1_SCL,
|
.scl = I2C1_SCL,
|
||||||
.sda = I2C1_SDA,
|
.sda = I2C1_SDA,
|
||||||
|
.scl_pullup = I2C1_SCL_PULLUP,
|
||||||
|
.sda_pullup = I2C1_SCL_PULLUP,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -287,18 +311,18 @@ static const uart_conf_t uart_config[] = {
|
|||||||
.txd = UART0_TXD,
|
.txd = UART0_TXD,
|
||||||
.rxd = UART0_RXD,
|
.rxd = UART0_RXD,
|
||||||
},
|
},
|
||||||
#if defined(UART1_TXD) && defined(UART1_RXD)
|
#if defined(UART1_TXD) && defined(UART1_RXD)
|
||||||
{
|
{
|
||||||
.txd = UART1_TXD,
|
.txd = UART1_TXD,
|
||||||
.rxd = UART1_RXD,
|
.rxd = UART1_RXD,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
#if defined(UART2_TXD) && defined(UART2_RXD)
|
#if defined(UART2_TXD) && defined(UART2_RXD)
|
||||||
{
|
{
|
||||||
.txd = UART2_TXD,
|
.txd = UART2_TXD,
|
||||||
.rxd = UART2_RXD,
|
.rxd = UART2_RXD,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#ifndef PERIPH_CPU_H
|
#ifndef PERIPH_CPU_H
|
||||||
#define PERIPH_CPU_H
|
#define PERIPH_CPU_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "hal/ledc_types.h"
|
#include "hal/ledc_types.h"
|
||||||
@ -349,15 +350,18 @@ typedef enum {
|
|||||||
* @brief I2C configuration structure type
|
* @brief I2C configuration structure type
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
uint8_t module; /**< I2C module identifier */
|
||||||
i2c_speed_t speed; /**< I2C bus speed */
|
i2c_speed_t speed; /**< I2C bus speed */
|
||||||
gpio_t scl; /**< GPIO used as SCL pin */
|
gpio_t scl; /**< GPIO used as SCL pin */
|
||||||
gpio_t sda; /**< GPIO used as SDA pin */
|
gpio_t sda; /**< GPIO used as SDA pin */
|
||||||
|
bool scl_pullup; /**< Pullup enabled for SCL pin */
|
||||||
|
bool sda_pullup; /**< Pullup enabled for SDA pin */
|
||||||
} i2c_conf_t;
|
} i2c_conf_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Maximum number of I2C interfaces that can be used by board definitions
|
* @brief Maximum number of I2C interfaces that can be used by board definitions
|
||||||
*/
|
*/
|
||||||
#define I2C_NUMOF_MAX (2)
|
#define I2C_NUMOF_MAX (SOC_I2C_NUM)
|
||||||
|
|
||||||
#define PERIPH_I2C_NEED_READ_REG /**< i2c_read_reg required */
|
#define PERIPH_I2C_NEED_READ_REG /**< i2c_read_reg required */
|
||||||
#define PERIPH_I2C_NEED_READ_REGS /**< i2c_read_regs required */
|
#define PERIPH_I2C_NEED_READ_REGS /**< i2c_read_regs required */
|
||||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user