From a4f9ac50418a173746993529838ed504df6a45f9 Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Tue, 9 Jun 2026 19:12:44 +0800 Subject: [PATCH 01/17] Create ds1307.h --- bsp/novosns/ns800/ds1307.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 bsp/novosns/ns800/ds1307.h diff --git a/bsp/novosns/ns800/ds1307.h b/bsp/novosns/ns800/ds1307.h new file mode 100644 index 00000000000..44b6a7aaca5 --- /dev/null +++ b/bsp/novosns/ns800/ds1307.h @@ -0,0 +1,27 @@ +/** + * @file ds1307.h + * @brief DS1307 RTC driver header + * + * Hardware: DS1307 RTC module, I2C address 0x68 + * Interface kept as ds1307_* for compatibility with drv_rtc.c + */ + +#ifndef __DS1307_H__ +#define __DS1307_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +rt_err_t ds1307_init(void); +rt_err_t ds1307_get_time(struct tm *time); +rt_err_t ds1307_set_time(struct tm *time); + +#ifdef __cplusplus +} +#endif + +#endif /* __DS1307_H__ */ From b9107f618e9483417d7e75a7f4359bfa75ba0eb1 Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Tue, 9 Jun 2026 19:13:27 +0800 Subject: [PATCH 02/17] Create ds1307.c --- bsp/novosns/ns800/ds1307.c | 116 +++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 bsp/novosns/ns800/ds1307.c diff --git a/bsp/novosns/ns800/ds1307.c b/bsp/novosns/ns800/ds1307.c new file mode 100644 index 00000000000..d4c6688fcde --- /dev/null +++ b/bsp/novosns/ns800/ds1307.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2026, NS800RT7P65D RTC Driver + * + * DS1307 RTC driver - GPIO bitbang I2C + * + * Hardware: DS1307 RTC module, I2C address 0x68, 5V supply + * Pins: PB2(SDA/GP34), PB3(SCL/GP35) + * + * NS800 GPIO configuration requirements: + * GPIO_setAnalogMode(..., GPIO_ANALOG_DISABLED) - enable digital input + * GPIO_setQualificationMode(..., GPIO_QUAL_ASYNC) - bypass input sampling + */ + +#include +#include +#include +#include "ds1307.h" +#include "gpio.h" +#include "board.h" + +#define ADDR 0x68 +#define PORT GPIOB +#define PIN_SDA GPIO_PIN_2 +#define PIN_SCL GPIO_PIN_3 +#define DELAY_CNT 3000 + +/* ========== I2C bitbang primitives ========== */ +static void dly(void) { volatile uint32_t i; for(i=0;i=0;i--) i2c_bit((d>>i)&1); + sda_h();scl_h();dly(); int ack=sda_r()?1:0; scl_l();dly(); return ack; +} + +static uint8_t i2c_recv(uint8_t nak) { + uint8_t d=0; sda_h(); + for(int i=7;i>=0;i--){ sda_h();dly();scl_h();dly(); if(sda_r()) d|=(1<>4)*10)+(x&0xF);} +static inline uint8_t x2b(uint8_t v){return ((v/10)<<4)|(v%10);} + +/* ========== Public API ========== */ +rt_err_t ds1307_init(void) { + uint8_t sec; i2c_init(); + rt_kprintf("[DS1307] Init...\n"); + if(ds_read(0x00,&sec,1)<0){rt_kprintf("No ACK\n");return -RT_ERROR;} + if(sec&0x80){sec&=0x7F; ds_write(0x00,&sec,1); rt_kprintf("Clock started\n");} + rt_kprintf("OK\n"); return RT_EOK; +} + +rt_err_t ds1307_get_time(struct tm *t) { + uint8_t b[7]; if(!t||ds_read(0x00,b,7)<0) return -RT_ERROR; + memset(t,0,sizeof(*t)); + t->tm_sec=b2b(b[0]&0x7F); t->tm_min=b2b(b[1]&0x7F); t->tm_hour=b2b(b[2]&0x3F); + t->tm_mday=b2b(b[3]&0x3F); t->tm_wday=b[4]&0x07; t->tm_mon=b2b(b[5]&0x1F)-1; + t->tm_year=b2b(b[6])+100; return RT_EOK; +} + +rt_err_t ds1307_set_time(struct tm *t) { + if(!t) return -RT_ERROR; + uint8_t v; + v=x2b(t->tm_year-100); if(ds_write(0x06,&v,1)<0) return -RT_ERROR; + v=x2b(t->tm_mon+1); if(ds_write(0x05,&v,1)<0) return -RT_ERROR; + v=x2b(t->tm_mday); if(ds_write(0x04,&v,1)<0) return -RT_ERROR; + v=t->tm_wday&0x07; if(ds_write(0x03,&v,1)<0) return -RT_ERROR; + v=x2b(t->tm_hour); if(ds_write(0x02,&v,1)<0) return -RT_ERROR; + v=x2b(t->tm_min); if(ds_write(0x01,&v,1)<0) return -RT_ERROR; + v=x2b(t->tm_sec); if(ds_write(0x00,&v,1)<0) return -RT_ERROR; + return RT_EOK; +} From 193f192a6ece845281321755a7fc9970f8487616 Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Tue, 9 Jun 2026 19:16:48 +0800 Subject: [PATCH 03/17] Create drv_rtc.c --- bsp/novosns/ns800/drv_rtc.c | 127 ++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 bsp/novosns/ns800/drv_rtc.c diff --git a/bsp/novosns/ns800/drv_rtc.c b/bsp/novosns/ns800/drv_rtc.c new file mode 100644 index 00000000000..119794c8021 --- /dev/null +++ b/bsp/novosns/ns800/drv_rtc.c @@ -0,0 +1,127 @@ +/** + * @file drv_rtc.c + * @brief RT-Thread RTC device driver (通用外接RTC芯片框架) + * + * 支持通过 rtconfig.h 中的宏定义选择 RTC 芯片: + * BSP_USING_DS1307 - DS1307 (I2C addr 0x68, 5V) + * BSP_USING_PCF8563 - PCF8563 (I2C addr 0x51, 3.3V) + * + * 添加新芯片: 在下方加 #elif 分支,实现 init/get_time/set_time 即可 + * + * 引脚: PA14(SDA/IO14), PA15(SCL/IO15) 或 GP34(SDA), GP35(SCL) + */ + +#include +#include +#include +#include +#include + +/* ========== RTC 芯片选择 ========== */ +#if defined(BSP_USING_DS1307) +# include "ds1307.h" +# define RTC_INIT() ds1307_init() +# define RTC_GET_TIME(t) ds1307_get_time(t) +# define RTC_SET_TIME(t) ds1307_set_time(t) +# define RTC_CHIP_NAME "DS1307" + +#elif defined(BSP_USING_PCF8563) +# include "pcf8563.h" +# define RTC_INIT() pcf8563_init() +# define RTC_GET_TIME(t) pcf8563_get_time(t) +# define RTC_SET_TIME(t) pcf8563_set_time(t) +# define RTC_CHIP_NAME "PCF8563" + +#else +# error "RTC chip not selected! Define BSP_USING_DS1307 or BSP_USING_PCF8563 in rtconfig.h" +#endif + +static struct rt_device g_rtc_dev; + +static rt_err_t ns800_rtc_init(struct rt_device *dev) +{ + rt_err_t result = RTC_INIT(); + if (result != RT_EOK) { + rt_kprintf("RTC: %s init failed!\n", RTC_CHIP_NAME); + return result; + } + rt_kprintf("RTC: %s init success!\n", RTC_CHIP_NAME); + return RT_EOK; +} + +static rt_err_t ns800_rtc_open(struct rt_device *dev, rt_uint16_t oflag) +{ + return RT_EOK; +} + +static rt_err_t ns800_rtc_close(struct rt_device *dev) +{ + return RT_EOK; +} + +static rt_err_t ns800_rtc_control(struct rt_device *dev, int cmd, void *args) +{ + rt_err_t result = RT_EOK; + struct tm time_struct; + time_t *time = (time_t *)args; + + switch (cmd) { + case RT_DEVICE_CTRL_RTC_GET_TIME: + result = RTC_GET_TIME(&time_struct); + if (result == RT_EOK) { + *time = mktime(&time_struct); + } + break; + + case RT_DEVICE_CTRL_RTC_SET_TIME: + result = RTC_SET_TIME(localtime(time)); + break; + + default: + result = -RT_ENOSYS; + break; + } + return result; +} + +int rt_hw_rtc_init(void) +{ + rt_err_t result; + + g_rtc_dev.type = RT_Device_Class_RTC; + g_rtc_dev.init = ns800_rtc_init; + g_rtc_dev.open = ns800_rtc_open; + g_rtc_dev.close = ns800_rtc_close; + g_rtc_dev.read = RT_NULL; + g_rtc_dev.write = RT_NULL; + g_rtc_dev.control = ns800_rtc_control; + + result = rt_device_register(&g_rtc_dev, "rtc", + RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE); + if (result != RT_EOK) { + rt_kprintf("RTC: device register failed!\n"); + return -1; + } + rt_kprintf("RTC: device registered successfully!\n"); + + result = ns800_rtc_init(&g_rtc_dev); + if (result != RT_EOK) { + rt_kprintf("[MAIN] RTC hardware init FAILED!\n"); + return -1; + } + rt_kprintf("[MAIN] RTC hardware init SUCCESS! Ready to use.\n"); + return 0; +} + +/* MSH cmd: use FINSH_FUNCTION_EXPORT instead */ +static void show_rtc(void) +{ + time_t now; + rt_device_t dev = rt_device_find("rtc"); + if (dev) { + rt_device_control(dev, RT_DEVICE_CTRL_RTC_GET_TIME, &now); + rt_kprintf("[RTC] %s", ctime(&now)); + } +} +#include +FINSH_FUNCTION_EXPORT(show_rtc, show rtc time) From f9347ee807197d270e4d05ad2d67ba05d82d74d6 Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Tue, 9 Jun 2026 19:17:24 +0800 Subject: [PATCH 04/17] Create drv_rtc.h --- bsp/novosns/ns800/drv_rtc.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 bsp/novosns/ns800/drv_rtc.h diff --git a/bsp/novosns/ns800/drv_rtc.h b/bsp/novosns/ns800/drv_rtc.h new file mode 100644 index 00000000000..5d3a15e781e --- /dev/null +++ b/bsp/novosns/ns800/drv_rtc.h @@ -0,0 +1,23 @@ +/** + * @file drv_rtc.h + * @brief NS800RT7P65D RTC driver header file + */ + +#ifndef __DRV_RTC_H__ +#define __DRV_RTC_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +int rt_hw_rtc_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __DRV_RTC_H__ */ From ddd5902926ac038ad1999253c033cd86a184da1c Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Tue, 9 Jun 2026 19:18:04 +0800 Subject: [PATCH 05/17] Update drv_rtc.c --- bsp/novosns/ns800/drv_rtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp/novosns/ns800/drv_rtc.c b/bsp/novosns/ns800/drv_rtc.c index 119794c8021..aeda0fa5ae6 100644 --- a/bsp/novosns/ns800/drv_rtc.c +++ b/bsp/novosns/ns800/drv_rtc.c @@ -8,7 +8,7 @@ * * 添加新芯片: 在下方加 #elif 分支,实现 init/get_time/set_time 即可 * - * 引脚: PA14(SDA/IO14), PA15(SCL/IO15) 或 GP34(SDA), GP35(SCL) + * 引脚: GP34(SDA), GP35(SCL) */ #include From 4b55f181f38ab0db309fb448d3a9d4a23c7beb2e Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Tue, 9 Jun 2026 19:20:43 +0800 Subject: [PATCH 06/17] Create rtcconfig.h --- bsp/novosns/ns800/rtcconfig.h | 442 ++++++++++++++++++++++++++++++++++ 1 file changed, 442 insertions(+) create mode 100644 bsp/novosns/ns800/rtcconfig.h diff --git a/bsp/novosns/ns800/rtcconfig.h b/bsp/novosns/ns800/rtcconfig.h new file mode 100644 index 00000000000..3323db6292b --- /dev/null +++ b/bsp/novosns/ns800/rtcconfig.h @@ -0,0 +1,442 @@ +#ifndef RT_CONFIG_H__ +#define RT_CONFIG_H__ + +#define SOC_SERIES_NS800RT7 +#define SOC_NS800RT7P6XX +#define BOARD_NS800RT7P65X +#define RT_USING_FINSH +#define FINSH_USING_MSH + +/* RT-Thread Kernel */ + +/* klibc options */ + +/* rt_vsnprintf options */ + +/* end of rt_vsnprintf options */ + +/* rt_vsscanf options */ + +/* end of rt_vsscanf options */ + +/* rt_memset options */ + +/* end of rt_memset options */ + +/* rt_memcpy options */ + +/* end of rt_memcpy options */ + +/* rt_memmove options */ + +/* end of rt_memmove options */ + +/* rt_memcmp options */ + +/* end of rt_memcmp options */ + +/* rt_strstr options */ + +/* end of rt_strstr options */ + +/* rt_strcasecmp options */ + +/* end of rt_strcasecmp options */ + +/* rt_strncpy options */ + +/* end of rt_strncpy options */ + +/* rt_strcpy options */ + +/* end of rt_strcpy options */ + +/* rt_strncmp options */ + +/* end of rt_strncmp options */ + +/* rt_strcmp options */ + +/* end of rt_strcmp options */ + +/* rt_strlen options */ + +/* end of rt_strlen options */ + +/* rt_strnlen options */ + +/* end of rt_strnlen options */ +/* end of klibc options */ +#define RT_NAME_MAX 16 +#define RT_CPUS_NR 1 +#define RT_ALIGN_SIZE 8 +#define RT_THREAD_PRIORITY_32 +#define RT_THREAD_PRIORITY_MAX 32 +#define RT_TICK_PER_SECOND 1000 +#define RT_USING_OVERFLOW_CHECK +#define RT_USING_HOOK +#define RT_HOOK_USING_FUNC_PTR +#define RT_USING_IDLE_HOOK +#define RT_IDLE_HOOK_LIST_SIZE 4 +#define IDLE_THREAD_STACK_SIZE 256 + +/* kservice options */ + +/* end of kservice options */ +#define RT_USING_DEBUG +#define RT_DEBUGING_ASSERT +#define RT_DEBUGING_COLOR +#define RT_DEBUGING_CONTEXT + +/* Inter-Thread communication */ + +#define RT_USING_SEMAPHORE +#define RT_USING_MUTEX +#define RT_USING_EVENT +#define RT_USING_MAILBOX +#define RT_USING_MESSAGEQUEUE +/* end of Inter-Thread communication */ + +/* Memory Management */ + +#define RT_USING_MEMPOOL +#define RT_USING_SMALL_MEM +#define RT_USING_SMALL_MEM_AS_HEAP +#define RT_USING_HEAP +/* end of Memory Management */ +#define RT_USING_DEVICE +#define RT_USING_CONSOLE +#define RT_CONSOLEBUF_SIZE 128 +#define RT_CONSOLE_DEVICE_NAME "uart1" +#define RT_USING_CONSOLE_OUTPUT_CTL +#define RT_VER_NUM 0x50300 +#define RT_BACKTRACE_LEVEL_MAX_NR 32 +/* end of RT-Thread Kernel */ + +/* RT-Thread Components */ + +#define RT_USING_COMPONENTS_INIT +#define RT_USING_USER_MAIN +#define RT_MAIN_THREAD_STACK_SIZE 2048 +#define RT_MAIN_THREAD_PRIORITY 10 +#define RT_USING_MSH +#define RT_USING_FINSH +#define FINSH_USING_MSH +#define FINSH_THREAD_NAME "tshell" +#define FINSH_THREAD_PRIORITY 20 +#define FINSH_THREAD_STACK_SIZE 4096 +#define FINSH_USING_HISTORY +#define FINSH_HISTORY_LINES 5 +#define FINSH_USING_SYMTAB +#define FINSH_CMD_SIZE 80 +#define MSH_USING_BUILT_IN_COMMANDS +#define FINSH_USING_DESCRIPTION +#define FINSH_ARG_MAX 10 +#define FINSH_USING_OPTION_COMPLETION +/* 在文件末尾添加 */ +#define RT_USING_RTC +#define BSP_USING_RTC + +/* DFS: device virtual file system */ + +/* end of DFS: device virtual file system */ + +/* Device Drivers */ + +#define RT_USING_DEVICE_IPC +#define RT_UNAMED_PIPE_NUMBER 64 +#define RT_USING_SERIAL +#define RT_USING_SERIAL_V1 +#define RT_SERIAL_RB_BUFSZ 64 +#define RT_USING_CAN +#define RT_CAN_USING_CANFD +#define RT_CANMSG_BOX_SZ 16 +#define RT_CANSND_BOX_NUM 1 +#define RT_CANSND_MSG_TIMEOUT 100 +#define RT_CAN_NB_TX_FIFO_SIZE 256 +#define RT_USING_PIN +#define RT_USING_I2C +#define RT_USING_I2C_BITOPS +#define BSP_USING_I2C1 +#define BSP_USING_DS1307 +/* end of Device Drivers */ + +/* C/C++ and POSIX layer */ + +/* ISO-ANSI C layer */ + +/* Timezone and Daylight Saving Time */ + +#define RT_LIBC_USING_LIGHT_TZ_DST +#define RT_LIBC_TZ_DEFAULT_HOUR 8 +#define RT_LIBC_TZ_DEFAULT_MIN 0 +#define RT_LIBC_TZ_DEFAULT_SEC 0 +/* end of Timezone and Daylight Saving Time */ +/* end of ISO-ANSI C layer */ + +/* POSIX (Portable Operating System Interface) layer */ + + +/* Interprocess Communication (IPC) */ + + +/* Socket is in the 'Network' category */ + +/* end of Interprocess Communication (IPC) */ +/* end of POSIX (Portable Operating System Interface) layer */ +/* end of C/C++ and POSIX layer */ + +/* Network */ + +/* end of Network */ + +/* Memory protection */ + +/* end of Memory protection */ + +/* Utilities */ + +/* end of Utilities */ + +/* Using USB legacy version */ + +/* end of Using USB legacy version */ +/* end of RT-Thread Components */ + +/* RT-Thread Utestcases */ + +/* end of RT-Thread Utestcases */ + +/* RT-Thread online packages */ + +/* IoT - internet of things */ + + +/* Wi-Fi */ + +/* Marvell WiFi */ + +/* end of Marvell WiFi */ + +/* Wiced WiFi */ + +/* end of Wiced WiFi */ + +/* CYW43012 WiFi */ + +/* end of CYW43012 WiFi */ + +/* BL808 WiFi */ + +/* end of BL808 WiFi */ + +/* CYW43439 WiFi */ + +/* end of CYW43439 WiFi */ +/* end of Wi-Fi */ + +/* IoT Cloud */ + +/* end of IoT Cloud */ +/* end of IoT - internet of things */ + +/* security packages */ + +/* end of security packages */ + +/* language packages */ + +/* JSON: JavaScript Object Notation, a lightweight data-interchange format */ + +/* end of JSON: JavaScript Object Notation, a lightweight data-interchange format */ + +/* XML: Extensible Markup Language */ + +/* end of XML: Extensible Markup Language */ +/* end of language packages */ + +/* multimedia packages */ + +/* LVGL: powerful and easy-to-use embedded GUI library */ + +/* end of LVGL: powerful and easy-to-use embedded GUI library */ + +/* u8g2: a monochrome graphic library */ + +/* end of u8g2: a monochrome graphic library */ +/* end of multimedia packages */ + +/* tools packages */ + +/* end of tools packages */ + +/* system packages */ + +/* enhanced kernel services */ + +/* end of enhanced kernel services */ + +/* acceleration: Assembly language or algorithmic acceleration packages */ + +/* end of acceleration: Assembly language or algorithmic acceleration packages */ + +/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */ + +#define PKG_USING_CMSIS_CORE +#define PKG_USING_CMSIS_CORE_LATEST_VERSION +/* end of CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */ + +/* Micrium: Micrium software products porting for RT-Thread */ + +/* end of Micrium: Micrium software products porting for RT-Thread */ +/* end of system packages */ + +/* peripheral libraries and drivers */ + +/* HAL & SDK Drivers */ + +/* STM32 HAL & SDK Drivers */ + +/* end of STM32 HAL & SDK Drivers */ + +/* Infineon HAL Packages */ + +/* end of Infineon HAL Packages */ + +/* Kendryte SDK */ + +/* end of Kendryte SDK */ + +/* WCH HAL & SDK Drivers */ + +/* end of WCH HAL & SDK Drivers */ + +/* AT32 HAL & SDK Drivers */ + +/* end of AT32 HAL & SDK Drivers */ + +/* HC32 DDL Drivers */ + +/* end of HC32 DDL Drivers */ + +/* NXP HAL & SDK Drivers */ + +/* end of NXP HAL & SDK Drivers */ + +/* NUVOTON Drivers */ + +/* end of NUVOTON Drivers */ + +/* GD32 Drivers */ + +/* end of GD32 Drivers */ + +/* HPMicro SDK */ + +/* end of HPMicro SDK */ + +/* FT32 HAL & SDK Drivers */ + +/* end of FT32 HAL & SDK Drivers */ + +/* NOVOSNS Drivers */ + +#define PKG_USING_NOVOSNS_SERIES_DRIVER +#define PKG_USING_NOVOSNS_SERIES_DRIVER_LATEST_VERSION +/* end of NOVOSNS Drivers */ +/* end of HAL & SDK Drivers */ + +/* sensors drivers */ + +/* end of sensors drivers */ + +/* touch drivers */ + +/* end of touch drivers */ +/* end of peripheral libraries and drivers */ + +/* AI packages */ + +/* end of AI packages */ + +/* Signal Processing and Control Algorithm Packages */ + +/* end of Signal Processing and Control Algorithm Packages */ + +/* miscellaneous packages */ + +/* project laboratory */ + +/* end of project laboratory */ + +/* samples: kernel and components samples */ + +/* end of samples: kernel and components samples */ + +/* entertainment: terminal games and other interesting software packages */ + +/* end of entertainment: terminal games and other interesting software packages */ +/* end of miscellaneous packages */ + +/* Arduino libraries */ + + +/* Projects and Demos */ + +/* end of Projects and Demos */ + +/* Sensors */ + +/* end of Sensors */ + +/* Display */ + +/* end of Display */ + +/* Timing */ + +/* end of Timing */ + +/* Data Processing */ + +/* end of Data Processing */ + +/* Data Storage */ + +/* Communication */ + +/* end of Communication */ + +/* Device Control */ + +/* end of Device Control */ + +/* Other */ + +/* end of Other */ + +/* Signal IO */ + +/* end of Signal IO */ + +/* Uncategorized */ + +/* end of Arduino libraries */ +/* end of RT-Thread online packages */ + +/* On-chip Peripheral Drivers */ + +#define BOARD_CLK_CONF +#define SYSCLK_USE_PLL +#define SYSCLK_SOURCE_USE_HXTL +#define PLLCLK_SOURCE_USE_HXTL +#define BSP_USING_GPIO +#define BSP_USING_UART +#define BSP_NS800_UART_TX_TIMEOUT 6000 +#define BSP_USING_UART1 +#define BSP_USING_ECAP +#define BSP_USING_CAN +#define BSP_USING_CANFD1 +/* end of On-chip Peripheral Drivers */ + +#endif From 25e34c191d9d7444adaefdcbb77b1d89468e2923 Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Thu, 18 Jun 2026 14:15:54 +0800 Subject: [PATCH 07/17] Create drv_rtc.c --- .../libraries/HAL_Drivers/drivers/drv_rtc.c | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.c diff --git a/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.c b/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.c new file mode 100644 index 00000000000..4388f08a31e --- /dev/null +++ b/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.c @@ -0,0 +1,80 @@ +/* Copyright (c) 2006-2026, RT-Thread Development Team */ + +#include +#include +#include +#include "ds1307.h" + +static struct rt_device g_rtc_dev; + +static rt_err_t ns800_rtc_init(struct rt_device *dev) +{ + uint8_t sec; + rt_err_t ret; + + ret = ds1307_init(); + if (ret != RT_EOK) + { + rt_kprintf("ds1307: i2c bus not found\n"); + return ret; + } + + return RT_EOK; +} + +static rt_err_t ns800_rtc_control(struct rt_device *dev, int cmd, void *args) +{ + rt_err_t result = RT_EOK; + struct tm time_struct; + + switch (cmd) + { + case RT_DEVICE_CTRL_RTC_GET_TIME: + result = ds1307_get_time(&time_struct); + if (result == RT_EOK) + *(time_t *)args = mktime(&time_struct); + break; + + case RT_DEVICE_CTRL_RTC_SET_TIME: + result = ds1307_set_time(localtime((const time_t *)args)); + break; + + default: + result = -RT_ENOSYS; + break; + } + + return result; +} + +int rt_hw_rtc_init(void) +{ + rt_err_t result; + + g_rtc_dev.type = RT_Device_Class_RTC; + g_rtc_dev.init = ns800_rtc_init; + g_rtc_dev.open = RT_NULL; + g_rtc_dev.close = RT_NULL; + g_rtc_dev.read = RT_NULL; + g_rtc_dev.write = RT_NULL; + g_rtc_dev.control = ns800_rtc_control; + + result = rt_device_register(&g_rtc_dev, "rtc", + RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE); + if (result != RT_EOK) + { + rt_kprintf("rtc register failed\n"); + return -1; + } + + result = ns800_rtc_init(&g_rtc_dev); + if (result != RT_EOK) + { + rt_kprintf("ds1307 init failed\n"); + return -1; + } + + rt_kprintf("ds1307 rtc ready\n"); + return 0; +} +INIT_DEVICE_EXPORT(rt_hw_rtc_init); From ea136b10795904de63150c7e728012f4af9c695a Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Thu, 18 Jun 2026 14:17:29 +0800 Subject: [PATCH 08/17] Create drv_rtc.h --- .../libraries/HAL_Drivers/drivers/drv_rtc.h | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.h diff --git a/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.h b/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.h new file mode 100644 index 00000000000..5d3a15e781e --- /dev/null +++ b/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.h @@ -0,0 +1,23 @@ +/** + * @file drv_rtc.h + * @brief NS800RT7P65D RTC driver header file + */ + +#ifndef __DRV_RTC_H__ +#define __DRV_RTC_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +int rt_hw_rtc_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __DRV_RTC_H__ */ From ebf081e5c14a2c762d655abda3883bd0fc48f68f Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Thu, 18 Jun 2026 14:19:32 +0800 Subject: [PATCH 09/17] Update drv_rtc.c --- .../ns800/libraries/HAL_Drivers/drivers/drv_rtc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.c b/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.c index 4388f08a31e..533132b7884 100644 --- a/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.c +++ b/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.c @@ -1,5 +1,12 @@ -/* Copyright (c) 2006-2026, RT-Thread Development Team */ - +/* + * Copyright (c) 2006-2026, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2026-06-18 wenzhi346 add NS800 rtc driver + */ #include #include #include From dbf6ad5f5f052694050fb03fcbbf00da96acf16e Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Thu, 18 Jun 2026 14:20:44 +0800 Subject: [PATCH 10/17] Update drv_rtc.h --- .../ns800/libraries/HAL_Drivers/drivers/drv_rtc.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.h b/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.h index 5d3a15e781e..151f1ba5617 100644 --- a/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.h +++ b/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_rtc.h @@ -1,6 +1,10 @@ -/** - * @file drv_rtc.h - * @brief NS800RT7P65D RTC driver header file +/* + * Copyright (c) 2006-2026, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes */ #ifndef __DRV_RTC_H__ From b40efb432a8852d590806d83362b5ac773249946 Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Thu, 18 Jun 2026 14:22:19 +0800 Subject: [PATCH 11/17] Create ds1307.c --- .../libraries/HAL_Drivers/drivers/ds1307.c | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 bsp/novosns/ns800/libraries/HAL_Drivers/drivers/ds1307.c diff --git a/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/ds1307.c b/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/ds1307.c new file mode 100644 index 00000000000..8592af92722 --- /dev/null +++ b/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/ds1307.c @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2006-2026, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2026-06-18 coworkspace first version + */ + +#include +#include +#include +#include "ds1307.h" + +#define DS1307_ADDR 0x68 + +static struct rt_i2c_bus_device *ds1307_i2c = RT_NULL; + +rt_err_t ds1307_init(void) +{ + ds1307_i2c = (struct rt_i2c_bus_device *)rt_device_find("i2c1"); + if (ds1307_i2c == RT_NULL) + return -RT_ERROR; + + return RT_EOK; +} + +static rt_err_t read_regs(uint8_t reg, uint8_t *buf, uint8_t len) +{ + struct rt_i2c_msg msgs[2]; + + msgs[0].addr = DS1307_ADDR; + msgs[0].flags = RT_I2C_WR; + msgs[0].len = 1; + msgs[0].buf = ® + + msgs[1].addr = DS1307_ADDR; + msgs[1].flags = RT_I2C_RD; + msgs[1].len = len; + msgs[1].buf = buf; + + return (rt_i2c_transfer(ds1307_i2c, msgs, 2) == 2) ? RT_EOK : -RT_ERROR; +} + +static rt_err_t write_reg(uint8_t reg, uint8_t val) +{ + uint8_t buf[2] = {reg, val}; + + return (rt_i2c_master_send(ds1307_i2c, DS1307_ADDR, 0, buf, 2) == 2) + ? RT_EOK : -RT_ERROR; +} + +static uint8_t bcd2bin(uint8_t bcd) +{ + return ((bcd >> 4) * 10) + (bcd & 0x0F); +} + +static uint8_t bin2bcd(uint8_t val) +{ + return ((val / 10) << 4) | (val % 10); +} + +rt_err_t ds1307_get_time(struct tm *tm) +{ + uint8_t buf[7]; + + if (read_regs(0x00, buf, 7) != RT_EOK) + return -RT_ERROR; + + memset(tm, 0, sizeof(*tm)); + tm->tm_sec = bcd2bin(buf[0] & 0x7F); + tm->tm_min = bcd2bin(buf[1] & 0x7F); + tm->tm_hour = bcd2bin(buf[2] & 0x3F); + tm->tm_mday = bcd2bin(buf[3] & 0x3F); + tm->tm_wday = buf[4] & 0x07; + tm->tm_mon = bcd2bin(buf[5] & 0x1F) - 1; + tm->tm_year = bcd2bin(buf[6]) + 100; + + return RT_EOK; +} + +rt_err_t ds1307_set_time(struct tm *tm) +{ + uint8_t v; + + v = bin2bcd(tm->tm_year - 100); + if (write_reg(0x06, v) != RT_EOK) return -RT_ERROR; + + v = bin2bcd(tm->tm_mon + 1); + if (write_reg(0x05, v) != RT_EOK) return -RT_ERROR; + + v = bin2bcd(tm->tm_mday); + if (write_reg(0x04, v) != RT_EOK) return -RT_ERROR; + + v = tm->tm_wday & 0x07; + if (write_reg(0x03, v) != RT_EOK) return -RT_ERROR; + + v = bin2bcd(tm->tm_hour); + if (write_reg(0x02, v) != RT_EOK) return -RT_ERROR; + + v = bin2bcd(tm->tm_min); + if (write_reg(0x01, v) != RT_EOK) return -RT_ERROR; + + v = bin2bcd(tm->tm_sec); + if (write_reg(0x00, v) != RT_EOK) return -RT_ERROR; + + return RT_EOK; +} From 1d2ad8e3d683806de72853afff56ea77d95cf9a8 Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Thu, 18 Jun 2026 14:23:12 +0800 Subject: [PATCH 12/17] Create ds1307.h --- .../libraries/HAL_Drivers/drivers/ds1307.h | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 bsp/novosns/ns800/libraries/HAL_Drivers/drivers/ds1307.h diff --git a/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/ds1307.h b/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/ds1307.h new file mode 100644 index 00000000000..4e3bc04db37 --- /dev/null +++ b/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/ds1307.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2006-2026, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2026-06-18 coworkspace first version + */ +#ifndef __DS1307_H__ +#define __DS1307_H__ + +#include +#include + +rt_err_t ds1307_init(void); +rt_err_t ds1307_get_time(struct tm *time); +rt_err_t ds1307_set_time(struct tm *time); + +#endif From 39418f11988824b4ee26526fa2c6ed4851bfebb7 Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Thu, 18 Jun 2026 14:34:54 +0800 Subject: [PATCH 13/17] Delete bsp/novosns/ns800/drv_rtc.h --- bsp/novosns/ns800/drv_rtc.h | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 bsp/novosns/ns800/drv_rtc.h diff --git a/bsp/novosns/ns800/drv_rtc.h b/bsp/novosns/ns800/drv_rtc.h deleted file mode 100644 index 5d3a15e781e..00000000000 --- a/bsp/novosns/ns800/drv_rtc.h +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @file drv_rtc.h - * @brief NS800RT7P65D RTC driver header file - */ - -#ifndef __DRV_RTC_H__ -#define __DRV_RTC_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -int rt_hw_rtc_init(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __DRV_RTC_H__ */ From ae1dd003ead97de89df728c3934b5555df5c373d Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Thu, 18 Jun 2026 14:35:10 +0800 Subject: [PATCH 14/17] Delete bsp/novosns/ns800/drv_rtc.c --- bsp/novosns/ns800/drv_rtc.c | 127 ------------------------------------ 1 file changed, 127 deletions(-) delete mode 100644 bsp/novosns/ns800/drv_rtc.c diff --git a/bsp/novosns/ns800/drv_rtc.c b/bsp/novosns/ns800/drv_rtc.c deleted file mode 100644 index aeda0fa5ae6..00000000000 --- a/bsp/novosns/ns800/drv_rtc.c +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file drv_rtc.c - * @brief RT-Thread RTC device driver (通用外接RTC芯片框架) - * - * 支持通过 rtconfig.h 中的宏定义选择 RTC 芯片: - * BSP_USING_DS1307 - DS1307 (I2C addr 0x68, 5V) - * BSP_USING_PCF8563 - PCF8563 (I2C addr 0x51, 3.3V) - * - * 添加新芯片: 在下方加 #elif 分支,实现 init/get_time/set_time 即可 - * - * 引脚: GP34(SDA), GP35(SCL) - */ - -#include -#include -#include -#include -#include - -/* ========== RTC 芯片选择 ========== */ -#if defined(BSP_USING_DS1307) -# include "ds1307.h" -# define RTC_INIT() ds1307_init() -# define RTC_GET_TIME(t) ds1307_get_time(t) -# define RTC_SET_TIME(t) ds1307_set_time(t) -# define RTC_CHIP_NAME "DS1307" - -#elif defined(BSP_USING_PCF8563) -# include "pcf8563.h" -# define RTC_INIT() pcf8563_init() -# define RTC_GET_TIME(t) pcf8563_get_time(t) -# define RTC_SET_TIME(t) pcf8563_set_time(t) -# define RTC_CHIP_NAME "PCF8563" - -#else -# error "RTC chip not selected! Define BSP_USING_DS1307 or BSP_USING_PCF8563 in rtconfig.h" -#endif - -static struct rt_device g_rtc_dev; - -static rt_err_t ns800_rtc_init(struct rt_device *dev) -{ - rt_err_t result = RTC_INIT(); - if (result != RT_EOK) { - rt_kprintf("RTC: %s init failed!\n", RTC_CHIP_NAME); - return result; - } - rt_kprintf("RTC: %s init success!\n", RTC_CHIP_NAME); - return RT_EOK; -} - -static rt_err_t ns800_rtc_open(struct rt_device *dev, rt_uint16_t oflag) -{ - return RT_EOK; -} - -static rt_err_t ns800_rtc_close(struct rt_device *dev) -{ - return RT_EOK; -} - -static rt_err_t ns800_rtc_control(struct rt_device *dev, int cmd, void *args) -{ - rt_err_t result = RT_EOK; - struct tm time_struct; - time_t *time = (time_t *)args; - - switch (cmd) { - case RT_DEVICE_CTRL_RTC_GET_TIME: - result = RTC_GET_TIME(&time_struct); - if (result == RT_EOK) { - *time = mktime(&time_struct); - } - break; - - case RT_DEVICE_CTRL_RTC_SET_TIME: - result = RTC_SET_TIME(localtime(time)); - break; - - default: - result = -RT_ENOSYS; - break; - } - return result; -} - -int rt_hw_rtc_init(void) -{ - rt_err_t result; - - g_rtc_dev.type = RT_Device_Class_RTC; - g_rtc_dev.init = ns800_rtc_init; - g_rtc_dev.open = ns800_rtc_open; - g_rtc_dev.close = ns800_rtc_close; - g_rtc_dev.read = RT_NULL; - g_rtc_dev.write = RT_NULL; - g_rtc_dev.control = ns800_rtc_control; - - result = rt_device_register(&g_rtc_dev, "rtc", - RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE); - if (result != RT_EOK) { - rt_kprintf("RTC: device register failed!\n"); - return -1; - } - rt_kprintf("RTC: device registered successfully!\n"); - - result = ns800_rtc_init(&g_rtc_dev); - if (result != RT_EOK) { - rt_kprintf("[MAIN] RTC hardware init FAILED!\n"); - return -1; - } - rt_kprintf("[MAIN] RTC hardware init SUCCESS! Ready to use.\n"); - return 0; -} - -/* MSH cmd: use FINSH_FUNCTION_EXPORT instead */ -static void show_rtc(void) -{ - time_t now; - rt_device_t dev = rt_device_find("rtc"); - if (dev) { - rt_device_control(dev, RT_DEVICE_CTRL_RTC_GET_TIME, &now); - rt_kprintf("[RTC] %s", ctime(&now)); - } -} -#include -FINSH_FUNCTION_EXPORT(show_rtc, show rtc time) From abce30c77396a48bd11cb1a9fca78ef0789540d2 Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Thu, 18 Jun 2026 14:35:40 +0800 Subject: [PATCH 15/17] Delete bsp/novosns/ns800/ds1307.c --- bsp/novosns/ns800/ds1307.c | 116 ------------------------------------- 1 file changed, 116 deletions(-) delete mode 100644 bsp/novosns/ns800/ds1307.c diff --git a/bsp/novosns/ns800/ds1307.c b/bsp/novosns/ns800/ds1307.c deleted file mode 100644 index d4c6688fcde..00000000000 --- a/bsp/novosns/ns800/ds1307.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2026, NS800RT7P65D RTC Driver - * - * DS1307 RTC driver - GPIO bitbang I2C - * - * Hardware: DS1307 RTC module, I2C address 0x68, 5V supply - * Pins: PB2(SDA/GP34), PB3(SCL/GP35) - * - * NS800 GPIO configuration requirements: - * GPIO_setAnalogMode(..., GPIO_ANALOG_DISABLED) - enable digital input - * GPIO_setQualificationMode(..., GPIO_QUAL_ASYNC) - bypass input sampling - */ - -#include -#include -#include -#include "ds1307.h" -#include "gpio.h" -#include "board.h" - -#define ADDR 0x68 -#define PORT GPIOB -#define PIN_SDA GPIO_PIN_2 -#define PIN_SCL GPIO_PIN_3 -#define DELAY_CNT 3000 - -/* ========== I2C bitbang primitives ========== */ -static void dly(void) { volatile uint32_t i; for(i=0;i=0;i--) i2c_bit((d>>i)&1); - sda_h();scl_h();dly(); int ack=sda_r()?1:0; scl_l();dly(); return ack; -} - -static uint8_t i2c_recv(uint8_t nak) { - uint8_t d=0; sda_h(); - for(int i=7;i>=0;i--){ sda_h();dly();scl_h();dly(); if(sda_r()) d|=(1<>4)*10)+(x&0xF);} -static inline uint8_t x2b(uint8_t v){return ((v/10)<<4)|(v%10);} - -/* ========== Public API ========== */ -rt_err_t ds1307_init(void) { - uint8_t sec; i2c_init(); - rt_kprintf("[DS1307] Init...\n"); - if(ds_read(0x00,&sec,1)<0){rt_kprintf("No ACK\n");return -RT_ERROR;} - if(sec&0x80){sec&=0x7F; ds_write(0x00,&sec,1); rt_kprintf("Clock started\n");} - rt_kprintf("OK\n"); return RT_EOK; -} - -rt_err_t ds1307_get_time(struct tm *t) { - uint8_t b[7]; if(!t||ds_read(0x00,b,7)<0) return -RT_ERROR; - memset(t,0,sizeof(*t)); - t->tm_sec=b2b(b[0]&0x7F); t->tm_min=b2b(b[1]&0x7F); t->tm_hour=b2b(b[2]&0x3F); - t->tm_mday=b2b(b[3]&0x3F); t->tm_wday=b[4]&0x07; t->tm_mon=b2b(b[5]&0x1F)-1; - t->tm_year=b2b(b[6])+100; return RT_EOK; -} - -rt_err_t ds1307_set_time(struct tm *t) { - if(!t) return -RT_ERROR; - uint8_t v; - v=x2b(t->tm_year-100); if(ds_write(0x06,&v,1)<0) return -RT_ERROR; - v=x2b(t->tm_mon+1); if(ds_write(0x05,&v,1)<0) return -RT_ERROR; - v=x2b(t->tm_mday); if(ds_write(0x04,&v,1)<0) return -RT_ERROR; - v=t->tm_wday&0x07; if(ds_write(0x03,&v,1)<0) return -RT_ERROR; - v=x2b(t->tm_hour); if(ds_write(0x02,&v,1)<0) return -RT_ERROR; - v=x2b(t->tm_min); if(ds_write(0x01,&v,1)<0) return -RT_ERROR; - v=x2b(t->tm_sec); if(ds_write(0x00,&v,1)<0) return -RT_ERROR; - return RT_EOK; -} From 27de595cd106e565c230d95a9ca71139e1ade230 Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Thu, 18 Jun 2026 14:35:50 +0800 Subject: [PATCH 16/17] Delete bsp/novosns/ns800/ds1307.h --- bsp/novosns/ns800/ds1307.h | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 bsp/novosns/ns800/ds1307.h diff --git a/bsp/novosns/ns800/ds1307.h b/bsp/novosns/ns800/ds1307.h deleted file mode 100644 index 44b6a7aaca5..00000000000 --- a/bsp/novosns/ns800/ds1307.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @file ds1307.h - * @brief DS1307 RTC driver header - * - * Hardware: DS1307 RTC module, I2C address 0x68 - * Interface kept as ds1307_* for compatibility with drv_rtc.c - */ - -#ifndef __DS1307_H__ -#define __DS1307_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -rt_err_t ds1307_init(void); -rt_err_t ds1307_get_time(struct tm *time); -rt_err_t ds1307_set_time(struct tm *time); - -#ifdef __cplusplus -} -#endif - -#endif /* __DS1307_H__ */ From a2e812c8c595a21d05b9e28f58f09a4d85946d44 Mon Sep 17 00:00:00 2001 From: wenzhi346 <18303884705@163.com> Date: Thu, 18 Jun 2026 14:36:08 +0800 Subject: [PATCH 17/17] Delete bsp/novosns/ns800/rtcconfig.h --- bsp/novosns/ns800/rtcconfig.h | 442 ---------------------------------- 1 file changed, 442 deletions(-) delete mode 100644 bsp/novosns/ns800/rtcconfig.h diff --git a/bsp/novosns/ns800/rtcconfig.h b/bsp/novosns/ns800/rtcconfig.h deleted file mode 100644 index 3323db6292b..00000000000 --- a/bsp/novosns/ns800/rtcconfig.h +++ /dev/null @@ -1,442 +0,0 @@ -#ifndef RT_CONFIG_H__ -#define RT_CONFIG_H__ - -#define SOC_SERIES_NS800RT7 -#define SOC_NS800RT7P6XX -#define BOARD_NS800RT7P65X -#define RT_USING_FINSH -#define FINSH_USING_MSH - -/* RT-Thread Kernel */ - -/* klibc options */ - -/* rt_vsnprintf options */ - -/* end of rt_vsnprintf options */ - -/* rt_vsscanf options */ - -/* end of rt_vsscanf options */ - -/* rt_memset options */ - -/* end of rt_memset options */ - -/* rt_memcpy options */ - -/* end of rt_memcpy options */ - -/* rt_memmove options */ - -/* end of rt_memmove options */ - -/* rt_memcmp options */ - -/* end of rt_memcmp options */ - -/* rt_strstr options */ - -/* end of rt_strstr options */ - -/* rt_strcasecmp options */ - -/* end of rt_strcasecmp options */ - -/* rt_strncpy options */ - -/* end of rt_strncpy options */ - -/* rt_strcpy options */ - -/* end of rt_strcpy options */ - -/* rt_strncmp options */ - -/* end of rt_strncmp options */ - -/* rt_strcmp options */ - -/* end of rt_strcmp options */ - -/* rt_strlen options */ - -/* end of rt_strlen options */ - -/* rt_strnlen options */ - -/* end of rt_strnlen options */ -/* end of klibc options */ -#define RT_NAME_MAX 16 -#define RT_CPUS_NR 1 -#define RT_ALIGN_SIZE 8 -#define RT_THREAD_PRIORITY_32 -#define RT_THREAD_PRIORITY_MAX 32 -#define RT_TICK_PER_SECOND 1000 -#define RT_USING_OVERFLOW_CHECK -#define RT_USING_HOOK -#define RT_HOOK_USING_FUNC_PTR -#define RT_USING_IDLE_HOOK -#define RT_IDLE_HOOK_LIST_SIZE 4 -#define IDLE_THREAD_STACK_SIZE 256 - -/* kservice options */ - -/* end of kservice options */ -#define RT_USING_DEBUG -#define RT_DEBUGING_ASSERT -#define RT_DEBUGING_COLOR -#define RT_DEBUGING_CONTEXT - -/* Inter-Thread communication */ - -#define RT_USING_SEMAPHORE -#define RT_USING_MUTEX -#define RT_USING_EVENT -#define RT_USING_MAILBOX -#define RT_USING_MESSAGEQUEUE -/* end of Inter-Thread communication */ - -/* Memory Management */ - -#define RT_USING_MEMPOOL -#define RT_USING_SMALL_MEM -#define RT_USING_SMALL_MEM_AS_HEAP -#define RT_USING_HEAP -/* end of Memory Management */ -#define RT_USING_DEVICE -#define RT_USING_CONSOLE -#define RT_CONSOLEBUF_SIZE 128 -#define RT_CONSOLE_DEVICE_NAME "uart1" -#define RT_USING_CONSOLE_OUTPUT_CTL -#define RT_VER_NUM 0x50300 -#define RT_BACKTRACE_LEVEL_MAX_NR 32 -/* end of RT-Thread Kernel */ - -/* RT-Thread Components */ - -#define RT_USING_COMPONENTS_INIT -#define RT_USING_USER_MAIN -#define RT_MAIN_THREAD_STACK_SIZE 2048 -#define RT_MAIN_THREAD_PRIORITY 10 -#define RT_USING_MSH -#define RT_USING_FINSH -#define FINSH_USING_MSH -#define FINSH_THREAD_NAME "tshell" -#define FINSH_THREAD_PRIORITY 20 -#define FINSH_THREAD_STACK_SIZE 4096 -#define FINSH_USING_HISTORY -#define FINSH_HISTORY_LINES 5 -#define FINSH_USING_SYMTAB -#define FINSH_CMD_SIZE 80 -#define MSH_USING_BUILT_IN_COMMANDS -#define FINSH_USING_DESCRIPTION -#define FINSH_ARG_MAX 10 -#define FINSH_USING_OPTION_COMPLETION -/* 在文件末尾添加 */ -#define RT_USING_RTC -#define BSP_USING_RTC - -/* DFS: device virtual file system */ - -/* end of DFS: device virtual file system */ - -/* Device Drivers */ - -#define RT_USING_DEVICE_IPC -#define RT_UNAMED_PIPE_NUMBER 64 -#define RT_USING_SERIAL -#define RT_USING_SERIAL_V1 -#define RT_SERIAL_RB_BUFSZ 64 -#define RT_USING_CAN -#define RT_CAN_USING_CANFD -#define RT_CANMSG_BOX_SZ 16 -#define RT_CANSND_BOX_NUM 1 -#define RT_CANSND_MSG_TIMEOUT 100 -#define RT_CAN_NB_TX_FIFO_SIZE 256 -#define RT_USING_PIN -#define RT_USING_I2C -#define RT_USING_I2C_BITOPS -#define BSP_USING_I2C1 -#define BSP_USING_DS1307 -/* end of Device Drivers */ - -/* C/C++ and POSIX layer */ - -/* ISO-ANSI C layer */ - -/* Timezone and Daylight Saving Time */ - -#define RT_LIBC_USING_LIGHT_TZ_DST -#define RT_LIBC_TZ_DEFAULT_HOUR 8 -#define RT_LIBC_TZ_DEFAULT_MIN 0 -#define RT_LIBC_TZ_DEFAULT_SEC 0 -/* end of Timezone and Daylight Saving Time */ -/* end of ISO-ANSI C layer */ - -/* POSIX (Portable Operating System Interface) layer */ - - -/* Interprocess Communication (IPC) */ - - -/* Socket is in the 'Network' category */ - -/* end of Interprocess Communication (IPC) */ -/* end of POSIX (Portable Operating System Interface) layer */ -/* end of C/C++ and POSIX layer */ - -/* Network */ - -/* end of Network */ - -/* Memory protection */ - -/* end of Memory protection */ - -/* Utilities */ - -/* end of Utilities */ - -/* Using USB legacy version */ - -/* end of Using USB legacy version */ -/* end of RT-Thread Components */ - -/* RT-Thread Utestcases */ - -/* end of RT-Thread Utestcases */ - -/* RT-Thread online packages */ - -/* IoT - internet of things */ - - -/* Wi-Fi */ - -/* Marvell WiFi */ - -/* end of Marvell WiFi */ - -/* Wiced WiFi */ - -/* end of Wiced WiFi */ - -/* CYW43012 WiFi */ - -/* end of CYW43012 WiFi */ - -/* BL808 WiFi */ - -/* end of BL808 WiFi */ - -/* CYW43439 WiFi */ - -/* end of CYW43439 WiFi */ -/* end of Wi-Fi */ - -/* IoT Cloud */ - -/* end of IoT Cloud */ -/* end of IoT - internet of things */ - -/* security packages */ - -/* end of security packages */ - -/* language packages */ - -/* JSON: JavaScript Object Notation, a lightweight data-interchange format */ - -/* end of JSON: JavaScript Object Notation, a lightweight data-interchange format */ - -/* XML: Extensible Markup Language */ - -/* end of XML: Extensible Markup Language */ -/* end of language packages */ - -/* multimedia packages */ - -/* LVGL: powerful and easy-to-use embedded GUI library */ - -/* end of LVGL: powerful and easy-to-use embedded GUI library */ - -/* u8g2: a monochrome graphic library */ - -/* end of u8g2: a monochrome graphic library */ -/* end of multimedia packages */ - -/* tools packages */ - -/* end of tools packages */ - -/* system packages */ - -/* enhanced kernel services */ - -/* end of enhanced kernel services */ - -/* acceleration: Assembly language or algorithmic acceleration packages */ - -/* end of acceleration: Assembly language or algorithmic acceleration packages */ - -/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */ - -#define PKG_USING_CMSIS_CORE -#define PKG_USING_CMSIS_CORE_LATEST_VERSION -/* end of CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */ - -/* Micrium: Micrium software products porting for RT-Thread */ - -/* end of Micrium: Micrium software products porting for RT-Thread */ -/* end of system packages */ - -/* peripheral libraries and drivers */ - -/* HAL & SDK Drivers */ - -/* STM32 HAL & SDK Drivers */ - -/* end of STM32 HAL & SDK Drivers */ - -/* Infineon HAL Packages */ - -/* end of Infineon HAL Packages */ - -/* Kendryte SDK */ - -/* end of Kendryte SDK */ - -/* WCH HAL & SDK Drivers */ - -/* end of WCH HAL & SDK Drivers */ - -/* AT32 HAL & SDK Drivers */ - -/* end of AT32 HAL & SDK Drivers */ - -/* HC32 DDL Drivers */ - -/* end of HC32 DDL Drivers */ - -/* NXP HAL & SDK Drivers */ - -/* end of NXP HAL & SDK Drivers */ - -/* NUVOTON Drivers */ - -/* end of NUVOTON Drivers */ - -/* GD32 Drivers */ - -/* end of GD32 Drivers */ - -/* HPMicro SDK */ - -/* end of HPMicro SDK */ - -/* FT32 HAL & SDK Drivers */ - -/* end of FT32 HAL & SDK Drivers */ - -/* NOVOSNS Drivers */ - -#define PKG_USING_NOVOSNS_SERIES_DRIVER -#define PKG_USING_NOVOSNS_SERIES_DRIVER_LATEST_VERSION -/* end of NOVOSNS Drivers */ -/* end of HAL & SDK Drivers */ - -/* sensors drivers */ - -/* end of sensors drivers */ - -/* touch drivers */ - -/* end of touch drivers */ -/* end of peripheral libraries and drivers */ - -/* AI packages */ - -/* end of AI packages */ - -/* Signal Processing and Control Algorithm Packages */ - -/* end of Signal Processing and Control Algorithm Packages */ - -/* miscellaneous packages */ - -/* project laboratory */ - -/* end of project laboratory */ - -/* samples: kernel and components samples */ - -/* end of samples: kernel and components samples */ - -/* entertainment: terminal games and other interesting software packages */ - -/* end of entertainment: terminal games and other interesting software packages */ -/* end of miscellaneous packages */ - -/* Arduino libraries */ - - -/* Projects and Demos */ - -/* end of Projects and Demos */ - -/* Sensors */ - -/* end of Sensors */ - -/* Display */ - -/* end of Display */ - -/* Timing */ - -/* end of Timing */ - -/* Data Processing */ - -/* end of Data Processing */ - -/* Data Storage */ - -/* Communication */ - -/* end of Communication */ - -/* Device Control */ - -/* end of Device Control */ - -/* Other */ - -/* end of Other */ - -/* Signal IO */ - -/* end of Signal IO */ - -/* Uncategorized */ - -/* end of Arduino libraries */ -/* end of RT-Thread online packages */ - -/* On-chip Peripheral Drivers */ - -#define BOARD_CLK_CONF -#define SYSCLK_USE_PLL -#define SYSCLK_SOURCE_USE_HXTL -#define PLLCLK_SOURCE_USE_HXTL -#define BSP_USING_GPIO -#define BSP_USING_UART -#define BSP_NS800_UART_TX_TIMEOUT 6000 -#define BSP_USING_UART1 -#define BSP_USING_ECAP -#define BSP_USING_CAN -#define BSP_USING_CANFD1 -/* end of On-chip Peripheral Drivers */ - -#endif