2021-10-18 16:56:27 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2021-07-29 KyleChan first version
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DRV_I2C__
|
|
|
|
#define __DRV_I2C__
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include <rthw.h>
|
|
|
|
#include <rtdevice.h>
|
|
|
|
#include <rtdbg.h>
|
|
|
|
|
|
|
|
/* ra config class */
|
|
|
|
struct ra_soft_i2c_config
|
|
|
|
{
|
|
|
|
rt_uint32_t scl;
|
|
|
|
rt_uint32_t sda;
|
|
|
|
const char *bus_name;
|
|
|
|
};
|
|
|
|
/* ra i2c dirver class */
|
|
|
|
struct ra_i2c
|
|
|
|
{
|
|
|
|
struct rt_i2c_bit_ops ops;
|
2023-12-28 16:57:28 +08:00
|
|
|
struct rt_i2c_bus_device i2c_bus;
|
2021-10-18 16:56:27 +08:00
|
|
|
};
|
|
|
|
|
2023-11-01 06:07:46 +08:00
|
|
|
#ifdef BSP_USING_I2C0
|
|
|
|
#define I2C0_BUS_CONFIG \
|
|
|
|
{ \
|
|
|
|
.scl = BSP_I2C0_SCL_PIN, \
|
|
|
|
.sda = BSP_I2C0_SDA_PIN, \
|
|
|
|
.bus_name = "i2c0", \
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-10-18 16:56:27 +08:00
|
|
|
#ifdef BSP_USING_I2C1
|
|
|
|
#define I2C1_BUS_CONFIG \
|
|
|
|
{ \
|
|
|
|
.scl = BSP_I2C1_SCL_PIN, \
|
|
|
|
.sda = BSP_I2C1_SDA_PIN, \
|
|
|
|
.bus_name = "i2c1", \
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BSP_USING_I2C2
|
|
|
|
#define I2C2_BUS_CONFIG \
|
|
|
|
{ \
|
|
|
|
.scl = BSP_I2C2_SCL_PIN, \
|
|
|
|
.sda = BSP_I2C2_SDA_PIN, \
|
|
|
|
.bus_name = "i2c2", \
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int rt_hw_i2c_init(void);
|
|
|
|
|
|
|
|
#endif
|