[bsp][ch32v307v]添加了硬件iic驱动

This commit is contained in:
白熊
2024-04-01 00:40:55 -04:00
committed by GitHub
parent 1bf8a460e7
commit 1ea7ddfa9a
4 changed files with 306 additions and 0 deletions
@@ -18,6 +18,9 @@ if GetDepend('SOC_RISCV_FAMILY_CH32'):
if GetDepend('BSP_USING_DAC'):
src += ['drv_dac.c']
if GetDepend('BSP_USING_I2C'):
src += ['drv_i2c.c']
if GetDepend('BSP_USING_SOFT_I2C'):
src += ['drv_soft_i2c.c']
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2006-2024, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2024-4-1 IceBear003 the first version
*/
#ifndef __DRV_I2C_H_
#define __DRV_I2C_H_
#include <rtthread.h>
#include <rtdevice.h>
struct i2c_bus_device
{
struct rt_i2c_bus_device parent;
I2C_TypeDef *periph;
};
struct i2c_config
{
rt_uint32_t clock_speed;
uint16_t duty_cycle;
uint16_t own_address;
uint8_t enable_ack;
uint8_t is_7_bit_address;
};
struct i2c_config i2c_default_conf={5000, I2C_Mode_I2C, I2C_DutyCycle_2, 0, I2C_Ack_Disable, I2C_AcknowledgedAddress_7bit};
int rt_hw_i2c_init(struct i2c_config *config);
#endif
+15
View File
@@ -121,6 +121,21 @@ menu "On-chip Peripheral Drivers"
default n
endif
menuconfig BSP_USING_I2C
bool "Enable I2C"
select RT_USING_I2C
if BSP_USING_I2C
config BSP_USING_I2C1
bool "Enable I2C1"
default n
config BSP_USING_I2C2
bool "Enable I2C2"
default n
endif
menuconfig BSP_USING_SOFT_I2C
bool "Enable I2C Bus"
select RT_USING_I2C