修改i2c和rtc驱动 (#6166)

* 修改I2C和RTC 驱动
This commit is contained in:
NationsHuanghanbin authored and GitHub committed 2022-07-15 13:36:32 +08:00
1 parent 8027291e09
commit 2ece5c277d
7 files changed
+269 -111

No files matched your search

@@ -46,6 +46,9 @@ if GetDepend(['RT_USING_RTC']):
if GetDepend(['RT_USING_WDT']):
src += ['n32g45x_std_periph_driver/src/n32g45x_wwdg.c']
src += ['n32g45x_std_periph_driver/src/n32g45x_iwdg.c']
if GetDepend(['BSP_USING_RTC']):
src += ['n32g45x_std_periph_driver/src/n32g45x_bkp.c']
if GetDepend(['RT_USING_SDIO']):
src += ['n32g45x_std_periph_driver/src/n32g45x_sdio.c']
+3 -1
View File
@@ -39,7 +39,9 @@ if GetDepend(['RT_USING_DAC']):
if GetDepend(['RT_USING_CAN']):
src += ['drv_can.c']
if GetDepend(['BSP_USING_RTC']):
src += ['drv_rtc.c']
if GetDepend(['BSP_USING_WDT']):
src += ['drv_wdt.c']
File diff suppressed because it is too large. Load diff
+55 -2
View File
@@ -36,7 +36,60 @@
#ifndef __DRV_I2C__
#define __DRV_I2C__
#include "i2c.h"
#include <rtthread.h>
#include <rthw.h>
#include <rtdevice.h>
/* n32 config class */
struct n32_soft_i2c_config
{
rt_uint8_t scl;
rt_uint8_t sda;
const char *bus_name;
};
/* n32 i2c dirver class */
struct n32_i2c
{
struct rt_i2c_bit_ops ops;
struct rt_i2c_bus_device i2c2_bus;
};
#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
#ifdef BSP_USING_I2C3
#define I2C3_BUS_CONFIG \
{ \
.scl = BSP_I2C3_SCL_PIN, \
.sda = BSP_I2C3_SDA_PIN, \
.bus_name = "i2c3", \
}
#endif
#ifdef BSP_USING_I2C4
#define I2C4_BUS_CONFIG \
{ \
.scl = BSP_I2C4_SCL_PIN, \
.sda = BSP_I2C4_SDA_PIN, \
.bus_name = "i2c4", \
}
#endif
struct rt_i2c_bus
{
@@ -46,4 +99,4 @@ struct rt_i2c_bus
int rt_hw_i2c_init(void);
#endif
#endif /* __DRV_I2C__ */
+4 -7
View File
@@ -32,12 +32,9 @@
*
* @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
*/
#include <rtthread.h>
#include <n32g45x.h>
#include "board.h"
#include "time.h"
#include "rtdef.h"
#include "rtc.h"
#include <sys/time.h>
#include <rtdevice.h>
#ifdef BSP_USING_RTC
@@ -105,8 +102,8 @@ static rt_err_t rt_rtc_config(void)
RTC_InitType RTC_InitStructure;
/* Configure the RTC data register and RTC prescaler */
RTC_InitStructure.RTC_AsynchPrediv = 128;
RTC_InitStructure.RTC_SynchPrediv = 128;
RTC_InitStructure.RTC_AsynchPrediv = AsynchPrediv;
RTC_InitStructure.RTC_SynchPrediv = SynchPrediv;
RTC_InitStructure.RTC_HourFormat = RTC_24HOUR_FORMAT;
/* Check on RTC init */
+3 -2
View File
@@ -224,6 +224,7 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
#
# IoT - internet of things
#
# CONFIG_PKG_USING_LWIP is not set
# CONFIG_PKG_USING_LORAWAN_DRIVER is not set
# CONFIG_PKG_USING_PAHOMQTT is not set
@@ -237,7 +238,6 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
# CONFIG_PKG_USING_WEBTERMINAL is not set
# CONFIG_PKG_USING_LIBMODBUS is not set
# CONFIG_PKG_USING_FREEMODBUS is not set
# CONFIG_PKG_USING_NANOPB is not set
#
# Wi-Fi
@@ -689,7 +689,8 @@ CONFIG_BSP_USING_USART1=y
# CONFIG_BSP_USING_UART6 is not set
# CONFIG_BSP_USING_UART7 is not set
# CONFIG_BSP_USING_SPI is not set
# CONFIG_BSP_USING_I2C is not set
# CONFIG_BSP_USING_I2C1 is not set
# CONFIG_BSP_USING_RTC is not set
# CONFIG_BSP_USING_WDT is not set
# CONFIG_BSP_USING_HWTIMER is not set
# CONFIG_BSP_USING_ADC is not set
+29 -18
View File
@@ -75,27 +75,38 @@ menu "On-chip Peripheral Drivers"
endif
menuconfig BSP_USING_I2C
bool "Enable I2C BUS"
menuconfig BSP_USING_I2C1
bool "Enable I2C1 BUS (software simulation)"
default n
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
config BSP_USING_I2C3
bool "Enable I2C3"
default n
config BSP_USING_I2C4
bool "Enable I2C4"
default n
select RT_USING_I2C_BITOPS
select RT_USING_PIN
if BSP_USING_I2C1
config BSP_I2C1_SCL_PIN
int "i2c1 scl pin number"
range 0 111
default 22
config BSP_I2C1_SDA_PIN
int "I2C1 sda pin number"
range 0 111
default 23
endif
menuconfig BSP_USING_RTC
bool "Enable RTC"
select RT_USING_RTC
default n
if BSP_USING_RTC
choice
prompt "Select clock source"
default BSP_RTC_USING_LSE
config BSP_RTC_USING_LSE
bool "RTC USING LSE"
config BSP_RTC_USING_LSI
bool "RTC USING LSI"
endchoice
endif
config BSP_USING_WDT