From bbd563b0694c10dcdea97fcfca279a8edee6a3f3 Mon Sep 17 00:00:00 2001 From: YuanHongbin <975559679@qq.com> Date: Thu, 23 Apr 2026 14:02:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MDK/EventRecorderStub.scvd | 9 + MDK/JLinkSettings.ini | 35 + MDK/RTE/RTOS/board.c | 79 + MDK/RTE/RTOS/board.c.base@3.1.5 | 79 + MDK/RTE/RTOS/finsh_config.h | 29 + MDK/RTE/RTOS/finsh_config.h.base@3.1.5 | 29 + MDK/RTE/RTOS/finsh_port.c | 30 + MDK/RTE/RTOS/finsh_port.c.base@3.1.5 | 30 + MDK/RTE/RTOS/rtconfig.h | 139 + MDK/RTE/RTOS/rtconfig.h.base@3.1.5 | 139 + MDK/RTE/_HC32L17X/RTE_Components.h | 21 + MDK/RTE/__FEATURE__Release/RTE_Components.h | 20 + MDK/RTE/_template_Release/RTE_Components.h | 21 + MDK/hc32l17x.uvoptx | 798 + MDK/hc32l17x.uvprojx | 650 + MDK/output/hc32l17x.sct | 16 + MDK/startup_hc32l17x.s | 301 + Module/Imu/Imu.c | 298 + Module/Imu/Imu.h | 24 + Module/LORA/sx127x.c | 613 + Module/LORA/sx127x.h | 826 + Module/MahonyAHRS/MahonyAHRS.c | 247 + Module/MahonyAHRS/MahonyAHRS.h | 32 + Module/lsm6dsl/lsm6dsl_app.c | 269 + Module/lsm6dsl/lsm6dsl_app.h | 36 + Module/lsm6dsl/lsm6dsl_reg.c | 7948 ++++ Module/lsm6dsl/lsm6dsl_reg.h | 2722 ++ Module/mmc5983/mmc5983.c | 343 + Module/mmc5983/mmc5983.h | 140 + ReadMe.txt | 31 + driver/inc/adc.h | 470 + driver/inc/adt.h | 878 + driver/inc/aes.h | 132 + driver/inc/bgr.h | 109 + driver/inc/bt.h | 771 + driver/inc/crc.h | 120 + driver/inc/dac.h | 234 + driver/inc/ddl.h | 174 + driver/inc/debug.h | 129 + driver/inc/dmac.h | 356 + driver/inc/flash.h | 167 + driver/inc/gpio.h | 1227 + driver/inc/i2c.h | 154 + driver/inc/lcd.h | 250 + driver/inc/lpm.h | 106 + driver/inc/lptim.h | 185 + driver/inc/lpuart.h | 276 + driver/inc/lvd.h | 231 + driver/inc/opa.h | 152 + driver/inc/pca.h | 261 + driver/inc/pcnt.h | 233 + driver/inc/ram.h | 119 + driver/inc/reset.h | 175 + driver/inc/rtc.h | 248 + driver/inc/spi.h | 212 + driver/inc/sysctrl.h | 456 + driver/inc/timer3.h | 781 + driver/inc/trim.h | 184 + driver/inc/trng.h | 108 + driver/inc/uart.h | 252 + driver/inc/vc.h | 299 + driver/inc/wdt.h | 135 + driver/src/adc.c | 649 + driver/src/adt.c | 1657 + driver/src/aes.c | 206 + driver/src/bgr.c | 143 + driver/src/bt.c | 1381 + driver/src/crc.c | 438 + driver/src/dac.c | 253 + driver/src/ddl.c | 250 + driver/src/debug.c | 119 + driver/src/dmac.c | 624 + driver/src/flash.c | 696 + driver/src/gpio.c | 582 + driver/src/i2c.c | 398 + driver/src/lcd.c | 289 + driver/src/lpm.c | 122 + driver/src/lptim.c | 171 + driver/src/lpuart.c | 409 + driver/src/lvd.c | 216 + driver/src/opa.c | 153 + driver/src/pca.c | 555 + driver/src/pcnt.c | 316 + driver/src/ram.c | 156 + driver/src/reset.c | 184 + driver/src/rtc.c | 520 + driver/src/spi.c | 363 + driver/src/sysctrl.c | 746 + driver/src/timer3.c | 1368 + driver/src/trim.c | 248 + driver/src/trng.c | 191 + driver/src/uart.c | 405 + driver/src/vc.c | 298 + driver/src/wdt.c | 203 + keilkill.bat | 30 + mcu/EWARM/HC32L17X.svd | 37132 ++++++++++++++++ .../config/flashloader/FlashHC32L17X.flash | 10 + .../config/flashloader/FlashHC32L17X.mac | 23 + mcu/EWARM/config/flashloader/HC32L17X.board | 8 + mcu/EWARM/config/hc32l17x_ram.icf | 29 + mcu/EWARM/config/reset.mac | 8 + mcu/MDK/HC32L17X.sfr | Bin 0 -> 804549 bytes mcu/MDK/config/FlashHC32L17X_128K.FLM | Bin 0 -> 18856 bytes mcu/common/base_types.h | 147 + mcu/common/board_stkhc32l17x.h | 130 + mcu/common/hc32l17x.h | 10833 +++++ mcu/common/interrupts_hc32l17x.c | 610 + mcu/common/interrupts_hc32l17x.h | 150 + mcu/common/system_hc32l17x.c | 212 + mcu/common/system_hc32l17x.h | 116 + source/ddl_device.h | 76 + source/inc/Algorithm.h | 55 + source/inc/SGCP.h | 290 + source/inc/Update.h | 61 + source/inc/bsp.h | 271 + source/inc/main.h | 107 + source/src/Algorithm.c | 783 + source/src/SGCP.c | 2227 + source/src/Update.c | 48 + source/src/bsp.c | 937 + source/src/main.c | 571 + 121 files changed, 94711 insertions(+) create mode 100644 MDK/EventRecorderStub.scvd create mode 100644 MDK/JLinkSettings.ini create mode 100644 MDK/RTE/RTOS/board.c create mode 100644 MDK/RTE/RTOS/board.c.base@3.1.5 create mode 100644 MDK/RTE/RTOS/finsh_config.h create mode 100644 MDK/RTE/RTOS/finsh_config.h.base@3.1.5 create mode 100644 MDK/RTE/RTOS/finsh_port.c create mode 100644 MDK/RTE/RTOS/finsh_port.c.base@3.1.5 create mode 100644 MDK/RTE/RTOS/rtconfig.h create mode 100644 MDK/RTE/RTOS/rtconfig.h.base@3.1.5 create mode 100644 MDK/RTE/_HC32L17X/RTE_Components.h create mode 100644 MDK/RTE/__FEATURE__Release/RTE_Components.h create mode 100644 MDK/RTE/_template_Release/RTE_Components.h create mode 100644 MDK/hc32l17x.uvoptx create mode 100644 MDK/hc32l17x.uvprojx create mode 100644 MDK/output/hc32l17x.sct create mode 100644 MDK/startup_hc32l17x.s create mode 100644 Module/Imu/Imu.c create mode 100644 Module/Imu/Imu.h create mode 100644 Module/LORA/sx127x.c create mode 100644 Module/LORA/sx127x.h create mode 100644 Module/MahonyAHRS/MahonyAHRS.c create mode 100644 Module/MahonyAHRS/MahonyAHRS.h create mode 100644 Module/lsm6dsl/lsm6dsl_app.c create mode 100644 Module/lsm6dsl/lsm6dsl_app.h create mode 100644 Module/lsm6dsl/lsm6dsl_reg.c create mode 100644 Module/lsm6dsl/lsm6dsl_reg.h create mode 100644 Module/mmc5983/mmc5983.c create mode 100644 Module/mmc5983/mmc5983.h create mode 100644 ReadMe.txt create mode 100644 driver/inc/adc.h create mode 100644 driver/inc/adt.h create mode 100644 driver/inc/aes.h create mode 100644 driver/inc/bgr.h create mode 100644 driver/inc/bt.h create mode 100644 driver/inc/crc.h create mode 100644 driver/inc/dac.h create mode 100644 driver/inc/ddl.h create mode 100644 driver/inc/debug.h create mode 100644 driver/inc/dmac.h create mode 100644 driver/inc/flash.h create mode 100644 driver/inc/gpio.h create mode 100644 driver/inc/i2c.h create mode 100644 driver/inc/lcd.h create mode 100644 driver/inc/lpm.h create mode 100644 driver/inc/lptim.h create mode 100644 driver/inc/lpuart.h create mode 100644 driver/inc/lvd.h create mode 100644 driver/inc/opa.h create mode 100644 driver/inc/pca.h create mode 100644 driver/inc/pcnt.h create mode 100644 driver/inc/ram.h create mode 100644 driver/inc/reset.h create mode 100644 driver/inc/rtc.h create mode 100644 driver/inc/spi.h create mode 100644 driver/inc/sysctrl.h create mode 100644 driver/inc/timer3.h create mode 100644 driver/inc/trim.h create mode 100644 driver/inc/trng.h create mode 100644 driver/inc/uart.h create mode 100644 driver/inc/vc.h create mode 100644 driver/inc/wdt.h create mode 100644 driver/src/adc.c create mode 100644 driver/src/adt.c create mode 100644 driver/src/aes.c create mode 100644 driver/src/bgr.c create mode 100644 driver/src/bt.c create mode 100644 driver/src/crc.c create mode 100644 driver/src/dac.c create mode 100644 driver/src/ddl.c create mode 100644 driver/src/debug.c create mode 100644 driver/src/dmac.c create mode 100644 driver/src/flash.c create mode 100644 driver/src/gpio.c create mode 100644 driver/src/i2c.c create mode 100644 driver/src/lcd.c create mode 100644 driver/src/lpm.c create mode 100644 driver/src/lptim.c create mode 100644 driver/src/lpuart.c create mode 100644 driver/src/lvd.c create mode 100644 driver/src/opa.c create mode 100644 driver/src/pca.c create mode 100644 driver/src/pcnt.c create mode 100644 driver/src/ram.c create mode 100644 driver/src/reset.c create mode 100644 driver/src/rtc.c create mode 100644 driver/src/spi.c create mode 100644 driver/src/sysctrl.c create mode 100644 driver/src/timer3.c create mode 100644 driver/src/trim.c create mode 100644 driver/src/trng.c create mode 100644 driver/src/uart.c create mode 100644 driver/src/vc.c create mode 100644 driver/src/wdt.c create mode 100644 keilkill.bat create mode 100644 mcu/EWARM/HC32L17X.svd create mode 100644 mcu/EWARM/config/flashloader/FlashHC32L17X.flash create mode 100644 mcu/EWARM/config/flashloader/FlashHC32L17X.mac create mode 100644 mcu/EWARM/config/flashloader/HC32L17X.board create mode 100644 mcu/EWARM/config/hc32l17x_ram.icf create mode 100644 mcu/EWARM/config/reset.mac create mode 100644 mcu/MDK/HC32L17X.sfr create mode 100644 mcu/MDK/config/FlashHC32L17X_128K.FLM create mode 100644 mcu/common/base_types.h create mode 100644 mcu/common/board_stkhc32l17x.h create mode 100644 mcu/common/hc32l17x.h create mode 100644 mcu/common/interrupts_hc32l17x.c create mode 100644 mcu/common/interrupts_hc32l17x.h create mode 100644 mcu/common/system_hc32l17x.c create mode 100644 mcu/common/system_hc32l17x.h create mode 100644 source/ddl_device.h create mode 100644 source/inc/Algorithm.h create mode 100644 source/inc/SGCP.h create mode 100644 source/inc/Update.h create mode 100644 source/inc/bsp.h create mode 100644 source/inc/main.h create mode 100644 source/src/Algorithm.c create mode 100644 source/src/SGCP.c create mode 100644 source/src/Update.c create mode 100644 source/src/bsp.c create mode 100644 source/src/main.c diff --git a/MDK/EventRecorderStub.scvd b/MDK/EventRecorderStub.scvd new file mode 100644 index 0000000..2956b29 --- /dev/null +++ b/MDK/EventRecorderStub.scvd @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/MDK/JLinkSettings.ini b/MDK/JLinkSettings.ini new file mode 100644 index 0000000..79743a7 --- /dev/null +++ b/MDK/JLinkSettings.ini @@ -0,0 +1,35 @@ +[BREAKPOINTS] +ForceImpTypeAny = 0 +ShowInfoWin = 1 +EnableFlashBP = 2 +BPDuringExecution = 0 +[CFI] +CFISize = 0x00 +CFIAddr = 0x00 +[CPU] +OverrideMemMap = 0 +AllowSimulation = 1 +ScriptFile="" +[FLASH] +CacheExcludeSize = 0x00 +CacheExcludeAddr = 0x00 +MinNumBytesFlashDL = 0 +SkipProgOnCRCMatch = 1 +VerifyDownload = 1 +AllowCaching = 1 +EnableFlashDL = 2 +Override = 1 +Device="Cortex-M0+" +[GENERAL] +WorkRAMSize = 0x00 +WorkRAMAddr = 0x00 +RAMUsageLimit = 0x00 +[SWO] +SWOLogFile="" +[MEM] +RdOverrideOrMask = 0x00 +RdOverrideAndMask = 0xFFFFFFFF +RdOverrideAddr = 0xFFFFFFFF +WrOverrideOrMask = 0x00 +WrOverrideAndMask = 0xFFFFFFFF +WrOverrideAddr = 0xFFFFFFFF diff --git a/MDK/RTE/RTOS/board.c b/MDK/RTE/RTOS/board.c new file mode 100644 index 0000000..e45e75f --- /dev/null +++ b/MDK/RTE/RTOS/board.c @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2006-2019, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-05-24 the first version + */ + +#include +#include + +#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP) +/* + * Please modify RT_HEAP_SIZE if you enable RT_USING_HEAP + * the RT_HEAP_SIZE max value = (sram size - ZI size), 1024 means 1024 bytes + */ +#define RT_HEAP_SIZE (15*1024) +static rt_uint8_t rt_heap[RT_HEAP_SIZE]; + +RT_WEAK void *rt_heap_begin_get(void) +{ + return rt_heap; +} + +RT_WEAK void *rt_heap_end_get(void) +{ + return rt_heap + RT_HEAP_SIZE; +} +#endif + +void rt_os_tick_callback(void) +{ + rt_interrupt_enter(); + + rt_tick_increase(); + + rt_interrupt_leave(); +} + +/** + * This function will initial your board. + */ +void rt_hw_board_init(void) +{ +#error "TODO 1: OS Tick Configuration." + /* + * TODO 1: OS Tick Configuration + * Enable the hardware timer and call the rt_os_tick_callback function + * periodically with the frequency RT_TICK_PER_SECOND. + */ + + /* Call components board initial (use INIT_BOARD_EXPORT()) */ +#ifdef RT_USING_COMPONENTS_INIT + rt_components_board_init(); +#endif + +#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP) + rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get()); +#endif +} + +#ifdef RT_USING_CONSOLE + +static int uart_init(void) +{ +#error "TODO 2: Enable the hardware uart and config baudrate." + return 0; +} +INIT_BOARD_EXPORT(uart_init); + +void rt_hw_console_output(const char *str) +{ +#error "TODO 3: Output the string 'str' through the uart." +} + +#endif + diff --git a/MDK/RTE/RTOS/board.c.base@3.1.5 b/MDK/RTE/RTOS/board.c.base@3.1.5 new file mode 100644 index 0000000..e45e75f --- /dev/null +++ b/MDK/RTE/RTOS/board.c.base@3.1.5 @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2006-2019, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-05-24 the first version + */ + +#include +#include + +#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP) +/* + * Please modify RT_HEAP_SIZE if you enable RT_USING_HEAP + * the RT_HEAP_SIZE max value = (sram size - ZI size), 1024 means 1024 bytes + */ +#define RT_HEAP_SIZE (15*1024) +static rt_uint8_t rt_heap[RT_HEAP_SIZE]; + +RT_WEAK void *rt_heap_begin_get(void) +{ + return rt_heap; +} + +RT_WEAK void *rt_heap_end_get(void) +{ + return rt_heap + RT_HEAP_SIZE; +} +#endif + +void rt_os_tick_callback(void) +{ + rt_interrupt_enter(); + + rt_tick_increase(); + + rt_interrupt_leave(); +} + +/** + * This function will initial your board. + */ +void rt_hw_board_init(void) +{ +#error "TODO 1: OS Tick Configuration." + /* + * TODO 1: OS Tick Configuration + * Enable the hardware timer and call the rt_os_tick_callback function + * periodically with the frequency RT_TICK_PER_SECOND. + */ + + /* Call components board initial (use INIT_BOARD_EXPORT()) */ +#ifdef RT_USING_COMPONENTS_INIT + rt_components_board_init(); +#endif + +#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP) + rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get()); +#endif +} + +#ifdef RT_USING_CONSOLE + +static int uart_init(void) +{ +#error "TODO 2: Enable the hardware uart and config baudrate." + return 0; +} +INIT_BOARD_EXPORT(uart_init); + +void rt_hw_console_output(const char *str) +{ +#error "TODO 3: Output the string 'str' through the uart." +} + +#endif + diff --git a/MDK/RTE/RTOS/finsh_config.h b/MDK/RTE/RTOS/finsh_config.h new file mode 100644 index 0000000..a5a7340 --- /dev/null +++ b/MDK/RTE/RTOS/finsh_config.h @@ -0,0 +1,29 @@ +/* FinSH config file */ + +#ifndef __MSH_CFG_H__ +#define __MSH_CFG_H__ + +// <<< Use Configuration Wizard in Context Menu >>> +#define RT_USING_FINSH +#define FINSH_USING_MSH +#define FINSH_USING_MSH_ONLY +// FinSH Configuration +// the priority of finsh thread <1-30> +// the priority of finsh thread +// Default: 21 +#define FINSH_THREAD_PRIORITY 21 +// the stack of finsh thread <1-4096> +// the stack of finsh thread +// Default: 4096 (4096Byte) +#define FINSH_THREAD_STACK_SIZE 1024 + +#define FINSH_USING_SYMTAB +// Enable command description +// Enable command description +#define FINSH_USING_DESCRIPTION +// +// + +// <<< end of configuration section >>> +#endif + diff --git a/MDK/RTE/RTOS/finsh_config.h.base@3.1.5 b/MDK/RTE/RTOS/finsh_config.h.base@3.1.5 new file mode 100644 index 0000000..a5a7340 --- /dev/null +++ b/MDK/RTE/RTOS/finsh_config.h.base@3.1.5 @@ -0,0 +1,29 @@ +/* FinSH config file */ + +#ifndef __MSH_CFG_H__ +#define __MSH_CFG_H__ + +// <<< Use Configuration Wizard in Context Menu >>> +#define RT_USING_FINSH +#define FINSH_USING_MSH +#define FINSH_USING_MSH_ONLY +// FinSH Configuration +// the priority of finsh thread <1-30> +// the priority of finsh thread +// Default: 21 +#define FINSH_THREAD_PRIORITY 21 +// the stack of finsh thread <1-4096> +// the stack of finsh thread +// Default: 4096 (4096Byte) +#define FINSH_THREAD_STACK_SIZE 1024 + +#define FINSH_USING_SYMTAB +// Enable command description +// Enable command description +#define FINSH_USING_DESCRIPTION +// +// + +// <<< end of configuration section >>> +#endif + diff --git a/MDK/RTE/RTOS/finsh_port.c b/MDK/RTE/RTOS/finsh_port.c new file mode 100644 index 0000000..4e3f7ff --- /dev/null +++ b/MDK/RTE/RTOS/finsh_port.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + */ + +#include +#include + +#ifndef RT_USING_FINSH +#error Please uncomment the line <#include "finsh_config.h"> in the rtconfig.h +#endif + +#ifdef RT_USING_FINSH + +RT_WEAK char rt_hw_console_getchar(void) +{ + /* Note: the initial value of ch must < 0 */ + int ch = -1; + +#error "TODO 4: Read a char from the uart and assign it to 'ch'." + + return ch; +} + +#endif /* RT_USING_FINSH */ + diff --git a/MDK/RTE/RTOS/finsh_port.c.base@3.1.5 b/MDK/RTE/RTOS/finsh_port.c.base@3.1.5 new file mode 100644 index 0000000..4e3f7ff --- /dev/null +++ b/MDK/RTE/RTOS/finsh_port.c.base@3.1.5 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + */ + +#include +#include + +#ifndef RT_USING_FINSH +#error Please uncomment the line <#include "finsh_config.h"> in the rtconfig.h +#endif + +#ifdef RT_USING_FINSH + +RT_WEAK char rt_hw_console_getchar(void) +{ + /* Note: the initial value of ch must < 0 */ + int ch = -1; + +#error "TODO 4: Read a char from the uart and assign it to 'ch'." + + return ch; +} + +#endif /* RT_USING_FINSH */ + diff --git a/MDK/RTE/RTOS/rtconfig.h b/MDK/RTE/RTOS/rtconfig.h new file mode 100644 index 0000000..5b54665 --- /dev/null +++ b/MDK/RTE/RTOS/rtconfig.h @@ -0,0 +1,139 @@ +/* RT-Thread config file */ + +#ifndef __RTTHREAD_CFG_H__ +#define __RTTHREAD_CFG_H__ + +// <<< Use Configuration Wizard in Context Menu >>> + +// Basic Configuration +// Maximal level of thread priority <8-256> +// Default: 32 +#define RT_THREAD_PRIORITY_MAX 32 +// OS tick per second +// Default: 1000 (1ms) +#define RT_TICK_PER_SECOND 1000 +// Alignment size for CPU architecture data access +// Default: 4 +#define RT_ALIGN_SIZE 4 +// the max length of object name<2-16> +// Default: 8 +#define RT_NAME_MAX 8 +// Using RT-Thread components initialization +// Using RT-Thread components initialization +#define RT_USING_COMPONENTS_INIT +// + +#define RT_USING_USER_MAIN + +// the stack size of main thread<1-4086> +// Default: 512 +#define RT_MAIN_THREAD_STACK_SIZE 256 + +// + +// Debug Configuration +// enable kernel debug configuration +// Default: enable kernel debug configuration +//#define RT_DEBUG +// +// enable components initialization debug configuration<0-1> +// Default: 0 +#define RT_DEBUG_INIT 0 +// thread stack over flow detect +// Diable Thread stack over flow detect +//#define RT_USING_OVERFLOW_CHECK +// +// + +// Hook Configuration +// using hook +// using hook +//#define RT_USING_HOOK +// +// using idle hook +// using idle hook +//#define RT_USING_IDLE_HOOK +// +// + +// Software timers Configuration +// Enables user timers +#define RT_USING_TIMER_SOFT 0 +#if RT_USING_TIMER_SOFT == 0 + #undef RT_USING_TIMER_SOFT +#endif +// The priority level of timer thread <0-31> +// Default: 4 +#define RT_TIMER_THREAD_PRIO 4 +// The stack size of timer thread <0-8192> +// Default: 512 +#define RT_TIMER_THREAD_STACK_SIZE 512 +// + +// IPC(Inter-process communication) Configuration +// Using Semaphore +// Using Semaphore +#define RT_USING_SEMAPHORE +// +// Using Mutex +// Using Mutex +//#define RT_USING_MUTEX +// +// Using Event +// Using Event +//#define RT_USING_EVENT +// +// Using MailBox +// Using MailBox +#define RT_USING_MAILBOX +// +// Using Message Queue +// Using Message Queue +//#define RT_USING_MESSAGEQUEUE +// +// + +// Memory Management Configuration +// Memory Pool Management +// Memory Pool Management +//#define RT_USING_MEMPOOL +// +// Dynamic Heap Management(Algorithm: small memory ) +// Dynamic Heap Management +#define RT_USING_HEAP +#define RT_USING_SMALL_MEM +// +// using tiny size of memory +// using tiny size of memory +//#define RT_USING_TINY_SIZE +// +// + +// Console Configuration +// Using console +// Using console +//#define RT_USING_CONSOLE +// +// the buffer size of console <1-1024> +// the buffer size of console +// Default: 128 (128Byte) +#define RT_CONSOLEBUF_SIZE 256 +// + +// FinSH Configuration +// include finsh config +// Select this choice if you using FinSH +//#include "finsh_config.h" +// +// + +// Device Configuration +// using device framework +// using device framework +//#define RT_USING_DEVICE +// +// + +// <<< end of configuration section >>> + +#endif diff --git a/MDK/RTE/RTOS/rtconfig.h.base@3.1.5 b/MDK/RTE/RTOS/rtconfig.h.base@3.1.5 new file mode 100644 index 0000000..5b54665 --- /dev/null +++ b/MDK/RTE/RTOS/rtconfig.h.base@3.1.5 @@ -0,0 +1,139 @@ +/* RT-Thread config file */ + +#ifndef __RTTHREAD_CFG_H__ +#define __RTTHREAD_CFG_H__ + +// <<< Use Configuration Wizard in Context Menu >>> + +// Basic Configuration +// Maximal level of thread priority <8-256> +// Default: 32 +#define RT_THREAD_PRIORITY_MAX 32 +// OS tick per second +// Default: 1000 (1ms) +#define RT_TICK_PER_SECOND 1000 +// Alignment size for CPU architecture data access +// Default: 4 +#define RT_ALIGN_SIZE 4 +// the max length of object name<2-16> +// Default: 8 +#define RT_NAME_MAX 8 +// Using RT-Thread components initialization +// Using RT-Thread components initialization +#define RT_USING_COMPONENTS_INIT +// + +#define RT_USING_USER_MAIN + +// the stack size of main thread<1-4086> +// Default: 512 +#define RT_MAIN_THREAD_STACK_SIZE 256 + +// + +// Debug Configuration +// enable kernel debug configuration +// Default: enable kernel debug configuration +//#define RT_DEBUG +// +// enable components initialization debug configuration<0-1> +// Default: 0 +#define RT_DEBUG_INIT 0 +// thread stack over flow detect +// Diable Thread stack over flow detect +//#define RT_USING_OVERFLOW_CHECK +// +// + +// Hook Configuration +// using hook +// using hook +//#define RT_USING_HOOK +// +// using idle hook +// using idle hook +//#define RT_USING_IDLE_HOOK +// +// + +// Software timers Configuration +// Enables user timers +#define RT_USING_TIMER_SOFT 0 +#if RT_USING_TIMER_SOFT == 0 + #undef RT_USING_TIMER_SOFT +#endif +// The priority level of timer thread <0-31> +// Default: 4 +#define RT_TIMER_THREAD_PRIO 4 +// The stack size of timer thread <0-8192> +// Default: 512 +#define RT_TIMER_THREAD_STACK_SIZE 512 +// + +// IPC(Inter-process communication) Configuration +// Using Semaphore +// Using Semaphore +#define RT_USING_SEMAPHORE +// +// Using Mutex +// Using Mutex +//#define RT_USING_MUTEX +// +// Using Event +// Using Event +//#define RT_USING_EVENT +// +// Using MailBox +// Using MailBox +#define RT_USING_MAILBOX +// +// Using Message Queue +// Using Message Queue +//#define RT_USING_MESSAGEQUEUE +// +// + +// Memory Management Configuration +// Memory Pool Management +// Memory Pool Management +//#define RT_USING_MEMPOOL +// +// Dynamic Heap Management(Algorithm: small memory ) +// Dynamic Heap Management +#define RT_USING_HEAP +#define RT_USING_SMALL_MEM +// +// using tiny size of memory +// using tiny size of memory +//#define RT_USING_TINY_SIZE +// +// + +// Console Configuration +// Using console +// Using console +//#define RT_USING_CONSOLE +// +// the buffer size of console <1-1024> +// the buffer size of console +// Default: 128 (128Byte) +#define RT_CONSOLEBUF_SIZE 256 +// + +// FinSH Configuration +// include finsh config +// Select this choice if you using FinSH +//#include "finsh_config.h" +// +// + +// Device Configuration +// using device framework +// using device framework +//#define RT_USING_DEVICE +// +// + +// <<< end of configuration section >>> + +#endif diff --git a/MDK/RTE/_HC32L17X/RTE_Components.h b/MDK/RTE/_HC32L17X/RTE_Components.h new file mode 100644 index 0000000..4e84c89 --- /dev/null +++ b/MDK/RTE/_HC32L17X/RTE_Components.h @@ -0,0 +1,21 @@ + +/* + * Auto generated Run-Time-Environment Configuration File + * *** Do not modify ! *** + * + * Project: 'hc32l17x' + * Target: 'HC32L17X' + */ + +#ifndef RTE_COMPONENTS_H +#define RTE_COMPONENTS_H + + +/* + * Define the Device Header File: + */ +#define CMSIS_device_header "HC32L170JATA.h" + + + +#endif /* RTE_COMPONENTS_H */ diff --git a/MDK/RTE/__FEATURE__Release/RTE_Components.h b/MDK/RTE/__FEATURE__Release/RTE_Components.h new file mode 100644 index 0000000..a2dd5ef --- /dev/null +++ b/MDK/RTE/__FEATURE__Release/RTE_Components.h @@ -0,0 +1,20 @@ + +/* + * Auto generated Run-Time-Environment Component Configuration File + * *** Do not modify ! *** + * + * Project: 'ddl_template' + * Target: '{FEATURE}_Release' + */ + +#ifndef RTE_COMPONENTS_H +#define RTE_COMPONENTS_H + + +/* + * Define the Device Header File: + */ +#define CMSIS_device_header "ARMCM0plus.h" + + +#endif /* RTE_COMPONENTS_H */ diff --git a/MDK/RTE/_template_Release/RTE_Components.h b/MDK/RTE/_template_Release/RTE_Components.h new file mode 100644 index 0000000..97bd6b0 --- /dev/null +++ b/MDK/RTE/_template_Release/RTE_Components.h @@ -0,0 +1,21 @@ + +/* + * Auto generated Run-Time-Environment Configuration File + * *** Do not modify ! *** + * + * Project: 'hc32l17x' + * Target: 'template_Release' + */ + +#ifndef RTE_COMPONENTS_H +#define RTE_COMPONENTS_H + + +/* + * Define the Device Header File: + */ +#define CMSIS_device_header "ARMCM0plus.h" + + + +#endif /* RTE_COMPONENTS_H */ diff --git a/MDK/hc32l17x.uvoptx b/MDK/hc32l17x.uvoptx new file mode 100644 index 0000000..942295c --- /dev/null +++ b/MDK/hc32l17x.uvoptx @@ -0,0 +1,798 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc; *.md + *.plm + *.cpp; *.cc; *.cxx + 0 + + + + 0 + 0 + + + + HC32L17X + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\output\release\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 255 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 12 + + + + + + + + + + + BIN\CMSIS_AGDI.dll + + + + 0 + DLGUARM + + + + 0 + CMSIS_AGDI + -X"Any" -UAny -O206 -S8 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0FlashHC32L17X_128K.FLM -FS00 -FL020000 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 ) -FN1 -FC1000 -FD20000000 -FF0FlashHC32L17X_128K -FL020000 -FS00 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM) + + + 0 + JL2CM3 + -U4294967295 -O78 -S1 -ZTIFSpeedSel10000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8027 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0FlashHC32L17X_128K.FLM -FS00 -FL020000 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM) + + + 0 + ARMRTXEVENTFLAGS + -L70 -Z18 -C0 -M0 -T1 + + + 0 + DLGTARM + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0) + + + 0 + ARMDBGFLAGS + + + + + + + 0 + 1 + App.Login2Min30SCount,0x0A + + + 1 + 1 + App.TD1mSDelayCnt,0x0A + + + 2 + 1 + App.Nonce,0x0A + + + 3 + 1 + App.RDStatus,0x0A + + + 4 + 1 + SGCP.TimingAcquisition + + + 5 + 1 + App.Para.Layout.CollectTime,0x0A + + + 6 + 1 + App.Para.Layout.ReportInterval,0x0A + + + 7 + 1 + App.Para.Layout.ERInterval,0x0A + + + 8 + 1 + App.Para.Layout.ERTime,0x0A + + + 9 + 1 + App.Para.Layout.TimeStamp,0x0A + + + 10 + 1 + SGCP.DeviceData + + + 11 + 1 + SGCP.GatewayBuff + + + 12 + 1 + VBAT_12V,0x0A + + + 13 + 1 + i,0x0A + + + 14 + 1 + VBAT_Percentage,0x0A + + + 15 + 1 + App.Tcnt,0x0A + + + 16 + 1 + App.Status,0x0A + + + 17 + 1 + App.TestTimeCnt,0x0A + + + 18 + 1 + App.LaserFlag,0x0A + + + + + 1 + 0 + 0x1fe00 + 0 + + + + + 2 + 2 + 0x20000f35 + 0 + + + + 0 + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + 1 + 0 + 0 + 2 + 10000000 + + + + + + common + 1 + 0 + 0 + 0 + + 1 + 1 + 2 + 0 + 0 + 0 + .\startup_hc32l17x.s + startup_hc32l17x.s + 0 + 0 + + + 1 + 2 + 1 + 0 + 0 + 0 + ..\mcu\common\system_hc32l17x.c + system_hc32l17x.c + 0 + 0 + + + 1 + 3 + 1 + 0 + 0 + 0 + ..\mcu\common\interrupts_hc32l17x.c + interrupts_hc32l17x.c + 0 + 0 + + + + + source + 1 + 0 + 0 + 0 + + 2 + 4 + 1 + 0 + 0 + 0 + ..\source\Src\main.c + main.c + 0 + 0 + + + 2 + 5 + 1 + 0 + 0 + 0 + ..\source\src\bsp.c + bsp.c + 0 + 0 + + + 2 + 6 + 1 + 0 + 0 + 0 + ..\source\src\Algorithm.c + Algorithm.c + 0 + 0 + + + 2 + 7 + 1 + 0 + 0 + 0 + ..\source\src\SGCP.c + SGCP.c + 0 + 0 + + + 2 + 8 + 1 + 0 + 0 + 0 + ..\source\src\Update.c + Update.c + 0 + 0 + + + + + driver + 0 + 0 + 0 + 0 + + 3 + 9 + 1 + 0 + 0 + 0 + ..\driver\src\dmac.c + dmac.c + 0 + 0 + + + 3 + 10 + 1 + 0 + 0 + 0 + ..\driver\src\flash.c + flash.c + 0 + 0 + + + 3 + 11 + 1 + 0 + 0 + 0 + ..\driver\src\gpio.c + gpio.c + 0 + 0 + + + 3 + 12 + 1 + 0 + 0 + 0 + ..\driver\src\lpm.c + lpm.c + 0 + 0 + + + 3 + 13 + 1 + 0 + 0 + 0 + ..\driver\src\lpuart.c + lpuart.c + 0 + 0 + + + 3 + 14 + 1 + 0 + 0 + 0 + ..\driver\src\spi.c + spi.c + 0 + 0 + + + 3 + 15 + 1 + 0 + 0 + 0 + ..\driver\src\uart.c + uart.c + 0 + 0 + + + 3 + 16 + 1 + 0 + 0 + 0 + ..\driver\src\wdt.c + wdt.c + 0 + 0 + + + 3 + 17 + 1 + 0 + 0 + 0 + ..\driver\src\ddl.c + ddl.c + 0 + 0 + + + 3 + 18 + 1 + 0 + 0 + 0 + ..\driver\src\sysctrl.c + sysctrl.c + 0 + 0 + + + 3 + 19 + 1 + 0 + 0 + 0 + ..\driver\src\reset.c + reset.c + 0 + 0 + + + 3 + 20 + 1 + 0 + 0 + 0 + ..\driver\src\lptim.c + lptim.c + 0 + 0 + + + 3 + 21 + 1 + 0 + 0 + 0 + ..\driver\src\rtc.c + rtc.c + 0 + 0 + + + 3 + 22 + 1 + 0 + 0 + 0 + ..\driver\src\trim.c + trim.c + 0 + 0 + + + 3 + 23 + 1 + 0 + 0 + 0 + ..\driver\src\i2c.c + i2c.c + 0 + 0 + + + 3 + 24 + 1 + 0 + 0 + 0 + ..\driver\src\bt.c + bt.c + 0 + 0 + + + 3 + 25 + 1 + 0 + 0 + 0 + ..\driver\src\adc.c + adc.c + 0 + 0 + + + 3 + 26 + 1 + 0 + 0 + 0 + ..\driver\src\bgr.c + bgr.c + 0 + 0 + + + + + Debug + 0 + 0 + 0 + 0 + + 4 + 27 + 1 + 0 + 0 + 0 + ..\Module\Debug\UartDebug.c + UartDebug.c + 0 + 0 + + + + + LSM6DSL + 1 + 0 + 0 + 0 + + 5 + 28 + 1 + 0 + 0 + 0 + ..\Module\lsm6dsl\lsm6dsl_reg.c + lsm6dsl_reg.c + 0 + 0 + + + 5 + 29 + 1 + 0 + 0 + 0 + ..\Module\lsm6dsl\lsm6dsl_app.c + lsm6dsl_app.c + 0 + 0 + + + + + MMC5893 + 1 + 0 + 0 + 0 + + 6 + 30 + 1 + 0 + 0 + 0 + ..\Module\MMC5983\mmc5983.c + mmc5983.c + 0 + 0 + + + + + LORA + 1 + 0 + 0 + 0 + + 7 + 31 + 1 + 0 + 0 + 0 + ..\Module\LORA\sx127x.c + sx127x.c + 0 + 0 + + + + + Imu + 0 + 0 + 0 + 0 + + 8 + 32 + 1 + 0 + 0 + 0 + ..\Module\Imu\Imu.c + Imu.c + 0 + 0 + + + + + ReadMe + 1 + 0 + 0 + 0 + + 9 + 33 + 5 + 0 + 0 + 0 + ..\ReadMe.txt + ReadMe.txt + 0 + 0 + + + + + ::CMSIS + 0 + 0 + 0 + 1 + + +
diff --git a/MDK/hc32l17x.uvprojx b/MDK/hc32l17x.uvprojx new file mode 100644 index 0000000..8c21bb1 --- /dev/null +++ b/MDK/hc32l17x.uvprojx @@ -0,0 +1,650 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + HC32L17X + 0x4 + ARM-ADS + 6160000::V6.16::ARMCLANG + 6160000::V6.16::ARMCLANG + 1 + + + HC32L170JATA + HDSC + HDSC.HC32L17X.1.0.1 + https://raw.githubusercontent.com/hdscmcu/pack/master/ + IRAM(0x20000000,0x4000) IROM(0x00000000,0x20000) CPUTYPE("Cortex-M0+") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0FlashHC32L17X_128K -FS00 -FL020000 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM)) + 0 + $$Device:HC32L170JATA$Device\Include\HC32L170JATA.h + + + + + + + + + + $$Device:HC32L170JATA$SVD\HC32L170JATA.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\ + hc32l17x + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 1 + + D:\Keil5\ARM\ARMCC\bin\fromelf.exe --bin -o .\output\app.bin .\output\hc32l17x.axf + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x4000 + + + 1 + 0x0 + 0x20000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x2a00 + 0x1d600 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x4000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 1 + 0 + 0 + 0 + 3 + 0 + 0 + 1 + 0 + 0 + 3 + 5 + 0 + 0 + 0 + 0 + 0 + + + + + ..\mcu\common;..\source;..\driver\inc;..\source\inc;..\Module\Debug;..\Module\lsm6dsl;..\Module\MMC5983;..\Module\LORA;..\Module\Imu + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 4 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + template.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32l17x.s + 2 + .\startup_hc32l17x.s + + + system_hc32l17x.c + 1 + ..\mcu\common\system_hc32l17x.c + + + interrupts_hc32l17x.c + 1 + ..\mcu\common\interrupts_hc32l17x.c + + + + + source + + + main.c + 1 + ..\source\Src\main.c + + + bsp.c + 1 + ..\source\src\bsp.c + + + Algorithm.c + 1 + ..\source\src\Algorithm.c + + + SGCP.c + 1 + ..\source\src\SGCP.c + + + Update.c + 1 + ..\source\src\Update.c + + + + + driver + + + dmac.c + 1 + ..\driver\src\dmac.c + + + flash.c + 1 + ..\driver\src\flash.c + + + gpio.c + 1 + ..\driver\src\gpio.c + + + lpm.c + 1 + ..\driver\src\lpm.c + + + lpuart.c + 1 + ..\driver\src\lpuart.c + + + spi.c + 1 + ..\driver\src\spi.c + + + uart.c + 1 + ..\driver\src\uart.c + + + wdt.c + 1 + ..\driver\src\wdt.c + + + ddl.c + 1 + ..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\driver\src\sysctrl.c + + + reset.c + 1 + ..\driver\src\reset.c + + + lptim.c + 1 + ..\driver\src\lptim.c + + + rtc.c + 1 + ..\driver\src\rtc.c + + + trim.c + 1 + ..\driver\src\trim.c + + + i2c.c + 1 + ..\driver\src\i2c.c + + + bt.c + 1 + ..\driver\src\bt.c + + + adc.c + 1 + ..\driver\src\adc.c + + + bgr.c + 1 + ..\driver\src\bgr.c + + + + + Debug + + + UartDebug.c + 1 + ..\Module\Debug\UartDebug.c + + + + + LSM6DSL + + + lsm6dsl_reg.c + 1 + ..\Module\lsm6dsl\lsm6dsl_reg.c + + + lsm6dsl_app.c + 1 + ..\Module\lsm6dsl\lsm6dsl_app.c + + + + + MMC5893 + + + mmc5983.c + 1 + ..\Module\MMC5983\mmc5983.c + + + + + LORA + + + sx127x.c + 1 + ..\Module\LORA\sx127x.c + + + + + Imu + + + Imu.c + 1 + ..\Module\Imu\Imu.c + + + + + ReadMe + + + ReadMe.txt + 5 + ..\ReadMe.txt + + + + + ::CMSIS + + + + + + + + + + + + + + + + + + RTE\RTOS\board.c + + + + + + RTE\RTOS\finsh_config.h + + + + + + RTE\RTOS\finsh_port.c + + + + + + RTE\RTOS\rtconfig.h + + + + + + + + + + + hc32l17x + 0 + 1 + + + + +
diff --git a/MDK/output/hc32l17x.sct b/MDK/output/hc32l17x.sct new file mode 100644 index 0000000..cb5ea6a --- /dev/null +++ b/MDK/output/hc32l17x.sct @@ -0,0 +1,16 @@ +; ************************************************************* +; *** Scatter-Loading Description File generated by uVision *** +; ************************************************************* + +LR_IROM1 0x00002A00 0x0001D600 { ; load region size_region + ER_IROM1 0x00002A00 0x0001D600 { ; load address = execution address + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + .ANY (+XO) + } + RW_IRAM1 0x20000000 0x00004000 { ; RW data + .ANY (+RW +ZI) + } +} + diff --git a/MDK/startup_hc32l17x.s b/MDK/startup_hc32l17x.s new file mode 100644 index 0000000..75e56af --- /dev/null +++ b/MDK/startup_hc32l17x.s @@ -0,0 +1,301 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00002200 + +new_vect_table EQU 0x00002A00 ;中断向量偏移长度 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORTA_IRQHandler + DCD PORTB_IRQHandler + DCD PORTC_E_IRQHandler + DCD PORTD_F_IRQHandler + DCD DMAC_IRQHandler + DCD TIM3_IRQHandler + DCD UART0_2_IRQHandler + DCD UART1_3_IRQHandler + DCD LPUART0_IRQHandler + DCD LPUART1_IRQHandler + DCD SPI0_IRQHandler + DCD SPI1_IRQHandler + DCD I2C0_IRQHandler + DCD I2C1_IRQHandler + DCD TIM0_IRQHandler + DCD TIM1_IRQHandler + DCD TIM2_IRQHandler + DCD LPTIM0_1_IRQHandler + DCD TIM4_IRQHandler + DCD TIM5_IRQHandler + DCD TIM6_IRQHandler + DCD PCA_IRQHandler + DCD WDT_IRQHandler + DCD RTC_IRQHandler + DCD ADC_DAC_IRQHandler + DCD PCNT_IRQHandler + DCD VC0_IRQHandler + DCD VC1_2_IRQHandler + DCD LVD_IRQHandler + DCD LCD_IRQHandler + DCD FLASH_RAM_IRQHandler + DCD CLKTRIM_IRQHandler + + + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + LDR R2, =new_vect_table ;升级时打开 + STR R2, [R0] + + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + + +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT PORTA_IRQHandler [WEAK] + EXPORT PORTB_IRQHandler [WEAK] + EXPORT PORTC_E_IRQHandler [WEAK] + EXPORT PORTD_F_IRQHandler [WEAK] + EXPORT DMAC_IRQHandler [WEAK] + EXPORT TIM3_IRQHandler [WEAK] + EXPORT UART0_2_IRQHandler [WEAK] + EXPORT UART1_3_IRQHandler [WEAK] + EXPORT LPUART0_IRQHandler [WEAK] + EXPORT LPUART1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM0_1_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_DAC_IRQHandler [WEAK] + EXPORT PCNT_IRQHandler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_2_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT LCD_IRQHandler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] +PORTA_IRQHandler +PORTB_IRQHandler +PORTC_E_IRQHandler +PORTD_F_IRQHandler +DMAC_IRQHandler +TIM3_IRQHandler +UART0_2_IRQHandler +UART1_3_IRQHandler +LPUART0_IRQHandler +LPUART1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM0_1_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_DAC_IRQHandler +PCNT_IRQHandler +VC0_IRQHandler +VC1_2_IRQHandler +LVD_IRQHandler +LCD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler + + + B . + + ENDP + + + ALIGN + + +; User Initial Stack & Heap + + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + + END diff --git a/Module/Imu/Imu.c b/Module/Imu/Imu.c new file mode 100644 index 0000000..79b428b --- /dev/null +++ b/Module/Imu/Imu.c @@ -0,0 +1,298 @@ +/************************************************************************************************ +* 程序版本:V3.0 +* 程序日期:2022-11-3 +* 程序作者: +************************************************************************************************/ +#include "Imu.h" +#include "main.h" + +#define Kp_New 0.9f //互补滤波当前数据的权重 +#define Kp_Old 0.1f //互补滤波历史数据的权重 +#define Acc_Gain 0.0001220f //加速度变成G (初始化加速度满量程-+4g LSBa = 2*4/65535.0) +#define Gyro_Gain 0.0609756f //角速度变成度 (初始化陀螺仪满量程+-2000 LSBg = 2*2000/65535.0) +#define Gyro_Gr 0.0010641f //角速度变成弧度(3.1415/180 * LSBg) + +//kp=ki=0 就是完全相信陀螺仪 +#define Kp 1.5f // proportional gain governs rate of convergence to accelerometer/magnetometer + //比例增益控制加速度计,磁力计的收敛速率 +#define Ki 0.005f // integral gain governs rate of convergence of gyroscope biases + //积分增益控制陀螺偏差的收敛速度 +#define halfT 0.005f // half the sample period 采样周期的一半 + +static volatile float q0 = 1, q1 = 0, q2 = 0, q3 = 0; // quaternion elements representing the estimated orientation +static volatile float exInt = 0, eyInt = 0, ezInt = 0; // scaled integral error + +/* +static float MedianValue(float *value_buf, unsigned int size) +{ + + unsigned int i,j; + float temp; + + //排序采用冒泡法 + for (j=0;j<=size;j++){ + for (i=0;i<=size-j;i++){ + if (value_buf[i] > value_buf[i+1]){ + temp = value_buf[i]; + value_buf[i] = value_buf[i+1]; + value_buf[i+1] = temp; + } + } + } + + return value_buf[(size-1)/2]; +} +*/ + +static float MedianValue(float *value_buf, unsigned int size) +{ + unsigned int i; + float temp = 0; + + for (i=0; i=Imu_AccFilterSize)cnt=0; + + return MedianValue(value_buf, Imu_AccFilterSize); +} + +static float Acc_Filter_Y(float in_data) +{ + static float value_buf[Imu_AccFilterSize] = {0}; + static unsigned char cnt = 0; + value_buf[cnt] = in_data; + cnt++; + if (cnt>=Imu_AccFilterSize)cnt=0; + + return MedianValue(value_buf, Imu_AccFilterSize); +} + +static float Acc_Filter_Z(float in_data) +{ + + static float value_buf[Imu_AccFilterSize] = {0}; + static unsigned char cnt = 0; + value_buf[cnt] = in_data; + cnt++; + if (cnt>=Imu_AccFilterSize)cnt=0; + + return MedianValue(value_buf, Imu_AccFilterSize); +} + + +static float Mag_Filter_X(float in_data) +{ + + static float value_buf[Imu_MagFilterSize] = {0}; + static unsigned char cnt = 0; + value_buf[cnt] = in_data; + cnt++; + if (cnt>=Imu_MagFilterSize)cnt=0; + + return MedianValue(value_buf, Imu_MagFilterSize); +} + +static float Mag_Filter_Y(float in_data) +{ + static float value_buf[Imu_MagFilterSize] = {0}; + static unsigned char cnt = 0; + value_buf[cnt] = in_data; + cnt++; + if (cnt>=Imu_MagFilterSize)cnt=0; + + return MedianValue(value_buf, Imu_MagFilterSize); +} + +static float Mag_Filter_Z(float in_data) +{ + + static float value_buf[Imu_MagFilterSize] = {0}; + static unsigned char cnt = 0; + value_buf[cnt] = in_data; + cnt++; + if (cnt>=Imu_MagFilterSize)cnt=0; + + return MedianValue(value_buf, Imu_MagFilterSize); +} + + + + +static float Gyro_Filter_X(float in_data) +{ + static float value_buf[Imu_GyroFilterSize] = {0}; + static unsigned char cnt = 0; + value_buf[cnt] = in_data; + cnt++; + if (cnt>=Imu_GyroFilterSize)cnt=0; + + return MedianValue(value_buf, Imu_GyroFilterSize); +} + +static float Gyro_Filter_Y(float in_data) +{ + static float value_buf[Imu_GyroFilterSize] = {0}; + static unsigned char cnt = 0; + value_buf[cnt] = in_data; + cnt++; + if (cnt>=Imu_GyroFilterSize)cnt=0; + + return MedianValue(value_buf, Imu_GyroFilterSize); +} + +static float Gyro_Filter_Z(float in_data) +{ + static float value_buf[Imu_GyroFilterSize] = {0}; + static unsigned char cnt = 0; + value_buf[cnt] = in_data; + cnt++; + if (cnt>=Imu_GyroFilterSize)cnt=0; + + return MedianValue(value_buf, Imu_GyroFilterSize); +} + + + +static float invSqrt(float x) { + float halfx = 0.5f * x; + float y = x; + long i = *(long*)&y; + i = 0x5f3759df - (i>>1); + y = *(float*)&i; + y = y * (1.5f - (halfx * y * y)); + return y; +} + +static void IMUupdate(float gx, float gy, float gz, float ax, float ay, float az) +{ + float vx, vy, vz; + float ex, ey, ez; + float norm; + + float q0q0 = q0*q0; + float q0q1 = q0*q1; + float q0q2 = q0*q2; + float q0q3 = q0*q3; + float q1q1 = q1*q1; + float q1q2 = q1*q2; + float q1q3 = q1*q3; + float q2q2 = q2*q2; + float q2q3 = q2*q3; + float q3q3 = q3*q3; + + if(ax*ay*az==0) + return; + + //加速度计<测量>的重力加速度向量(机体坐标系) + norm = invSqrt(ax*ax + ay*ay + az*az); + ax = ax * norm; + ay = ay * norm; + az = az * norm; +// printf("ax=%0.2f ay=%0.2f az=%0.2f\r\n",ax,ay,az); + + //陀螺仪积分<估计>重力向量(机体坐标系) + vx = 2*(q1q3 - q0q2); //矩阵(3,1)项 + vy = 2*(q0q1 + q2q3); //矩阵(3,2)项 + vz = q0q0 - q1q1 - q2q2 + q3q3 ; //矩阵(3,3)项 + + + //向量叉乘所得的值 + ex = (ay*vz - az*vy); + ey = (az*vx - ax*vz); + ez = (ax*vy - ay*vx); + + //用上面求出误差进行积分 + exInt = exInt + ex * Ki; + eyInt = eyInt + ey * Ki; + ezInt = ezInt + ez * Ki; + + //将误差PI后补偿到陀螺仪 + gx = gx + Kp*ex + exInt; + gy = gy + Kp*ey + eyInt; + gz = gz + Kp*ez + ezInt;//这里的gz由于没有观测者进行矫正会产生漂移,表现出来的就是积分自增或自减 + + //四元素的微分方程 + q0 = q0 + (-q1*gx - q2*gy - q3*gz)*halfT; + q1 = q1 + (q0*gx + q2*gz - q3*gy)*halfT; + q2 = q2 + (q0*gy - q1*gz + q3*gx)*halfT; + q3 = q3 + (q0*gz + q1*gy - q2*gx)*halfT; + + //单位化四元数 + norm = invSqrt(q0*q0 + q1*q1 + q2*q2 + q3*q3); + q0 = q0 * norm; + q1 = q1 * norm; + q2 = q2 * norm; + q3 = q3 * norm; + +// 矩阵表达式 +// matrix[0] = q0q0 + q1q1 - q2q2 - q3q3; // 11 +// matrix[1] = 2.f * (q1q2 + q0q3); // 12 +// matrix[2] = 2.f * (q1q3 - q0q2); // 13 +// matrix[3] = 2.f * (q1q2 - q0q3); // 21 +// matrix[4] = q0q0 - q1q1 + q2q2 - q3q3; // 22 +// matrix[5] = 2.f * (q2q3 + q0q1); // 23 +// matrix[6] = 2.f * (q1q3 + q0q2); // 31 +// matrix[7] = 2.f * (q2q3 - q0q1); // 32 +// matrix[8] = q0q0 - q1q1 - q2q2 + q3q3; // 33 + + //下一步是四元数转换成欧拉角(Z->Y->X) + +} + +#define ALPHA 0.01 +void IMU_Update(float *gy,float *acc, float *mag, RadDp Rad, DegDp Deg) +{ + static volatile double Phi,Theta, Psi, Gz2, By2, Bz2, Bx3; + volatile float Gyr[XYZ], Acc[XYZ], Mag[XYZ]; + + Gyr[X] = gy[X]; + Gyr[Y] = gy[Y]; + Gyr[Z] = gy[Z]; + + Acc[X] = acc[X]; + Acc[Y] = acc[Y]; + Acc[Z] = acc[Z]; + + Mag[X] = -mag[X]; + Mag[Y] = -mag[Y]; + Mag[Z] = -mag[Z]; + +// IMUupdate(Gyr[X], Gyr[Y], Gyr[Z], Acc[X], Acc[Y], Acc[Z]); + +// Phi = -atan2(2.f * q0*q1 + 2.f * q2*q3, 1 - 2.f * q1*q1 - 2.f * q2*q2); +// Theta = -asin(2.f * (q0*q2 - q1*q3)); + +// volatile float xh = Mag[0]*cos(Theta) + Mag[1]*sin(Phi)*sin(Theta) + Mag[2]*cos(Phi)*sin(Theta); +// volatile float yh = Mag[1]*cos(Phi) - Mag[2]*sin(Phi); +// Psi = atan2(yh, xh); + + Phi = atan2(Acc[Y], (Acc[Z] + Acc[X] * ALPHA)); + //Phi = atan2(Acc[Y], Acc[Z]); + Gz2 = Acc[Y] * sin(Phi) + Acc[Z] * cos(Phi); + Theta = atan(-Acc[X] / Gz2); + + By2 = Mag[Z] * sin(Phi) - Mag[Y] * cos(Phi); + Bz2 = Mag[Y] * sin(Phi) + Mag[Z] * cos(Phi); + Bx3 = Mag[X] * cos(Theta) + Bz2 * sin(Theta); + Psi = atan2(By2, Bx3); + + Rad->roll = Phi; + Rad->pitch = Theta; + Rad->yaw = Psi; + + Deg->roll = Rad->roll * RAD_TO_DEG; + Deg->pitch = Rad->pitch * RAD_TO_DEG; + Deg->yaw = Rad->yaw * RAD_TO_DEG; +} + diff --git a/Module/Imu/Imu.h b/Module/Imu/Imu.h new file mode 100644 index 0000000..3005d6f --- /dev/null +++ b/Module/Imu/Imu.h @@ -0,0 +1,24 @@ +#ifndef _IMU_H_ +#define _IMU_H_ +#include + +#define PI 3.14159265358979323846f +#define RAD_TO_DEG 57.2957795 // 弧度到度的转换系数 +#define DEG_TO_RAD 0.0174533 // 度到弧度的转换系数 + +// 定义欧拉角结构体 +typedef struct { + volatile float roll, pitch, yaw;//弧度 +}Rad_T, *RadDp; +typedef struct { + volatile float roll, pitch, yaw;//角度 +}Deg_T, *DegDp; + +#define Imu_AccFilterSize 10 +#define Imu_MagFilterSize 20 +#define Imu_GyroFilterSize 10 + +void IMU_Update(float *gy,float *acc, float *mag, RadDp Rad, DegDp Deg); + + +#endif diff --git a/Module/LORA/sx127x.c b/Module/LORA/sx127x.c new file mode 100644 index 0000000..e726f37 --- /dev/null +++ b/Module/LORA/sx127x.c @@ -0,0 +1,613 @@ +#include "sx127x.h" +#include "ddl.h" +#include "Debug.h" +#include "spi.h" +#include "bsp.h" + + +#define LORAChannel 8 +#define LORARegPreamble 10 + +#if (LORA_MODULE == SX1278W1) +Sx1276Type_t LoRaPara = { + .ucChannel = LORAChannel, //4 or 12 + .dwFreqHz = FREQ_CENT, + .ucPower = 20, + .SignalBw = SX1276_BW_250K, + .SpreadFactor = SX1276_SF_512, + .ErrorCoding = SX1276_EC_4_6, + .RegPreamble = LORARegPreamble,//10 or 16 + .ucOpModePrev = RFLR_OPMODE_STANDBY, + .bAntSwPrev = RF_ANT_RECEIVER, + .RegBuff = 0, + .State = SX1276_IDLE, + .ucRxPacketSize = 0, + .ucTxPacketSize = 0, + .RxCallBack = NULL, +}; + +void LoraReset(void) +{ + LORA_RESET_CLR(); + delay_ms(1); + LORA_RESET_SET(); +} + +///////////////////////////////////////////////// +void SX1276SetAntSw(Sx1276AntStatus_m Status) +{ + switch(Status){ + case RF_ANT_TRANSMITTER: + LORA_ANTTXEN(); + break; + case RF_ANT_RECEIVER: + LORA_ANTRXEN(); + break; + case RF_ANT_CLOSE: + LORA_ANTCLOSE(); + break; + } +} + +void SX1276ReadBuffer(uint8_t ucAddr, uint8_t *pucBuff, uint8_t ucLen) +{ + uint8_t ucCnt; + LORA_SPI_NSS_CLR(); + LORA_SPI_READ_WRITE(ucAddr & 0x7F); + for( ucCnt = 0; ucCnt < ucLen; ucCnt++ ){ + pucBuff[ucCnt] = LORA_SPI_READ_WRITE(0); + } + LORA_SPI_NSS_SET(); +} + +void SX1276WriteBuffer(uint8_t ucAddr, uint8_t *pucBuff, uint8_t ucLen) +{ + uint8_t ucCnt; + LORA_SPI_NSS_CLR(); + LORA_SPI_READ_WRITE(ucAddr | 0x80); + for( ucCnt = 0; ucCnt < ucLen; ucCnt++ ){ + LORA_SPI_READ_WRITE(pucBuff[ucCnt]); + } + LORA_SPI_NSS_SET(); +} +void SX1276Write(uint8_t ucAddr, uint8_t ucData) +{ + SX1276WriteBuffer(ucAddr, &ucData, 1); +} + +void SX1276Read(uint8_t ucAddr, uint8_t * pucData) +{ + SX1276ReadBuffer(ucAddr, pucData, 1); +} + +void SX1276WriteFifo(uint8_t *pucBuff, uint8_t ucLen) +{ + SX1276WriteBuffer(0, pucBuff, ucLen); +} + +void SX1276ReadFifo(uint8_t *pucBuff, uint8_t ucLen) +{ + SX1276ReadBuffer(0, pucBuff, ucLen); +} + +///////////////////////////////////////////////// +void SX1276LoRaSetNbTrigPeaks(uint8_t ucValue) +{ + SX1276Read(0x31, &(LoRaPara.RegBuff.RegTestReserved31)); + LoRaPara.RegBuff.RegTestReserved31 = (LoRaPara.RegBuff.RegTestReserved31 & 0xF8) | ucValue; + SX1276Write(0x31, LoRaPara.RegBuff.RegTestReserved31 ); +} + +void SX1276LoRaSetSignalBandwidth(Sx1276BwType Bw) +{ + SX1276Read(REG_LR_MODEMCONFIG1, &(LoRaPara.RegBuff.RegModemConfig1)); + LoRaPara.RegBuff.RegModemConfig1 = (LoRaPara.RegBuff.RegModemConfig1 & RFLR_MODEMCONFIG1_BW_MASK) | Bw; + SX1276Write(REG_LR_MODEMCONFIG1, LoRaPara.RegBuff.RegModemConfig1); + LoRaPara.SignalBw = Bw; +} + +void SX1276LoRaSetSpreadingFactor(Sx1276SpreadFactorType Factor) +{ + if (Factor > SX1276_SF_4096){ + Factor = SX1276_SF_4096; + } + else if (Factor < SX1276_SF_64){ + Factor = SX1276_SF_64; + } + if (Factor == SX1276_SF_64){ + SX1276LoRaSetNbTrigPeaks(5); + } + else{ + SX1276LoRaSetNbTrigPeaks(3); + } + SX1276Read(REG_LR_MODEMCONFIG2, &(LoRaPara.RegBuff.RegModemConfig2)); + LoRaPara.RegBuff.RegModemConfig2 = (LoRaPara.RegBuff.RegModemConfig2 & RFLR_MODEMCONFIG2_SF_MASK ) | Factor; + SX1276Write(REG_LR_MODEMCONFIG2, LoRaPara.RegBuff.RegModemConfig2); + LoRaPara.SpreadFactor = Factor; +} + +void SX1276LoRaSetErrorCoding(Sx1276ErrorCodingType Value){ + SX1276Read(REG_LR_MODEMCONFIG1, &(LoRaPara.RegBuff.RegModemConfig1)); + LoRaPara.RegBuff.RegModemConfig1 = (LoRaPara.RegBuff.RegModemConfig1 & RFLR_MODEMCONFIG1_CODINGRATE_MASK ) | Value; + SX1276Write(REG_LR_MODEMCONFIG1, LoRaPara.RegBuff.RegModemConfig1 ); + LoRaPara.ErrorCoding = Value; +} + +void SX1276LoRaSetFreqHz(uint32_t dwFreqHz) +{ + LoRaPara.dwFreqHz = dwFreqHz; + dwFreqHz = ( uint32_t )( ( double )dwFreqHz / ( double )FREQ_STEP ); + LoRaPara.RegBuff.RegFrfMsb = ( uint8_t )( ( dwFreqHz >> 16 ) & 0xFF ); + LoRaPara.RegBuff.RegFrfMid = ( uint8_t )( ( dwFreqHz >> 8 ) & 0xFF ); + LoRaPara.RegBuff.RegFrfLsb = ( uint8_t )( dwFreqHz & 0xFF ); + SX1276WriteBuffer(REG_LR_FRFMSB, &(LoRaPara.RegBuff.RegFrfMsb), 3); +} + +void SX1276LoRaSetSymbTimeout(uint16_t ucValue) +{ + SX1276ReadBuffer(REG_LR_MODEMCONFIG2, &(LoRaPara.RegBuff.RegModemConfig2), 2); + LoRaPara.RegBuff.RegModemConfig2 = (LoRaPara.RegBuff.RegModemConfig2 & RFLR_MODEMCONFIG2_SYMBTIMEOUTMSB_MASK) | (( ucValue >> 8) & ~RFLR_MODEMCONFIG2_SYMBTIMEOUTMSB_MASK ); + LoRaPara.RegBuff.RegSymbTimeoutLsb = ucValue & 0xFF; + SX1276WriteBuffer(REG_LR_MODEMCONFIG2, &(LoRaPara.RegBuff.RegModemConfig2), 2); +} + +void SX1276LoRaSetLowDatarateOptimize(boolean_t bEnable) +{ + SX1276Read(REG_LR_MODEMCONFIG3, &(LoRaPara.RegBuff.RegModemConfig3)); + LoRaPara.RegBuff.RegModemConfig3 = (LoRaPara.RegBuff.RegModemConfig3 & RFLR_MODEMCONFIG3_LOWDATARATEOPTIMIZE_MASK ) | ( bEnable << 3 ); + SX1276Write(REG_LR_MODEMCONFIG3, LoRaPara.RegBuff.RegModemConfig3); +} + +void SX1276LoRaSetPAOutput(uint8_t ucOutputPin) +{ + SX1276Read(REG_LR_PACONFIG, &(LoRaPara.RegBuff.RegPaConfig)); + LoRaPara.RegBuff.RegPaConfig = (LoRaPara.RegBuff.RegPaConfig & RFLR_PACONFIG_PASELECT_MASK ) | ucOutputPin; + SX1276Write(REG_LR_PACONFIG, LoRaPara.RegBuff.RegPaConfig ); +} + +void SX1276LoRaSetPa20dBm(boolean_t bEnable) +{ + SX1276Read(REG_LR_PADAC, &(LoRaPara.RegBuff.RegPaDac)); + SX1276Read(REG_LR_PACONFIG, &(LoRaPara.RegBuff.RegPaConfig)); + if ((LoRaPara.RegBuff.RegPaConfig & RFLR_PACONFIG_PASELECT_PABOOST ) == RFLR_PACONFIG_PASELECT_PABOOST ) { + if( bEnable == TRUE ){ + LoRaPara.RegBuff.RegPaDac = 0x87; + } + } + else{ + LoRaPara.RegBuff.RegPaDac = 0x84; + } + SX1276Write(REG_LR_PADAC, LoRaPara.RegBuff.RegPaDac ); +} + +void SX1276LoRaSetRfPower(int8_t sbPower) +{ + SX1276Read(REG_LR_PACONFIG, &(LoRaPara.RegBuff.RegPaConfig)); + SX1276Read(REG_LR_PADAC, &(LoRaPara.RegBuff.RegPaDac)); + if ((LoRaPara.RegBuff.RegPaConfig & RFLR_PACONFIG_PASELECT_PABOOST ) == RFLR_PACONFIG_PASELECT_PABOOST ) { + if ((LoRaPara.RegBuff.RegPaDac & 0x87) == 0x87){ + if( sbPower < 5 ){ + sbPower = 5; + } + if( sbPower > 20){ + sbPower = 20; + } + LoRaPara.RegBuff.RegPaConfig = (LoRaPara.RegBuff.RegPaConfig & RFLR_PACONFIG_MAX_POWER_MASK ) | 0x70; + LoRaPara.RegBuff.RegPaConfig = (LoRaPara.RegBuff.RegPaConfig & RFLR_PACONFIG_OUTPUTPOWER_MASK ) | + ( uint8_t )( ( uint16_t )( sbPower - 5 ) & 0x0F ); + } + else{ + if( sbPower < 2){ + sbPower = 2; + } + if( sbPower > 17){ + sbPower = 17; + } + LoRaPara.RegBuff.RegPaConfig = (LoRaPara.RegBuff.RegPaConfig & RFLR_PACONFIG_MAX_POWER_MASK ) | 0x70; + LoRaPara.RegBuff.RegPaConfig = (LoRaPara.RegBuff.RegPaConfig & RFLR_PACONFIG_OUTPUTPOWER_MASK ) | + ( uint8_t )( ( uint16_t )( sbPower - 2 ) & 0x0F ); + } + } + else{ + if( sbPower < -1){ + sbPower = -1; + } + if( sbPower > 14){ + sbPower = 14; + } + LoRaPara.RegBuff.RegPaConfig = (LoRaPara.RegBuff.RegPaConfig & RFLR_PACONFIG_MAX_POWER_MASK ) | 0x70; + LoRaPara.RegBuff.RegPaConfig = (LoRaPara.RegBuff.RegPaConfig & RFLR_PACONFIG_OUTPUTPOWER_MASK ) | + ( uint8_t )( ( uint16_t )( sbPower + 1 ) & 0x0F ); + } + SX1276Write(REG_LR_PACONFIG, LoRaPara.RegBuff.RegPaConfig); + LoRaPara.ucPower = sbPower; +} + +void SX1276LoRaSetOpMode(Sx1276OpModeType ucOpMode) +{ + Sx1276AntStatus_m bAntSwStatus = RF_ANT_RECEIVER; + LoRaPara.ucOpModePrev = LoRaPara.RegBuff.RegOpMode & ~RFLR_OPMODE_MASK; + if( ucOpMode != LoRaPara.ucOpModePrev){ + if(ucOpMode == RFLR_OPMODE_TRANSMITTER){ + + //CLR_LORA_RXEN(); + //SET_LORA_TXEN(); + + + bAntSwStatus = RF_ANT_TRANSMITTER; + } + else if(ucOpMode == RFLR_OPMODE_RECEIVER){ + bAntSwStatus = RF_ANT_RECEIVER; + + //CLR_LORA_TXEN(); + //SET_LORA_RXEN(); + } + else { + bAntSwStatus = RF_ANT_CLOSE; + } + if( bAntSwStatus != LoRaPara.bAntSwPrev ){ + LoRaPara.bAntSwPrev = bAntSwStatus; + SX1276SetAntSw(bAntSwStatus); + } + LoRaPara.RegBuff.RegOpMode = (LoRaPara.RegBuff.RegOpMode & RFLR_OPMODE_MASK ) | ucOpMode; + SX1276Write( REG_LR_OPMODE, LoRaPara.RegBuff.RegOpMode); + } +} +//////////////////////////////////////////////////////////////// + +void Sx1276LoRaEnterRx(void) +{ + uint8_t ucCnt; + SX1276LoRaSetOpMode(RFLR_OPMODE_STANDBY); + LoRaPara.RegBuff.RegIrqFlagsMask = RFLR_IRQFLAGS_RXTIMEOUT | RFLR_IRQFLAGS_VALIDHEADER | RFLR_IRQFLAGS_TXDONE; + SX1276Write(REG_LR_IRQFLAGSMASK, LoRaPara.RegBuff.RegIrqFlagsMask); + LoRaPara.RegBuff.RegHopPeriod = 255; + SX1276Write(REG_LR_HOPPERIOD, LoRaPara.RegBuff.RegHopPeriod ); + // RxDone RxTimeout FhssChangeChannel ValidHeader + LoRaPara.RegBuff.RegDioMapping1 = RFLR_DIOMAPPING1_DIO0_00 | RFLR_DIOMAPPING1_DIO1_00 | RFLR_DIOMAPPING1_DIO2_01 | RFLR_DIOMAPPING1_DIO3_01; + // CadDetected ModeReady + LoRaPara.RegBuff.RegDioMapping2 = RFLR_DIOMAPPING2_DIO4_00 | RFLR_DIOMAPPING2_DIO5_00; + SX1276WriteBuffer(REG_LR_DIOMAPPING1, &(LoRaPara.RegBuff.RegDioMapping1), 2); + LoRaPara.RegBuff.RegFifoAddrPtr = LoRaPara.RegBuff.RegFifoRxBaseAddr; + SX1276Write(REG_LR_FIFOADDRPTR, LoRaPara.RegBuff.RegFifoAddrPtr); + SX1276LoRaSetOpMode(RFLR_OPMODE_RECEIVER); + for (ucCnt=0; ucCnt< LORA_BUFF_SIZE; ucCnt++){ + LoRaPara.RxTxBuff[ucCnt] = 0; + } + LoRaPara.State = SX1276_IDLE;//COMST_RX + uint8_t temp; + SX1276Read(REG_LR_IRQFLAGS, &temp); + + //设置接收模式 + LORA_ANTRXEN(); +} + +///////////////////////////////////////////////// +void Sx1276LoRaInit(void (*RxCallBack)(uint8_t *rBuff, uint8_t rlen)) +{ + if(RxCallBack != NULL) { + LoRaPara.RxCallBack = RxCallBack; + } + LoraReset(); + SX1276LoRaSetOpMode(RFLR_OPMODE_SLEEP); + LoRaPara.RegBuff.RegOpMode = (LoRaPara.RegBuff.RegOpMode & RFLR_OPMODE_LONGRANGEMODE_MASK ) | RFLR_OPMODE_LONGRANGEMODE_ON; + SX1276Write(REG_LR_OPMODE, LoRaPara.RegBuff.RegOpMode ); + SX1276LoRaSetOpMode(RFLR_OPMODE_STANDBY); + // RxDone RxTimeout FhssChangeChannel ValidHeader + LoRaPara.RegBuff.RegDioMapping1 = RFLR_DIOMAPPING1_DIO0_00 | RFLR_DIOMAPPING1_DIO1_00 | RFLR_DIOMAPPING1_DIO2_00 | RFLR_DIOMAPPING1_DIO3_01; + // CadDetected ModeReady + LoRaPara.RegBuff.RegDioMapping2 = RFLR_DIOMAPPING2_DIO4_00 | RFLR_DIOMAPPING2_DIO5_00; + SX1276WriteBuffer(REG_LR_DIOMAPPING1, &(LoRaPara.RegBuff.RegDioMapping1), 2 ); + SX1276ReadBuffer(REG_LR_OPMODE, (uint8_t*)&(LoRaPara.RegBuff) + 1, SIZE_OF_REGISTERS); + LoRaPara.State = SX1276_BUSY; + SX1276Read(REG_LR_VERSION, &(LoRaPara.RegBuff.RegVersion)); + SX1276ReadBuffer(REG_LR_OPMODE, (uint8_t*)&(LoRaPara.RegBuff) + 1, SIZE_OF_REGISTERS); + LoRaPara.RegBuff.RegLna = RFLR_LNA_GAIN_G1; + SX1276WriteBuffer(REG_LR_OPMODE, (uint8_t*)&(LoRaPara.RegBuff) + 1, SIZE_OF_REGISTERS); + //set the RF settings + SX1276LoRaWriteChannel(LoRaPara.ucChannel); + //SX1276LoRaSetFreqHz(LoRaPara.dwFreqHz); + //REG_LR_MODEMCONFIG1 + SX1276Read(REG_LR_MODEMCONFIG1, &(LoRaPara.RegBuff.RegModemConfig1)); + //SignalBandwidth + LoRaPara.RegBuff.RegModemConfig1 = (LoRaPara.RegBuff.RegModemConfig1 & RFLR_MODEMCONFIG1_BW_MASK ) | LoRaPara.SignalBw; + //ErrorCoding + LoRaPara.RegBuff.RegModemConfig1 = (LoRaPara.RegBuff.RegModemConfig1 & RFLR_MODEMCONFIG1_CODINGRATE_MASK ) | LoRaPara.ErrorCoding; + //IMPLICITHEADER + LoRaPara.RegBuff.RegModemConfig1 = LoRaPara.RegBuff.RegModemConfig1 | RFLR_MODEMCONFIG1_IMPLICITHEADER_ON; + SX1276Write(REG_LR_MODEMCONFIG1, LoRaPara.RegBuff.RegModemConfig1); + //REG_LR_MODEMCONFIG2 + SX1276Read(REG_LR_MODEMCONFIG2, &(LoRaPara.RegBuff.RegModemConfig2)); + //SpreadingFactor + if( LoRaPara.SpreadFactor == SX1276_SF_64){ + SX1276LoRaSetNbTrigPeaks(5); + SX1276LoRaSetLowDatarateOptimize(TRUE); //低数据速率设置 + } + else{ + SX1276LoRaSetNbTrigPeaks(3); + SX1276LoRaSetLowDatarateOptimize(FALSE); //低数据速率设置 + } + LoRaPara.RegBuff.RegModemConfig2 = (LoRaPara.RegBuff.RegModemConfig2 & RFLR_MODEMCONFIG2_SF_MASK ) | LoRaPara.SpreadFactor; + //PacketCrcOn + LoRaPara.RegBuff.RegModemConfig2 = (LoRaPara.RegBuff.RegModemConfig2 & RFLR_MODEMCONFIG2_RXPAYLOADCRC_MASK ) | SX1276_CRC_ON; //SX1276_CRC_OFF + + //验证寄存器操作是否成功 + SX1276Write(REG_LR_MODEMCONFIG2, LoRaPara.RegBuff.RegModemConfig2); + LoRaPara.RegBuff.RegModemConfig2 = 0; + SX1276Read(REG_LR_MODEMCONFIG2, &(LoRaPara.RegBuff.RegModemConfig2)); + + SX1276LoRaSetSymbTimeout(0x3FF); + LoRaPara.RegBuff.RegPreambleMsb= (LoRaPara.RegPreamble >> 8) & 0x00ff; + LoRaPara.RegBuff.RegPreambleLsb= LoRaPara.RegPreamble & 0x00ff; + SX1276Write(REG_LR_PREAMBLEMSB, LoRaPara.RegBuff.RegPreambleMsb); + SX1276Write(REG_LR_PREAMBLELSB, LoRaPara.RegBuff.RegPreambleLsb); + SX1276Write(REG_LR_PAYLOADLENGTH, LORA_BUFF_SIZE); + SX1276Write(REG_LR_PAYLOADMAXLENGTH, LORA_BUFF_SIZE); + LoRaPara.RegBuff.RegPayloadLength = LORA_BUFF_SIZE; + + #ifndef USE_LORA_860_PA + if(LoRaPara.dwFreqHz > 860000000 ){ + SX1276LoRaSetPAOutput(RFLR_PACONFIG_PASELECT_RFO); + SX1276LoRaSetPa20dBm(FALSE); + LoRaPara.ucPower = 14; + } + else + #endif + { + SX1276LoRaSetPAOutput(RFLR_PACONFIG_PASELECT_PABOOST); + SX1276LoRaSetPa20dBm(TRUE); + LoRaPara.ucPower = 20; + } + SX1276LoRaSetRfPower(LoRaPara.ucPower); + SX1276LoRaSetOpMode(RFLR_OPMODE_STANDBY); + Sx1276LoRaEnterRx(); +} + +void IsrSx1276LoRaTxRx(void){ + switch (LoRaPara.State){ + case SX1276_IDLE: + case SX1276_RX: + // Clear Irq + //SET_LORA_RX_LED(); + do { + SX1276Write(REG_LR_IRQFLAGS, RFLR_IRQFLAGS_RXDONE); + SX1276Read(REG_LR_IRQFLAGS, &(LoRaPara.RegBuff.RegIrqFlags)); + if((LoRaPara.RegBuff.RegIrqFlags & RFLR_IRQFLAGS_RXDONE) != RFLR_IRQFLAGS_RXDONE) + break; + }while(1); + if((LoRaPara.RegBuff.RegIrqFlags & RFLR_IRQFLAGS_PAYLOADCRCERROR ) == RFLR_IRQFLAGS_PAYLOADCRCERROR) { + // Clear Irq + SX1276Write(REG_LR_IRQFLAGS, RFLR_IRQFLAGS_PAYLOADCRCERROR); + LoRaPara.State = SX1276_IDLE; + break; + } + SX1276Read(REG_LR_PKTSNRVALUE, &(LoRaPara.RegBuff.RegPktSnrValue)); + SX1276Read(REG_LR_RSSIVALUE, &(LoRaPara.RegBuff.RegRssiValue)); + SX1276Read(REG_LR_PKTRSSIVALUE, &(LoRaPara.RegBuff.RegPktRssiValue)); + SX1276Read(REG_LR_FIFORXCURRENTADDR, &(LoRaPara.RegBuff.RegFifoRxCurrentAddr)); + SX1276Read(REG_LR_NBRXBYTES, &(LoRaPara.RegBuff.RegNbRxBytes)); + LoRaPara.ucRxPacketSize = LoRaPara.RegBuff.RegNbRxBytes; + LoRaPara.RegBuff.RegFifoAddrPtr = LoRaPara.RegBuff.RegFifoRxCurrentAddr; + SX1276Write(REG_LR_FIFOADDRPTR, LoRaPara.RegBuff.RegFifoAddrPtr); + SX1276ReadFifo(LoRaPara.RxTxBuff, (LoRaPara.ucRxPacketSize > LORA_BUFF_SIZE) ? LORA_BUFF_SIZE : LoRaPara.ucRxPacketSize); + uint8_t ucLen; + if(LoRaPara.ucRxPacketSize < LORA_BUFF_SIZE) { + ucLen= LoRaPara.ucRxPacketSize; + } + else { + ucLen= LORA_BUFF_SIZE; + } + LoRaPara.RxTxBuff[ucLen] = 0; + if(LoRaPara.RxCallBack != NULL) + LoRaPara.RxCallBack(LoRaPara.RxTxBuff, ucLen); + + LoRaPara.ucRxPacketSize = 0; + LoRaPara.State = SX1276_IDLE; + //CLR_LORA_RX_LED(); + break; + case SX1276_TX: + // Clear Irq + SX1276Write(REG_LR_IRQFLAGS, RFLR_IRQFLAGS_TXDONE); + //LORA_TXLED_OFF(); + Sx1276LoRaEnterRx(); + break; + default: + break; + } +} + +void Sx1276LoRaLoopHandler(void) +{ + if(LORA_GETDIO0() > 0){ // RxDone or TxDone + IsrSx1276LoRaTxRx(); + } +} +void Sx1276LoRaSendBuffer(uint8_t* pucBuff, uint8_t ucLen) +{ + + //设置发送模式 + LORA_ANTTXEN(); + + LoRaPara.State = SX1276_BUSY; + if (ucLen > LORA_BUFF_SIZE){ + ucLen = LORA_BUFF_SIZE; + } + LoRaPara.ucTxPacketSize = ucLen; + while(ucLen--){ + LoRaPara.RxTxBuff[ucLen] = pucBuff[ucLen]; + }; + SX1276LoRaSetOpMode(RFLR_OPMODE_STANDBY); + LoRaPara.RegBuff.RegIrqFlagsMask = RFLR_IRQFLAGS_RXTIMEOUT | RFLR_IRQFLAGS_RXDONE | RFLR_IRQFLAGS_PAYLOADCRCERROR | RFLR_IRQFLAGS_VALIDHEADER; + //LoRaPara.RegBuff.RegHopPeriod = 0; + //SX1276Write(REG_LR_HOPPERIOD, LoRaPara.RegBuff.RegHopPeriod); + SX1276Write(REG_LR_IRQFLAGSMASK, LoRaPara.RegBuff.RegIrqFlagsMask); + // Initializes the payload size + LoRaPara.RegBuff.RegPayloadLength = LoRaPara.ucTxPacketSize; + SX1276Write(REG_LR_PAYLOADLENGTH, LoRaPara.RegBuff.RegPayloadLength); + LoRaPara.RegBuff.RegFifoTxBaseAddr = 0x00; // Full buffer used for Tx + SX1276Write(REG_LR_FIFOTXBASEADDR, LoRaPara.RegBuff.RegFifoTxBaseAddr); + LoRaPara.RegBuff.RegFifoAddrPtr = LoRaPara.RegBuff.RegFifoTxBaseAddr; + SX1276Write(REG_LR_FIFOADDRPTR, LoRaPara.RegBuff.RegFifoAddrPtr); + // Write payload buffer to LORA modem + SX1276WriteFifo(LoRaPara.RxTxBuff, LoRaPara.RegBuff.RegPayloadLength); + // TxDone RxTimeout FhssChangeChannel ValidHeader + LoRaPara.RegBuff.RegDioMapping1 = RFLR_DIOMAPPING1_DIO0_01 | RFLR_DIOMAPPING1_DIO1_00 | RFLR_DIOMAPPING1_DIO2_00 | RFLR_DIOMAPPING1_DIO3_01; + // PllLock Mode Ready + LoRaPara.RegBuff.RegDioMapping2 = RFLR_DIOMAPPING2_DIO4_01 | RFLR_DIOMAPPING2_DIO5_00; + SX1276WriteBuffer(REG_LR_DIOMAPPING1, &(LoRaPara.RegBuff.RegDioMapping1), 2); + SX1276LoRaSetOpMode(RFLR_OPMODE_TRANSMITTER); + uint8_t temp; + SX1276Read(REG_LR_IRQFLAGS, &temp); + //LORA_TXLED_ON(); + LoRaPara.State = SX1276_TX; +} + +void Sx1276LoRaSleep(void) +{ + SX1276LoRaSetOpMode(RFLR_OPMODE_SLEEP);//RFLR_OPMODE_STANDBY +} + +void Sx1276LoRaWakeup(void) +{ + Sx1276LoRaEnterRx(); +} + +//////////////////////////////////////// +//配置本层参数的函数 +//频道表 +const uint32_t gdwSx1276ChannelTbl[SX1276_CHANNEL_MAX]={ + FREQ_CENT-FREQ_DEV*8, FREQ_CENT-FREQ_DEV*7, FREQ_CENT-FREQ_DEV*6, FREQ_CENT-FREQ_DEV*5, + FREQ_CENT-FREQ_DEV*4, FREQ_CENT-FREQ_DEV*3, FREQ_CENT-FREQ_DEV*2, FREQ_CENT-FREQ_DEV*1, + FREQ_CENT+FREQ_DEV*0, FREQ_CENT+FREQ_DEV*1, FREQ_CENT+FREQ_DEV*2, FREQ_CENT+FREQ_DEV*3, + FREQ_CENT+FREQ_DEV*4, FREQ_CENT+FREQ_DEV*5, FREQ_CENT+FREQ_DEV*6, FREQ_CENT+FREQ_DEV*7, + FREQ_CENT+FREQ_DEV*8 +}; + +//LORAPT_CHANNEL +uint8_t SX1276LoRaReadChannel(void) +{ + return LoRaPara.ucChannel; +} + +boolean_t SX1276LoRaWriteChannel(uint8_t Channel) +{ + if(Channel > SX1276_CHANNEL_MAX) { + return FALSE; + } + + LoRaPara.dwFreqHz = gdwSx1276ChannelTbl[Channel]; + SX1276LoRaSetFreqHz(LoRaPara.dwFreqHz); + + return TRUE; +} + +//LORAPT_FREQ, +uint32_t SX1276LoRaReadFreq(void) +{ + return LoRaPara.dwFreqHz; +} + +void SX1276LoRaWriteFreq(uint32_t Freq) +{ + SX1276LoRaSetFreqHz(Freq); +} + +//LORAPT_BW, +uint32_t SX1276LoRaReadBw(void) +{ + return LoRaPara.SignalBw; +} + +void SX1276LoRaWriteBw(Sx1276BwType SignalBw) +{ + LoRaPara.SignalBw = SignalBw; + SX1276LoRaSetSignalBandwidth(SignalBw); +} + +//LORAPT_SF, +uint8_t SX1276LoRaReadSf(void) +{ + return LoRaPara.SpreadFactor; +} + +void SX1276LoRaWriteSf(Sx1276SpreadFactorType SpreadFactor) +{ + LoRaPara.SpreadFactor = SpreadFactor; + SX1276LoRaSetSpreadingFactor(LoRaPara.SpreadFactor); +} + +//LORAPT_EC, +uint8_t SX1276LoRaReadEc(void) +{ + return LoRaPara.ErrorCoding; +} + +void SX1276LoRaWriteEc(Sx1276ErrorCodingType ErrorCoding) +{ + LoRaPara.ErrorCoding = ErrorCoding; + SX1276LoRaSetErrorCoding(ErrorCoding); +} + +//LORAPT_RSSI, +uint32_t SX1276LoRaParaReadRssi(void) +{ + uint32_t rssi; + + SX1276Read(REG_LR_PKTRSSIVALUE, &(LoRaPara.RegBuff.RegPktRssiValue)); + SX1276Read(REG_LR_RSSIVALUE, &(LoRaPara.RegBuff.RegRssiValue)); + rssi = (uint16_t)(LoRaPara.RegBuff.RegPktSnrValue)<<16; + rssi |= (uint16_t)(LoRaPara.RegBuff.RegRssiValue)<<8; + rssi |= LoRaPara.RegBuff.RegPktRssiValue; + return rssi; +} + +uint8_t SX1276LoRaReadRssiPkt(void) +{ + uint8_t RssiPkt; + + SX1276Read(REG_LR_PKTRSSIVALUE, &LoRaPara.RegBuff.RegPktRssiValue); + RssiPkt = LoRaPara.RegBuff.RegPktRssiValue; + return RssiPkt; +} + +//LORAPT_POWER, +void SX1276LoRaWritePwr(int8_t Pwr) +{ + SX1276LoRaSetRfPower(Pwr); +} + +//LORAPT_SET_RX, +void SX1276LoRaWriteRx(void) +{ + Sx1276LoRaEnterRx(); +} + +//LORAPT_SET_SLEEP,true-Sleep, false-Wakeup +void SX1276LoRaWriteSleep(boolean_t Sleep) +{ + if(Sleep){ + Sx1276LoRaSleep(); + } + else { + Sx1276LoRaWakeup(); + } +} + +Sx1276StateType_t SX1276LoRaReadStatus(void) +{ + return LoRaPara.State; +} + +///////////////RSSI Calc/////////////// +void SX1276LoCalcRssiSnr(int8_t *pswRssi, int8_t *psbSnr) +{ + int8_t sbSnr= LoRaPara.RegBuff.RegPktSnrValue & 0x80 ? (-1)*((int8_t)(((~LoRaPara.RegBuff.RegPktSnrValue+ 1)& 0xFF)/4)): (~LoRaPara.RegBuff.RegPktSnrValue& 0xFF)/4; + if (sbSnr > 0) { + *pswRssi= RSSI_OFFSET_LF+ LoRaPara.RegBuff.RegPktRssiValue; + } + else { + *pswRssi= NOISE_ABSOLUTE_ZERO + 10 + SIGNAL_BW_LOG_125KHZ + NOISE_FIGURE_LF + sbSnr; + } + *psbSnr= sbSnr; +} +#endif diff --git a/Module/LORA/sx127x.h b/Module/LORA/sx127x.h new file mode 100644 index 0000000..e977a1a --- /dev/null +++ b/Module/LORA/sx127x.h @@ -0,0 +1,826 @@ +#ifndef __SX127X_H +#define __SX127X_H + +#include "bsp.h" + +//Constant values need to compute the RSSI value +#define RSSI_OFFSET_LF -155 +#define RSSI_OFFSET_HF -150 +#define NOISE_ABSOLUTE_ZERO -174 +#define NOISE_FIGURE_LF 4 +#define NOISE_FIGURE_HF 6 +#define SIGNAL_BW_LOG_125KHZ 5 + +//SX1276 definitions +#define XTAL_FREQ 32000000 +#define FREQ_STEP 61.03515625 + +//SX1276 Internal registers Address +#define REG_LR_FIFO 0x00 +// Common settings +#define REG_LR_OPMODE 0x01 +#define REG_LR_BANDSETTING 0x04 +#define REG_LR_FRFMSB 0x06 +#define REG_LR_FRFMID 0x07 +#define REG_LR_FRFLSB 0x08 +// Tx settings +#define REG_LR_PACONFIG 0x09 +#define REG_LR_PARAMP 0x0A +#define REG_LR_OCP 0x0B +// Rx settings +#define REG_LR_LNA 0x0C +// LoRa registers +#define REG_LR_FIFOADDRPTR 0x0D +#define REG_LR_FIFOTXBASEADDR 0x0E +#define REG_LR_FIFORXBASEADDR 0x0F +#define REG_LR_FIFORXCURRENTADDR 0x10 +#define REG_LR_IRQFLAGSMASK 0x11 +#define REG_LR_IRQFLAGS 0x12 +#define REG_LR_NBRXBYTES 0x13 +#define REG_LR_RXHEADERCNTVALUEMSB 0x14 +#define REG_LR_RXHEADERCNTVALUELSB 0x15 +#define REG_LR_RXPACKETCNTVALUEMSB 0x16 +#define REG_LR_RXPACKETCNTVALUELSB 0x17 +#define REG_LR_MODEMSTAT 0x18 +#define REG_LR_PKTSNRVALUE 0x19 +#define REG_LR_PKTRSSIVALUE 0x1A +#define REG_LR_RSSIVALUE 0x1B +#define REG_LR_HOPCHANNEL 0x1C +#define REG_LR_MODEMCONFIG1 0x1D +#define REG_LR_MODEMCONFIG2 0x1E +#define REG_LR_SYMBTIMEOUTLSB 0x1F +#define REG_LR_PREAMBLEMSB 0x20 +#define REG_LR_PREAMBLELSB 0x21 +#define REG_LR_PAYLOADLENGTH 0x22 +#define REG_LR_PAYLOADMAXLENGTH 0x23 +#define REG_LR_HOPPERIOD 0x24 +#define REG_LR_FIFORXBYTEADDR 0x25 +#define REG_LR_MODEMCONFIG3 0x26 +// end of documented register in datasheet +// I/O settings +#define REG_LR_DIOMAPPING1 0x40 +#define REG_LR_DIOMAPPING2 0x41 +// Version +#define REG_LR_VERSION 0x42 +// Additional settings +#define REG_LR_PLLHOP 0x44 +#define REG_LR_TCXO 0x4B +#define REG_LR_PADAC 0x4D +#define REG_LR_FORMERTEMP 0x5B +#define REG_LR_BITRATEFRAC 0x5D +#define REG_LR_AGCREF 0x61 +#define REG_LR_AGCTHRESH1 0x62 +#define REG_LR_AGCTHRESH2 0x63 +#define REG_LR_AGCTHRESH3 0x64 + +//RegOpMode +typedef enum{ + RFLR_OPMODE_LONGRANGEMODE_MASK =0x7F, + RFLR_OPMODE_LONGRANGEMODE_OFF =0x00, // Default + RFLR_OPMODE_LONGRANGEMODE_ON =0x80, + RFLR_OPMODE_ACCESSSHAREDREG_MASK =0xBF, + RFLR_OPMODE_ACCESSSHAREDREG_ENABLE =0x40, + RFLR_OPMODE_ACCESSSHAREDREG_DISABLE =0x00, // Default + RFLR_OPMODE_FREQMODE_ACCESS_MASK =0xF7, + RFLR_OPMODE_FREQMODE_ACCESS_LF =0x08, // Default + RFLR_OPMODE_FREQMODE_ACCESS_HF =0x00, + RFLR_OPMODE_MASK =0xF8, + RFLR_OPMODE_SLEEP =0x00, + RFLR_OPMODE_STANDBY =0x01, // Default + RFLR_OPMODE_SYNTHESIZER_TX =0x02, + RFLR_OPMODE_TRANSMITTER =0x03, + RFLR_OPMODE_SYNTHESIZER_RX =0x04, + RFLR_OPMODE_RECEIVER =0x05, + // LoRa specific modes + RFLR_OPMODE_RECEIVER_SINGLE =0x06, + RFLR_OPMODE_CAD =0x07 +}Sx1276OpModeType; + +//RegBandSetting +#define RFLR_BANDSETTING_MASK 0x3F +#define RFLR_BANDSETTING_AUTO 0x00 // Default +#define RFLR_BANDSETTING_DIV_BY_1 0x40 +#define RFLR_BANDSETTING_DIV_BY_2 0x80 +#define RFLR_BANDSETTING_DIV_BY_6 0xC0 + +//RegFrf (MHz) +#define RFLR_FRFMSB_434_MHZ 0x6C // Default +#define RFLR_FRFMID_434_MHZ 0x80 // Default +#define RFLR_FRFLSB_434_MHZ 0x00 // Default +#define RFLR_FRFMSB_863_MHZ 0xD7 +#define RFLR_FRFMID_863_MHZ 0xC0 +#define RFLR_FRFLSB_863_MHZ 0x00 +#define RFLR_FRFMSB_864_MHZ 0xD8 +#define RFLR_FRFMID_864_MHZ 0x00 +#define RFLR_FRFLSB_864_MHZ 0x00 +#define RFLR_FRFMSB_865_MHZ 0xD8 +#define RFLR_FRFMID_865_MHZ 0x40 +#define RFLR_FRFLSB_865_MHZ 0x00 +#define RFLR_FRFMSB_866_MHZ 0xD8 +#define RFLR_FRFMID_866_MHZ 0x80 +#define RFLR_FRFLSB_866_MHZ 0x00 +#define RFLR_FRFMSB_867_MHZ 0xD8 +#define RFLR_FRFMID_867_MHZ 0xC0 +#define RFLR_FRFLSB_867_MHZ 0x00 +#define RFLR_FRFMSB_868_MHZ 0xD9 +#define RFLR_FRFMID_868_MHZ 0x00 +#define RFLR_FRFLSB_868_MHZ 0x00 +#define RFLR_FRFMSB_869_MHZ 0xD9 +#define RFLR_FRFMID_869_MHZ 0x40 +#define RFLR_FRFLSB_869_MHZ 0x00 +#define RFLR_FRFMSB_870_MHZ 0xD9 +#define RFLR_FRFMID_870_MHZ 0x80 +#define RFLR_FRFLSB_870_MHZ 0x00 +#define RFLR_FRFMSB_902_MHZ 0xE1 +#define RFLR_FRFMID_902_MHZ 0x80 +#define RFLR_FRFLSB_902_MHZ 0x00 +#define RFLR_FRFMSB_903_MHZ 0xE1 +#define RFLR_FRFMID_903_MHZ 0xC0 +#define RFLR_FRFLSB_903_MHZ 0x00 +#define RFLR_FRFMSB_904_MHZ 0xE2 +#define RFLR_FRFMID_904_MHZ 0x00 +#define RFLR_FRFLSB_904_MHZ 0x00 +#define RFLR_FRFMSB_905_MHZ 0xE2 +#define RFLR_FRFMID_905_MHZ 0x40 +#define RFLR_FRFLSB_905_MHZ 0x00 +#define RFLR_FRFMSB_906_MHZ 0xE2 +#define RFLR_FRFMID_906_MHZ 0x80 +#define RFLR_FRFLSB_906_MHZ 0x00 +#define RFLR_FRFMSB_907_MHZ 0xE2 +#define RFLR_FRFMID_907_MHZ 0xC0 +#define RFLR_FRFLSB_907_MHZ 0x00 +#define RFLR_FRFMSB_908_MHZ 0xE3 +#define RFLR_FRFMID_908_MHZ 0x00 +#define RFLR_FRFLSB_908_MHZ 0x00 +#define RFLR_FRFMSB_909_MHZ 0xE3 +#define RFLR_FRFMID_909_MHZ 0x40 +#define RFLR_FRFLSB_909_MHZ 0x00 +#define RFLR_FRFMSB_910_MHZ 0xE3 +#define RFLR_FRFMID_910_MHZ 0x80 +#define RFLR_FRFLSB_910_MHZ 0x00 +#define RFLR_FRFMSB_911_MHZ 0xE3 +#define RFLR_FRFMID_911_MHZ 0xC0 +#define RFLR_FRFLSB_911_MHZ 0x00 +#define RFLR_FRFMSB_912_MHZ 0xE4 +#define RFLR_FRFMID_912_MHZ 0x00 +#define RFLR_FRFLSB_912_MHZ 0x00 +#define RFLR_FRFMSB_913_MHZ 0xE4 +#define RFLR_FRFMID_913_MHZ 0x40 +#define RFLR_FRFLSB_913_MHZ 0x00 +#define RFLR_FRFMSB_914_MHZ 0xE4 +#define RFLR_FRFMID_914_MHZ 0x80 +#define RFLR_FRFLSB_914_MHZ 0x00 +#define RFLR_FRFMSB_915_MHZ 0xE4 // Default +#define RFLR_FRFMID_915_MHZ 0xC0 // Default +#define RFLR_FRFLSB_915_MHZ 0x00 // Default +#define RFLR_FRFMSB_916_MHZ 0xE5 +#define RFLR_FRFMID_916_MHZ 0x00 +#define RFLR_FRFLSB_916_MHZ 0x00 +#define RFLR_FRFMSB_917_MHZ 0xE5 +#define RFLR_FRFMID_917_MHZ 0x40 +#define RFLR_FRFLSB_917_MHZ 0x00 +#define RFLR_FRFMSB_918_MHZ 0xE5 +#define RFLR_FRFMID_918_MHZ 0x80 +#define RFLR_FRFLSB_918_MHZ 0x00 +#define RFLR_FRFMSB_919_MHZ 0xE5 +#define RFLR_FRFMID_919_MHZ 0xC0 +#define RFLR_FRFLSB_919_MHZ 0x00 +#define RFLR_FRFMSB_920_MHZ 0xE6 +#define RFLR_FRFMID_920_MHZ 0x00 +#define RFLR_FRFLSB_920_MHZ 0x00 +#define RFLR_FRFMSB_921_MHZ 0xE6 +#define RFLR_FRFMID_921_MHZ 0x40 +#define RFLR_FRFLSB_921_MHZ 0x00 +#define RFLR_FRFMSB_922_MHZ 0xE6 +#define RFLR_FRFMID_922_MHZ 0x80 +#define RFLR_FRFLSB_922_MHZ 0x00 +#define RFLR_FRFMSB_923_MHZ 0xE6 +#define RFLR_FRFMID_923_MHZ 0xC0 +#define RFLR_FRFLSB_923_MHZ 0x00 +#define RFLR_FRFMSB_924_MHZ 0xE7 +#define RFLR_FRFMID_924_MHZ 0x00 +#define RFLR_FRFLSB_924_MHZ 0x00 +#define RFLR_FRFMSB_925_MHZ 0xE7 +#define RFLR_FRFMID_925_MHZ 0x40 +#define RFLR_FRFLSB_925_MHZ 0x00 +#define RFLR_FRFMSB_926_MHZ 0xE7 +#define RFLR_FRFMID_926_MHZ 0x80 +#define RFLR_FRFLSB_926_MHZ 0x00 +#define RFLR_FRFMSB_927_MHZ 0xE7 +#define RFLR_FRFMID_927_MHZ 0xC0 +#define RFLR_FRFLSB_927_MHZ 0x00 +#define RFLR_FRFMSB_928_MHZ 0xE8 +#define RFLR_FRFMID_928_MHZ 0x00 +#define RFLR_FRFLSB_928_MHZ 0x00 + +//RegPaConfig +#define RFLR_PACONFIG_PASELECT_MASK 0x7F +#define RFLR_PACONFIG_PASELECT_PABOOST 0x80 +#define RFLR_PACONFIG_PASELECT_RFO 0x00 // Default +#define RFLR_PACONFIG_MAX_POWER_MASK 0x8F +#define RFLR_PACONFIG_OUTPUTPOWER_MASK 0xF0 + +//RegPaRamp +#define RFLR_PARAMP_TXBANDFORCE_MASK 0xEF +#define RFLR_PARAMP_TXBANDFORCE_BAND_SEL 0x10 +#define RFLR_PARAMP_TXBANDFORCE_AUTO 0x00 // Default +#define RFLR_PARAMP_MASK 0xF0 +#define RFLR_PARAMP_3400_US 0x00 +#define RFLR_PARAMP_2000_US 0x01 +#define RFLR_PARAMP_1000_US 0x02 +#define RFLR_PARAMP_0500_US 0x03 +#define RFLR_PARAMP_0250_US 0x04 +#define RFLR_PARAMP_0125_US 0x05 +#define RFLR_PARAMP_0100_US 0x06 +#define RFLR_PARAMP_0062_US 0x07 +#define RFLR_PARAMP_0050_US 0x08 +#define RFLR_PARAMP_0040_US 0x09 // Default +#define RFLR_PARAMP_0031_US 0x0A +#define RFLR_PARAMP_0025_US 0x0B +#define RFLR_PARAMP_0020_US 0x0C +#define RFLR_PARAMP_0015_US 0x0D +#define RFLR_PARAMP_0012_US 0x0E +#define RFLR_PARAMP_0010_US 0x0F + +//RegOcp +#define RFLR_OCP_MASK 0xDF +#define RFLR_OCP_ON 0x20 // Default +#define RFLR_OCP_OFF 0x00 +#define RFLR_OCP_TRIM_MASK 0xE0 +#define RFLR_OCP_TRIM_045_MA 0x00 +#define RFLR_OCP_TRIM_050_MA 0x01 +#define RFLR_OCP_TRIM_055_MA 0x02 +#define RFLR_OCP_TRIM_060_MA 0x03 +#define RFLR_OCP_TRIM_065_MA 0x04 +#define RFLR_OCP_TRIM_070_MA 0x05 +#define RFLR_OCP_TRIM_075_MA 0x06 +#define RFLR_OCP_TRIM_080_MA 0x07 +#define RFLR_OCP_TRIM_085_MA 0x08 +#define RFLR_OCP_TRIM_090_MA 0x09 +#define RFLR_OCP_TRIM_095_MA 0x0A +#define RFLR_OCP_TRIM_100_MA 0x0B // Default +#define RFLR_OCP_TRIM_105_MA 0x0C +#define RFLR_OCP_TRIM_110_MA 0x0D +#define RFLR_OCP_TRIM_115_MA 0x0E +#define RFLR_OCP_TRIM_120_MA 0x0F +#define RFLR_OCP_TRIM_130_MA 0x10 +#define RFLR_OCP_TRIM_140_MA 0x11 +#define RFLR_OCP_TRIM_150_MA 0x12 +#define RFLR_OCP_TRIM_160_MA 0x13 +#define RFLR_OCP_TRIM_170_MA 0x14 +#define RFLR_OCP_TRIM_180_MA 0x15 +#define RFLR_OCP_TRIM_190_MA 0x16 +#define RFLR_OCP_TRIM_200_MA 0x17 +#define RFLR_OCP_TRIM_210_MA 0x18 +#define RFLR_OCP_TRIM_220_MA 0x19 +#define RFLR_OCP_TRIM_230_MA 0x1A +#define RFLR_OCP_TRIM_240_MA 0x1B + +//RegLna +#define RFLR_LNA_GAIN_MASK 0x1F +#define RFLR_LNA_GAIN_G1 0x20 // Default +#define RFLR_LNA_GAIN_G2 0x40 +#define RFLR_LNA_GAIN_G3 0x60 +#define RFLR_LNA_GAIN_G4 0x80 +#define RFLR_LNA_GAIN_G5 0xA0 +#define RFLR_LNA_GAIN_G6 0xC0 +#define RFLR_LNA_BOOST_LF_MASK 0xE7 +#define RFLR_LNA_BOOST_LF_DEFAULT 0x00 // Default +#define RFLR_LNA_BOOST_LF_GAIN 0x08 +#define RFLR_LNA_BOOST_LF_IP3 0x10 +#define RFLR_LNA_BOOST_LF_BOOST 0x18 +#define RFLR_LNA_RXBANDFORCE_MASK 0xFB +#define RFLR_LNA_RXBANDFORCE_BAND_SEL 0x04 +#define RFLR_LNA_RXBANDFORCE_AUTO 0x00 // Default +#define RFLR_LNA_BOOST_HF_MASK 0xFC +#define RFLR_LNA_BOOST_HF_OFF 0x00 // Default +#define RFLR_LNA_BOOST_HF_ON 0x03 + +//RegFifoAddrPtr +#define RFLR_FIFOADDRPTR 0x00 // Default + +//RegFifoTxBaseAddr +#define RFLR_FIFOTXBASEADDR 0x80 // Default + +//RegFifoTxBaseAddr +#define RFLR_FIFORXBASEADDR 0x00 // Default + +//RegFifoRxCurrentAddr (Read Only) + +//RegIrqFlagsMask +#define RFLR_IRQFLAGS_RXTIMEOUT_MASK 0x80 +#define RFLR_IRQFLAGS_RXDONE_MASK 0x40 +#define RFLR_IRQFLAGS_PAYLOADCRCERROR_MASK 0x20 +#define RFLR_IRQFLAGS_VALIDHEADER_MASK 0x10 +#define RFLR_IRQFLAGS_TXDONE_MASK 0x08 +#define RFLR_IRQFLAGS_CADDONE_MASK 0x04 +#define RFLR_IRQFLAGS_FHSSCHANGEDCHANNEL_MASK 0x02 +#define RFLR_IRQFLAGS_CADDETECTED_MASK 0x01 + +//RegIrqFlags +#define RFLR_IRQFLAGS_RXTIMEOUT 0x80 +#define RFLR_IRQFLAGS_RXDONE 0x40 +#define RFLR_IRQFLAGS_PAYLOADCRCERROR 0x20 +#define RFLR_IRQFLAGS_VALIDHEADER 0x10 +#define RFLR_IRQFLAGS_TXDONE 0x08 +#define RFLR_IRQFLAGS_CADDONE 0x04 +#define RFLR_IRQFLAGS_FHSSCHANGEDCHANNEL 0x02 +#define RFLR_IRQFLAGS_CADDETECTED 0x01 + + //RegModemStat (Read Only) +#define RFLR_MODEMSTAT_RX_CR_MASK 0x1F +#define RFLR_MODEMSTAT_MODEM_STATUS_MASK 0xE0 + +//RegModemConfig1 +#define RFLR_MODEMCONFIG1_BW_MASK 0x0F +#define RFLR_MODEMCONFIG1_BW_7_81_KHZ 0x00 +#define RFLR_MODEMCONFIG1_BW_10_41_KHZ 0x10 +#define RFLR_MODEMCONFIG1_BW_15_62_KHZ 0x20 +#define RFLR_MODEMCONFIG1_BW_20_83_KHZ 0x30 +#define RFLR_MODEMCONFIG1_BW_31_25_KHZ 0x40 +#define RFLR_MODEMCONFIG1_BW_41_66_KHZ 0x50 +#define RFLR_MODEMCONFIG1_BW_62_50_KHZ 0x60 +#define RFLR_MODEMCONFIG1_BW_125_KHZ 0x70 // Default +#define RFLR_MODEMCONFIG1_BW_250_KHZ 0x80 +#define RFLR_MODEMCONFIG1_BW_500_KHZ 0x90 +#define RFLR_MODEMCONFIG1_CODINGRATE_MASK 0xF1 +#define RFLR_MODEMCONFIG1_CODINGRATE_4_5 0x02 +#define RFLR_MODEMCONFIG1_CODINGRATE_4_6 0x04 // Default +#define RFLR_MODEMCONFIG1_CODINGRATE_4_7 0x06 +#define RFLR_MODEMCONFIG1_CODINGRATE_4_8 0x08 +#define RFLR_MODEMCONFIG1_IMPLICITHEADER_MASK 0xFE +#define RFLR_MODEMCONFIG1_IMPLICITHEADER_ON 0x00 +#define RFLR_MODEMCONFIG1_IMPLICITHEADER_OFF 0x01 // Default + + //RegModemConfig2 +#define RFLR_MODEMCONFIG2_SF_MASK 0x0F +#define RFLR_MODEMCONFIG2_SF_6 0x60 +#define RFLR_MODEMCONFIG2_SF_7 0x70 // Default +#define RFLR_MODEMCONFIG2_SF_8 0x80 +#define RFLR_MODEMCONFIG2_SF_9 0x90 +#define RFLR_MODEMCONFIG2_SF_10 0xA0 +#define RFLR_MODEMCONFIG2_SF_11 0xB0 +#define RFLR_MODEMCONFIG2_SF_12 0xC0 + +#define RFLR_MODEMCONFIG2_TXCONTINUOUSMODE_MASK 0xF7 +#define RFLR_MODEMCONFIG2_TXCONTINUOUSMODE_ON 0x08 +#define RFLR_MODEMCONFIG2_TXCONTINUOUSMODE_OFF 0x00 + +#define RFLR_MODEMCONFIG2_RXPAYLOADCRC_MASK 0xFB +#define RFLR_MODEMCONFIG2_RXPAYLOADCRC_ON 0x04 +#define RFLR_MODEMCONFIG2_RXPAYLOADCRC_OFF 0x00 // Default + +#define RFLR_MODEMCONFIG2_SYMBTIMEOUTMSB_MASK 0xFC +#define RFLR_MODEMCONFIG2_SYMBTIMEOUTMSB 0x00 // Default + + +//RegHopChannel (Read Only) +#define RFLR_HOPCHANNEL_PLL_LOCK_TIMEOUT_MASK 0x7F +#define RFLR_HOPCHANNEL_PLL_LOCK_FAIL 0x80 +#define RFLR_HOPCHANNEL_PLL_LOCK_SUCCEED 0x00 // Default +#define RFLR_HOPCHANNEL_PAYLOAD_CRC16_MASK 0xBF +#define RFLR_HOPCHANNEL_PAYLOAD_CRC16_ON 0x40 +#define RFLR_HOPCHANNEL_PAYLOAD_CRC16_OFF 0x00 // Default +#define RFLR_HOPCHANNEL_CHANNEL_MASK 0x3F + + +//RegSymbTimeoutLsb +#define RFLR_SYMBTIMEOUTLSB_SYMBTIMEOUT 0x64 // Default + +//RegPreambleLengthMsb +#define RFLR_PREAMBLELENGTHMSB 0x00 // Default + +//RegPreambleLengthLsb +#define RFLR_PREAMBLELENGTHLSB 0x08 // Default + +//RegPayloadLength +#define RFLR_PAYLOADLENGTH 0x0E // Default + +//RegPayloadMaxLength +#define RFLR_PAYLOADMAXLENGTH 0xFF // Default + +//RegHopPeriod +#define RFLR_HOPPERIOD_FREQFOPPINGPERIOD 0x00 // Default + + +//RegDioMapping1 +//DIO0 +#define RFLR_DIOMAPPING1_DIO0_MASK 0x3F +#define RFLR_DIOMAPPING1_DIO0_00 0x00 // Default +#define RFLR_DIOMAPPING1_DIO0_01 0x40 +#define RFLR_DIOMAPPING1_DIO0_10 0x80 +#define RFLR_DIOMAPPING1_DIO0_11 0xC0 +//DIO1 +#define RFLR_DIOMAPPING1_DIO1_MASK 0xCF +#define RFLR_DIOMAPPING1_DIO1_00 0x00 // Default +#define RFLR_DIOMAPPING1_DIO1_01 0x10 +#define RFLR_DIOMAPPING1_DIO1_10 0x20 +#define RFLR_DIOMAPPING1_DIO1_11 0x30 +//DIO2 +#define RFLR_DIOMAPPING1_DIO2_MASK 0xF3 +#define RFLR_DIOMAPPING1_DIO2_00 0x00 // Default +#define RFLR_DIOMAPPING1_DIO2_01 0x04 +#define RFLR_DIOMAPPING1_DIO2_10 0x08 +#define RFLR_DIOMAPPING1_DIO2_11 0x0C +//DIO3 +#define RFLR_DIOMAPPING1_DIO3_MASK 0xFC +#define RFLR_DIOMAPPING1_DIO3_00 0x00 // Default +#define RFLR_DIOMAPPING1_DIO3_01 0x01 +#define RFLR_DIOMAPPING1_DIO3_10 0x02 +#define RFLR_DIOMAPPING1_DIO3_11 0x03 + +//RegDioMapping2 +//DIO4 +#define RFLR_DIOMAPPING2_DIO4_MASK 0x3F +#define RFLR_DIOMAPPING2_DIO4_00 0x00 // Default +#define RFLR_DIOMAPPING2_DIO4_01 0x40 +#define RFLR_DIOMAPPING2_DIO4_10 0x80 +#define RFLR_DIOMAPPING2_DIO4_11 0xC0 +//DIO5 +#define RFLR_DIOMAPPING2_DIO5_MASK 0xCF +#define RFLR_DIOMAPPING2_DIO5_00 0x00 // Default +#define RFLR_DIOMAPPING2_DIO5_01 0x10 +#define RFLR_DIOMAPPING2_DIO5_10 0x20 +#define RFLR_DIOMAPPING2_DIO5_11 0x30 +//MAP +#define RFLR_DIOMAPPING2_MAP_MASK 0xFE +#define RFLR_DIOMAPPING2_MAP_PREAMBLEDETECT 0x01 +#define RFLR_DIOMAPPING2_MAP_RSSI 0x00 // Default + +// RegPllHop +#define RFLR_PLLHOP_FASTHOP_MASK 0x7F +#define RFLR_PLLHOP_FASTHOP_ON 0x80 +#define RFLR_PLLHOP_FASTHOP_OFF 0x00 // Default + +//RegTcxo +#define RFLR_TCXO_TCXOINPUT_MASK 0xEF +#define RFLR_TCXO_TCXOINPUT_ON 0x10 +#define RFLR_TCXO_TCXOINPUT_OFF 0x00 // Default + +//RegPaDac +#define RFLR_PADAC_20DBM_MASK 0xF8 +#define RFLR_PADAC_20DBM_ON 0x07 +#define RFLR_PADAC_20DBM_OFF 0x04 // Default + +//RegPll +#define RFLR_PLL_BANDWIDTH_MASK 0x3F +#define RFLR_PLL_BANDWIDTH_75 0x00 +#define RFLR_PLL_BANDWIDTH_150 0x40 +#define RFLR_PLL_BANDWIDTH_225 0x80 +#define RFLR_PLL_BANDWIDTH_300 0xC0 // Default + +//RegPllLowPn +#define RFLR_PLLLOWPN_BANDWIDTH_MASK 0x3F +#define RFLR_PLLLOWPN_BANDWIDTH_75 0x00 +#define RFLR_PLLLOWPN_BANDWIDTH_150 0x40 +#define RFLR_PLLLOWPN_BANDWIDTH_225 0x80 +#define RFLR_PLLLOWPN_BANDWIDTH_300 0xC0 // Default + +//RegModemConfig3 +#define RFLR_MODEMCONFIG3_LOWDATARATEOPTIMIZE_MASK 0xF7 +#define RFLR_MODEMCONFIG3_LOWDATARATEOPTIMIZE_ON 0x08 +#define RFLR_MODEMCONFIG3_LOWDATARATEOPTIMIZE_OFF 0x00 // Default +#define RFLR_MODEMCONFIG3_AGCAUTO_MASK 0xFB +#define RFLR_MODEMCONFIG3_AGCAUTO_ON 0x04 // Default +#define RFLR_MODEMCONFIG3_AGCAUTO_OFF 0x00 + +//REGISTER +typedef struct _Sx1276RegType{ + uint8_t RegFifo; // 0x00 + // Common settings + uint8_t RegOpMode; // 0x01 + uint8_t RegRes02; // 0x02 + uint8_t RegRes03; // 0x03 + uint8_t RegBandSetting; // 0x04 + uint8_t RegRes05; // 0x05 + uint8_t RegFrfMsb; // 0x06 + uint8_t RegFrfMid; // 0x07 + uint8_t RegFrfLsb; // 0x08 + // Tx settings + uint8_t RegPaConfig; // 0x09 + uint8_t RegPaRamp; // 0x0A + uint8_t RegOcp; // 0x0B + // Rx settings + uint8_t RegLna; // 0x0C + // LoRa registers + uint8_t RegFifoAddrPtr; // 0x0D + uint8_t RegFifoTxBaseAddr; // 0x0E + uint8_t RegFifoRxBaseAddr; // 0x0F + uint8_t RegFifoRxCurrentAddr; // 0x10 + uint8_t RegIrqFlagsMask; // 0x11 + uint8_t RegIrqFlags; // 0x12 + uint8_t RegNbRxBytes; // 0x13 + uint8_t RegRxHeaderCntValueMsb; // 0x14 + uint8_t RegRxHeaderCntValueLsb; // 0x15 + uint8_t RegRxPacketCntValueMsb; // 0x16 + uint8_t RegRxPacketCntValueLsb; // 0x17 + uint8_t RegModemStat; // 0x18 + uint8_t RegPktSnrValue; // 0x19 + uint8_t RegPktRssiValue; // 0x1A + uint8_t RegRssiValue; // 0x1B + uint8_t RegHopChannel; // 0x1C + uint8_t RegModemConfig1; // 0x1D + uint8_t RegModemConfig2; // 0x1E + uint8_t RegSymbTimeoutLsb; // 0x1F + uint8_t RegPreambleMsb; // 0x20 + uint8_t RegPreambleLsb; // 0x21 + uint8_t RegPayloadLength; // 0x22 + uint8_t RegMaxPayloadLength; // 0x23 + uint8_t RegHopPeriod; // 0x24 + uint8_t RegFifoRxByteAddr; // 0x25 + uint8_t RegModemConfig3; // 0x26 + uint8_t RegTestReserved27[0x30 - 0x27]; // 0x27-0x30 + uint8_t RegTestReserved31; // 0x31 + uint8_t RegTestReserved32[0x40 - 0x32]; // 0x32-0x40 + // I/O settings + uint8_t RegDioMapping1; // 0x40 + uint8_t RegDioMapping2; // 0x41 + // Version + uint8_t RegVersion; // 0x42 + // Additional settings + uint8_t RegAgcRef; // 0x43 + uint8_t RegAgcThresh1; // 0x44 + uint8_t RegAgcThresh2; // 0x45 + uint8_t RegAgcThresh3; // 0x46 + // Test + uint8_t RegTestReserved47[0x4B - 0x47]; // 0x47-0x4A + // Additional settings + uint8_t RegPllHop; // 0x4B + uint8_t RegTestReserved4C; // 0x4C + uint8_t RegPaDac; // 0x4D + // Test + //uint8_t RegTestReserved4E[0x58-0x4E]; // 0x4E-0x57 + // Additional settings + //uint8_t RegTcxo; // 0x58 + // Test + //uint8_t RegTestReserved59; // 0x59 + // Test + //uint8_t RegTestReserved5B; // 0x5B + // Additional settings + //uint8_t RegPll; // 0x5C + // Test + //uint8_t RegTestReserved5D; // 0x5D + // Additional settings + //uint8_t RegPllLowPn; // 0x5E + // Test + //uint8_t RegTestReserved5F[0x6C - 0x5F]; // 0x5F-0x6B + // Additional settings + //uint8_t RegFormerTemp; // 0x6C + // Test + //uint8_t RegTestReserved6D[0x71 - 0x6D]; // 0x6D-0x70 +}Sx1276RegType; + +#define SIZE_OF_REGISTERS (sizeof(Sx1276RegType)) + +//RF state machine +typedef enum{ + RFLR_STATE_IDLE, + RFLR_STATE_RX_RUNNING, + RFLR_STATE_TX_RUNNING, +}LRStateType; + +typedef enum{ + RADIO_RESET_OFF, + RADIO_RESET_ON, +}tRadioResetState; + +typedef enum{ + RF_IDLE, + RF_BUSY, + RF_RX_DONE, + RF_RX_TIMEOUT, + RF_TX_DONE, + RF_TX_TIMEOUT, + RF_LEN_ERROR, + RF_CHANNEL_EMPTY, + RF_CHANNEL_ACTIVITY_DETECTED, +}Sx1276RetType; + +typedef enum{ + SX1276_BW_7K8= (0), + SX1276_BW_10K4= (1<<4), + SX1276_BW_15K6= (2<<4), + SX1276_BW_20K8= (3<<4), + SX1276_BW_31K2= (4<<4), + SX1276_BW_41K6= (5<<4), + SX1276_BW_62K5= (6<<4), + SX1276_BW_125K= (7<<4), + SX1276_BW_250K= (8<<4), + SX1276_BW_500K= (9<<4) +}Sx1276BwType; + +typedef enum{ + SX1276_SF_64= (6<<4), + SX1276_SF_128= (7<<4), + SX1276_SF_256= (8<<4), + SX1276_SF_512= (9<<4), + SX1276_SF_1024= (10<<4), + SX1276_SF_2048= (11<<4), + SX1276_SF_4096= (12<<4) +}Sx1276SpreadFactorType; + +typedef enum{ + SX1276_EC_4_5= (1<<1), + SX1276_EC_4_6= (2<<1), + SX1276_EC_4_7= (3<<1), + SX1276_EC_4_8= (4<<1) +}Sx1276ErrorCodingType; + +typedef enum{ + SX1276_CRC_OFF= (0), + SX1276_CRC_ON= (1<<2) +}Sx1276CrcOnType; + +typedef enum{ + SX1276_IH_OFF= (0), + SX1276_IH_ON= (1) +}Sx1276ImplicitHeaderOnType; + +// 杀 +typedef struct _AutoSfType{ + Sx1276SpreadFactorType Sf; + uint8_t ucRssiMin, ucRssiMax; + uint16_t wTimeout; +}AutoSfType, *PAutoSf; + +//Parameter +typedef enum{ + LORAPT_STATUS, + LORAPT_CHANNEL, + LORAPT_FREQ, + LORAPT_BW, + LORAPT_SF, + LORAPT_EC, + LORAPT_RSSI, + LORAPT_POWER, + LORAPT_SET_RX, + LORAPT_SET_SLEEP, + LORAPT_MAX +}Sx1276LoraParaType; + +#define SX1276_CHANNEL_MAX 17 + +#define LORA_RESET_SET() SET_LORA_RST() +#define LORA_RESET_CLR() CLR_LORA_RST() +#define LORA_SPI_NSS_SET() Spi_SetCS(M0P_SPI0, TRUE) //鍙栨秷鐗囬 +#define LORA_SPI_NSS_CLR() Spi_SetCS(M0P_SPI0, FALSE) //浣胯兘鍣ㄤ欢 +#define LORA_SPI_READ_WRITE(x) Spi0SendReceive(x) +#define LORA_GETDIO0() GET_LORA_DIO0() +#define LORA_GETDIO1() GET_LORA_DIO1() + +#define USE_RF_SW 0 +#define USE_LORA_LED 0 +#if USE_RF_SW == 1 +#define LORA_ANTTXEN() { \ + SET_LORA_TXEN();\ + CLR_LORA_RXEN();\ + } + +#define LORA_ANTRXEN() { \ + SET_LORA_RXEN();\ + CLR_LORA_TXEN();\ + } + +#define LORA_ANTCLOSE() { \ + CLR_LORA_RXEN();\ + CLR_LORA_TXEN();\ + } +#else +#define LORA_ANTTXEN() +#define LORA_ANTRXEN() +#define LORA_ANTCLOSE() +#endif + +#if USE_LORA_LED == 1 +#define LORA_TXLED_ON() SET_LED_PIN() +#define LORA_TXLED_OFF() CLR_LED_PIN() +#else +#define LORA_TXLED_ON() SET_LORA_TX_LED() +#define LORA_TXLED_OFF() CLR_LORA_TX_LED() +#endif + +#define LORA_BUFF_SIZE 255 + +typedef enum { + RF_ANT_TRANSMITTER, + RF_ANT_RECEIVER, + RF_ANT_CLOSE, +}Sx1276AntStatus_m; + +typedef enum { + SX1276_SLEEP, + SX1276_IDLE, + SX1276_RX, + SX1276_TX, + SX1276_BUSY, + SX1276_ERROR, + SX1276_MAX +}Sx1276StateType_t; + +typedef struct { + uint8_t ucChannel; + uint32_t dwFreqHz; + int8_t ucPower; + Sx1276BwType SignalBw; + Sx1276SpreadFactorType SpreadFactor; + Sx1276ErrorCodingType ErrorCoding; + uint8_t RegPreamble; + uint8_t ucOpModePrev; + Sx1276AntStatus_m bAntSwPrev; + Sx1276RegType RegBuff; + Sx1276StateType_t State; + uint8_t ucRxPacketSize; + uint8_t ucTxPacketSize; + uint8_t RxTxBuff[LORA_BUFF_SIZE]; + void (*RxCallBack)(uint8_t *rBuff, uint8_t rlen); +}Sx1276Type_t, *pSx1276Type; + +//ISM Freq In China +//Up Link: +//CH0-5: 470.3-471.3MHz +//CH39-44:478.1-479.1MHz +//CH78-95:485.9-489.3MHz +//Down Link: +//CH0-47:500.3-509.7MHz + +#define USE_915MHZ 0//=1使 915 =0使 433 + +#if (USE_915MHZ == 1) + // 频 剩 默 为449000000Hz + #define FREQ_CENT 915000000ul + //860MHz-1GHz使 PA 牛 默 喜 使 + //SX127x 澹琀OPERF模 要 + #define USE_LORA_860_PA +#endif + +/* +涓績棰戠巼閰嶇疆锛433100000ul + 200000*N +*/ +#define CH0 (433100000ul + 0) //娴嬭瘯棰戠巼 +#define CH1 (433100000ul + 200000) +#define CH2 (433100000ul + 400000) +#define CH3 (433100000ul + 600000) +#define CH4 (433100000ul + 800000) +#define CH5 (433100000ul + 1000000) +#define CH6 (433100000ul + 1200000) +#define CH7 (433100000ul + 1400000) +#define CH8 (433100000ul + 1600000) +#define CH9 (433100000ul + 1800000) +#define CH10 (433100000ul + 2000000) + +#if (USE_LORA_CH == 0) +#define FREQ_CENT CH0 +#elif (USE_LORA_CH == 1) +#define FREQ_CENT CH1 +#elif (USE_LORA_CH == 2) +#define FREQ_CENT CH2 +#elif (USE_LORA_CH == 3) +#define FREQ_CENT CH3 +#elif (USE_LORA_CH == 4) +#define FREQ_CENT CH4 +#elif (USE_LORA_CH == 5) +#define FREQ_CENT CH5 +#elif (USE_LORA_CH == 6) +#define FREQ_CENT CH6 +#elif (USE_LORA_CH == 7) +#define FREQ_CENT CH7 +#elif (USE_LORA_CH == 8) +#define FREQ_CENT CH8 +#elif (USE_LORA_CH == 9) +#define FREQ_CENT CH9 +#elif (USE_LORA_CH == 10) +#define FREQ_CENT CH10 +#endif + +#if !defined FREQ_CENT +#define FREQ_CENT (433100000ul + 0)//200000 +#endif +#if !defined FREQ_DEV +#define FREQ_DEV 1000000ul +#endif + +////////////////////////////////////////////////////////////////////// +void Sx1276LoRaLoopHandler(void); +void Sx1276LoRaInit(void (*RxCallBack)(uint8_t *rBuff, uint8_t rlen)); +void Sx1276LoRaSendBuffer(uint8_t* pucBuff, uint8_t ucLen); +uint8_t SX1276LoRaReadChannel(void); +boolean_t SX1276LoRaWriteChannel(uint8_t Channel); +uint32_t SX1276LoRaReadFreq(void); +void SX1276LoRaWriteFreq(uint32_t Freq); +void SX1276LoRaWriteBw(Sx1276BwType SignalBw); +uint32_t SX1276LoRaReadBw(void); +uint8_t SX1276LoRaReadSf(void); +void SX1276LoRaWriteSf(Sx1276SpreadFactorType SpreadFactor); +void SX1276LoRaWriteEc(Sx1276ErrorCodingType ErrorCoding); +uint8_t SX1276LoRaReadEc(void); +uint32_t SX1276LoRaParaReadRssi(void); +uint8_t SX1276LoRaReadRssiPkt(void); +void SX1276LoRaWritePwr(int8_t Pwr); +void SX1276LoRaWriteRx(void); +void SX1276LoRaWriteSleep(boolean_t Sleep); +Sx1276StateType_t SX1276LoRaReadStatus(void); +void SX1276LoCalcRssiSnr(int8_t *pswRssi, int8_t *psbSnr); +void Sx1276LoRaSleep(void); +void Sx1276LoRaWakeup(void); +#endif + diff --git a/Module/MahonyAHRS/MahonyAHRS.c b/Module/MahonyAHRS/MahonyAHRS.c new file mode 100644 index 0000000..5ac23de --- /dev/null +++ b/Module/MahonyAHRS/MahonyAHRS.c @@ -0,0 +1,247 @@ +//===================================================================================================== +// MahonyAHRS.c +//===================================================================================================== +// +// Madgwick's implementation of Mayhony's AHRS algorithm. +// See: http://www.x-io.co.uk/node/8#open_source_ahrs_and_imu_algorithms +// +// Date Author Notes +// 29/09/2011 SOH Madgwick Initial release +// 02/10/2011 SOH Madgwick Optimised for reduced CPU load +// +//===================================================================================================== + +//--------------------------------------------------------------------------------------------------- +// Header files + +#include "MahonyAHRS.h" +#include + +//--------------------------------------------------------------------------------------------------- +// Definitions + +#define sampleFreq 10.0f // sample frequency in Hz +#define twoKpDef (2.0f * 1.0f) // 2 * proportional gain +#define twoKiDef (2.0f * 0.0f) // 2 * integral gain + +//--------------------------------------------------------------------------------------------------- +// Variable definitions + +volatile float twoKp = twoKpDef; // 2 * proportional gain (Kp) +volatile float twoKi = twoKiDef; // 2 * integral gain (Ki) +volatile float q0 = 1.0f, q1 = 0.0f, q2 = 0.0f, q3 = 0.0f; // quaternion of sensor frame relative to auxiliary frame +volatile float integralFBx = 0.0f, integralFBy = 0.0f, integralFBz = 0.0f; // integral error terms scaled by Ki + +//--------------------------------------------------------------------------------------------------- +// Function declarations + + + +//==================================================================================================== +// Functions + +//--------------------------------------------------------------------------------------------------- +// AHRS algorithm update + +void MahonyAHRSupdate(float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz) { + float recipNorm; + float q0q0, q0q1, q0q2, q0q3, q1q1, q1q2, q1q3, q2q2, q2q3, q3q3; + float hx, hy, bx, bz; + float halfvx, halfvy, halfvz, halfwx, halfwy, halfwz; + float halfex, halfey, halfez; + float qa, qb, qc; + + // Use IMU algorithm if magnetometer measurement invalid (avoids NaN in magnetometer normalisation) + // 鍦ㄧ鍔涜鏁版嵁鏃犳晥鏃朵娇鐢ㄥ叚杞磋瀺鍚堢畻娉 + if((mx == 0.0f) && (my == 0.0f) && (mz == 0.0f)) { + MahonyAHRSupdateIMU(gx, gy, gz, ax, ay, az); + return; + } + + // Compute feedback only if accelerometer measurement valid (avoids NaN in accelerometer normalisation) + // 鍙湪鍔犻熷害璁℃暟鎹湁鏁堟椂鎵嶈繘琛岃繍绠 + if(!((ax == 0.0f) && (ay == 0.0f) && (az == 0.0f))) { + + // Normalise accelerometer measurement + // 灏嗗姞閫熷害璁″緱鍒扮殑瀹為檯閲嶅姏鍔犻熷害鍚戦噺v鍗曚綅鍖 + recipNorm = invSqrt(ax * ax + ay * ay + az * az); + ax *= recipNorm; + ay *= recipNorm; + az *= recipNorm; + + // Normalise magnetometer measurement + // 灏嗙鍔涜寰楀埌鐨勫疄闄呯鍦哄悜閲弇鍗曚綅鍖 + recipNorm = invSqrt(mx * mx + my * my + mz * mz); + mx *= recipNorm; + my *= recipNorm; + mz *= recipNorm; + + // Auxiliary variables to avoid repeated arithmetic + // 杈呭姪鍙橀噺锛屼互閬垮厤閲嶅杩愮畻 + q0q0 = q0 * q0; + q0q1 = q0 * q1; + q0q2 = q0 * q2; + q0q3 = q0 * q3; + q1q1 = q1 * q1; + q1q2 = q1 * q2; + q1q3 = q1 * q3; + q2q2 = q2 * q2; + q2q3 = q2 * q3; + q3q3 = q3 * q3; + + // Reference direction of Earth's magnetic field + // 閫氳繃纾佸姏璁℃祴閲忓间笌鍧愭爣杞崲鐭╅樀寰楀埌澶у湴鍧愭爣绯讳笅鐨勭悊璁哄湴纾佸悜閲 + hx = 2.0f * (mx * (0.5f - q2q2 - q3q3) + my * (q1q2 - q0q3) + mz * (q1q3 + q0q2)); + hy = 2.0f * (mx * (q1q2 + q0q3) + my * (0.5f - q1q1 - q3q3) + mz * (q2q3 - q0q1)); + bx = sqrt(hx * hx + hy * hy); + bz = 2.0f * (mx * (q1q3 - q0q2) + my * (q2q3 + q0q1) + mz * (0.5f - q1q1 - q2q2)); + + // Estimated direction of gravity and magnetic field + // 灏嗙悊璁洪噸鍔涘姞閫熷害鍚戦噺涓庣悊璁哄湴纾佸悜閲忓彉鎹㈣嚦鏈轰綋鍧愭爣绯 + halfvx = q1q3 - q0q2; + halfvy = q0q1 + q2q3; + halfvz = q0q0 - 0.5f + q3q3; + halfwx = bx * (0.5f - q2q2 - q3q3) + bz * (q1q3 - q0q2); + halfwy = bx * (q1q2 - q0q3) + bz * (q0q1 + q2q3); + halfwz = bx * (q0q2 + q1q3) + bz * (0.5f - q1q1 - q2q2); + + // Error is sum of cross product between estimated direction and measured direction of field vectors + // 閫氳繃鍚戦噺澶栫Н寰楀埌閲嶅姏鍔犻熷害鍚戦噺鍜屽湴纾佸悜閲忕殑瀹為檯鍊间笌娴嬮噺鍊间箣闂磋宸 + halfex = (ay * halfvz - az * halfvy) + (my * halfwz - mz * halfwy); + halfey = (az * halfvx - ax * halfvz) + (mz * halfwx - mx * halfwz); + halfez = (ax * halfvy - ay * halfvx) + (mx * halfwy - my * halfwx); + + // Compute and apply integral feedback if enabled + // 鍦≒I琛ュ伩鍣ㄤ腑绉垎椤逛娇鑳芥儏鍐典笅璁$畻骞跺簲鐢ㄧН鍒嗛」 + if(twoKi > 0.0f) { + integralFBx += twoKi * halfex * (1.0f / sampleFreq); // integral error scaled by Ki + integralFBy += twoKi * halfey * (1.0f / sampleFreq); + integralFBz += twoKi * halfez * (1.0f / sampleFreq); + gx += integralFBx; // apply integral feedback // 搴旂敤璇樊琛ュ伩涓殑绉垎椤 + gy += integralFBy; + gz += integralFBz; + } + else { + integralFBx = 0.0f; // prevent integral windup // 閬垮厤涓鸿礋鍊肩殑Ki鏃剁Н鍒嗗紓甯搁ケ鍜 + integralFBy = 0.0f; + integralFBz = 0.0f; + } + + // Apply proportional feedback + // 搴旂敤璇樊琛ュ伩涓殑姣斾緥椤 + gx += twoKp * halfex; + gy += twoKp * halfey; + gz += twoKp * halfez; + } + + // Integrate rate of change of quaternion + // 寰垎鏂圭▼杩唬姹傝В + gx *= (0.5f * (1.0f / sampleFreq)); // pre-multiply common factors + gy *= (0.5f * (1.0f / sampleFreq)); + gz *= (0.5f * (1.0f / sampleFreq)); + qa = q0; + qb = q1; + qc = q2; + q0 += (-qb * gx - qc * gy - q3 * gz); + q1 += (qa * gx + qc * gz - q3 * gy); + q2 += (qa * gy - qb * gz + q3 * gx); + q3 += (qa * gz + qb * gy - qc * gx); + + // Normalise quaternion + // 鍗曚綅鍖栧洓鍏冩暟 淇濊瘉鍥涘厓鏁板湪杩唬杩囩▼涓繚鎸佸崟浣嶆ц川 + recipNorm = invSqrt(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3); + q0 *= recipNorm; + q1 *= recipNorm; + q2 *= recipNorm; + q3 *= recipNorm; + //Mahony瀹樻柟绋嬪簭鍒版缁撴潫锛屼娇鐢ㄦ椂鍙渶鍦ㄥ嚱鏁板杩涜鍥涘厓鏁板弽瑙f鎷夎鍗冲彲瀹屾垚鍏ㄩ儴濮挎佽В绠楄繃绋 +} + +//--------------------------------------------------------------------------------------------------- +// IMU algorithm update + +void MahonyAHRSupdateIMU(float gx, float gy, float gz, float ax, float ay, float az) { + float recipNorm; + float halfvx, halfvy, halfvz;//1/2 閲嶅姏鍒嗛噺 + float halfex, halfey, halfez;//1/2 閲嶅姏璇樊 + float qa, qb, qc; + + + // Compute feedback only if accelerometer measurement valid (avoids NaN in accelerometer normalisation) + // 鍦ㄧ鍔涜鏁版嵁鏃犳晥鏃朵娇鐢ㄥ叚杞磋瀺鍚堢畻娉 + if(!((ax == 0.0f) && (ay == 0.0f) && (az == 0.0f))) { + + // Normalise accelerometer measurement + recipNorm = invSqrt(ax * ax + ay * ay + az * az); + ax *= recipNorm; + ay *= recipNorm; + az *= recipNorm; + + // Estimated direction of gravity and vector perpendicular to magnetic flux + halfvx = q1 * q3 - q0 * q2; + halfvy = q0 * q1 + q2 * q3; + halfvz = q0 * q0 - 0.5f + q3 * q3; + + // Error is sum of cross product between estimated and measured direction of gravity + halfex = (ay * halfvz - az * halfvy); + halfey = (az * halfvx - ax * halfvz); + halfez = (ax * halfvy - ay * halfvx); + + // Compute and apply integral feedback if enabled + if(twoKi > 0.0f) { + integralFBx += twoKi * halfex * (1.0f / sampleFreq); // integral error scaled by Ki + integralFBy += twoKi * halfey * (1.0f / sampleFreq); + integralFBz += twoKi * halfez * (1.0f / sampleFreq); + gx += integralFBx; // apply integral feedback + gy += integralFBy; + gz += integralFBz; + } + else { + integralFBx = 0.0f; // prevent integral windup + integralFBy = 0.0f; + integralFBz = 0.0f; + } + + // Apply proportional feedback + gx += twoKp * halfex; + gy += twoKp * halfey; + gz += twoKp * halfez; + } + + // Integrate rate of change of quaternion + gx *= (0.5f * (1.0f / sampleFreq)); // pre-multiply common factors + gy *= (0.5f * (1.0f / sampleFreq)); + gz *= (0.5f * (1.0f / sampleFreq)); + qa = q0; + qb = q1; + qc = q2; + q0 += (-qb * gx - qc * gy - q3 * gz); + q1 += (qa * gx + qc * gz - q3 * gy); + q2 += (qa * gy - qb * gz + q3 * gx); + q3 += (qa * gz + qb * gy - qc * gx); + + // Normalise quaternion + recipNorm = invSqrt(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3); + q0 *= recipNorm; + q1 *= recipNorm; + q2 *= recipNorm; + q3 *= recipNorm; +} + +//--------------------------------------------------------------------------------------------------- +// Fast inverse square-root +// See: http://en.wikipedia.org/wiki/Fast_inverse_square_root + +float invSqrt(float x) { + float halfx = 0.5f * x; + float y = x; + long i = *(long*)&y; + i = 0x5f3759df - (i>>1); + y = *(float*)&i; + y = y * (1.5f - (halfx * y * y)); + return y; +} + +//==================================================================================================== +// END OF CODE +//==================================================================================================== diff --git a/Module/MahonyAHRS/MahonyAHRS.h b/Module/MahonyAHRS/MahonyAHRS.h new file mode 100644 index 0000000..a61e75c --- /dev/null +++ b/Module/MahonyAHRS/MahonyAHRS.h @@ -0,0 +1,32 @@ +//===================================================================================================== +// MahonyAHRS.h +//===================================================================================================== +// +// Madgwick's implementation of Mayhony's AHRS algorithm. +// See: http://www.x-io.co.uk/node/8#open_source_ahrs_and_imu_algorithms +// +// Date Author Notes +// 29/09/2011 SOH Madgwick Initial release +// 02/10/2011 SOH Madgwick Optimised for reduced CPU load +// +//===================================================================================================== +#ifndef MahonyAHRS_h +#define MahonyAHRS_h + +//---------------------------------------------------------------------------------------------------- +// Variable declaration + +extern volatile float twoKp; // 2 * proportional gain (Kp) +extern volatile float twoKi; // 2 * integral gain (Ki) +extern volatile float q0, q1, q2, q3; // quaternion of sensor frame relative to auxiliary frame + +//--------------------------------------------------------------------------------------------------- +// Function declarations +float invSqrt(float x); +void MahonyAHRSupdate(float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz); +void MahonyAHRSupdateIMU(float gx, float gy, float gz, float ax, float ay, float az); + +#endif +//===================================================================================================== +// End of file +//===================================================================================================== diff --git a/Module/lsm6dsl/lsm6dsl_app.c b/Module/lsm6dsl/lsm6dsl_app.c new file mode 100644 index 0000000..0317d9d --- /dev/null +++ b/Module/lsm6dsl/lsm6dsl_app.c @@ -0,0 +1,269 @@ + +/* Includes ------------------------------------------------------------------*/ +#include "lsm6dsl_app.h" +#include "lsm6dsl_reg.h" +#include +#include +#include "bsp.h" +#include "UartDebug.h" +#include "main.h" +#include "i2c.h" +#include "Algorithm.h" + +dev_ctx_t dev_ctx; +static bool InitFlag; + +#define ACC_CVTTIME (20 * 1000) +#define ACC_COLL_CNT_MAX 6 +#define ACC_FIFO_WATERMASK (ACC_COLL_CNT_MAX * 6) //采集一秒数据 +#define TX_BUF_DIM 1000 +#define BOOT_TIME 15 //ms + +typedef enum { + Acc_Idle, + Acc_Start, + Acc_Get_Data, + Acc_Wait_GetData, + Acc_Go_Bypass, +}AccStatusType_m; + +static AccStatusType_m acc_status; +static uint32_t acc_cvttime; +static bool Lsm6dslWaterMarkFullIntFlag; +static bool Lsm6dslWakeupIntFlag; + +static int16_t data_raw_acceleration[3]; +static int16_t data_raw_angular_rate[3]; +static int16_t data_raw_temperature; +static float acceleration_mg[3][ACC_COLL_CNT_MAX]; +static float angular_rate_mdps[3][ACC_COLL_CNT_MAX]; +static float temperature_degC; +static uint8_t whoamI, rst; + + +static void platform_delay(uint32_t ms) +{ + delay_ms(ms); +} + + +static void platform_write(uint8_t reg, uint8_t *bufp, uint32_t len) +{ + uint16_t Selve_Add = LSM6DSL_I2C_ADD_L >> 1; + I2C_MasterWriteData(M0P_I2C0, Selve_Add, reg, bufp, len); +} + + +static void platform_read(uint8_t reg, uint8_t *bufp, uint32_t len) +{ + uint16_t Selve_Add = LSM6DSL_I2C_ADD_L >> 1; + I2C_MasterReadData(M0P_I2C0, Selve_Add, reg, bufp, len); +} + +static void Lsm6dsl_Init(void) +{ + /* Initialize mems driver interface */ + dev_ctx.write_reg = platform_write; + dev_ctx.read_reg = platform_read; + dev_ctx.mdelay = platform_delay; + /* Wait sensor boot time */ + platform_delay(BOOT_TIME); + /* Check device ID */ + whoamI = 0; + lsm6dsl_device_id_get(&dev_ctx, &whoamI); + acc_cvttime = 100; + while(whoamI != LSM6DSL_ID){ + if(acc_cvttime <= 0){ + DBG_LOG("LSM6DS INIT Err...\r\n"); /*manage here device not found */ + InitFlag = false; + return; + } + } + + /* Restore default configuration */ + lsm6dsl_reset_set(&dev_ctx, PROPERTY_ENABLE); + + do { + lsm6dsl_reset_get(&dev_ctx, &rst); + } while (rst); + + lsm6dsl_xl_power_mode_set(&dev_ctx, LSM6DSL_XL_NORMAL); + /* Enable Block Data Update */ + lsm6dsl_block_data_update_set(&dev_ctx, PROPERTY_ENABLE); + /* Set Output Data Rate */ + lsm6dsl_xl_data_rate_set(&dev_ctx, LSM6DSL_XL_ODR_12Hz5); + lsm6dsl_gy_data_rate_set(&dev_ctx, LSM6DSL_GY_ODR_12Hz5); + //lsm6dsl_gy_data_rate_set(&left_dev_ctx, LSM6DSL_GY_ODR_OFF); //关闭地磁 + /* Set full scale */ + lsm6dsl_xl_full_scale_set(&dev_ctx, LSM6DSL_2g); + lsm6dsl_gy_full_scale_set(&dev_ctx, LSM6DSL_2000dps); + /* Configure filtering chain(No aux interface) */ + /* Accelerometer - analog filter */ + lsm6dsl_xl_filter_analog_set(&dev_ctx, LSM6DSL_XL_ANA_BW_400Hz); + /* Accelerometer - LPF1 path ( LPF2 not used )*/ + /*lsm6dsl_xl_lp1_bandwidth_set(&left_dev_ctx, LSM6DSL_XL_LP1_ODR_DIV_4);*/ + /* Accelerometer - LPF1 + LPF2 path */ + lsm6dsl_xl_lp2_bandwidth_set(&dev_ctx, LSM6DSL_XL_LOW_NOISE_LP_ODR_DIV_9); + /* Accelerometer - High Pass / Slope path */ + /*lsm6dsl_xl_reference_mode_set(&left_dev_ctx, PROPERTY_DISABLE);*/ + /*lsm6dsl_xl_hp_bandwidth_set(&left_dev_ctx, LSM6DSL_XL_HP_ODR_DIV_100);*/ + /* Gyroscope - filtering chain */ + lsm6dsl_gy_band_pass_set(&dev_ctx, LSM6DSL_HP_260mHz_LP1_STRONG); + + //fifo模式设置 + lsm6dsl_fifo_xl_batch_set(&dev_ctx, LSM6DSL_FIFO_XL_NO_DEC);//fifo加速度写入频率设置 + lsm6dsl_fifo_gy_batch_set(&dev_ctx, LSM6DSL_FIFO_GY_NO_DEC);//fifo陀螺仪写入频率设置 + lsm6dsl_fifo_data_rate_set(&dev_ctx, LSM6DSL_FIFO_12Hz5);//FIFO ODR选择 + + //中断1设置,watermark full中断 + lsm6dsl_int1_route_t int1val ={0, 0, 0}; + int1val.int1_full_flag = 1; //开阀值中断,fifo存储到缓存深度时触发 + lsm6dsl_pin_int1_route_set(&dev_ctx, int1val); + lsm6dsl_fifo_watermark_set(&dev_ctx, ACC_FIFO_WATERMASK);//FIFO水印电平设置,阈值设置,缓存深度 + lsm6dsl_fifo_stop_on_wtm_set(&dev_ctx, 1);//fifo缓存深度存满时,不再存储 + //lsm6dsl_fifo_xl_gy_8bit_format_set(&left_dev_ctx, 1);//在FIFO中为XL和陀螺启用MSByte记忆,缓存宽度 + lsm6dsl_block_data_update_set(&dev_ctx, 1); //fifo模式ctrl3_c bdu必须为1,直到读取MSB和LSB后才更新输出寄存器 + lsm6dsl_auto_increment_set(&dev_ctx, 1); //fifo模式ctrl3_c if_inc必须为1,通过串行接口(I2C或SPI)进行多字节访问时自动增加寄存器地址。 + lsm6dsl_ctrl3_c_t ctrl3_c; + platform_read(LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + //lsm6dsl_fifo_mode_set(&dev_ctx, LSM6DSL_FIFO_MODE); + + //中断2设置,唤醒中断 +// uint8_t temp = 0x90; //唤醒中断 +// platform_write(LSM6DSL_TAP_CFG, &temp, 1); +// temp = 0; +// platform_write(LSM6DSL_WAKE_UP_DUR, &temp, 1); +// lsm6dsl_wkup_threshold_set(&left_dev_ctx, 0x20); +// lsm6dsl_int2_route_t int2val ={0, 0, 0}; +// int2val.int2_wu = 1; +// lsm6dsl_pin_int2_route_set(&left_dev_ctx, int2val); + + if(InitFlag == false){ + DBG_LOG("LSM6DS INIT OK...\r\n"); + InitFlag = true; + } +} + +extern void Lsm6dDataProcessCallBack(float *Acc, float *Gy); +static void Acc_IntHandler(void) +{ + uint16_t DiffFifo; + AccGyData_t AccGy; + AccData_t Acc; + float VectorG; + float AverageAcc[XYZ], AverageGy[XYZ]; + + lsm6dsl_fifo_data_level_get(&dev_ctx, &DiffFifo); + if(DiffFifo == 0) { + return; + } + + if(DiffFifo > ACC_FIFO_WATERMASK) + DiffFifo = ACC_FIFO_WATERMASK; + for(int i = 0; i < DiffFifo / 6; i++) { + lsm6dsl_fifo_raw_data_get(&dev_ctx, (uint8_t *)&AccGy, sizeof(AccGy)); + angular_rate_mdps[X][i] = lsm6dsl_from_fs2000dps_to_mdps(AccGy.GyX); + angular_rate_mdps[Y][i] = lsm6dsl_from_fs2000dps_to_mdps(AccGy.GyY); + angular_rate_mdps[Z][i] = lsm6dsl_from_fs2000dps_to_mdps(AccGy.GyZ); + acceleration_mg[X][i] = lsm6dsl_from_fs2g_to_mg(AccGy.AccX); + acceleration_mg[Y][i] = lsm6dsl_from_fs2g_to_mg(AccGy.AccY); + acceleration_mg[Z][i] = lsm6dsl_from_fs2g_to_mg(AccGy.AccZ); + } + AverageGy[X] = IntFilter_Float(angular_rate_mdps[0], DiffFifo / 6, 2); + AverageGy[Y] = IntFilter_Float(angular_rate_mdps[1], DiffFifo / 6, 2); + AverageGy[Z] = IntFilter_Float(angular_rate_mdps[2], DiffFifo / 6, 2); + AverageAcc[X] = IntFilter_Float(acceleration_mg[0], DiffFifo / 6, 2); + AverageAcc[Y] = IntFilter_Float(acceleration_mg[1], DiffFifo / 6, 2); + AverageAcc[Z] = IntFilter_Float(acceleration_mg[2], DiffFifo / 6, 2); + Lsm6dDataProcessCallBack(AverageAcc, AverageGy); + + acc_status = Acc_Go_Bypass; +} + +static void ReadWakeUpIntStatus(void) +{ + lsm6dsl_wake_up_src_t wake_up_src; + if(Lsm6dslWakeupIntFlag) { + Lsm6dslWakeupIntFlag = false; + platform_read(LSM6DSL_WAKE_UP_SRC, (uint8_t *)&wake_up_src, sizeof(lsm6dsl_wake_up_src_t)); + } +} + +void Lsm6dslLoopHandler(void) +{ + ReadWakeUpIntStatus(); + switch(acc_status) + { + case Acc_Idle: + break; + + case Acc_Start: + if(acc_cvttime > 0) + break; + lsm6dsl_fifo_mode_set(&dev_ctx, LSM6DSL_FIFO_MODE); + acc_status = Acc_Get_Data; + acc_cvttime = ACC_CVTTIME; + break; + + case Acc_Get_Data: + acc_cvttime = 1000; + acc_status = Acc_Wait_GetData; + break; + + case Acc_Wait_GetData: + if(acc_cvttime <= 0){ + acc_status = Acc_Go_Bypass; + } + else if(Lsm6dslWaterMarkFullIntFlag) { + Lsm6dslWaterMarkFullIntFlag = false; + uint8_t wtm_flag; + lsm6dsl_fifo_wtm_flag_get(&dev_ctx, &wtm_flag); + Acc_IntHandler(); + acc_status = Acc_Go_Bypass; + } + break; + + case Acc_Go_Bypass: + lsm6dsl_fifo_mode_set(&dev_ctx, LSM6DSL_BYPASS_MODE); + Lsm6dsStop(); + acc_status = Acc_Idle; + acc_cvttime = 1; + break; + } +} + +void Lsm6dsl1mSRoutine(void) +{ + if(acc_cvttime > 0) + acc_cvttime--; +} + +void Lsm6dslInit(void) +{ + Lsm6dsl_Init(); +} + +void Lsm6dsStart(void) +{ + Lsm6dsl_Init(); + acc_status = Acc_Start; +} + +void Lsm6dsStop(void) +{ + lsm6dsl_xl_data_rate_set(&dev_ctx, LSM6DSL_XL_ODR_OFF); + lsm6dsl_gy_data_rate_set(&dev_ctx, LSM6DSL_GY_ODR_OFF); + lsm6dsl_fifo_data_rate_set(&dev_ctx, LSM6DSL_FIFO_DISABLE); + acc_status = Acc_Idle; +} + +void Lsm6dsInt1CallBack(void) +{ + Lsm6dslWaterMarkFullIntFlag = true; +} + +void Lsm6dsInt2CallBack(void) +{ + Lsm6dslWakeupIntFlag = true; + //Tilt.Acc_IRQ_Status = true; +} diff --git a/Module/lsm6dsl/lsm6dsl_app.h b/Module/lsm6dsl/lsm6dsl_app.h new file mode 100644 index 0000000..2143093 --- /dev/null +++ b/Module/lsm6dsl/lsm6dsl_app.h @@ -0,0 +1,36 @@ +#ifndef __LSM6DSL_APP_H__ +#define __LSM6DSL_APP_H__ + +#include "bsp.h" + +#define X 0 +#define Y 1 +#define Z 2 +#define XYZ 3 + +typedef struct { + uint16_t GyX; + uint16_t GyY; + uint16_t GyZ; + uint16_t AccX; + uint16_t AccY; + uint16_t AccZ; +}AccGyData_t; + +typedef struct { + uint16_t AccX; + uint16_t AccY; + uint16_t AccZ; +}AccData_t; + +void Lsm6dslInit(void); +void Lsm6dslLoopHandler(void); +void Lsm6dsl1mSRoutine(void); +void Lsm6dsStart(void); +void Lsm6dsStop(void); +void Lsm6dsInt1CallBack(void); +void Lsm6dsInt2CallBack(void); +#endif + + + diff --git a/Module/lsm6dsl/lsm6dsl_reg.c b/Module/lsm6dsl/lsm6dsl_reg.c new file mode 100644 index 0000000..de0745a --- /dev/null +++ b/Module/lsm6dsl/lsm6dsl_reg.c @@ -0,0 +1,7948 @@ +/** + ****************************************************************************** + * @file lsm6dsl_reg.c + * @author Sensors Software Solution Team + * @brief LSM6DSL driver file + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +#include "lsm6dsl_reg.h" + +/** + * @defgroup LSM6DSL + * @brief This file provides a set of functions needed to drive the + * lsm6dsl enanced inertial module. + * @{ + * + */ + +/** + * @defgroup LSM6DSL_interfaces_functions + * @brief This section provide a set of functions used to read and + * write a generic register of the device. + * MANDATORY: return 0 -> no Error. + * @{ + * + */ + +/** + * @brief Read generic device register + * + * @param ctx read / write interface definitions(ptr) + * @param reg register to read + * @param data pointer to buffer that store the data read(ptr) + * @param len number of consecutive register to read + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t __weak lsm6dsl_read_reg(dev_ctx_t *ctx, uint8_t reg, + uint8_t *data, + uint16_t len) +{ + //int32_t ret; + + ctx->read_reg(reg, data, len); + + return 0; +} + +/** + * @brief Write generic device register + * + * @param ctx read / write interface definitions(ptr) + * @param reg register to write + * @param data pointer to data to write in register reg(ptr) + * @param len number of consecutive register to write + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t __weak lsm6dsl_write_reg(dev_ctx_t *ctx, uint8_t reg, + uint8_t *data, + uint16_t len) +{ + //int32_t ret; + + ctx->write_reg(reg, data, len); + + return 0; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_Sensitivity + * @brief These functions convert raw-data into engineering units. + * @{ + * + */ + +float_t lsm6dsl_from_fs2g_to_mg(int16_t lsb) +{ + return ((float_t)lsb * 0.061f); +} + +float_t lsm6dsl_from_fs4g_to_mg(int16_t lsb) +{ + return ((float_t)lsb * 0.122f); +} + +float_t lsm6dsl_from_fs8g_to_mg(int16_t lsb) +{ + return ((float_t)lsb * 0.244f); +} + +float_t lsm6dsl_from_fs16g_to_mg(int16_t lsb) +{ + return ((float_t)lsb * 0.488f); +} + +float_t lsm6dsl_from_fs125dps_to_mdps(int16_t lsb) +{ + return ((float_t)lsb * 4.375f); +} + +float_t lsm6dsl_from_fs250dps_to_mdps(int16_t lsb) +{ + return ((float_t)lsb * 8.750f); +} + +float_t lsm6dsl_from_fs500dps_to_mdps(int16_t lsb) +{ + return ((float_t)lsb * 17.50f); +} + +float_t lsm6dsl_from_fs1000dps_to_mdps(int16_t lsb) +{ + return ((float_t)lsb * 35.0f); +} + +float_t lsm6dsl_from_fs2000dps_to_mdps(int16_t lsb) +{ + return ((float_t)lsb * 70.0f); +} + +float_t lsm6dsl_from_lsb_to_celsius(int16_t lsb) +{ + return (((float_t)lsb / 256.0f) + 25.0f); +} + +/** + * @} + * + */ + + +/** + * @defgroup LSM6DSL_data_generation + * @brief This section groups all the functions concerning data + * generation + * @{ + * + */ + +/** + * @brief Accelerometer full-scale selection.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of fs_xl in reg CTRL1_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_full_scale_set(dev_ctx_t *ctx, + lsm6dsl_fs_xl_t val) +{ + lsm6dsl_ctrl1_xl_t ctrl1_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1); + + if (ret == 0) + { + ctrl1_xl.fs_xl = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1); + } + + return ret; +} + +/** + * @brief Accelerometer full-scale selection.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of fs_xl in reg CTRL1_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_full_scale_get(dev_ctx_t *ctx, + lsm6dsl_fs_xl_t *val) +{ + lsm6dsl_ctrl1_xl_t ctrl1_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1); + + switch (ctrl1_xl.fs_xl) + { + case LSM6DSL_2g: + *val = LSM6DSL_2g; + break; + + case LSM6DSL_16g: + *val = LSM6DSL_16g; + break; + + case LSM6DSL_4g: + *val = LSM6DSL_4g; + break; + + case LSM6DSL_8g: + *val = LSM6DSL_8g; + break; + + default: + *val = LSM6DSL_XL_FS_ND; + break; + } + + return ret; +} + +/** + * @brief Accelerometer data rate selection.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of odr_xl in reg CTRL1_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_data_rate_set(dev_ctx_t *ctx, + lsm6dsl_odr_xl_t val) +{ + lsm6dsl_ctrl1_xl_t ctrl1_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1); + + if (ret == 0) + { + ctrl1_xl.odr_xl = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1); + } + + return ret; +} + +/** + * @brief Accelerometer data rate selection.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of odr_xl in reg CTRL1_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_data_rate_get(dev_ctx_t *ctx, + lsm6dsl_odr_xl_t *val) +{ + lsm6dsl_ctrl1_xl_t ctrl1_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1); + + switch (ctrl1_xl.odr_xl) + { + case LSM6DSL_XL_ODR_OFF: + *val = LSM6DSL_XL_ODR_OFF; + break; + + case LSM6DSL_XL_ODR_12Hz5: + *val = LSM6DSL_XL_ODR_12Hz5; + break; + + case LSM6DSL_XL_ODR_26Hz: + *val = LSM6DSL_XL_ODR_26Hz; + break; + + case LSM6DSL_XL_ODR_52Hz: + *val = LSM6DSL_XL_ODR_52Hz; + break; + + case LSM6DSL_XL_ODR_104Hz: + *val = LSM6DSL_XL_ODR_104Hz; + break; + + case LSM6DSL_XL_ODR_208Hz: + *val = LSM6DSL_XL_ODR_208Hz; + break; + + case LSM6DSL_XL_ODR_416Hz: + *val = LSM6DSL_XL_ODR_416Hz; + break; + + case LSM6DSL_XL_ODR_833Hz: + *val = LSM6DSL_XL_ODR_833Hz; + break; + + case LSM6DSL_XL_ODR_1k66Hz: + *val = LSM6DSL_XL_ODR_1k66Hz; + break; + + case LSM6DSL_XL_ODR_3k33Hz: + *val = LSM6DSL_XL_ODR_3k33Hz; + break; + + case LSM6DSL_XL_ODR_6k66Hz: + *val = LSM6DSL_XL_ODR_6k66Hz; + break; + + case LSM6DSL_XL_ODR_1Hz6: + *val = LSM6DSL_XL_ODR_1Hz6; + break; + + default: + *val = LSM6DSL_XL_ODR_ND; + break; + } + + return ret; +} + +/** + * @brief Gyroscope chain full-scale selection.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of fs_g in reg CTRL2_G + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_gy_full_scale_set(dev_ctx_t *ctx, + lsm6dsl_fs_g_t val) +{ + lsm6dsl_ctrl2_g_t ctrl2_g; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL2_G, (uint8_t *)&ctrl2_g, 1); + + if (ret == 0) + { + ctrl2_g.fs_g = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL2_G, (uint8_t *)&ctrl2_g, 1); + } + + return ret; +} + +/** + * @brief Gyroscope chain full-scale selection.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of fs_g in reg CTRL2_G + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_gy_full_scale_get(dev_ctx_t *ctx, + lsm6dsl_fs_g_t *val) +{ + lsm6dsl_ctrl2_g_t ctrl2_g; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL2_G, (uint8_t *)&ctrl2_g, 1); + + switch (ctrl2_g.fs_g) + { + case LSM6DSL_250dps: + *val = LSM6DSL_250dps; + break; + + case LSM6DSL_125dps: + *val = LSM6DSL_125dps; + break; + + case LSM6DSL_500dps: + *val = LSM6DSL_500dps; + break; + + case LSM6DSL_1000dps: + *val = LSM6DSL_1000dps; + break; + + case LSM6DSL_2000dps: + *val = LSM6DSL_2000dps; + break; + + default: + *val = LSM6DSL_GY_FS_ND; + break; + } + + return ret; +} + +/** + * @brief Gyroscope data rate selection.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of odr_g in reg CTRL2_G + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_gy_data_rate_set(dev_ctx_t *ctx, + lsm6dsl_odr_g_t val) +{ + lsm6dsl_ctrl2_g_t ctrl2_g; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL2_G, (uint8_t *)&ctrl2_g, 1); + + if (ret == 0) + { + ctrl2_g.odr_g = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL2_G, (uint8_t *)&ctrl2_g, 1); + } + + return ret; +} + +/** + * @brief Gyroscope data rate selection.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of odr_g in reg CTRL2_G + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_gy_data_rate_get(dev_ctx_t *ctx, + lsm6dsl_odr_g_t *val) +{ + lsm6dsl_ctrl2_g_t ctrl2_g; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL2_G, (uint8_t *)&ctrl2_g, 1); + + switch (ctrl2_g.odr_g) + { + case LSM6DSL_GY_ODR_OFF: + *val = LSM6DSL_GY_ODR_OFF; + break; + + case LSM6DSL_GY_ODR_12Hz5: + *val = LSM6DSL_GY_ODR_12Hz5; + break; + + case LSM6DSL_GY_ODR_26Hz: + *val = LSM6DSL_GY_ODR_26Hz; + break; + + case LSM6DSL_GY_ODR_52Hz: + *val = LSM6DSL_GY_ODR_52Hz; + break; + + case LSM6DSL_GY_ODR_104Hz: + *val = LSM6DSL_GY_ODR_104Hz; + break; + + case LSM6DSL_GY_ODR_208Hz: + *val = LSM6DSL_GY_ODR_208Hz; + break; + + case LSM6DSL_GY_ODR_416Hz: + *val = LSM6DSL_GY_ODR_416Hz; + break; + + case LSM6DSL_GY_ODR_833Hz: + *val = LSM6DSL_GY_ODR_833Hz; + break; + + case LSM6DSL_GY_ODR_1k66Hz: + *val = LSM6DSL_GY_ODR_1k66Hz; + break; + + case LSM6DSL_GY_ODR_3k33Hz: + *val = LSM6DSL_GY_ODR_3k33Hz; + break; + + case LSM6DSL_GY_ODR_6k66Hz: + *val = LSM6DSL_GY_ODR_6k66Hz; + break; + + default: + *val = LSM6DSL_GY_ODR_ND; + break; + } + + return ret; +} + +/** + * @brief Block data update.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of bdu in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_block_data_update_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + + if (ret == 0) + { + ctrl3_c.bdu = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + } + + return ret; +} + +/** + * @brief Block data update.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of bdu in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_block_data_update_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + *val = ctrl3_c.bdu; + + return ret; +} + +/** + * @brief Weight of XL user offset bits of registers + * X_OFS_USR(73h), Y_OFS_USR(74h), Z_OFS_USR(75h).[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of usr_off_w in reg CTRL6_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_offset_weight_set(dev_ctx_t *ctx, + lsm6dsl_usr_off_w_t val) +{ + lsm6dsl_ctrl6_c_t ctrl6_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL6_C, (uint8_t *)&ctrl6_c, 1); + + if (ret == 0) + { + ctrl6_c.usr_off_w = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL6_C, (uint8_t *)&ctrl6_c, 1); + } + + return ret; +} + +/** + * @brief Weight of XL user offset bits of registers + * X_OFS_USR(73h), Y_OFS_USR(74h), Z_OFS_USR(75h).[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of usr_off_w in reg CTRL6_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_offset_weight_get(dev_ctx_t *ctx, + lsm6dsl_usr_off_w_t *val) +{ + lsm6dsl_ctrl6_c_t ctrl6_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL6_C, (uint8_t *)&ctrl6_c, 1); + + switch (ctrl6_c.usr_off_w) + { + case LSM6DSL_LSb_1mg: + *val = LSM6DSL_LSb_1mg; + break; + + case LSM6DSL_LSb_16mg: + *val = LSM6DSL_LSb_16mg; + break; + + default: + *val = LSM6DSL_WEIGHT_ND; + break; + } + + return ret; +} + +/** + * @brief High-performance operating mode for accelerometer[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of xl_hm_mode in reg CTRL6_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_power_mode_set(dev_ctx_t *ctx, + lsm6dsl_xl_hm_mode_t val) +{ + lsm6dsl_ctrl6_c_t ctrl6_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL6_C, (uint8_t *)&ctrl6_c, 1); + + if (ret == 0) + { + ctrl6_c.xl_hm_mode = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL6_C, (uint8_t *)&ctrl6_c, 1); + } + + return ret; +} + +/** + * @brief High-performance operating mode for accelerometer.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of xl_hm_mode in reg CTRL6_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_power_mode_get(dev_ctx_t *ctx, + lsm6dsl_xl_hm_mode_t *val) +{ + lsm6dsl_ctrl6_c_t ctrl6_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL6_C, (uint8_t *)&ctrl6_c, 1); + + switch (ctrl6_c.xl_hm_mode) + { + case LSM6DSL_XL_HIGH_PERFORMANCE: + *val = LSM6DSL_XL_HIGH_PERFORMANCE; + break; + + case LSM6DSL_XL_NORMAL: + *val = LSM6DSL_XL_NORMAL; + break; + + default: + *val = LSM6DSL_XL_PW_MODE_ND; + break; + } + + return ret; +} + +/** + * @brief Source register rounding function on WAKE_UP_SRC (1Bh), + * TAP_SRC (1Ch), D6D_SRC (1Dh), STATUS_REG (1Eh) and + * FUNC_SRC1 (53h) registers in the primary interface.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of rounding_status in reg CTRL7_G + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_rounding_on_status_set(dev_ctx_t *ctx, + lsm6dsl_rounding_status_t val) +{ + lsm6dsl_ctrl7_g_t ctrl7_g; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL7_G, (uint8_t *)&ctrl7_g, 1); + + if (ret == 0) + { + ctrl7_g.rounding_status = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL7_G, (uint8_t *)&ctrl7_g, 1); + } + + return ret; +} + +/** + * @brief Source register rounding function on WAKE_UP_SRC (1Bh), + * TAP_SRC (1Ch), D6D_SRC (1Dh), STATUS_REG (1Eh) and + * FUNC_SRC1 (53h) registers in the primary interface.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of rounding_status in reg CTRL7_G + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_rounding_on_status_get(dev_ctx_t *ctx, + lsm6dsl_rounding_status_t *val) +{ + lsm6dsl_ctrl7_g_t ctrl7_g; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL7_G, (uint8_t *)&ctrl7_g, 1); + + switch (ctrl7_g.rounding_status) + { + case LSM6DSL_STAT_RND_DISABLE: + *val = LSM6DSL_STAT_RND_DISABLE; + break; + + case LSM6DSL_STAT_RND_ENABLE: + *val = LSM6DSL_STAT_RND_ENABLE; + break; + + default: + *val = LSM6DSL_STAT_RND_ND; + break; + } + + return ret; +} + +/** + * @brief High-performance operating mode disable for gyroscope.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of g_hm_mode in reg CTRL7_G + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_gy_power_mode_set(dev_ctx_t *ctx, + lsm6dsl_g_hm_mode_t val) +{ + lsm6dsl_ctrl7_g_t ctrl7_g; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL7_G, (uint8_t *)&ctrl7_g, 1); + + if (ret == 0) + { + ctrl7_g.g_hm_mode = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL7_G, (uint8_t *)&ctrl7_g, 1); + } + + return ret; +} + +/** + * @brief High-performance operating mode disable for gyroscope.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of g_hm_mode in reg CTRL7_G + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_gy_power_mode_get(dev_ctx_t *ctx, + lsm6dsl_g_hm_mode_t *val) +{ + lsm6dsl_ctrl7_g_t ctrl7_g; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL7_G, (uint8_t *)&ctrl7_g, 1); + + switch (ctrl7_g.g_hm_mode) + { + case LSM6DSL_GY_HIGH_PERFORMANCE: + *val = LSM6DSL_GY_HIGH_PERFORMANCE; + break; + + case LSM6DSL_GY_NORMAL: + *val = LSM6DSL_GY_NORMAL; + break; + + default: + *val = LSM6DSL_GY_PW_MODE_ND; + break; + } + + return ret; +} + +/** + * @brief Read all the interrupt/status flag of the device.[get] + * + * @param ctx Read / write interface definitions + * @param val WAKE_UP_SRC, TAP_SRC, D6D_SRC, STATUS_REG, + * FUNC_SRC1, FUNC_SRC2, WRIST_TILT_IA, A_WRIST_TILT_Mask + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_all_sources_get(dev_ctx_t *ctx, + lsm6dsl_all_sources_t *val) +{ + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WAKE_UP_SRC, + (uint8_t *) & (val->wake_up_src), 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_SRC, + (uint8_t *) & (val->tap_src), 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_D6D_SRC, + (uint8_t *) & (val->d6d_src), 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_STATUS_REG, + (uint8_t *) & (val->status_reg), 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FUNC_SRC1, + (uint8_t *) & (val->func_src1), 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FUNC_SRC2, + (uint8_t *) & (val->func_src2), 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WRIST_TILT_IA, + (uint8_t *) & (val->wrist_tilt_ia), 1); + } + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_B); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_A_WRIST_TILT_MASK, + (uint8_t *) & (val->a_wrist_tilt_mask), 1); + } + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + + return ret; +} +/** + * @brief The STATUS_REG register is read by the primary interface[get] + * + * @param ctx Read / write interface definitions + * @param val Registers STATUS_REG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_status_reg_get(dev_ctx_t *ctx, + lsm6dsl_status_reg_t *val) +{ + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_STATUS_REG, (uint8_t *) val, 1); + + return ret; +} + +/** + * @brief Accelerometer new data available.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of xlda in reg STATUS_REG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_flag_data_ready_get(dev_ctx_t *ctx, + uint8_t *val) +{ + lsm6dsl_status_reg_t status_reg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_STATUS_REG, + (uint8_t *)&status_reg, 1); + *val = status_reg.xlda; + + return ret; +} + +/** + * @brief Gyroscope new data available.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of gda in reg STATUS_REG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_gy_flag_data_ready_get(dev_ctx_t *ctx, + uint8_t *val) +{ + lsm6dsl_status_reg_t status_reg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_STATUS_REG, + (uint8_t *)&status_reg, 1); + *val = status_reg.gda; + + return ret; +} + +/** + * @brief Temperature new data available.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tda in reg STATUS_REG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_temp_flag_data_ready_get(dev_ctx_t *ctx, + uint8_t *val) +{ + lsm6dsl_status_reg_t status_reg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_STATUS_REG, + (uint8_t *)&status_reg, 1); + *val = status_reg.tda; + + return ret; +} + +/** + * @brief Accelerometer axis user offset correction expressed in two鈥檚 + * complement, weight depends on USR_OFF_W in CTRL6_C. + * The value must be in the range [-127 127].[set] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that contains data to write + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_usr_offset_set(dev_ctx_t *ctx, uint8_t *buff) +{ + int32_t ret; + + ret = lsm6dsl_write_reg(ctx, LSM6DSL_X_OFS_USR, buff, 3); + + return ret; +} + +/** + * @brief Accelerometer axis user offset correction xpressed in two鈥檚 + * complement, weight depends on USR_OFF_W in CTRL6_C. + * The value must be in the range [-127 127].[get] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that stores data read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_usr_offset_get(dev_ctx_t *ctx, uint8_t *buff) +{ + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_X_OFS_USR, buff, 3); + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_Timestamp + * @brief This section groups all the functions that manage the + * timestamp generation. + * @{ + * + */ + +/** + * @brief Enable timestamp count. The count is saved in TIMESTAMP0_REG (40h), + * TIMESTAMP1_REG (41h) and TIMESTAMP2_REG (42h).[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of timer_en in reg CTRL10_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_timestamp_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + + if (ret == 0) + { + ctrl10_c.timer_en = val; + + if (val != 0x00U) + { + ctrl10_c.func_en = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + } + } + + return ret; +} + +/** + * @brief Enable timestamp count. The count is saved in TIMESTAMP0_REG (40h), + * TIMESTAMP1_REG (41h) and TIMESTAMP2_REG (42h).[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of timer_en in reg CTRL10_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_timestamp_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + *val = ctrl10_c.timer_en; + + return ret; +} + +/** + * @brief Timestamp register resolution setting. + * Configuration of this bit affects + * TIMESTAMP0_REG(40h), TIMESTAMP1_REG(41h), + * TIMESTAMP2_REG(42h), STEP_TIMESTAMP_L(49h), + * STEP_TIMESTAMP_H(4Ah) and + * STEP_COUNT_DELTA(15h) registers.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of timer_hr in reg WAKE_UP_DUR + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_timestamp_res_set(dev_ctx_t *ctx, + lsm6dsl_timer_hr_t val) +{ + lsm6dsl_wake_up_dur_t wake_up_dur; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WAKE_UP_DUR, + (uint8_t *)&wake_up_dur, 1); + + if (ret == 0) + { + wake_up_dur.timer_hr = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_WAKE_UP_DUR, + (uint8_t *)&wake_up_dur, 1); + } + + return ret; +} + +/** + * @brief Timestamp register resolution setting. + * Configuration of this bit affects + * TIMESTAMP0_REG(40h), TIMESTAMP1_REG(41h), + * TIMESTAMP2_REG(42h), STEP_TIMESTAMP_L(49h), + * STEP_TIMESTAMP_H(4Ah) and + * STEP_COUNT_DELTA(15h) registers.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of timer_hr in reg WAKE_UP_DUR + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_timestamp_res_get(dev_ctx_t *ctx, + lsm6dsl_timer_hr_t *val) +{ + lsm6dsl_wake_up_dur_t wake_up_dur; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WAKE_UP_DUR, + (uint8_t *)&wake_up_dur, 1); + + switch (wake_up_dur.timer_hr) + { + case LSM6DSL_LSB_6ms4: + *val = LSM6DSL_LSB_6ms4; + break; + + case LSM6DSL_LSB_25us: + *val = LSM6DSL_LSB_25us; + break; + + default: + *val = LSM6DSL_TS_RES_ND; + break; + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_Dataoutput + * @brief This section groups all the data output functions. + * @{ + * + */ + +/** + * @brief Circular burst-mode (rounding) read from output registers + * through the primary interface.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of rounding in reg CTRL5_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_rounding_mode_set(dev_ctx_t *ctx, + lsm6dsl_rounding_t val) +{ + lsm6dsl_ctrl5_c_t ctrl5_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t *)&ctrl5_c, 1); + + if (ret == 0) + { + ctrl5_c.rounding = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t *)&ctrl5_c, 1); + } + + return ret; +} + +/** + * @brief Circular burst-mode (rounding) read from output registers + * through the primary interface.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of rounding in reg CTRL5_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_rounding_mode_get(dev_ctx_t *ctx, + lsm6dsl_rounding_t *val) +{ + lsm6dsl_ctrl5_c_t ctrl5_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t *)&ctrl5_c, 1); + + switch (ctrl5_c.rounding) + { + case LSM6DSL_ROUND_DISABLE: + *val = LSM6DSL_ROUND_DISABLE; + break; + + case LSM6DSL_ROUND_XL: + *val = LSM6DSL_ROUND_XL; + break; + + case LSM6DSL_ROUND_GY: + *val = LSM6DSL_ROUND_GY; + break; + + case LSM6DSL_ROUND_GY_XL: + *val = LSM6DSL_ROUND_GY_XL; + break; + + case LSM6DSL_ROUND_SH1_TO_SH6: + *val = LSM6DSL_ROUND_SH1_TO_SH6; + break; + + case LSM6DSL_ROUND_XL_SH1_TO_SH6: + *val = LSM6DSL_ROUND_XL_SH1_TO_SH6; + break; + + case LSM6DSL_ROUND_GY_XL_SH1_TO_SH12: + *val = LSM6DSL_ROUND_GY_XL_SH1_TO_SH12; + break; + + case LSM6DSL_ROUND_GY_XL_SH1_TO_SH6: + *val = LSM6DSL_ROUND_GY_XL_SH1_TO_SH6; + break; + + default: + *val = LSM6DSL_ROUND_OUT_ND; + break; + } + + return ret; +} + +/** + * @brief Temperature data output register (r). L and H registers together + * express a 16-bit word in two鈥檚 complement.[get] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that stores data read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_temperature_raw_get(dev_ctx_t *ctx, int16_t *val) +{ + uint8_t buff[2]; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_OUT_TEMP_L, buff, 2); + val[0] = (int16_t)buff[1]; + val[0] = (val[0] * 256) + (int16_t)buff[0]; + + return ret; +} + +/** + * @brief Angular rate sensor. The value is expressed as a 16-bit word in + * two鈥檚 complement.[get] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that stores data read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_angular_rate_raw_get(dev_ctx_t *ctx, int16_t *val) +{ + uint8_t buff[6]; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_OUTX_L_G, buff, 6); + val[0] = (int16_t)buff[1]; + val[0] = (val[0] * 256) + (int16_t)buff[0]; + val[1] = (int16_t)buff[3]; + val[1] = (val[1] * 256) + (int16_t)buff[2]; + val[2] = (int16_t)buff[5]; + val[2] = (val[2] * 256) + (int16_t)buff[4]; + + return ret; +} + +/** + * @brief Linear acceleration output register. The value is expressed + * as a 16-bit word in two鈥檚 complement.[get] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that stores data read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_acceleration_raw_get(dev_ctx_t *ctx, int16_t *val) +{ + uint8_t buff[6]; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_OUTX_L_XL, buff, 6); + val[0] = (int16_t)buff[1]; + val[0] = (val[0] * 256) + (int16_t)buff[0]; + val[1] = (int16_t)buff[3]; + val[1] = (val[1] * 256) + (int16_t)buff[2]; + val[2] = (int16_t)buff[5]; + val[2] = (val[2] * 256) + (int16_t)buff[4]; + + return ret; +} + +/** + * @brief External magnetometer raw data.[get] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that stores data read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_mag_calibrated_raw_get(dev_ctx_t *ctx, + int16_t *val) +{ + uint8_t buff[6]; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_OUT_MAG_RAW_X_L, buff, 6); + val[0] = (int16_t)buff[1]; + val[0] = (val[0] * 256) + (int16_t)buff[0]; + val[1] = (int16_t)buff[3]; + val[1] = (val[1] * 256) + (int16_t)buff[2]; + val[2] = (int16_t)buff[5]; + val[2] = (val[2] * 256) + (int16_t)buff[4]; + + return ret; +} + +/** + * @brief Read data in FIFO.[get] + * + * @param ctx Read / write interface definitions + * @param buffer Data buffer to store FIFO data. + * @param len Number of data to read from FIFO. + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_raw_data_get(dev_ctx_t *ctx, uint8_t *buffer, + uint8_t len) +{ + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_DATA_OUT_L, buffer, len); + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_common + * @brief This section groups common useful functions. + * @{ + * + */ + +/** + * @brief Enable access to the embedded functions/sensor hub + * configuration registers[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of func_cfg_en in reg FUNC_CFG_ACCESS + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_mem_bank_set(dev_ctx_t *ctx, + lsm6dsl_func_cfg_en_t val) +{ + lsm6dsl_func_cfg_access_t func_cfg_access; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FUNC_CFG_ACCESS, + (uint8_t *)&func_cfg_access, 1); + + if (ret == 0) + { + func_cfg_access.func_cfg_en = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FUNC_CFG_ACCESS, + (uint8_t *)&func_cfg_access, 1); + } + + return ret; +} + +/** + * @brief Enable access to the embedded functions/sensor hub configuration + * registers[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of func_cfg_en in reg FUNC_CFG_ACCESS + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_mem_bank_get(dev_ctx_t *ctx, + lsm6dsl_func_cfg_en_t *val) +{ + lsm6dsl_func_cfg_access_t func_cfg_access; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FUNC_CFG_ACCESS, + (uint8_t *)&func_cfg_access, 1); + + switch (func_cfg_access.func_cfg_en) + { + case LSM6DSL_USER_BANK: + *val = LSM6DSL_USER_BANK; + break; + + case LSM6DSL_BANK_B: + *val = LSM6DSL_BANK_B; + break; + + default: + *val = LSM6DSL_BANK_ND; + break; + } + + return ret; +} + +/** + * @brief Data-ready pulsed / letched mode[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of drdy_pulsed in reg DRDY_PULSE_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_data_ready_mode_set(dev_ctx_t *ctx, + lsm6dsl_drdy_pulsed_g_t val) +{ + lsm6dsl_drdy_pulse_cfg_g_t drdy_pulse_cfg_g; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_DRDY_PULSE_CFG_G, + (uint8_t *)&drdy_pulse_cfg_g, 1); + + if (ret == 0) + { + drdy_pulse_cfg_g.drdy_pulsed = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_DRDY_PULSE_CFG_G, + (uint8_t *)&drdy_pulse_cfg_g, 1); + } + + return ret; +} + +/** + * @brief Data-ready pulsed / letched mode[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of drdy_pulsed in reg DRDY_PULSE_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_data_ready_mode_get(dev_ctx_t *ctx, + lsm6dsl_drdy_pulsed_g_t *val) +{ + lsm6dsl_drdy_pulse_cfg_g_t drdy_pulse_cfg_g; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_DRDY_PULSE_CFG_G, + (uint8_t *)&drdy_pulse_cfg_g, 1); + + switch (drdy_pulse_cfg_g.drdy_pulsed) + { + case LSM6DSL_DRDY_LATCHED: + *val = LSM6DSL_DRDY_LATCHED; + break; + + case LSM6DSL_DRDY_PULSED: + *val = LSM6DSL_DRDY_PULSED; + break; + + default: + *val = LSM6DSL_DRDY_ND; + break; + } + + return ret; +} + +/** + * @brief DeviceWhoamI.[get] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that stores data read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_device_id_get(dev_ctx_t *ctx, uint8_t *buff) +{ + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WHO_AM_I, buff, 1); + + return ret; +} + +/** + * @brief Software reset. Restore the default values in user registers[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of sw_reset in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_reset_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + + if (ret == 0) + { + ctrl3_c.sw_reset = val; + ret = lsm6dsl_write_reg(ctx, 0x12, (uint8_t *)&ctrl3_c, 1); + } + + return ret; +} + +/** + * @brief Software reset. Restore the default values in user registers[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of sw_reset in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_reset_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + *val = ctrl3_c.sw_reset; + + return ret; +} + +/** + * @brief Big/Little Endian Data selection.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of ble in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_data_format_set(dev_ctx_t *ctx, lsm6dsl_ble_t val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + + if (ret == 0) + { + ctrl3_c.ble = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + } + + return ret; +} + +/** + * @brief Big/Little Endian Data selection.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of ble in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_data_format_get(dev_ctx_t *ctx, lsm6dsl_ble_t *val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + + switch (ctrl3_c.ble) + { + case LSM6DSL_LSB_AT_LOW_ADD: + *val = LSM6DSL_LSB_AT_LOW_ADD; + break; + + case LSM6DSL_MSB_AT_LOW_ADD: + *val = LSM6DSL_MSB_AT_LOW_ADD; + break; + + default: + *val = LSM6DSL_DATA_FMT_ND; + break; + } + + return ret; +} + +/** + * @brief Register address automatically incremented during a multiple byte + * access with a serial interface.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of if_inc in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_auto_increment_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + + if (ret == 0) + { + ctrl3_c.if_inc = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + } + + return ret; +} + +/** + * @brief Register address automatically incremented during a multiple byte + * access with a serial interface.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of if_inc in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_auto_increment_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + *val = ctrl3_c.if_inc; + + return ret; +} + +/** + * @brief Reboot memory content. Reload the calibration parameters.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of boot in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_boot_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + + if (ret == 0) + { + ctrl3_c.boot = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + } + + return ret; +} + +/** + * @brief Reboot memory content. Reload the calibration parameters.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of boot in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_boot_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + *val = ctrl3_c.boot; + + return ret; +} + +/** + * @brief Linear acceleration sensor self-test enable.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of st_xl in reg CTRL5_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_self_test_set(dev_ctx_t *ctx, + lsm6dsl_st_xl_t val) +{ + lsm6dsl_ctrl5_c_t ctrl5_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t *)&ctrl5_c, 1); + + if (ret == 0) + { + ctrl5_c.st_xl = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t *)&ctrl5_c, 1); + } + + return ret; +} + +/** + * @brief Linear acceleration sensor self-test enable.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of st_xl in reg CTRL5_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_self_test_get(dev_ctx_t *ctx, + lsm6dsl_st_xl_t *val) +{ + lsm6dsl_ctrl5_c_t ctrl5_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t *)&ctrl5_c, 1); + + switch (ctrl5_c.st_xl) + { + case LSM6DSL_XL_ST_DISABLE: + *val = LSM6DSL_XL_ST_DISABLE; + break; + + case LSM6DSL_XL_ST_POSITIVE: + *val = LSM6DSL_XL_ST_POSITIVE; + break; + + case LSM6DSL_XL_ST_NEGATIVE: + *val = LSM6DSL_XL_ST_NEGATIVE; + break; + + default: + *val = LSM6DSL_XL_ST_ND; + break; + } + + return ret; +} + +/** + * @brief Angular rate sensor self-test enable.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of st_g in reg CTRL5_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_gy_self_test_set(dev_ctx_t *ctx, + lsm6dsl_st_g_t val) +{ + lsm6dsl_ctrl5_c_t ctrl5_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t *)&ctrl5_c, 1); + + if (ret == 0) + { + ctrl5_c.st_g = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t *)&ctrl5_c, 1); + } + + return ret; +} + +/** + * @brief Angular rate sensor self-test enable.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of st_g in reg CTRL5_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_gy_self_test_get(dev_ctx_t *ctx, + lsm6dsl_st_g_t *val) +{ + lsm6dsl_ctrl5_c_t ctrl5_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t *)&ctrl5_c, 1); + + switch (ctrl5_c.st_g) + { + case LSM6DSL_GY_ST_DISABLE: + *val = LSM6DSL_GY_ST_DISABLE; + break; + + case LSM6DSL_GY_ST_POSITIVE: + *val = LSM6DSL_GY_ST_POSITIVE; + break; + + case LSM6DSL_GY_ST_NEGATIVE: + *val = LSM6DSL_GY_ST_NEGATIVE; + break; + + default: + *val = LSM6DSL_GY_ST_ND; + break; + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_filters + * @brief This section group all the functions concerning the filters + * configuration that impact both accelerometer and gyro. + * @{ + * + */ + +/** + * @brief Mask DRDY on pin (both XL & Gyro) until filter settling ends + * (XL and Gyro independently masked).[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of drdy_mask in reg CTRL4_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_filter_settling_mask_set(dev_ctx_t *ctx, + uint8_t val) +{ + lsm6dsl_ctrl4_c_t ctrl4_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + + if (ret == 0) + { + ctrl4_c.drdy_mask = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + } + + return ret; +} + +/** + * @brief Mask DRDY on pin (both XL & Gyro) until filter settling ends + * (XL and Gyro independently masked).[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of drdy_mask in reg CTRL4_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_filter_settling_mask_get(dev_ctx_t *ctx, + uint8_t *val) +{ + lsm6dsl_ctrl4_c_t ctrl4_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + *val = ctrl4_c.drdy_mask; + + return ret; +} + +/** + * @brief HPF or SLOPE filter selection on wake-up and Activity/Inactivity + * functions.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of slope_fds in reg TAP_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_hp_path_internal_set(dev_ctx_t *ctx, + lsm6dsl_slope_fds_t val) +{ + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + + if (ret == 0) + { + tap_cfg.slope_fds = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + } + + return ret; +} + +/** + * @brief HPF or SLOPE filter selection on wake-up and Activity/Inactivity + * functions.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of slope_fds in reg TAP_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_hp_path_internal_get(dev_ctx_t *ctx, + lsm6dsl_slope_fds_t *val) +{ + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + + switch (tap_cfg.slope_fds) + { + case LSM6DSL_USE_SLOPE: + *val = LSM6DSL_USE_SLOPE; + break; + + case LSM6DSL_USE_HPF: + *val = LSM6DSL_USE_HPF; + break; + + default: + *val = LSM6DSL_HP_PATH_ND; + break; + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_accelerometer_filters + * @brief This section group all the functions concerning the filters + * configuration that impact accelerometer in every mode. + * @{ + * + */ + +/** + * @brief Accelerometer analog chain bandwidth selection (only for + * accelerometer ODR 鈮 1.67 kHz).[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of bw0_xl in reg CTRL1_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_filter_analog_set(dev_ctx_t *ctx, + lsm6dsl_bw0_xl_t val) +{ + lsm6dsl_ctrl1_xl_t ctrl1_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1); + + if (ret == 0) + { + ctrl1_xl.bw0_xl = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1); + } + + return ret; +} + +/** + * @brief Accelerometer analog chain bandwidth selection (only for + * accelerometer ODR 鈮 1.67 kHz).[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of bw0_xl in reg CTRL1_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_filter_analog_get(dev_ctx_t *ctx, + lsm6dsl_bw0_xl_t *val) +{ + lsm6dsl_ctrl1_xl_t ctrl1_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1); + + switch (ctrl1_xl.bw0_xl) + { + case LSM6DSL_XL_ANA_BW_1k5Hz: + *val = LSM6DSL_XL_ANA_BW_1k5Hz; + break; + + case LSM6DSL_XL_ANA_BW_400Hz: + *val = LSM6DSL_XL_ANA_BW_400Hz; + break; + + default: + *val = LSM6DSL_XL_ANA_BW_ND; + break; + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_accelerometer_filters + * @brief This section group all the functions concerning the filters + * configuration that impact accelerometer. + * @{ + * + */ + +/** + * @brief Accelerometer digital LPF (LPF1) bandwidth selection LPF2 is + * not used.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of lpf1_bw_sel in reg CTRL1_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_lp1_bandwidth_set(dev_ctx_t *ctx, + lsm6dsl_lpf1_bw_sel_t val) +{ + lsm6dsl_ctrl1_xl_t ctrl1_xl; + lsm6dsl_ctrl8_xl_t ctrl8_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1); + + if (ret == 0) + { + ctrl1_xl.lpf1_bw_sel = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + + if (ret == 0) + { + ctrl8_xl.lpf2_xl_en = 0; + ctrl8_xl.hp_slope_xl_en = 0; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + } + } + } + + return ret; +} + +/** + * @brief Accelerometer digital LPF (LPF1) bandwidth selection LPF2 + * is not used.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of lpf1_bw_sel in reg CTRL1_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_lp1_bandwidth_get(dev_ctx_t *ctx, + lsm6dsl_lpf1_bw_sel_t *val) +{ + lsm6dsl_ctrl1_xl_t ctrl1_xl; + lsm6dsl_ctrl8_xl_t ctrl8_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + + if (ret == 0) + { + if ((ctrl8_xl.lpf2_xl_en != 0x00U) || + (ctrl8_xl.hp_slope_xl_en != 0x00U)) + { + *val = LSM6DSL_XL_LP1_NA; + } + + else + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1); + + switch (ctrl1_xl.lpf1_bw_sel) + { + case LSM6DSL_XL_LP1_ODR_DIV_2: + *val = LSM6DSL_XL_LP1_ODR_DIV_2; + break; + + case LSM6DSL_XL_LP1_ODR_DIV_4: + *val = LSM6DSL_XL_LP1_ODR_DIV_4; + break; + + default: + *val = LSM6DSL_XL_LP1_NA; + break; + } + } + } + + return ret; +} + +/** + * @brief LPF2 on outputs[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of input_composite in reg CTRL8_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_lp2_bandwidth_set(dev_ctx_t *ctx, + lsm6dsl_input_composite_t val) +{ + lsm6dsl_ctrl8_xl_t ctrl8_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + + if (ret == 0) + { + ctrl8_xl.input_composite = ((uint8_t) val & 0x10U) >> 4; + ctrl8_xl.hpcf_xl = (uint8_t) val & 0x03U; + ctrl8_xl.lpf2_xl_en = 1; + ctrl8_xl.hp_slope_xl_en = 0; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + } + + return ret; +} + +/** + * @brief LPF2 on outputs[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of input_composite in reg CTRL8_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_lp2_bandwidth_get(dev_ctx_t *ctx, + lsm6dsl_input_composite_t *val) +{ + lsm6dsl_ctrl8_xl_t ctrl8_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + + if (ret == 0) + { + if ((ctrl8_xl.lpf2_xl_en == 0x00U) || + (ctrl8_xl.hp_slope_xl_en != 0x00U)) + { + *val = LSM6DSL_XL_LP_NA; + } + + else + { + switch ((ctrl8_xl.input_composite << 4) + ctrl8_xl.hpcf_xl) + { + case LSM6DSL_XL_LOW_LAT_LP_ODR_DIV_50: + *val = LSM6DSL_XL_LOW_LAT_LP_ODR_DIV_50; + break; + + case LSM6DSL_XL_LOW_LAT_LP_ODR_DIV_100: + *val = LSM6DSL_XL_LOW_LAT_LP_ODR_DIV_100; + break; + + case LSM6DSL_XL_LOW_LAT_LP_ODR_DIV_9: + *val = LSM6DSL_XL_LOW_LAT_LP_ODR_DIV_9; + break; + + case LSM6DSL_XL_LOW_LAT_LP_ODR_DIV_400: + *val = LSM6DSL_XL_LOW_LAT_LP_ODR_DIV_400; + break; + + case LSM6DSL_XL_LOW_NOISE_LP_ODR_DIV_50: + *val = LSM6DSL_XL_LOW_NOISE_LP_ODR_DIV_50; + break; + + case LSM6DSL_XL_LOW_NOISE_LP_ODR_DIV_100: + *val = LSM6DSL_XL_LOW_NOISE_LP_ODR_DIV_100; + break; + + case LSM6DSL_XL_LOW_NOISE_LP_ODR_DIV_9: + *val = LSM6DSL_XL_LOW_NOISE_LP_ODR_DIV_9; + break; + + case LSM6DSL_XL_LOW_NOISE_LP_ODR_DIV_400: + *val = LSM6DSL_XL_LOW_NOISE_LP_ODR_DIV_400; + break; + + default: + *val = LSM6DSL_XL_LP_NA; + break; + } + } + } + + return ret; +} + +/** + * @brief Enable HP filter reference mode.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of hp_ref_mode in reg CTRL8_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_reference_mode_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl8_xl_t ctrl8_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + + if (ret == 0) + { + ctrl8_xl.hp_ref_mode = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + } + + return ret; +} + +/** + * @brief Enable HP filter reference mode.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of hp_ref_mode in reg CTRL8_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_reference_mode_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl8_xl_t ctrl8_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + *val = ctrl8_xl.hp_ref_mode; + + return ret; +} + +/** + * @brief High pass/Slope on outputs.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of hpcf_xl in reg CTRL8_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_hp_bandwidth_set(dev_ctx_t *ctx, + lsm6dsl_hpcf_xl_t val) +{ + lsm6dsl_ctrl8_xl_t ctrl8_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + + if (ret == 0) + { + ctrl8_xl.input_composite = 0; + ctrl8_xl.hpcf_xl = (uint8_t)val & 0x03U; + ctrl8_xl.hp_slope_xl_en = 1; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + } + + return ret; +} + +/** + * @brief High pass/Slope on outputs.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of hpcf_xl in reg CTRL8_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_xl_hp_bandwidth_get(dev_ctx_t *ctx, + lsm6dsl_hpcf_xl_t *val) +{ + lsm6dsl_ctrl8_xl_t ctrl8_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + + if (ctrl8_xl.hp_slope_xl_en == 0x00U) + { + *val = LSM6DSL_XL_HP_NA; + } + + switch (ctrl8_xl.hpcf_xl) + { + case LSM6DSL_XL_HP_ODR_DIV_4: + *val = LSM6DSL_XL_HP_ODR_DIV_4; + break; + + case LSM6DSL_XL_HP_ODR_DIV_100: + *val = LSM6DSL_XL_HP_ODR_DIV_100; + break; + + case LSM6DSL_XL_HP_ODR_DIV_9: + *val = LSM6DSL_XL_HP_ODR_DIV_9; + break; + + case LSM6DSL_XL_HP_ODR_DIV_400: + *val = LSM6DSL_XL_HP_ODR_DIV_400; + break; + + default: + *val = LSM6DSL_XL_HP_NA; + break; + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_gyroscope_filters + * @brief This section group all the functions concerning the filters + * configuration that impact gyroscope. + * @{ + * + */ + +/** + * @brief Gyroscope low pass path bandwidth.[set] + * + * @param ctx Read / write interface definitions + * @param val gyroscope filtering chain configuration. + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_gy_band_pass_set(dev_ctx_t *ctx, + lsm6dsl_lpf1_sel_g_t val) +{ + lsm6dsl_ctrl4_c_t ctrl4_c; + lsm6dsl_ctrl6_c_t ctrl6_c; + lsm6dsl_ctrl7_g_t ctrl7_g; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL7_G, (uint8_t *)&ctrl7_g, 1); + + if (ret == 0) + { + ctrl7_g.hpm_g = ((uint8_t)val & 0x30U) >> 4; + ctrl7_g.hp_en_g = ((uint8_t)val & 0x80U) >> 7; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL7_G, (uint8_t *)&ctrl7_g, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL6_C, (uint8_t *)&ctrl6_c, 1); + + if (ret == 0) + { + ctrl6_c.ftype = (uint8_t)val & 0x03U; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL6_C, (uint8_t *)&ctrl6_c, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, + (uint8_t *)&ctrl4_c, 1); + + if (ret == 0) + { + ctrl4_c.lpf1_sel_g = ((uint8_t)val & 0x08U) >> 3; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL4_C, + (uint8_t *)&ctrl4_c, 1); + } + } + } + } + } + + return ret; +} + +/** + * @brief Gyroscope low pass path bandwidth.[get] + * + * @param ctx Read / write interface definitions + * @param val gyroscope filtering chain + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_gy_band_pass_get(dev_ctx_t *ctx, + lsm6dsl_lpf1_sel_g_t *val) +{ + lsm6dsl_ctrl4_c_t ctrl4_c; + lsm6dsl_ctrl6_c_t ctrl6_c; + lsm6dsl_ctrl7_g_t ctrl7_g; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL6_C, (uint8_t *)&ctrl6_c, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL7_G, (uint8_t *)&ctrl7_g, 1); + + switch ((ctrl7_g.hp_en_g << 7) + (ctrl7_g.hpm_g << 4) + + (ctrl4_c.lpf1_sel_g << 3) + ctrl6_c.ftype) + { + case LSM6DSL_HP_16mHz_LP2: + *val = LSM6DSL_HP_16mHz_LP2; + break; + + case LSM6DSL_HP_65mHz_LP2: + *val = LSM6DSL_HP_65mHz_LP2; + break; + + case LSM6DSL_HP_260mHz_LP2: + *val = LSM6DSL_HP_260mHz_LP2; + break; + + case LSM6DSL_HP_1Hz04_LP2: + *val = LSM6DSL_HP_1Hz04_LP2; + break; + + case LSM6DSL_HP_DISABLE_LP1_LIGHT: + *val = LSM6DSL_HP_DISABLE_LP1_LIGHT; + break; + + case LSM6DSL_HP_DISABLE_LP1_NORMAL: + *val = LSM6DSL_HP_DISABLE_LP1_NORMAL; + break; + + case LSM6DSL_HP_DISABLE_LP_STRONG: + *val = LSM6DSL_HP_DISABLE_LP_STRONG; + break; + + case LSM6DSL_HP_DISABLE_LP1_AGGRESSIVE: + *val = LSM6DSL_HP_DISABLE_LP1_AGGRESSIVE; + break; + + case LSM6DSL_HP_16mHz_LP1_LIGHT: + *val = LSM6DSL_HP_16mHz_LP1_LIGHT; + break; + + case LSM6DSL_HP_65mHz_LP1_NORMAL: + *val = LSM6DSL_HP_65mHz_LP1_NORMAL; + break; + + case LSM6DSL_HP_260mHz_LP1_STRONG: + *val = LSM6DSL_HP_260mHz_LP1_STRONG; + break; + + case LSM6DSL_HP_1Hz04_LP1_AGGRESSIVE: + *val = LSM6DSL_HP_1Hz04_LP1_AGGRESSIVE; + break; + + default: + *val = LSM6DSL_HP_GY_BAND_NA; + break; + } + } + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_serial_interface + * @brief This section groups all the functions concerning serial + * interface management + * @{ + * + */ + +/** + * @brief SPI Serial Interface Mode selection.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of sim in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_spi_mode_set(dev_ctx_t *ctx, lsm6dsl_sim_t val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + + if (ret == 0) + { + ctrl3_c.sim = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + } + + return ret; +} + +/** + * @brief SPI Serial Interface Mode selection.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of sim in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_spi_mode_get(dev_ctx_t *ctx, lsm6dsl_sim_t *val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + + switch (ctrl3_c.sim) + { + case LSM6DSL_SPI_4_WIRE: + *val = LSM6DSL_SPI_4_WIRE; + break; + + case LSM6DSL_SPI_3_WIRE: + *val = LSM6DSL_SPI_3_WIRE; + break; + + default: + *val = LSM6DSL_SPI_MODE_ND; + break; + } + + return ret; +} + +/** + * @brief Disable / Enable I2C interface.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of i2c_disable in reg CTRL4_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_i2c_interface_set(dev_ctx_t *ctx, + lsm6dsl_i2c_disable_t val) +{ + lsm6dsl_ctrl4_c_t ctrl4_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + + if (ret == 0) + { + ctrl4_c.i2c_disable = (uint8_t)val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + } + + return ret; +} + +/** + * @brief Disable / Enable I2C interface.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of i2c_disable in reg CTRL4_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_i2c_interface_get(dev_ctx_t *ctx, + lsm6dsl_i2c_disable_t *val) +{ + lsm6dsl_ctrl4_c_t ctrl4_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + + switch (ctrl4_c.i2c_disable) + { + case LSM6DSL_I2C_ENABLE: + *val = LSM6DSL_I2C_ENABLE; + break; + + case LSM6DSL_I2C_DISABLE: + *val = LSM6DSL_I2C_DISABLE; + break; + + default: + *val = LSM6DSL_I2C_MODE_ND; + break; + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_interrupt_pins + * @brief This section groups all the functions that manage + * interrupt pins + * @{ + * + */ + +/** + * @brief Select the signal that need to route on int1 pad[set] + * + * @param ctx Read / write interface definitions + * @param val configure INT1_CTRL, MD1_CFG, CTRL4_C(den_drdy_int1), + * MASTER_CONFIG(drdy_on_int1) + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pin_int1_route_set(dev_ctx_t *ctx, + lsm6dsl_int1_route_t val) +{ + lsm6dsl_master_config_t master_config; + lsm6dsl_int1_ctrl_t int1_ctrl; + lsm6dsl_md1_cfg_t md1_cfg; + lsm6dsl_md2_cfg_t md2_cfg; + lsm6dsl_ctrl4_c_t ctrl4_c; + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_INT1_CTRL, (uint8_t *)&int1_ctrl, 1); + + if (ret == 0) + { + int1_ctrl.int1_drdy_xl = val.int1_drdy_xl; + int1_ctrl.int1_drdy_g = val.int1_drdy_g; + int1_ctrl.int1_boot = val.int1_boot; + int1_ctrl.int1_fth = val.int1_fth; + int1_ctrl.int1_fifo_ovr = val.int1_fifo_ovr; + int1_ctrl.int1_full_flag = val.int1_full_flag; + int1_ctrl.int1_sign_mot = val.int1_sign_mot; + int1_ctrl.int1_step_detector = val.int1_step_detector; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_INT1_CTRL, (uint8_t *)&int1_ctrl, 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MD1_CFG, (uint8_t *)&md1_cfg, 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MD2_CFG, (uint8_t *)&md2_cfg, 1); + } + + if (ret == 0) + { + md1_cfg.int1_timer = val.int1_timer; + md1_cfg.int1_tilt = val.int1_tilt; + md1_cfg.int1_6d = val.int1_6d; + md1_cfg.int1_double_tap = val.int1_double_tap; + md1_cfg.int1_ff = val.int1_ff; + md1_cfg.int1_wu = val.int1_wu; + md1_cfg.int1_single_tap = val.int1_single_tap; + md1_cfg.int1_inact_state = val.int1_inact_state; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_MD1_CFG, (uint8_t *)&md1_cfg, 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + } + + if (ret == 0) + { + ctrl4_c.den_drdy_int1 = val.den_drdy_int1; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + } + + if (ret == 0) + { + master_config.drdy_on_int1 = val.den_drdy_int1; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + + if ((val.int1_6d != 0x00U) || + (val.int1_ff != 0x00U) || + (val.int1_wu != 0x00U) || + (val.int1_single_tap != 0x00U) || + (val.int1_double_tap != 0x00U) || + (val.int1_inact_state != 0x00U) || + (md2_cfg.int2_6d != 0x00U) || + (md2_cfg.int2_ff != 0x00U) || + (md2_cfg.int2_wu != 0x00U) || + (md2_cfg.int2_single_tap != 0x00U) || + (md2_cfg.int2_double_tap != 0x00U) || + (md2_cfg.int2_inact_state != 0x00U)) + { + tap_cfg.interrupts_enable = PROPERTY_ENABLE; + } + + else + { + tap_cfg.interrupts_enable = PROPERTY_DISABLE; + } + } + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + } + + return ret; +} + +/** + * @brief Select the signal that need to route on int1 pad[get] + * + * @param ctx Read / write interface definitions + * @param val read INT1_CTRL, MD1_CFG, CTRL4_C(den_drdy_int1), + * MASTER_CONFIG(drdy_on_int1) + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pin_int1_route_get(dev_ctx_t *ctx, + lsm6dsl_int1_route_t *val) +{ + lsm6dsl_master_config_t master_config; + lsm6dsl_int1_ctrl_t int1_ctrl; + lsm6dsl_md1_cfg_t md1_cfg; + lsm6dsl_ctrl4_c_t ctrl4_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_INT1_CTRL, (uint8_t *)&int1_ctrl, 1); + + if (ret == 0) + { + val->int1_drdy_xl = int1_ctrl.int1_drdy_xl; + val->int1_drdy_g = int1_ctrl.int1_drdy_g; + val->int1_boot = int1_ctrl.int1_boot; + val->int1_fth = int1_ctrl.int1_fth; + val->int1_fifo_ovr = int1_ctrl.int1_fifo_ovr; + val->int1_full_flag = int1_ctrl.int1_full_flag; + val->int1_sign_mot = int1_ctrl.int1_sign_mot; + val->int1_step_detector = int1_ctrl.int1_step_detector ; + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MD1_CFG, (uint8_t *)&md1_cfg, 1); + + if (ret == 0) + { + val->int1_timer = md1_cfg.int1_timer; + val->int1_tilt = md1_cfg.int1_tilt; + val->int1_6d = md1_cfg.int1_6d; + val->int1_double_tap = md1_cfg.int1_double_tap; + val->int1_ff = md1_cfg.int1_ff; + val->int1_wu = md1_cfg.int1_wu; + val->int1_single_tap = md1_cfg.int1_single_tap; + val->int1_inact_state = md1_cfg.int1_inact_state; + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + + if (ret == 0) + { + val->den_drdy_int1 = ctrl4_c.den_drdy_int1; + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + val->den_drdy_int1 = master_config.drdy_on_int1; + } + } + } + + return ret; +} + +/** + * @brief Select the signal that need to route on int2 pad[set] + * + * @param ctx Read / write interface definitions + * @param val INT2_CTRL, DRDY_PULSE_CFG(int2_wrist_tilt), MD2_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pin_int2_route_set(dev_ctx_t *ctx, + lsm6dsl_int2_route_t val) +{ + lsm6dsl_int2_ctrl_t int2_ctrl; + lsm6dsl_md1_cfg_t md1_cfg; + lsm6dsl_md2_cfg_t md2_cfg; + lsm6dsl_drdy_pulse_cfg_g_t drdy_pulse_cfg_g; + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_INT2_CTRL, (uint8_t *)&int2_ctrl, 1); + + if (ret == 0) + { + int2_ctrl.int2_drdy_xl = val.int2_drdy_xl; + int2_ctrl.int2_drdy_g = val.int2_drdy_g; + int2_ctrl.int2_drdy_temp = val.int2_drdy_temp; + int2_ctrl.int2_fth = val.int2_fth; + int2_ctrl.int2_fifo_ovr = val.int2_fifo_ovr; + int2_ctrl.int2_full_flag = val.int2_full_flag; + int2_ctrl.int2_step_count_ov = val.int2_step_count_ov; + int2_ctrl.int2_step_delta = val.int2_step_delta; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_INT2_CTRL, (uint8_t *)&int2_ctrl, 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MD1_CFG, (uint8_t *)&md1_cfg, 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MD2_CFG, (uint8_t *)&md2_cfg, 1); + } + + if (ret == 0) + { + md2_cfg.int2_iron = val.int2_iron; + md2_cfg.int2_tilt = val.int2_tilt; + md2_cfg.int2_6d = val.int2_6d; + md2_cfg.int2_double_tap = val.int2_double_tap; + md2_cfg.int2_ff = val.int2_ff; + md2_cfg.int2_wu = val.int2_wu; + md2_cfg.int2_single_tap = val.int2_single_tap; + md2_cfg.int2_inact_state = val.int2_inact_state; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_MD2_CFG, (uint8_t *)&md2_cfg, 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_DRDY_PULSE_CFG_G, + (uint8_t *)&drdy_pulse_cfg_g, 1); + } + + if (ret == 0) + { + drdy_pulse_cfg_g.int2_wrist_tilt = val.int2_wrist_tilt; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_DRDY_PULSE_CFG_G, + (uint8_t *)&drdy_pulse_cfg_g, 1); + } + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + + if ((md1_cfg.int1_6d != 0x00U) || + (md1_cfg.int1_ff != 0x00U) || + (md1_cfg.int1_wu != 0x00U) || + (md1_cfg.int1_single_tap != 0x00U) || + (md1_cfg.int1_double_tap != 0x00U) || + (md1_cfg.int1_inact_state != 0x00U) || + (val.int2_6d != 0x00U) || + (val.int2_ff != 0x00U) || + (val.int2_wu != 0x00U) || + (val.int2_single_tap != 0x00U) || + (val.int2_double_tap != 0x00U) || + (val.int2_inact_state != 0x00U)) + { + tap_cfg.interrupts_enable = PROPERTY_ENABLE; + } + + else + { + tap_cfg.interrupts_enable = PROPERTY_DISABLE; + } + } + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + } + + return ret; +} + +/** + * @brief Select the signal that need to route on int2 pad[get] + * + * @param ctx Read / write interface definitions + * @param val INT2_CTRL, DRDY_PULSE_CFG(int2_wrist_tilt), MD2_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pin_int2_route_get(dev_ctx_t *ctx, + lsm6dsl_int2_route_t *val) +{ + lsm6dsl_int2_ctrl_t int2_ctrl; + lsm6dsl_md2_cfg_t md2_cfg; + lsm6dsl_drdy_pulse_cfg_g_t drdy_pulse_cfg_g; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_INT2_CTRL, (uint8_t *)&int2_ctrl, 1); + + if (ret == 0) + { + val->int2_drdy_xl = int2_ctrl.int2_drdy_xl; + val->int2_drdy_g = int2_ctrl.int2_drdy_g; + val->int2_drdy_temp = int2_ctrl.int2_drdy_temp; + val->int2_fth = int2_ctrl.int2_fth; + val->int2_fifo_ovr = int2_ctrl.int2_fifo_ovr; + val->int2_full_flag = int2_ctrl.int2_full_flag; + val->int2_step_count_ov = int2_ctrl.int2_step_count_ov; + val->int2_step_delta = int2_ctrl.int2_step_delta; + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MD2_CFG, (uint8_t *)&md2_cfg, 1); + + if (ret == 0) + { + val->int2_iron = md2_cfg.int2_iron; + val->int2_tilt = md2_cfg.int2_tilt; + val->int2_6d = md2_cfg.int2_6d; + val->int2_double_tap = md2_cfg.int2_double_tap; + val->int2_ff = md2_cfg.int2_ff; + val->int2_wu = md2_cfg.int2_wu; + val->int2_single_tap = md2_cfg.int2_single_tap; + val->int2_inact_state = md2_cfg.int2_inact_state; + ret = lsm6dsl_read_reg(ctx, LSM6DSL_DRDY_PULSE_CFG_G, + (uint8_t *)&drdy_pulse_cfg_g, 1); + val->int2_wrist_tilt = drdy_pulse_cfg_g.int2_wrist_tilt; + } + } + + return ret; +} + +/** + * @brief Push-pull/open drain selection on interrupt pads.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of pp_od in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pin_mode_set(dev_ctx_t *ctx, lsm6dsl_pp_od_t val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + + if (ret == 0) + { + ctrl3_c.pp_od = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + } + + return ret; +} + +/** + * @brief Push-pull/open drain selection on interrupt pads.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of pp_od in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pin_mode_get(dev_ctx_t *ctx, lsm6dsl_pp_od_t *val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + + switch (ctrl3_c.pp_od) + { + case LSM6DSL_PUSH_PULL: + *val = LSM6DSL_PUSH_PULL; + break; + + case LSM6DSL_OPEN_DRAIN: + *val = LSM6DSL_OPEN_DRAIN; + break; + + default: + *val = LSM6DSL_PIN_MODE_ND; + break; + } + + return ret; +} + +/** + * @brief Interrupt active-high/low.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of h_lactive in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pin_polarity_set(dev_ctx_t *ctx, + lsm6dsl_h_lactive_t val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + + if (ret == 0) + { + ctrl3_c.h_lactive = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + } + + return ret; +} + +/** + * @brief Interrupt active-high/low.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of h_lactive in reg CTRL3_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pin_polarity_get(dev_ctx_t *ctx, + lsm6dsl_h_lactive_t *val) +{ + lsm6dsl_ctrl3_c_t ctrl3_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t *)&ctrl3_c, 1); + + switch (ctrl3_c.h_lactive) + { + case LSM6DSL_ACTIVE_HIGH: + *val = LSM6DSL_ACTIVE_HIGH; + break; + + case LSM6DSL_ACTIVE_LOW: + *val = LSM6DSL_ACTIVE_LOW; + break; + + default: + *val = LSM6DSL_POLARITY_ND; + break; + } + + return ret; +} + +/** + * @brief All interrupt signals become available on INT1 pin.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of int2_on_int1 in reg CTRL4_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_all_on_int1_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl4_c_t ctrl4_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + + if (ret == 0) + { + ctrl4_c.int2_on_int1 = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + } + + return ret; +} + +/** + * @brief All interrupt signals become available on INT1 pin.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of int2_on_int1 in reg CTRL4_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_all_on_int1_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl4_c_t ctrl4_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + *val = ctrl4_c.int2_on_int1; + + return ret; +} + +/** + * @brief Latched/pulsed interrupt.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of lir in reg TAP_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_int_notification_set(dev_ctx_t *ctx, + lsm6dsl_lir_t val) +{ + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + + if (ret == 0) + { + tap_cfg.lir = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + } + + return ret; +} + +/** + * @brief Latched/pulsed interrupt.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of lir in reg TAP_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_int_notification_get(dev_ctx_t *ctx, + lsm6dsl_lir_t *val) +{ + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + + switch (tap_cfg.lir) + { + case LSM6DSL_INT_PULSED: + *val = LSM6DSL_INT_PULSED; + break; + + case LSM6DSL_INT_LATCHED: + *val = LSM6DSL_INT_LATCHED; + break; + + default: + *val = LSM6DSL_INT_MODE; + break; + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_Wake_Up_event + * @brief This section groups all the functions that manage the + * Wake Up event generation. + * @{ + * + */ + +/** + * @brief Threshold for wakeup.1 LSB = FS_XL / 64.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of wk_ths in reg WAKE_UP_THS + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_wkup_threshold_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_wake_up_ths_t wake_up_ths; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WAKE_UP_THS, + (uint8_t *)&wake_up_ths, 1); + + if (ret == 0) + { + wake_up_ths.wk_ths = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_WAKE_UP_THS, + (uint8_t *)&wake_up_ths, 1); + } + + return ret; +} + +/** + * @brief Threshold for wakeup.1 LSB = FS_XL / 64.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of wk_ths in reg WAKE_UP_THS + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_wkup_threshold_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_wake_up_ths_t wake_up_ths; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WAKE_UP_THS, + (uint8_t *)&wake_up_ths, 1); + *val = wake_up_ths.wk_ths; + + return ret; +} + +/** + * @brief Wake up duration event.1LSb = 1 / ODR[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of wake_dur in reg WAKE_UP_DUR + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_wkup_dur_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_wake_up_dur_t wake_up_dur; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WAKE_UP_DUR, + (uint8_t *)&wake_up_dur, 1); + + if (ret == 0) + { + wake_up_dur.wake_dur = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_WAKE_UP_DUR, + (uint8_t *)&wake_up_dur, 1); + } + + return ret; +} + +/** + * @brief Wake up duration event.1LSb = 1 / ODR[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of wake_dur in reg WAKE_UP_DUR + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_wkup_dur_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_wake_up_dur_t wake_up_dur; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WAKE_UP_DUR, + (uint8_t *)&wake_up_dur, 1); + *val = wake_up_dur.wake_dur; + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_Activity/Inactivity_detection + * @brief This section groups all the functions concerning + * activity/inactivity detection. + * @{ + * + */ + +/** + * @brief Enables gyroscope Sleep mode.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of sleep in reg CTRL4_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_gy_sleep_mode_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl4_c_t ctrl4_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + + if (ret == 0) + { + ctrl4_c.sleep = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + } + + return ret; +} + +/** + * @brief Enables gyroscope Sleep mode.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of sleep in reg CTRL4_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_gy_sleep_mode_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl4_c_t ctrl4_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + *val = ctrl4_c.sleep; + + return ret; +} + +/** + * @brief Enable inactivity function.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of inact_en in reg TAP_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_act_mode_set(dev_ctx_t *ctx, + lsm6dsl_inact_en_t val) +{ + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + + if (ret == 0) + { + tap_cfg.inact_en = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + } + + return ret; +} + +/** + * @brief Enable inactivity function.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of inact_en in reg TAP_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_act_mode_get(dev_ctx_t *ctx, + lsm6dsl_inact_en_t *val) +{ + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + + switch (tap_cfg.inact_en) + { + case LSM6DSL_PROPERTY_DISABLE: + *val = LSM6DSL_PROPERTY_DISABLE; + break; + + case LSM6DSL_XL_12Hz5_GY_NOT_AFFECTED: + *val = LSM6DSL_XL_12Hz5_GY_NOT_AFFECTED; + break; + + case LSM6DSL_XL_12Hz5_GY_SLEEP: + *val = LSM6DSL_XL_12Hz5_GY_SLEEP; + break; + + case LSM6DSL_XL_12Hz5_GY_PD: + *val = LSM6DSL_XL_12Hz5_GY_PD; + break; + + default: + *val = LSM6DSL_ACT_MODE_ND; + break; + } + + return ret; +} + +/** + * @brief Duration to go in sleep mode.1 LSb = 512 / ODR[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of sleep_dur in reg WAKE_UP_DUR + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_act_sleep_dur_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_wake_up_dur_t wake_up_dur; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WAKE_UP_DUR, + (uint8_t *)&wake_up_dur, 1); + + if (ret == 0) + { + wake_up_dur.sleep_dur = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_WAKE_UP_DUR, + (uint8_t *)&wake_up_dur, 1); + } + + return ret; +} + +/** + * @brief Duration to go in sleep mode. 1 LSb = 512 / ODR[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of sleep_dur in reg WAKE_UP_DUR + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_act_sleep_dur_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_wake_up_dur_t wake_up_dur; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WAKE_UP_DUR, + (uint8_t *)&wake_up_dur, 1); + *val = wake_up_dur.sleep_dur; + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_tap_generator + * @brief This section groups all the functions that manage the + * tap and double tap event generation. + * @{ + * + */ + +/** + * @brief Read the tap / double tap source register.[get] + * + * @param ctx Read / write interface definitions + * @param val Structure of registers from TAP_SRC + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_src_get(dev_ctx_t *ctx, lsm6dsl_tap_src_t *val) +{ + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_SRC, (uint8_t *) val, 1); + + return ret; +} + +/** + * @brief Enable Z direction in tap recognition.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tap_z_en in reg TAP_CFG + * + */ +int32_t lsm6dsl_tap_detection_on_z_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + + if (ret == 0) + { + tap_cfg.tap_z_en = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + } + + return ret; +} + +/** + * @brief Enable Z direction in tap recognition.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tap_z_en in reg TAP_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_detection_on_z_get(dev_ctx_t *ctx, + uint8_t *val) +{ + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + *val = tap_cfg.tap_z_en; + + return ret; +} + +/** + * @brief Enable Y direction in tap recognition.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tap_y_en in reg TAP_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_detection_on_y_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + + if (ret == 0) + { + tap_cfg.tap_y_en = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + } + + return ret; +} + +/** + * @brief Enable Y direction in tap recognition.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tap_y_en in reg TAP_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_detection_on_y_get(dev_ctx_t *ctx, + uint8_t *val) +{ + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + *val = tap_cfg.tap_y_en; + + return ret; +} + +/** + * @brief Enable X direction in tap recognition.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tap_x_en in reg TAP_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_detection_on_x_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + + if (ret == 0) + { + tap_cfg.tap_x_en = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + } + + return ret; +} + +/** + * @brief Enable X direction in tap recognition.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tap_x_en in reg TAP_CFG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_detection_on_x_get(dev_ctx_t *ctx, + uint8_t *val) +{ + lsm6dsl_tap_cfg_t tap_cfg; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_CFG, (uint8_t *)&tap_cfg, 1); + *val = tap_cfg.tap_x_en; + + return ret; +} + +/** + * @brief Threshold for tap recognition.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tap_ths in reg TAP_THS_6D + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_threshold_x_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_tap_ths_6d_t tap_ths_6d; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_THS_6D, + (uint8_t *)&tap_ths_6d, 1); + + if (ret == 0) + { + tap_ths_6d.tap_ths = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_TAP_THS_6D, + (uint8_t *)&tap_ths_6d, 1); + } + + return ret; +} + +/** + * @brief Threshold for tap recognition.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tap_ths in reg TAP_THS_6D + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_threshold_x_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_tap_ths_6d_t tap_ths_6d; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_THS_6D, + (uint8_t *)&tap_ths_6d, 1); + *val = tap_ths_6d.tap_ths; + + return ret; +} + +/** + * @brief Maximum duration is the maximum time of an overthreshold signal + * detection to be recognized as a tap event. + * The default value of these bits is 00b which corresponds to + * 4*ODR_XL time. + * If the SHOCK[1:0] bits are set to a different + * value, 1LSB corresponds to 8*ODR_XL time.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of shock in reg INT_DUR2 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_shock_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_int_dur2_t int_dur2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_INT_DUR2, (uint8_t *)&int_dur2, 1); + + if (ret == 0) + { + int_dur2.shock = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_INT_DUR2, (uint8_t *)&int_dur2, 1); + } + + return ret; +} + +/** + * @brief Maximum duration is the maximum time of an overthreshold signal + * detection to be recognized as a tap event. + * The default value of these bits is 00b which corresponds to + * 4*ODR_XL time. + * If the SHOCK[1:0] bits are set to a different value, 1LSB + * corresponds to 8*ODR_XL time.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of shock in reg INT_DUR2 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_shock_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_int_dur2_t int_dur2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_INT_DUR2, (uint8_t *)&int_dur2, 1); + *val = int_dur2.shock; + + return ret; +} + +/** + * @brief Quiet time is the time after the first detected tap in which there + * must not be any overthreshold event. + * The default value of these bits is 00b which corresponds to + * 2*ODR_XL time. + * If the QUIET[1:0] bits are set to a different value, 1LSB + * corresponds to 4*ODR_XL time.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of quiet in reg INT_DUR2 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_quiet_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_int_dur2_t int_dur2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_INT_DUR2, (uint8_t *)&int_dur2, 1); + + if (ret == 0) + { + int_dur2.quiet = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_INT_DUR2, (uint8_t *)&int_dur2, 1); + } + + return ret; +} + +/** + * @brief Quiet time is the time after the first detected tap in which there + * must not be any overthreshold event. + * The default value of these bits is 00b which corresponds to + * 2*ODR_XL time. + * If the QUIET[1:0] bits are set to a different value, 1LSB + * corresponds to 4*ODR_XL time.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of quiet in reg INT_DUR2 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_quiet_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_int_dur2_t int_dur2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_INT_DUR2, (uint8_t *)&int_dur2, 1); + *val = int_dur2.quiet; + + return ret; +} + +/** + * @brief When double tap recognition is enabled, this register expresses the + * maximum time between two consecutive detected taps to determine a + * double tap event. + * The default value of these bits is 0000b which corresponds to + * 16*ODR_XL time. + * If the DUR[3:0] bits are set to a different value,1LSB corresponds + * to 32*ODR_XL time.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of dur in reg INT_DUR2 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_dur_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_int_dur2_t int_dur2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_INT_DUR2, (uint8_t *)&int_dur2, 1); + + if (ret == 0) + { + int_dur2.dur = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_INT_DUR2, (uint8_t *)&int_dur2, 1); + } + + return ret; +} + +/** + * @brief When double tap recognition is enabled, this register expresses the + * maximum time between two consecutive detected taps to determine a + * double tap event. + * The default value of these bits is 0000b which corresponds to + * 16*ODR_XL time. + * If the DUR[3:0] bits are set to a different value,1LSB corresponds + * to 32*ODR_XL time.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of dur in reg INT_DUR2 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_dur_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_int_dur2_t int_dur2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_INT_DUR2, (uint8_t *)&int_dur2, 1); + *val = int_dur2.dur; + + return ret; +} + +/** + * @brief Single/double-tap event enable/disable.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of + * single_double_tap in reg WAKE_UP_THS + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_mode_set(dev_ctx_t *ctx, + lsm6dsl_single_double_tap_t val) +{ + lsm6dsl_wake_up_ths_t wake_up_ths; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WAKE_UP_THS, + (uint8_t *)&wake_up_ths, 1); + + if (ret == 0) + { + wake_up_ths.single_double_tap = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_WAKE_UP_THS, + (uint8_t *)&wake_up_ths, 1); + } + + return ret; +} + +/** + * @brief Single/double-tap event enable/disable.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of single_double_tap + * in reg WAKE_UP_THS + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tap_mode_get(dev_ctx_t *ctx, + lsm6dsl_single_double_tap_t *val) +{ + lsm6dsl_wake_up_ths_t wake_up_ths; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WAKE_UP_THS, + (uint8_t *)&wake_up_ths, 1); + + switch (wake_up_ths.single_double_tap) + { + case LSM6DSL_ONLY_SINGLE: + *val = LSM6DSL_ONLY_SINGLE; + break; + + case LSM6DSL_BOTH_SINGLE_DOUBLE: + *val = LSM6DSL_BOTH_SINGLE_DOUBLE; + break; + + default: + *val = LSM6DSL_TAP_MODE_ND; + break; + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_ Six_position_detection(6D/4D) + * @brief This section groups all the functions concerning six + * position detection (6D). + * @{ + * + */ + +/** + * @brief LPF2 feed 6D function selection.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of low_pass_on_6d in + * reg CTRL8_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_6d_feed_data_set(dev_ctx_t *ctx, + lsm6dsl_low_pass_on_6d_t val) +{ + lsm6dsl_ctrl8_xl_t ctrl8_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + + if (ret == 0) + { + ctrl8_xl.low_pass_on_6d = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + } + + return ret; +} + +/** + * @brief LPF2 feed 6D function selection.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of low_pass_on_6d in reg CTRL8_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_6d_feed_data_get(dev_ctx_t *ctx, + lsm6dsl_low_pass_on_6d_t *val) +{ + lsm6dsl_ctrl8_xl_t ctrl8_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL8_XL, (uint8_t *)&ctrl8_xl, 1); + + switch (ctrl8_xl.low_pass_on_6d) + { + case LSM6DSL_ODR_DIV_2_FEED: + *val = LSM6DSL_ODR_DIV_2_FEED; + break; + + case LSM6DSL_LPF2_FEED: + *val = LSM6DSL_LPF2_FEED; + break; + + default: + *val = LSM6DSL_6D_FEED_ND; + break; + } + + return ret; +} + +/** + * @brief Threshold for 4D/6D function.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of sixd_ths in reg TAP_THS_6D + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_6d_threshold_set(dev_ctx_t *ctx, + lsm6dsl_sixd_ths_t val) +{ + lsm6dsl_tap_ths_6d_t tap_ths_6d; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_THS_6D, + (uint8_t *)&tap_ths_6d, 1); + + if (ret == 0) + { + tap_ths_6d.sixd_ths = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_TAP_THS_6D, + (uint8_t *)&tap_ths_6d, 1); + } + + return ret; +} + +/** + * @brief Threshold for 4D/6D function.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of sixd_ths in reg TAP_THS_6D + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_6d_threshold_get(dev_ctx_t *ctx, + lsm6dsl_sixd_ths_t *val) +{ + lsm6dsl_tap_ths_6d_t tap_ths_6d; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_THS_6D, + (uint8_t *)&tap_ths_6d, 1); + + switch (tap_ths_6d.sixd_ths) + { + case LSM6DSL_DEG_80: + *val = LSM6DSL_DEG_80; + break; + + case LSM6DSL_DEG_70: + *val = LSM6DSL_DEG_70; + break; + + case LSM6DSL_DEG_60: + *val = LSM6DSL_DEG_60; + break; + + case LSM6DSL_DEG_50: + *val = LSM6DSL_DEG_50; + break; + + default: + *val = LSM6DSL_6D_TH_ND; + break; + } + + return ret; +} + +/** + * @brief 4D orientation detection enable.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of d4d_en in reg TAP_THS_6D + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_4d_mode_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_tap_ths_6d_t tap_ths_6d; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_THS_6D, + (uint8_t *)&tap_ths_6d, 1); + + if (ret == 0) + { + tap_ths_6d.d4d_en = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_TAP_THS_6D, + (uint8_t *)&tap_ths_6d, 1); + } + + return ret; +} + +/** + * @brief 4D orientation detection enable.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of d4d_en in reg TAP_THS_6D + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_4d_mode_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_tap_ths_6d_t tap_ths_6d; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_TAP_THS_6D, + (uint8_t *)&tap_ths_6d, 1); + *val = tap_ths_6d.d4d_en; + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_free_fall + * @brief This section group all the functions concerning the free + * fall detection. + * @{ + * + */ + +/** + * @brief Free-fall duration event. 1LSb = 1 / ODR[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of ff_dur in reg WAKE_UP_DUR + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_ff_dur_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_wake_up_dur_t wake_up_dur; + lsm6dsl_free_fall_t free_fall; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FREE_FALL, (uint8_t *)&free_fall, 1); + + if (ret == 0) + { + free_fall.ff_dur = (val & 0x1FU); + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FREE_FALL, (uint8_t *)&free_fall, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WAKE_UP_DUR, + (uint8_t *)&wake_up_dur, 1); + + if (ret == 0) + { + wake_up_dur.ff_dur = (val & 0x20U) >> 5; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_WAKE_UP_DUR, + (uint8_t *)&wake_up_dur, 1); + } + } + } + + return ret; +} + +/** + * @brief Free-fall duration event. 1LSb = 1 / ODR[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of ff_dur in reg WAKE_UP_DUR + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_ff_dur_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_wake_up_dur_t wake_up_dur; + lsm6dsl_free_fall_t free_fall; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_WAKE_UP_DUR, + (uint8_t *)&wake_up_dur, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FREE_FALL, (uint8_t *)&free_fall, 1); + } + + *val = (wake_up_dur.ff_dur << 5) + free_fall.ff_dur; + + return ret; +} + +/** + * @brief Free fall threshold setting.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of ff_ths in reg FREE_FALL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_ff_threshold_set(dev_ctx_t *ctx, + lsm6dsl_ff_ths_t val) +{ + lsm6dsl_free_fall_t free_fall; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FREE_FALL, (uint8_t *)&free_fall, 1); + + if (ret == 0) + { + free_fall.ff_ths = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FREE_FALL, (uint8_t *)&free_fall, 1); + } + + return ret; +} + +/** + * @brief Free fall threshold setting.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of ff_ths in reg FREE_FALL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_ff_threshold_get(dev_ctx_t *ctx, + lsm6dsl_ff_ths_t *val) +{ + lsm6dsl_free_fall_t free_fall; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FREE_FALL, (uint8_t *)&free_fall, 1); + + switch (free_fall.ff_ths) + { + case LSM6DSL_FF_TSH_156mg: + *val = LSM6DSL_FF_TSH_156mg; + break; + + case LSM6DSL_FF_TSH_219mg: + *val = LSM6DSL_FF_TSH_219mg; + break; + + case LSM6DSL_FF_TSH_250mg: + *val = LSM6DSL_FF_TSH_250mg; + break; + + case LSM6DSL_FF_TSH_312mg: + *val = LSM6DSL_FF_TSH_312mg; + break; + + case LSM6DSL_FF_TSH_344mg: + *val = LSM6DSL_FF_TSH_344mg; + break; + + case LSM6DSL_FF_TSH_406mg: + *val = LSM6DSL_FF_TSH_406mg; + break; + + case LSM6DSL_FF_TSH_469mg: + *val = LSM6DSL_FF_TSH_469mg; + break; + + case LSM6DSL_FF_TSH_500mg: + *val = LSM6DSL_FF_TSH_500mg; + break; + + default: + *val = LSM6DSL_FF_TSH_ND; + break; + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_fifo + * @brief This section group all the functions concerning the + * fifo usage + * @{ + * + */ + +/** + * @brief FIFO watermark level selection.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of fth in reg FIFO_CTRL1 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_watermark_set(dev_ctx_t *ctx, uint16_t val) +{ + lsm6dsl_fifo_ctrl1_t fifo_ctrl1; + lsm6dsl_fifo_ctrl2_t fifo_ctrl2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + + if (ret == 0) + { + fifo_ctrl1.fth = (uint8_t)(0x00FFU & val); + fifo_ctrl2.fth = (uint8_t)((0x0700U & val) >> 8); + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL1, + (uint8_t *)&fifo_ctrl1, 1); + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + } + } + + return ret; +} + +/** + * @brief FIFO watermark level selection.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of fth in reg FIFO_CTRL1 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_watermark_get(dev_ctx_t *ctx, uint16_t *val) +{ + lsm6dsl_fifo_ctrl1_t fifo_ctrl1; + lsm6dsl_fifo_ctrl2_t fifo_ctrl2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL1, + (uint8_t *)&fifo_ctrl1, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + } + + *val = ((uint16_t)fifo_ctrl2.fth << 8) + (uint16_t)fifo_ctrl1.fth; + + return ret; +} + +/** + * @brief FIFO data level.[get] + * + * @param ctx Read / write interface definitions + * @param val get the values of diff_fifo in reg FIFO_STATUS1 and + * FIFO_STATUS2(diff_fifo), it is recommended to set the + * BDU bit. + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_data_level_get(dev_ctx_t *ctx, uint16_t *val) +{ + lsm6dsl_fifo_status1_t fifo_status1; + lsm6dsl_fifo_status2_t fifo_status2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_STATUS1, + (uint8_t *)&fifo_status1, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_STATUS2, + (uint8_t *)&fifo_status2, 1); + *val = ((uint16_t) fifo_status2.diff_fifo << 8) + + (uint16_t) fifo_status1.diff_fifo; + } + + return ret; +} + +/** + * @brief FIFO watermark.[get] + * + * @param ctx Read / write interface definitions + * @param val get the values of watermark in reg FIFO_STATUS2 and + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_wtm_flag_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_fifo_status2_t fifo_status2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_STATUS2, + (uint8_t *)&fifo_status2, 1); + *val = fifo_status2.waterm; + + return ret; +} + +/** + * @brief FIFO pattern.[get] + * + * @param ctx Read / write interface definitions + * @param val get the values of fifo_pattern in reg FIFO_STATUS3 and + * FIFO_STATUS4, it is recommended to set the BDU bit + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_pattern_get(dev_ctx_t *ctx, uint16_t *val) +{ + lsm6dsl_fifo_status3_t fifo_status3; + lsm6dsl_fifo_status4_t fifo_status4; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_STATUS3, + (uint8_t *)&fifo_status3, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_STATUS4, + (uint8_t *)&fifo_status4, 1); + *val = ((uint16_t)fifo_status4.fifo_pattern << 8) + + fifo_status3.fifo_pattern; + } + + return ret; +} + +/** + * @brief Batching of temperature data[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of fifo_temp_en in reg FIFO_CTRL2 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_temp_batch_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_fifo_ctrl2_t fifo_ctrl2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + + if (ret == 0) + { + fifo_ctrl2.fifo_temp_en = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + } + + return ret; +} + +/** + * @brief Batching of temperature data[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of fifo_temp_en in reg FIFO_CTRL2 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_temp_batch_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_fifo_ctrl2_t fifo_ctrl2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + *val = fifo_ctrl2.fifo_temp_en; + + return ret; +} + +/** + * @brief Trigger signal for FIFO write operation.[set] + * + * @param ctx Read / write interface definitions + * @param val act on FIFO_CTRL2(timer_pedo_fifo_drdy) + * and MASTER_CONFIG(data_valid_sel_fifo) + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_write_trigger_set(dev_ctx_t *ctx, + lsm6dsl_trigger_fifo_t val) +{ + lsm6dsl_fifo_ctrl2_t fifo_ctrl2; + lsm6dsl_master_config_t master_config; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + + if (ret == 0) + { + fifo_ctrl2.timer_pedo_fifo_drdy = (uint8_t)val & 0x01U; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + + if (ret == 0) + { + master_config.data_valid_sel_fifo = (((uint8_t)val & 0x02U) >> 1); + ret = lsm6dsl_write_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + } + } + } + + return ret; +} + +/** + * @brief Trigger signal for FIFO write operation.[get] + * + * @param ctx Read / write interface definitions + * @param val act on FIFO_CTRL2(timer_pedo_fifo_drdy) + * and MASTER_CONFIG(data_valid_sel_fifo) + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_write_trigger_get(dev_ctx_t *ctx, + lsm6dsl_trigger_fifo_t *val) +{ + lsm6dsl_fifo_ctrl2_t fifo_ctrl2; + lsm6dsl_master_config_t master_config; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + + switch ((fifo_ctrl2.timer_pedo_fifo_drdy << 1) + + fifo_ctrl2. timer_pedo_fifo_drdy) + { + case LSM6DSL_TRG_XL_GY_DRDY: + *val = LSM6DSL_TRG_XL_GY_DRDY; + break; + + case LSM6DSL_TRG_STEP_DETECT: + *val = LSM6DSL_TRG_STEP_DETECT; + break; + + case LSM6DSL_TRG_SH_DRDY: + *val = LSM6DSL_TRG_SH_DRDY; + break; + + default: + *val = LSM6DSL_TRG_SH_ND; + break; + } + } + + return ret; +} + +/** + * @brief Enable pedometer step counter and timestamp as 4th + * FIFO data set.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of timer_pedo_fifo_en in reg FIFO_CTRL2 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_pedo_and_timestamp_batch_set(dev_ctx_t *ctx, + uint8_t val) +{ + lsm6dsl_fifo_ctrl2_t fifo_ctrl2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + + if (ret == 0) + { + fifo_ctrl2.timer_pedo_fifo_en = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + } + + return ret; +} + +/** + * @brief Enable pedometer step counter and timestamp as 4th + * FIFO data set.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of timer_pedo_fifo_en in reg FIFO_CTRL2 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_pedo_and_timestamp_batch_get(dev_ctx_t *ctx, + uint8_t *val) +{ + lsm6dsl_fifo_ctrl2_t fifo_ctrl2; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + *val = fifo_ctrl2.timer_pedo_fifo_en; + + return ret; +} + +/** + * @brief Selects Batching Data Rate (writing frequency in FIFO) for + * accelerometer data.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of dec_fifo_xl in reg FIFO_CTRL3 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_xl_batch_set(dev_ctx_t *ctx, + lsm6dsl_dec_fifo_xl_t val) +{ + lsm6dsl_fifo_ctrl3_t fifo_ctrl3; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL3, + (uint8_t *)&fifo_ctrl3, 1); + + if (ret == 0) + { + fifo_ctrl3.dec_fifo_xl = (uint8_t)val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL3, + (uint8_t *)&fifo_ctrl3, 1); + } + + return ret; +} + +/** + * @brief Selects Batching Data Rate (writing frequency in FIFO) for + * accelerometer data.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of dec_fifo_xl in reg FIFO_CTRL3 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_xl_batch_get(dev_ctx_t *ctx, + lsm6dsl_dec_fifo_xl_t *val) +{ + lsm6dsl_fifo_ctrl3_t fifo_ctrl3; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL3, + (uint8_t *)&fifo_ctrl3, 1); + + switch (fifo_ctrl3.dec_fifo_xl) + { + case LSM6DSL_FIFO_XL_DISABLE: + *val = LSM6DSL_FIFO_XL_DISABLE; + break; + + case LSM6DSL_FIFO_XL_NO_DEC: + *val = LSM6DSL_FIFO_XL_NO_DEC; + break; + + case LSM6DSL_FIFO_XL_DEC_2: + *val = LSM6DSL_FIFO_XL_DEC_2; + break; + + case LSM6DSL_FIFO_XL_DEC_3: + *val = LSM6DSL_FIFO_XL_DEC_3; + break; + + case LSM6DSL_FIFO_XL_DEC_4: + *val = LSM6DSL_FIFO_XL_DEC_4; + break; + + case LSM6DSL_FIFO_XL_DEC_8: + *val = LSM6DSL_FIFO_XL_DEC_8; + break; + + case LSM6DSL_FIFO_XL_DEC_16: + *val = LSM6DSL_FIFO_XL_DEC_16; + break; + + case LSM6DSL_FIFO_XL_DEC_32: + *val = LSM6DSL_FIFO_XL_DEC_32; + break; + + default: + *val = LSM6DSL_FIFO_XL_DEC_ND; + break; + } + + return ret; +} + +/** + * @brief Selects Batching Data Rate (writing frequency in FIFO) + * for gyroscope data.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of dec_fifo_gyro in reg FIFO_CTRL3 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_gy_batch_set(dev_ctx_t *ctx, + lsm6dsl_dec_fifo_gyro_t val) +{ + lsm6dsl_fifo_ctrl3_t fifo_ctrl3; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL3, + (uint8_t *)&fifo_ctrl3, 1); + + if (ret == 0) + { + fifo_ctrl3.dec_fifo_gyro = (uint8_t)val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL3, + (uint8_t *)&fifo_ctrl3, 1); + } + + return ret; +} + +/** + * @brief Selects Batching Data Rate (writing frequency in FIFO) + * for gyroscope data.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of dec_fifo_gyro in reg FIFO_CTRL3 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_gy_batch_get(dev_ctx_t *ctx, + lsm6dsl_dec_fifo_gyro_t *val) +{ + lsm6dsl_fifo_ctrl3_t fifo_ctrl3; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL3, + (uint8_t *)&fifo_ctrl3, 1); + + switch (fifo_ctrl3.dec_fifo_gyro) + { + case LSM6DSL_FIFO_GY_DISABLE: + *val = LSM6DSL_FIFO_GY_DISABLE; + break; + + case LSM6DSL_FIFO_GY_NO_DEC: + *val = LSM6DSL_FIFO_GY_NO_DEC; + break; + + case LSM6DSL_FIFO_GY_DEC_2: + *val = LSM6DSL_FIFO_GY_DEC_2; + break; + + case LSM6DSL_FIFO_GY_DEC_3: + *val = LSM6DSL_FIFO_GY_DEC_3; + break; + + case LSM6DSL_FIFO_GY_DEC_4: + *val = LSM6DSL_FIFO_GY_DEC_4; + break; + + case LSM6DSL_FIFO_GY_DEC_8: + *val = LSM6DSL_FIFO_GY_DEC_8; + break; + + case LSM6DSL_FIFO_GY_DEC_16: + *val = LSM6DSL_FIFO_GY_DEC_16; + break; + + case LSM6DSL_FIFO_GY_DEC_32: + *val = LSM6DSL_FIFO_GY_DEC_32; + break; + + default: + *val = LSM6DSL_FIFO_GY_DEC_ND; + break; + } + + return ret; +} + +/** + * @brief Selects Batching Data Rate (writing frequency in FIFO) + * for third data set.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of dec_ds3_fifo in reg FIFO_CTRL4 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_dataset_3_batch_set(dev_ctx_t *ctx, + lsm6dsl_dec_ds3_fifo_t val) +{ + lsm6dsl_fifo_ctrl4_t fifo_ctrl4; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL4, + (uint8_t *)&fifo_ctrl4, 1); + + if (ret == 0) + { + fifo_ctrl4.dec_ds3_fifo = (uint8_t)val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL4, + (uint8_t *)&fifo_ctrl4, 1); + } + + return ret; +} + +/** + * @brief Selects Batching Data Rate (writing frequency in FIFO) + * for third data set.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of dec_ds3_fifo in reg FIFO_CTRL4 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_dataset_3_batch_get(dev_ctx_t *ctx, + lsm6dsl_dec_ds3_fifo_t *val) +{ + lsm6dsl_fifo_ctrl4_t fifo_ctrl4; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL4, + (uint8_t *)&fifo_ctrl4, 1); + + switch (fifo_ctrl4.dec_ds3_fifo) + { + case LSM6DSL_FIFO_DS3_DISABLE: + *val = LSM6DSL_FIFO_DS3_DISABLE; + break; + + case LSM6DSL_FIFO_DS3_NO_DEC: + *val = LSM6DSL_FIFO_DS3_NO_DEC; + break; + + case LSM6DSL_FIFO_DS3_DEC_2: + *val = LSM6DSL_FIFO_DS3_DEC_2; + break; + + case LSM6DSL_FIFO_DS3_DEC_3: + *val = LSM6DSL_FIFO_DS3_DEC_3; + break; + + case LSM6DSL_FIFO_DS3_DEC_4: + *val = LSM6DSL_FIFO_DS3_DEC_4; + break; + + case LSM6DSL_FIFO_DS3_DEC_8: + *val = LSM6DSL_FIFO_DS3_DEC_8; + break; + + case LSM6DSL_FIFO_DS3_DEC_16: + *val = LSM6DSL_FIFO_DS3_DEC_16; + break; + + case LSM6DSL_FIFO_DS3_DEC_32: + *val = LSM6DSL_FIFO_DS3_DEC_32; + break; + + default: + *val = LSM6DSL_FIFO_DS3_DEC_ND; + break; + } + + return ret; +} + +/** + * @brief Selects Batching Data Rate (writing frequency in FIFO) + * for fourth data set.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of dec_ds4_fifo in reg FIFO_CTRL4 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_dataset_4_batch_set(dev_ctx_t *ctx, + lsm6dsl_dec_ds4_fifo_t val) +{ + lsm6dsl_fifo_ctrl4_t fifo_ctrl4; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL4, + (uint8_t *)&fifo_ctrl4, 1); + + if (ret == 0) + { + fifo_ctrl4.dec_ds4_fifo = (uint8_t)val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL4, + (uint8_t *)&fifo_ctrl4, 1); + } + + return ret; +} + +/** + * @brief Selects Batching Data Rate (writing frequency in FIFO) for + * fourth data set.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of dec_ds4_fifo in reg FIFO_CTRL4 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_dataset_4_batch_get(dev_ctx_t *ctx, + lsm6dsl_dec_ds4_fifo_t *val) +{ + lsm6dsl_fifo_ctrl4_t fifo_ctrl4; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL4, + (uint8_t *)&fifo_ctrl4, 1); + + switch (fifo_ctrl4.dec_ds4_fifo) + { + case LSM6DSL_FIFO_DS4_DISABLE: + *val = LSM6DSL_FIFO_DS4_DISABLE; + break; + + case LSM6DSL_FIFO_DS4_NO_DEC: + *val = LSM6DSL_FIFO_DS4_NO_DEC; + break; + + case LSM6DSL_FIFO_DS4_DEC_2: + *val = LSM6DSL_FIFO_DS4_DEC_2; + break; + + case LSM6DSL_FIFO_DS4_DEC_3: + *val = LSM6DSL_FIFO_DS4_DEC_3; + break; + + case LSM6DSL_FIFO_DS4_DEC_4: + *val = LSM6DSL_FIFO_DS4_DEC_4; + break; + + case LSM6DSL_FIFO_DS4_DEC_8: + *val = LSM6DSL_FIFO_DS4_DEC_8; + break; + + case LSM6DSL_FIFO_DS4_DEC_16: + *val = LSM6DSL_FIFO_DS4_DEC_16; + break; + + case LSM6DSL_FIFO_DS4_DEC_32: + *val = LSM6DSL_FIFO_DS4_DEC_32; + break; + + default: + *val = LSM6DSL_FIFO_DS4_DEC_ND; + break; + } + + return ret; +} + +/** + * @brief 8-bit data storage in FIFO.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of only_high_data in reg FIFO_CTRL4 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_xl_gy_8bit_format_set(dev_ctx_t *ctx, + uint8_t val) +{ + lsm6dsl_fifo_ctrl4_t fifo_ctrl4; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL4, + (uint8_t *)&fifo_ctrl4, 1); + + if (ret == 0) + { + fifo_ctrl4.only_high_data = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL4, + (uint8_t *)&fifo_ctrl4, 1); + } + + return ret; +} + +/** + * @brief 8-bit data storage in FIFO.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of only_high_data in reg FIFO_CTRL4 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_xl_gy_8bit_format_get(dev_ctx_t *ctx, + uint8_t *val) +{ + lsm6dsl_fifo_ctrl4_t fifo_ctrl4; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL4, + (uint8_t *)&fifo_ctrl4, 1); + *val = fifo_ctrl4.only_high_data; + + return ret; +} + +/** + * @brief Sensing chain FIFO stop values memorization at threshold + * level.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of stop_on_fth in reg FIFO_CTRL4 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_stop_on_wtm_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_fifo_ctrl4_t fifo_ctrl4; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL4, + (uint8_t *)&fifo_ctrl4, 1); + + if (ret == 0) + { + fifo_ctrl4.stop_on_fth = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL4, + (uint8_t *)&fifo_ctrl4, 1); + } + + return ret; +} + +/** + * @brief Sensing chain FIFO stop values memorization at threshold + * level.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of stop_on_fth in reg FIFO_CTRL4 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_stop_on_wtm_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_fifo_ctrl4_t fifo_ctrl4; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL4, + (uint8_t *)&fifo_ctrl4, 1); + *val = fifo_ctrl4.stop_on_fth; + + return ret; +} + +/** + * @brief FIFO mode selection.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of fifo_mode in reg FIFO_CTRL5 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_mode_set(dev_ctx_t *ctx, + lsm6dsl_fifo_mode_t val) +{ + lsm6dsl_fifo_ctrl5_t fifo_ctrl5; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL5, + (uint8_t *)&fifo_ctrl5, 1); + + if (ret == 0) + { + fifo_ctrl5.fifo_mode = (uint8_t)val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL5, + (uint8_t *)&fifo_ctrl5, 1); + } + + return ret; +} + +/** + * @brief FIFO mode selection.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of fifo_mode in reg FIFO_CTRL5 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_mode_get(dev_ctx_t *ctx, + lsm6dsl_fifo_mode_t *val) +{ + lsm6dsl_fifo_ctrl5_t fifo_ctrl5; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL5, + (uint8_t *)&fifo_ctrl5, 1); + + switch (fifo_ctrl5.fifo_mode) + { + case LSM6DSL_BYPASS_MODE: + *val = LSM6DSL_BYPASS_MODE; + break; + + case LSM6DSL_FIFO_MODE: + *val = LSM6DSL_FIFO_MODE; + break; + + case LSM6DSL_STREAM_TO_FIFO_MODE: + *val = LSM6DSL_STREAM_TO_FIFO_MODE; + break; + + case LSM6DSL_BYPASS_TO_STREAM_MODE: + *val = LSM6DSL_BYPASS_TO_STREAM_MODE; + break; + + case LSM6DSL_STREAM_MODE: + *val = LSM6DSL_STREAM_MODE; + break; + + default: + *val = LSM6DSL_FIFO_MODE_ND; + break; + } + + return ret; +} + +/** + * @brief FIFO ODR selection, setting FIFO_MODE also.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of odr_fifo in reg FIFO_CTRL5 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_data_rate_set(dev_ctx_t *ctx, + lsm6dsl_odr_fifo_t val) +{ + lsm6dsl_fifo_ctrl5_t fifo_ctrl5; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL5, + (uint8_t *)&fifo_ctrl5, 1); + + if (ret == 0) + { + fifo_ctrl5.odr_fifo = (uint8_t)val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL5, + (uint8_t *)&fifo_ctrl5, 1); + } + + return ret; +} + +/** + * @brief FIFO ODR selection, setting FIFO_MODE also.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of odr_fifo in reg FIFO_CTRL5 + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_fifo_data_rate_get(dev_ctx_t *ctx, + lsm6dsl_odr_fifo_t *val) +{ + lsm6dsl_fifo_ctrl5_t fifo_ctrl5; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL5, + (uint8_t *)&fifo_ctrl5, 1); + + switch (fifo_ctrl5.odr_fifo) + { + case LSM6DSL_FIFO_DISABLE: + *val = LSM6DSL_FIFO_DISABLE; + break; + + case LSM6DSL_FIFO_12Hz5: + *val = LSM6DSL_FIFO_12Hz5; + break; + + case LSM6DSL_FIFO_26Hz: + *val = LSM6DSL_FIFO_26Hz; + break; + + case LSM6DSL_FIFO_52Hz: + *val = LSM6DSL_FIFO_52Hz; + break; + + case LSM6DSL_FIFO_104Hz: + *val = LSM6DSL_FIFO_104Hz; + break; + + case LSM6DSL_FIFO_208Hz: + *val = LSM6DSL_FIFO_208Hz; + break; + + case LSM6DSL_FIFO_416Hz: + *val = LSM6DSL_FIFO_416Hz; + break; + + case LSM6DSL_FIFO_833Hz: + *val = LSM6DSL_FIFO_833Hz; + break; + + case LSM6DSL_FIFO_1k66Hz: + *val = LSM6DSL_FIFO_1k66Hz; + break; + + case LSM6DSL_FIFO_3k33Hz: + *val = LSM6DSL_FIFO_3k33Hz; + break; + + case LSM6DSL_FIFO_6k66Hz: + *val = LSM6DSL_FIFO_6k66Hz; + break; + + default: + *val = LSM6DSL_FIFO_RATE_ND; + break; + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_DEN_functionality + * @brief This section groups all the functions concerning DEN + * functionality. + * @{ + * + */ + +/** + * @brief DEN active level configuration.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of den_lh in reg CTRL5_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_den_polarity_set(dev_ctx_t *ctx, + lsm6dsl_den_lh_t val) +{ + lsm6dsl_ctrl5_c_t ctrl5_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t *)&ctrl5_c, 1); + + if (ret == 0) + { + ctrl5_c.den_lh = (uint8_t)val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t *)&ctrl5_c, 1); + } + + return ret; +} + +/** + * @brief DEN active level configuration.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of den_lh in reg CTRL5_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_den_polarity_get(dev_ctx_t *ctx, + lsm6dsl_den_lh_t *val) +{ + lsm6dsl_ctrl5_c_t ctrl5_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t *)&ctrl5_c, 1); + + switch (ctrl5_c.den_lh) + { + case LSM6DSL_DEN_ACT_LOW: + *val = LSM6DSL_DEN_ACT_LOW; + break; + + case LSM6DSL_DEN_ACT_HIGH: + *val = LSM6DSL_DEN_ACT_HIGH; + break; + + default: + *val = LSM6DSL_DEN_POL_ND; + break; + } + + return ret; +} + +/** + * @brief DEN functionality marking mode[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of den_mode in reg CTRL6_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_den_mode_set(dev_ctx_t *ctx, + lsm6dsl_den_mode_t val) +{ + lsm6dsl_ctrl6_c_t ctrl6_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL6_C, (uint8_t *)&ctrl6_c, 1); + + if (ret == 0) + { + ctrl6_c.den_mode = (uint8_t)val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL6_C, (uint8_t *)&ctrl6_c, 1); + } + + return ret; +} + +/** + * @brief DEN functionality marking mode[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of den_mode in reg CTRL6_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_den_mode_get(dev_ctx_t *ctx, + lsm6dsl_den_mode_t *val) +{ + lsm6dsl_ctrl6_c_t ctrl6_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL6_C, (uint8_t *)&ctrl6_c, 1); + + switch (ctrl6_c.den_mode) + { + case LSM6DSL_DEN_DISABLE: + *val = LSM6DSL_DEN_DISABLE; + break; + + case LSM6DSL_LEVEL_LETCHED: + *val = LSM6DSL_LEVEL_LETCHED; + break; + + case LSM6DSL_LEVEL_TRIGGER: + *val = LSM6DSL_LEVEL_TRIGGER; + break; + + case LSM6DSL_EDGE_TRIGGER: + *val = LSM6DSL_EDGE_TRIGGER; + break; + + default: + *val = LSM6DSL_DEN_MODE_ND; + break; + } + + return ret; +} + +/** + * @brief Extend DEN functionality to accelerometer sensor.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of den_xl_g in reg CTRL9_XL + * and den_xl_en in CTRL4_C. + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_den_enable_set(dev_ctx_t *ctx, + lsm6dsl_den_xl_en_t val) +{ + lsm6dsl_ctrl4_c_t ctrl4_c; + lsm6dsl_ctrl9_xl_t ctrl9_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + + if (ret == 0) + { + ctrl9_xl.den_xl_g = (uint8_t)val & 0x01U; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + + if (ret == 0) + { + ctrl4_c.den_xl_en = (uint8_t)val & 0x02U; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + } + } + } + + return ret; +} + +/** + * @brief Extend DEN functionality to accelerometer sensor. [get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of den_xl_g in reg CTRL9_XL + * and den_xl_en in CTRL4_C. + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_den_enable_get(dev_ctx_t *ctx, + lsm6dsl_den_xl_en_t *val) +{ + lsm6dsl_ctrl4_c_t ctrl4_c; + lsm6dsl_ctrl9_xl_t ctrl9_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t *)&ctrl4_c, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + + switch ((ctrl4_c.den_xl_en << 1) + ctrl9_xl.den_xl_g) + { + case LSM6DSL_STAMP_IN_GY_DATA: + *val = LSM6DSL_STAMP_IN_GY_DATA; + break; + + case LSM6DSL_STAMP_IN_XL_DATA: + *val = LSM6DSL_STAMP_IN_XL_DATA; + break; + + case LSM6DSL_STAMP_IN_GY_XL_DATA: + *val = LSM6DSL_STAMP_IN_GY_XL_DATA; + break; + + default: + *val = LSM6DSL_DEN_STAMP_ND; + break; + } + } + + return ret; +} + +/** + * @brief DEN value stored in LSB of Z-axis.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of den_z in reg CTRL9_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_den_mark_axis_z_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl9_xl_t ctrl9_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + + if (ret == 0) + { + ctrl9_xl.den_z = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + } + + return ret; +} + +/** + * @brief DEN value stored in LSB of Z-axis.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of den_z in reg CTRL9_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_den_mark_axis_z_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl9_xl_t ctrl9_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + *val = ctrl9_xl.den_z; + + return ret; +} + +/** + * @brief DEN value stored in LSB of Y-axis.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of den_y in reg CTRL9_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_den_mark_axis_y_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl9_xl_t ctrl9_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + + if (ret == 0) + { + ctrl9_xl.den_y = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + } + + return ret; +} + +/** + * @brief DEN value stored in LSB of Y-axis.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of den_y in reg CTRL9_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_den_mark_axis_y_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl9_xl_t ctrl9_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + *val = ctrl9_xl.den_y; + + return ret; +} + +/** + * @brief DEN value stored in LSB of X-axis.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of den_x in reg CTRL9_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_den_mark_axis_x_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl9_xl_t ctrl9_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + + if (ret == 0) + { + ctrl9_xl.den_x = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + } + + return ret; +} + +/** + * @brief DEN value stored in LSB of X-axis.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of den_x in reg CTRL9_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_den_mark_axis_x_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl9_xl_t ctrl9_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + *val = ctrl9_xl.den_x; + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_Pedometer + * @brief This section groups all the functions that manage pedometer. + * @{ + * + */ + +/** + * @brief Reset pedometer step counter.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of pedo_rst_step in reg CTRL10_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_step_reset_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + + if (ret == 0) + { + ctrl10_c.pedo_rst_step = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + } + + return ret; +} + +/** + * @brief Reset pedometer step counter.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of pedo_rst_step in reg CTRL10_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_step_reset_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + *val = ctrl10_c.pedo_rst_step; + + return ret; +} + +/** + * @brief Enable pedometer algorithm.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of pedo_en in reg CTRL10_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_sens_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + + if (ret == 0) + { + ctrl10_c.pedo_en = val; + + if (val != 0x00U) + { + ctrl10_c.func_en = val; + } + + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + } + + return ret; +} + +/** + * @brief pedo_sens: Enable pedometer algorithm.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of pedo_en in reg CTRL10_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_sens_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + *val = ctrl10_c.pedo_en; + + return ret; +} + +/** + * @brief Minimum threshold to detect a peak. Default is 10h.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of ths_min in reg + * CONFIG_PEDO_THS_MIN + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_threshold_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_config_pedo_ths_min_t config_pedo_ths_min; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CONFIG_PEDO_THS_MIN, + (uint8_t *)&config_pedo_ths_min, 1); + + if (ret == 0) + { + config_pedo_ths_min.ths_min = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CONFIG_PEDO_THS_MIN, + (uint8_t *)&config_pedo_ths_min, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + + return ret; +} + +/** + * @brief Minimum threshold to detect a peak. Default is 10h.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of ths_min in reg CONFIG_PEDO_THS_MIN + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_threshold_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_config_pedo_ths_min_t config_pedo_ths_min; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CONFIG_PEDO_THS_MIN, + (uint8_t *)&config_pedo_ths_min, 1); + + if (ret == 0) + { + *val = config_pedo_ths_min.ths_min; + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief pedo_full_scale: Pedometer data range.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of pedo_fs in + * reg CONFIG_PEDO_THS_MIN + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_full_scale_set(dev_ctx_t *ctx, + lsm6dsl_pedo_fs_t val) +{ + lsm6dsl_config_pedo_ths_min_t config_pedo_ths_min; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CONFIG_PEDO_THS_MIN, + (uint8_t *)&config_pedo_ths_min, 1); + + if (ret == 0) + { + config_pedo_ths_min.pedo_fs = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CONFIG_PEDO_THS_MIN, + (uint8_t *)&config_pedo_ths_min, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + + return ret; +} + +/** + * @brief Pedometer data range.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of pedo_fs in + * reg CONFIG_PEDO_THS_MIN + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_full_scale_get(dev_ctx_t *ctx, + lsm6dsl_pedo_fs_t *val) +{ + lsm6dsl_config_pedo_ths_min_t config_pedo_ths_min; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CONFIG_PEDO_THS_MIN, + (uint8_t *)&config_pedo_ths_min, 1); + + if (ret == 0) + { + switch (config_pedo_ths_min.pedo_fs) + { + case LSM6DSL_PEDO_AT_2g: + *val = LSM6DSL_PEDO_AT_2g; + break; + + case LSM6DSL_PEDO_AT_4g: + *val = LSM6DSL_PEDO_AT_4g; + break; + + default: + *val = LSM6DSL_PEDO_FS_ND; + break; + } + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Pedometer debounce configuration register (r/w).[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of deb_step in reg PEDO_DEB_REG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_debounce_steps_set(dev_ctx_t *ctx, + uint8_t val) +{ + lsm6dsl_pedo_deb_reg_t pedo_deb_reg; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_PEDO_DEB_REG, + (uint8_t *)&pedo_deb_reg, 1); + + if (ret == 0) + { + pedo_deb_reg.deb_step = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_PEDO_DEB_REG, + (uint8_t *)&pedo_deb_reg, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + + return ret; +} + +/** + * @brief Pedometer debounce configuration register (r/w).[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of deb_step in reg PEDO_DEB_REG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_debounce_steps_get(dev_ctx_t *ctx, + uint8_t *val) +{ + lsm6dsl_pedo_deb_reg_t pedo_deb_reg; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_PEDO_DEB_REG, + (uint8_t *)&pedo_deb_reg, 1); + + if (ret == 0) + { + *val = pedo_deb_reg.deb_step; + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Debounce time. If the time between two consecutive steps is + * greater than DEB_TIME*80ms, the debouncer is reactivated. + * Default value: 01101[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of deb_time in reg PEDO_DEB_REG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_timeout_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_pedo_deb_reg_t pedo_deb_reg; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_PEDO_DEB_REG, + (uint8_t *)&pedo_deb_reg, 1); + + if (ret == 0) + { + pedo_deb_reg.deb_time = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_PEDO_DEB_REG, + (uint8_t *)&pedo_deb_reg, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + + return ret; +} + +/** + * @brief Debounce time. If the time between two consecutive steps is + * greater than DEB_TIME*80ms, the debouncer is reactivated. + * Default value: 01101[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of deb_time in reg PEDO_DEB_REG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_timeout_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_pedo_deb_reg_t pedo_deb_reg; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_PEDO_DEB_REG, + (uint8_t *)&pedo_deb_reg, 1); + + if (ret == 0) + { + *val = pedo_deb_reg.deb_time; + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Time period register for step detection on delta time (r/w).[set] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that contains data to write + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_steps_period_set(dev_ctx_t *ctx, + uint8_t *buff) +{ + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_STEP_COUNT_DELTA, buff, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Time period register for step detection on delta time (r/w).[get] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that stores data read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_pedo_steps_period_get(dev_ctx_t *ctx, + uint8_t *buff) +{ + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_STEP_COUNT_DELTA, buff, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_significant_motion + * @brief This section groups all the functions that manage the + * significant motion detection. + * @{ + * + */ + +/** + * @brief Enable significant motion detection function.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of sign_motion_en in reg CTRL10_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_motion_sens_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + + if (ret == 0) + { + ctrl10_c.sign_motion_en = val; + + if (val != 0x00U) + { + ctrl10_c.func_en = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + } + } + + return ret; +} + +/** + * @brief Enable significant motion detection function.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of sign_motion_en in reg CTRL10_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_motion_sens_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + *val = ctrl10_c.sign_motion_en; + + return ret; +} + +/** + * @brief Significant motion threshold.[set] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that store significant motion threshold. + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_motion_threshold_set(dev_ctx_t *ctx, uint8_t *buff) +{ + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SM_THS, buff, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Significant motion threshold.[get] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that store significant motion threshold. + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_motion_threshold_get(dev_ctx_t *ctx, uint8_t *buff) +{ + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SM_THS, buff, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_tilt_detection + * @brief This section groups all the functions that manage the tilt + * event detection. + * @{ + * + */ + +/** + * @brief Enable tilt calculation.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tilt_en in reg CTRL10_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tilt_sens_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + + if (ret == 0) + { + ctrl10_c.tilt_en = val; + + if (val != 0x00U) + { + ctrl10_c.func_en = val; + } + + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + } + + return ret; +} + +/** + * @brief Enable tilt calculation.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tilt_en in reg CTRL10_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tilt_sens_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + *val = ctrl10_c.tilt_en; + + return ret; +} + +/** + * @brief Enable tilt calculation.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tilt_en in reg CTRL10_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_wrist_tilt_sens_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + + if (ret == 0) + { + ctrl10_c.wrist_tilt_en = val; + + if (val != 0x00U) + { + ctrl10_c.func_en = val; + } + + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + } + + return ret; +} + +/** + * @brief Enable tilt calculation.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tilt_en in reg CTRL10_C + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_wrist_tilt_sens_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + *val = ctrl10_c.wrist_tilt_en; + + return ret; +} + +/** + * @brief Absolute Wrist Tilt latency register (r/w). + * Absolute wrist tilt latency parameters. + * 1 LSB = 40 ms. Default value: 0Fh (600 ms).[set] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that contains data to write + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tilt_latency_set(dev_ctx_t *ctx, uint8_t *buff) +{ + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_B); + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_A_WRIST_TILT_LAT, buff, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Absolute Wrist Tilt latency register (r/w). + * Absolute wrist tilt latency parameters. + * 1 LSB = 40 ms. Default value: 0Fh (600 ms).[get] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that stores data read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tilt_latency_get(dev_ctx_t *ctx, uint8_t *buff) +{ + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_B); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_A_WRIST_TILT_LAT, buff, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Absolute Wrist Tilt threshold register(r/w). + * Absolute wrist tilt threshold parameters. + * 1 LSB = 15.625 mg.Default value: 20h (500 mg).[set] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that contains data to write + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tilt_threshold_set(dev_ctx_t *ctx, uint8_t *buff) +{ + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_B); + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_A_WRIST_TILT_THS, buff, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Absolute Wrist Tilt threshold register(r/w). + * Absolute wrist tilt threshold parameters. + * 1 LSB = 15.625 mg.Default value: 20h (500 mg).[get] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that stores data read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tilt_threshold_get(dev_ctx_t *ctx, uint8_t *buff) +{ + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_B); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_A_WRIST_TILT_THS, buff, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Absolute Wrist Tilt mask register (r/w).[set] + * + * @param ctx Read / write interface definitions + * @param val Registers A_WRIST_TILT_MASK + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tilt_src_set(dev_ctx_t *ctx, + lsm6dsl_a_wrist_tilt_mask_t *val) +{ + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_B); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_A_WRIST_TILT_MASK, + (uint8_t *) val, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Absolute Wrist Tilt mask register (r/w).[get] + * + * @param ctx Read / write interface definitions + * @param val Registers A_WRIST_TILT_MASK + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_tilt_src_get(dev_ctx_t *ctx, + lsm6dsl_a_wrist_tilt_mask_t *val) +{ + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_B); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_A_WRIST_TILT_MASK, + (uint8_t *) val, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_ magnetometer_sensor + * @brief This section groups all the functions that manage additional + * magnetometer sensor. + * @{ + * + */ + +/** + * @brief Enable soft-iron correction algorithm for magnetometer.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of soft_en in reg CTRL9_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_mag_soft_iron_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl9_xl_t ctrl9_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + + if (ret == 0) + { + ctrl9_xl.soft_en = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + } + + return ret; +} + +/** + * @brief Enable soft-iron correction algorithm for magnetometer.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of soft_en in reg CTRL9_XL + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_mag_soft_iron_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_ctrl9_xl_t ctrl9_xl; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + *val = ctrl9_xl.soft_en; + + return ret; +} + +/** + * @brief Enable hard-iron correction algorithm for magnetometer.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of iron_en in reg MASTER_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_mag_hard_iron_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_master_config_t master_config; + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + + if (ret == 0) + { + master_config.iron_en = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + + if (ret == 0) + { + if (val != 0x00U) + { + ctrl10_c.func_en = val; + } + + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL10_C, + (uint8_t *)&ctrl10_c, 1); + } + } + } + + return ret; +} + +/** + * @brief Enable hard-iron correction algorithm for magnetometer.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of iron_en in reg MASTER_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_mag_hard_iron_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_master_config_t master_config; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + *val = master_config.iron_en; + + return ret; +} + +/** + * @brief Soft iron 3x3 matrix. Value are expressed in sign-module format. + * (Es. SVVVVVVVb where S is the sign 0/+1/- and V is the value).[set] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that contains data to write + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_mag_soft_iron_mat_set(dev_ctx_t *ctx, + uint8_t *buff) +{ + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_MAG_SI_XX, buff, 9); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Soft iron 3x3 matrix. Value are expressed in sign-module format. + * (Es. SVVVVVVVb where S is the sign 0/+1/- and V is the value).[get] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that stores data read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_mag_soft_iron_mat_get(dev_ctx_t *ctx, + uint8_t *buff) +{ + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MAG_SI_XX, buff, 9); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Offset for hard-iron compensation register (r/w). The value is + * expressed as a 16-bit word in two鈥檚 complement.[set] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that contains data to write + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_mag_offset_set(dev_ctx_t *ctx, int16_t *val) +{ + uint8_t buff[6]; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + buff[1] = (uint8_t)((uint16_t)val[0] / 256U); + buff[0] = (uint8_t)((uint16_t)val[0] - (buff[1] * 256U)); + buff[3] = (uint8_t)((uint16_t)val[1] / 256U); + buff[2] = (uint8_t)((uint16_t)val[1] - (buff[3] * 256U)); + buff[5] = (uint8_t)((uint16_t)val[2] / 256U); + buff[4] = (uint8_t)((uint16_t)val[2] - (buff[5] * 256U)); + ret = lsm6dsl_write_reg(ctx, LSM6DSL_MAG_OFFX_L, buff, 6); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Offset for hard-iron compensation register(r/w). + * The value is expressed as a 16-bit word in two鈥檚 complement.[get] + * + * @param ctx Read / write interface definitions + * @param buff Buffer that stores data read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_mag_offset_get(dev_ctx_t *ctx, int16_t *val) +{ + uint8_t buff[6]; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MAG_OFFX_L, buff, 6); + val[0] = (int16_t)buff[1]; + val[0] = (val[0] * 256) + (int16_t)buff[0]; + val[1] = (int16_t)buff[3]; + val[1] = (val[1] * 256) + (int16_t)buff[2]; + val[2] = (int16_t)buff[5]; + val[2] = (val[2] * 256) + (int16_t)buff[4]; + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LSM6DSL_Sensor_hub + * @brief This section groups all the functions that manage the sensor + * hub functionality. + * @{ + * + */ + +/** + * @brief Enable function.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values func_en + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_func_en_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_ctrl10_c_t ctrl10_c; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + + if (ret == 0) + { + ctrl10_c.func_en = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL10_C, (uint8_t *)&ctrl10_c, 1); + } + + return ret; +} + +/** + * @brief Sensor synchronization time frame with the step of 500 ms and + * full range of 5s. Unsigned 8-bit.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tph in reg SENSOR_SYNC_TIME_FRAME + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_sync_sens_frame_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_sensor_sync_time_frame_t sensor_sync_time_frame; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SENSOR_SYNC_TIME_FRAME, + (uint8_t *)&sensor_sync_time_frame, 1); + + if (ret == 0) + { + sensor_sync_time_frame.tph = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SENSOR_SYNC_TIME_FRAME, + (uint8_t *)&sensor_sync_time_frame, 1); + } + + return ret; +} + +/** + * @brief Sensor synchronization time frame with the step of 500 ms and + * full range of 5s. Unsigned 8-bit.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of tph in reg SENSOR_SYNC_TIME_FRAME + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_sync_sens_frame_get(dev_ctx_t *ctx, + uint8_t *val) +{ + lsm6dsl_sensor_sync_time_frame_t sensor_sync_time_frame; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SENSOR_SYNC_TIME_FRAME, + (uint8_t *)&sensor_sync_time_frame, 1); + *val = sensor_sync_time_frame.tph; + + return ret; +} + +/** + * @brief Resolution ratio of error code for sensor synchronization.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of rr in reg SENSOR_SYNC_RES_RATIO + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_sync_sens_ratio_set(dev_ctx_t *ctx, + lsm6dsl_rr_t val) +{ + lsm6dsl_sensor_sync_res_ratio_t sensor_sync_res_ratio; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SENSOR_SYNC_RES_RATIO, + (uint8_t *)&sensor_sync_res_ratio, 1); + + if (ret == 0) + { + sensor_sync_res_ratio.rr = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SENSOR_SYNC_RES_RATIO, + (uint8_t *)&sensor_sync_res_ratio, 1); + } + + return ret; +} + +/** + * @brief Resolution ratio of error code for sensor synchronization.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of rr in reg SENSOR_SYNC_RES_RATIO + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_sync_sens_ratio_get(dev_ctx_t *ctx, + lsm6dsl_rr_t *val) +{ + lsm6dsl_sensor_sync_res_ratio_t sensor_sync_res_ratio; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SENSOR_SYNC_RES_RATIO, + (uint8_t *)&sensor_sync_res_ratio, 1); + + switch (sensor_sync_res_ratio.rr) + { + case LSM6DSL_RES_RATIO_2_11: + *val = LSM6DSL_RES_RATIO_2_11; + break; + + case LSM6DSL_RES_RATIO_2_12: + *val = LSM6DSL_RES_RATIO_2_12; + break; + + case LSM6DSL_RES_RATIO_2_13: + *val = LSM6DSL_RES_RATIO_2_13; + break; + + case LSM6DSL_RES_RATIO_2_14: + *val = LSM6DSL_RES_RATIO_2_14; + break; + + default: + *val = LSM6DSL_RES_RATIO_ND; + break; + } + + return ret; +} + +/** + * @brief Sensor hub I2C master enable.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of master_on in reg MASTER_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_master_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_master_config_t master_config; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + + if (ret == 0) + { + master_config.master_on = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + } + + return ret; +} + +/** + * @brief Sensor hub I2C master enable.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of master_on in reg MASTER_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_master_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_master_config_t master_config; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + *val = master_config.master_on; + + return ret; +} + +/** + * @brief I2C interface pass-through.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of pass_through_mode in reg MASTER_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_pass_through_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_master_config_t master_config; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + + if (ret == 0) + { + master_config.pass_through_mode = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + } + + return ret; +} + +/** + * @brief I2C interface pass-through.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of pass_through_mode in reg MASTER_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_pass_through_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_master_config_t master_config; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + *val = master_config.pass_through_mode; + + return ret; +} + +/** + * @brief Master I2C pull-up enable/disable.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of pull_up_en in reg MASTER_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_pin_mode_set(dev_ctx_t *ctx, + lsm6dsl_pull_up_en_t val) +{ + lsm6dsl_master_config_t master_config; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + + if (ret == 0) + { + master_config.pull_up_en = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + } + + return ret; +} + +/** + * @brief Master I2C pull-up enable/disable.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of pull_up_en in reg MASTER_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_pin_mode_get(dev_ctx_t *ctx, + lsm6dsl_pull_up_en_t *val) +{ + lsm6dsl_master_config_t master_config; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + + switch (master_config.pull_up_en) + { + case LSM6DSL_EXT_PULL_UP: + *val = LSM6DSL_EXT_PULL_UP; + break; + + case LSM6DSL_INTERNAL_PULL_UP: + *val = LSM6DSL_INTERNAL_PULL_UP; + break; + + default: + *val = LSM6DSL_SH_PIN_MODE; + break; + } + + return ret; +} + +/** + * @brief Sensor hub trigger signal selection.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of start_config in reg MASTER_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_syncro_mode_set(dev_ctx_t *ctx, + lsm6dsl_start_config_t val) +{ + lsm6dsl_master_config_t master_config; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + + if (ret == 0) + { + master_config.start_config = (uint8_t)val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + } + + return ret; +} + +/** + * @brief Sensor hub trigger signal selection.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of start_config in reg MASTER_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_syncro_mode_get(dev_ctx_t *ctx, + lsm6dsl_start_config_t *val) +{ + lsm6dsl_master_config_t master_config; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + + switch (master_config.start_config) + { + case LSM6DSL_XL_GY_DRDY: + *val = LSM6DSL_XL_GY_DRDY; + break; + + case LSM6DSL_EXT_ON_INT2_PIN: + *val = LSM6DSL_EXT_ON_INT2_PIN; + break; + + default: + *val = LSM6DSL_SH_SYNCRO_ND; + break; + } + + return ret; +} + +/** + * @brief Manage the Master DRDY signal on INT1 pad.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of drdy_on_int1 in reg MASTER_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_drdy_on_int1_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_master_config_t master_config; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + + if (ret == 0) + { + master_config.drdy_on_int1 = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + } + + return ret; +} + +/** + * @brief Manage the Master DRDY signal on INT1 pad.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of drdy_on_int1 in reg MASTER_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_drdy_on_int1_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_master_config_t master_config; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CONFIG, + (uint8_t *)&master_config, 1); + *val = master_config.drdy_on_int1; + + return ret; +} + +/** + * @brief Sensor hub output registers.[get] + * + * @param ctx Read / write interface definitions + * @param val Structure of registers from SENSORHUB1_REG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_read_data_raw_get(dev_ctx_t *ctx, + lsm6dsl_emb_sh_read_t *val) +{ + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SENSORHUB1_REG, + (uint8_t *) & (val->sh_byte_1), 12); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SENSORHUB13_REG, + (uint8_t *) & (val->sh_byte_13), 6); + } + + return ret; +} + +/** + * @brief Master command code used for stamping for sensor sync.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of master_cmd_code in + * reg MASTER_CMD_CODE + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_cmd_sens_sync_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_master_cmd_code_t master_cmd_code; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CMD_CODE, + (uint8_t *)&master_cmd_code, 1); + + if (ret == 0) + { + master_cmd_code.master_cmd_code = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_MASTER_CMD_CODE, + (uint8_t *)&master_cmd_code, 1); + } + + return ret; +} + +/** + * @brief Master command code used for stamping for sensor sync.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of master_cmd_code in + * reg MASTER_CMD_CODE + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_cmd_sens_sync_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_master_cmd_code_t master_cmd_code; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_MASTER_CMD_CODE, + (uint8_t *)&master_cmd_code, 1); + *val = master_cmd_code.master_cmd_code; + + return ret; +} + +/** + * @brief Error code used for sensor synchronization.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of error_code in + * reg SENS_SYNC_SPI_ERROR_CODE. + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_spi_sync_error_set(dev_ctx_t *ctx, uint8_t val) +{ + lsm6dsl_sens_sync_spi_error_code_t sens_sync_spi_error_code; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SENS_SYNC_SPI_ERROR_CODE, + (uint8_t *)&sens_sync_spi_error_code, 1); + + if (ret == 0) + { + sens_sync_spi_error_code.error_code = val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SENS_SYNC_SPI_ERROR_CODE, + (uint8_t *)&sens_sync_spi_error_code, 1); + } + + return ret; +} + +/** + * @brief Error code used for sensor synchronization.[get] + * + * @param ctx Read / write interface definitions + * @param val Change the values of error_code in + * reg SENS_SYNC_SPI_ERROR_CODE. + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_spi_sync_error_get(dev_ctx_t *ctx, uint8_t *val) +{ + lsm6dsl_sens_sync_spi_error_code_t sens_sync_spi_error_code; + int32_t ret; + + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SENS_SYNC_SPI_ERROR_CODE, + (uint8_t *)&sens_sync_spi_error_code, 1); + *val = sens_sync_spi_error_code.error_code; + + return ret; +} + +/** + * @brief Number of external sensors to be read by the sensor hub.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of aux_sens_on in reg SLAVE0_CONFIG. + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_num_of_dev_connected_set(dev_ctx_t *ctx, + lsm6dsl_aux_sens_on_t val) +{ + lsm6dsl_slave0_config_t slave0_config; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE0_CONFIG, + (uint8_t *)&slave0_config, 1); + + if (ret == 0) + { + slave0_config.aux_sens_on = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLAVE0_CONFIG, + (uint8_t *)&slave0_config, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + + return ret; +} + +/** + * @brief Number of external sensors to be read by the sensor hub.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of aux_sens_on in reg SLAVE0_CONFIG. + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_num_of_dev_connected_get(dev_ctx_t *ctx, + lsm6dsl_aux_sens_on_t *val) +{ + lsm6dsl_slave0_config_t slave0_config; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE0_CONFIG, + (uint8_t *)&slave0_config, 1); + + if (ret == 0) + { + switch (slave0_config.aux_sens_on) + { + case LSM6DSL_SLV_0: + *val = LSM6DSL_SLV_0; + break; + + case LSM6DSL_SLV_0_1: + *val = LSM6DSL_SLV_0_1; + break; + + case LSM6DSL_SLV_0_1_2: + *val = LSM6DSL_SLV_0_1_2; + break; + + case LSM6DSL_SLV_0_1_2_3: + *val = LSM6DSL_SLV_0_1_2_3; + break; + + default: + *val = LSM6DSL_SLV_EN_ND; + break; + } + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Configure slave 0 for perform a write.[set] + * + * @param ctx Read / write interface definitions + * @param val Structure that contain: + * - uint8_t slv_add; 8 bit i2c device address + * - uint8_t slv_subadd; 8 bit register device address + * - uint8_t slv_data; 8 bit data to write + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_cfg_write(dev_ctx_t *ctx, + lsm6dsl_sh_cfg_write_t *val) +{ + lsm6dsl_slv0_add_t slv0_add; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + slv0_add.slave0_add = val->slv0_add; + slv0_add.rw_0 = 0; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLV0_ADD, (uint8_t *)&slv0_add, 1); + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLV0_SUBADD, + &(val->slv0_subadd), 1); + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_DATAWRITE_SRC_MODE_SUB_SLV0, + &(val->slv0_data), 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + } + + return ret; +} + +/** + * @brief Configure slave 0 for perform a read.[get] + * + * @param ctx Read / write interface definitions + * @param val Structure that contain: + * - uint8_t slv_add; 8 bit i2c device address + * - uint8_t slv_subadd; 8 bit register device address + * - uint8_t slv_len; num of bit to read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_slv0_cfg_read(dev_ctx_t *ctx, + lsm6dsl_sh_cfg_read_t *val) +{ + lsm6dsl_slave0_config_t slave0_config; + lsm6dsl_slv0_add_t slv0_add; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + slv0_add.slave0_add = val->slv_add; + slv0_add.rw_0 = 1; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLV0_ADD, (uint8_t *)&slv0_add, 1); + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLV0_SUBADD, + &(val->slv_subadd), 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE0_CONFIG, + (uint8_t *)&slave0_config, 1); + slave0_config.slave0_numop = val->slv_len; + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLAVE0_CONFIG, + (uint8_t *)&slave0_config, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + } + } + + return ret; +} + +/** + * @brief Configure slave 1 for perform a read.[get] + * + * @param ctx Read / write interface definitions + * @param val Structure that contain: + * - uint8_t slv_add; 8 bit i2c device address + * - uint8_t slv_subadd; 8 bit register device address + * - uint8_t slv_len; num of bit to read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_slv1_cfg_read(dev_ctx_t *ctx, + lsm6dsl_sh_cfg_read_t *val) +{ + lsm6dsl_slave1_config_t slave1_config; + lsm6dsl_slv1_add_t slv1_add; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + slv1_add.slave1_add = val->slv_add; + slv1_add.r_1 = 1; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLV1_ADD, (uint8_t *)&slv1_add, 1); + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLV1_SUBADD, + &(val->slv_subadd), 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE1_CONFIG, + (uint8_t *)&slave1_config, 1); + slave1_config.slave1_numop = val->slv_len; + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLAVE1_CONFIG, + (uint8_t *)&slave1_config, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + } + } + + return ret; +} + +/** + * @brief Configure slave 2 for perform a read.[get] + * + * @param ctx Read / write interface definitions + * @param val Structure that contain: + * - uint8_t slv_add; 8 bit i2c device address + * - uint8_t slv_subadd; 8 bit register device address + * - uint8_t slv_len; num of bit to read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_slv2_cfg_read(dev_ctx_t *ctx, + lsm6dsl_sh_cfg_read_t *val) +{ + lsm6dsl_slv2_add_t slv2_add; + lsm6dsl_slave2_config_t slave2_config; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + slv2_add.slave2_add = val->slv_add; + slv2_add.r_2 = 1; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLV2_ADD, (uint8_t *)&slv2_add, 1); + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLV2_SUBADD, + &(val->slv_subadd), 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE2_CONFIG, + (uint8_t *)&slave2_config, 1); + + if (ret == 0) + { + slave2_config.slave2_numop = val->slv_len; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLAVE2_CONFIG, + (uint8_t *)&slave2_config, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + } + } + + return ret; +} + +/** + * @brief Configure slave 3 for perform a read.[get] + * + * @param ctx Read / write interface definitions + * @param val Structure that contain: + * - uint8_t slv_add; 8 bit i2c device address + * - uint8_t slv_subadd; 8 bit register device address + * - uint8_t slv_len; num of bit to read + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_slv3_cfg_read(dev_ctx_t *ctx, + lsm6dsl_sh_cfg_read_t *val) +{ + lsm6dsl_slave3_config_t slave3_config; + lsm6dsl_slv3_add_t slv3_add; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + slv3_add.slave3_add = val->slv_add; + slv3_add.r_3 = 1; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLV3_ADD, (uint8_t *)&slv3_add, 1); + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLV3_SUBADD, + (uint8_t *) & (val->slv_subadd), 1); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE3_CONFIG, + (uint8_t *)&slave3_config, 1); + + if (ret == 0) + { + slave3_config.slave3_numop = val->slv_len; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLAVE3_CONFIG, + (uint8_t *)&slave3_config, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + } + } + + return ret; +} + +/** + * @brief Decimation of read operation on Slave 0 starting from the + * sensor hub trigger.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of slave0_rate in reg SLAVE0_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_slave_0_dec_set(dev_ctx_t *ctx, + lsm6dsl_slave0_rate_t val) +{ + lsm6dsl_slave0_config_t slave0_config; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE0_CONFIG, + (uint8_t *)&slave0_config, 1); + + if (ret == 0) + { + slave0_config.slave0_rate = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLAVE0_CONFIG, + (uint8_t *)&slave0_config, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + + return ret; +} + +/** + * @brief Decimation of read operation on Slave 0 starting from the + * sensor hub trigger.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of slave0_rate in reg SLAVE0_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_slave_0_dec_get(dev_ctx_t *ctx, + lsm6dsl_slave0_rate_t *val) +{ + lsm6dsl_slave0_config_t slave0_config; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE0_CONFIG, + (uint8_t *)&slave0_config, 1); + + if (ret == 0) + { + switch (slave0_config.slave0_rate) + { + case LSM6DSL_SL0_NO_DEC: + *val = LSM6DSL_SL0_NO_DEC; + break; + + case LSM6DSL_SL0_DEC_2: + *val = LSM6DSL_SL0_DEC_2; + break; + + case LSM6DSL_SL0_DEC_4: + *val = LSM6DSL_SL0_DEC_4; + break; + + case LSM6DSL_SL0_DEC_8: + *val = LSM6DSL_SL0_DEC_8; + break; + + default: + *val = LSM6DSL_SL0_DEC_ND; + break; + } + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Slave 0 write operation is performed only at the first sensor + * hub cycle. + * This is effective if the Aux_sens_on[1:0] field in + * SLAVE0_CONFIG(04h) is set to a value other than 00.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of write_once in reg SLAVE1_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_write_mode_set(dev_ctx_t *ctx, + lsm6dsl_write_once_t val) +{ + lsm6dsl_slave1_config_t slave1_config; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE1_CONFIG, + (uint8_t *)&slave1_config, 1); + slave1_config.write_once = (uint8_t) val; + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLAVE1_CONFIG, + (uint8_t *)&slave1_config, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + + return ret; +} + +/** + * @brief Slave 0 write operation is performed only at the first sensor + * hub cycle. + * This is effective if the Aux_sens_on[1:0] field in + * SLAVE0_CONFIG(04h) is set to a value other than 00.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of write_once in reg SLAVE1_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_write_mode_get(dev_ctx_t *ctx, + lsm6dsl_write_once_t *val) +{ + lsm6dsl_slave1_config_t slave1_config; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE1_CONFIG, + (uint8_t *)&slave1_config, 1); + + if (ret == 0) + { + switch (slave1_config.write_once) + { + case LSM6DSL_EACH_SH_CYCLE: + *val = LSM6DSL_EACH_SH_CYCLE; + break; + + case LSM6DSL_ONLY_FIRST_CYCLE: + *val = LSM6DSL_ONLY_FIRST_CYCLE; + break; + + default: + *val = LSM6DSL_SH_WR_MODE_ND; + break; + } + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Decimation of read operation on Slave 1 starting from the + * sensor hub trigger.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of slave1_rate in reg SLAVE1_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_slave_1_dec_set(dev_ctx_t *ctx, + lsm6dsl_slave1_rate_t val) +{ + lsm6dsl_slave1_config_t slave1_config; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE1_CONFIG, + (uint8_t *)&slave1_config, 1); + + if (ret == 0) + { + slave1_config.slave1_rate = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLAVE1_CONFIG, + (uint8_t *)&slave1_config, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + + return ret; +} + +/** + * @brief Decimation of read operation on Slave 1 starting from the + * sensor hub trigger.[get] + * + * @param ctx Read / write interface definitions reg SLAVE1_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_slave_1_dec_get(dev_ctx_t *ctx, + lsm6dsl_slave1_rate_t *val) +{ + lsm6dsl_slave1_config_t slave1_config; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE1_CONFIG, + (uint8_t *)&slave1_config, 1); + + if (ret == 0) + { + switch (slave1_config.slave1_rate) + { + case LSM6DSL_SL1_NO_DEC: + *val = LSM6DSL_SL1_NO_DEC; + break; + + case LSM6DSL_SL1_DEC_2: + *val = LSM6DSL_SL1_DEC_2; + break; + + case LSM6DSL_SL1_DEC_4: + *val = LSM6DSL_SL1_DEC_4; + break; + + case LSM6DSL_SL1_DEC_8: + *val = LSM6DSL_SL1_DEC_8; + break; + + default: + *val = LSM6DSL_SL1_DEC_ND; + break; + } + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Decimation of read operation on Slave 2 starting from the + * sensor hub trigger.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of slave2_rate in reg SLAVE2_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_slave_2_dec_set(dev_ctx_t *ctx, + lsm6dsl_slave2_rate_t val) +{ + lsm6dsl_slave2_config_t slave2_config; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE2_CONFIG, + (uint8_t *)&slave2_config, 1); + + if (ret == 0) + { + slave2_config.slave2_rate = (uint8_t) val; + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLAVE2_CONFIG, + (uint8_t *)&slave2_config, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + + return ret; +} + +/** + * @brief Decimation of read operation on Slave 2 starting from the + * sensor hub trigger.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of slave2_rate in reg SLAVE2_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_slave_2_dec_get(dev_ctx_t *ctx, + lsm6dsl_slave2_rate_t *val) +{ + lsm6dsl_slave2_config_t slave2_config; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE2_CONFIG, + (uint8_t *)&slave2_config, 1); + + if (ret == 0) + { + switch (slave2_config.slave2_rate) + { + case LSM6DSL_SL2_NO_DEC: + *val = LSM6DSL_SL2_NO_DEC; + break; + + case LSM6DSL_SL2_DEC_2: + *val = LSM6DSL_SL2_DEC_2; + break; + + case LSM6DSL_SL2_DEC_4: + *val = LSM6DSL_SL2_DEC_4; + break; + + case LSM6DSL_SL2_DEC_8: + *val = LSM6DSL_SL2_DEC_8; + break; + + default: + *val = LSM6DSL_SL2_DEC_ND; + break; + } + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @brief Decimation of read operation on Slave 3 starting from the + * sensor hub trigger.[set] + * + * @param ctx Read / write interface definitions + * @param val Change the values of slave3_rate in reg SLAVE3_CONFIG + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_slave_3_dec_set(dev_ctx_t *ctx, + lsm6dsl_slave3_rate_t val) +{ + lsm6dsl_slave3_config_t slave3_config; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE3_CONFIG, + (uint8_t *)&slave3_config, 1); + slave3_config.slave3_rate = (uint8_t)val; + + if (ret == 0) + { + ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLAVE3_CONFIG, + (uint8_t *)&slave3_config, 1); + + if (ret == 0) + { + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + } + + return ret; +} + +/** + * @brief Decimation of read operation on Slave 3 starting from the + * sensor hub trigger.[get] + * + * @param ctx Read / write interface definitions + * @param val Get the values of slave3_rate in reg SLAVE3_CONFIG. + * @retval Interface status (MANDATORY: return 0 -> no Error). + * + */ +int32_t lsm6dsl_sh_slave_3_dec_get(dev_ctx_t *ctx, + lsm6dsl_slave3_rate_t *val) +{ + lsm6dsl_slave3_config_t slave3_config; + int32_t ret; + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); + + if (ret == 0) + { + ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE3_CONFIG, + (uint8_t *)&slave3_config, 1); + + if (ret == 0) + { + switch (slave3_config.slave3_rate) + { + case LSM6DSL_SL3_NO_DEC: + *val = LSM6DSL_SL3_NO_DEC; + break; + + case LSM6DSL_SL3_DEC_2: + *val = LSM6DSL_SL3_DEC_2; + break; + + case LSM6DSL_SL3_DEC_4: + *val = LSM6DSL_SL3_DEC_4; + break; + + case LSM6DSL_SL3_DEC_8: + *val = LSM6DSL_SL3_DEC_8; + break; + + default: + *val = LSM6DSL_SL3_DEC_ND; + break; + } + + ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); + } + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @} + * + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ \ No newline at end of file diff --git a/Module/lsm6dsl/lsm6dsl_reg.h b/Module/lsm6dsl/lsm6dsl_reg.h new file mode 100644 index 0000000..39f1e98 --- /dev/null +++ b/Module/lsm6dsl/lsm6dsl_reg.h @@ -0,0 +1,2722 @@ +#ifndef LSM6DSL_REGS_H +#define LSM6DSL_REGS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include + +/** @addtogroup LSM6DSL + * @{ + * + */ + +/** @defgroup Endianness definitions + * @{ + * + */ + +#ifndef DRV_BYTE_ORDER +#ifndef __BYTE_ORDER__ + +#define DRV_LITTLE_ENDIAN 1234 +#define DRV_BIG_ENDIAN 4321 + +/** if _BYTE_ORDER is not defined, choose the endianness of your architecture + * by uncommenting the define which fits your platform endianness + */ +//#define DRV_BYTE_ORDER DRV_BIG_ENDIAN +#define DRV_BYTE_ORDER DRV_LITTLE_ENDIAN + +#else /* defined __BYTE_ORDER__ */ + +#define DRV_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ +#define DRV_BIG_ENDIAN __ORDER_BIG_ENDIAN__ +#define DRV_BYTE_ORDER __BYTE_ORDER__ + +#endif /* __BYTE_ORDER__*/ +#endif /* DRV_BYTE_ORDER */ + + +#ifndef MEMS_SHARED_TYPES +#define MEMS_SHARED_TYPES + +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} bitwise_t; + +#define PROPERTY_DISABLE (0U) +#define PROPERTY_ENABLE (1U) + +/** @addtogroup Interfaces_Functions + * @brief This section provide a set of functions used to read and + * write a generic register of the device. + * MANDATORY: return 0 -> no Error. + * @{ + * + */ + +typedef void (*dev_write_ptr)(uint8_t, uint8_t *, uint32_t); +typedef void (*dev_read_ptr)(uint8_t, uint8_t *, uint32_t); +typedef void (*dev_mdelay_ptr)(uint32_t millisec); + +typedef struct +{ + /** Component mandatory fields **/ + dev_write_ptr write_reg; + dev_read_ptr read_reg; + /** Component optional fields **/ + dev_mdelay_ptr mdelay; +} dev_ctx_t; + +/** + * @} + * + */ + +#endif /* MEMS_SHARED_TYPES */ + +#ifndef MEMS_UCF_SHARED_TYPES +#define MEMS_UCF_SHARED_TYPES + +/** @defgroup Generic address-data structure definition + * @brief This structure is useful to load a predefined configuration + * of a sensor. + * You can create a sensor configuration by your own or using + * Unico / Unicleo tools available on STMicroelectronics + * web site. + * + * @{ + * + */ + +typedef struct +{ + uint8_t address; + uint8_t data; +} ucf_line_t; + +/** + * @} + * + */ + +#endif /* MEMS_UCF_SHARED_TYPES */ + +/** + * @} + * + */ + +/** @defgroup LSM6DSL_Infos + * @{ + * + */ + +/** I2C Device Address 8 bit format if SA0=0 -> D5 if SA0=1 -> D7 **/ +#define LSM6DSL_I2C_ADD_L 0xD5U +#define LSM6DSL_I2C_ADD_H 0xD7U + +/** Device Identification (Who am I) **/ +#define LSM6DSL_ID 0x6AU + +/** + * @} + * + */ + +#define LSM6DSL_FUNC_CFG_ACCESS 0x01U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t not_used_01 : 5; +uint8_t func_cfg_en : + 3; /* func_cfg_en + func_cfg_en_b */ +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN +uint8_t func_cfg_en : + 3; /* func_cfg_en + func_cfg_en_b */ + uint8_t not_used_01 : 5; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_func_cfg_access_t; + +#define LSM6DSL_SENSOR_SYNC_TIME_FRAME 0x04U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t tph : 4; + uint8_t not_used_01 : 4; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_01 : 4; + uint8_t tph : 4; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensor_sync_time_frame_t; + +#define LSM6DSL_SENSOR_SYNC_RES_RATIO 0x05U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t rr : 2; + uint8_t not_used_01 : 6; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_01 : 6; + uint8_t rr : 2; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensor_sync_res_ratio_t; + +#define LSM6DSL_FIFO_CTRL1 0x06U +typedef struct +{ + uint8_t fth : 8; /* + FIFO_CTRL2(fth) */ +} lsm6dsl_fifo_ctrl1_t; + +#define LSM6DSL_FIFO_CTRL2 0x07U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t fth : 3; /* + FIFO_CTRL1(fth) */ + uint8_t fifo_temp_en : 1; + uint8_t not_used_01 : 2; + uint8_t timer_pedo_fifo_drdy : 1; + uint8_t timer_pedo_fifo_en : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t timer_pedo_fifo_en : 1; + uint8_t timer_pedo_fifo_drdy : 1; + uint8_t not_used_01 : 2; + uint8_t fifo_temp_en : 1; + uint8_t fth : 3; /* + FIFO_CTRL1(fth) */ +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_fifo_ctrl2_t; + +#define LSM6DSL_FIFO_CTRL3 0x08U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t dec_fifo_xl : 3; + uint8_t dec_fifo_gyro : 3; + uint8_t not_used_01 : 2; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_01 : 2; + uint8_t dec_fifo_gyro : 3; + uint8_t dec_fifo_xl : 3; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_fifo_ctrl3_t; + +#define LSM6DSL_FIFO_CTRL4 0x09U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t dec_ds3_fifo : 3; + uint8_t dec_ds4_fifo : 3; + uint8_t only_high_data : 1; + uint8_t stop_on_fth : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t stop_on_fth : 1; + uint8_t only_high_data : 1; + uint8_t dec_ds4_fifo : 3; + uint8_t dec_ds3_fifo : 3; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_fifo_ctrl4_t; + +#define LSM6DSL_FIFO_CTRL5 0x0AU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t fifo_mode : 3; + uint8_t odr_fifo : 4; + uint8_t not_used_01 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_01 : 1; + uint8_t odr_fifo : 4; + uint8_t fifo_mode : 3; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_fifo_ctrl5_t; + +#define LSM6DSL_DRDY_PULSE_CFG_G 0x0BU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t int2_wrist_tilt : 1; + uint8_t not_used_01 : 6; + uint8_t drdy_pulsed : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t drdy_pulsed : 1; + uint8_t not_used_01 : 6; + uint8_t int2_wrist_tilt : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_drdy_pulse_cfg_g_t; + +#define LSM6DSL_INT1_CTRL 0x0DU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t int1_drdy_xl : 1; + uint8_t int1_drdy_g : 1; + uint8_t int1_boot : 1; + uint8_t int1_fth : 1; + uint8_t int1_fifo_ovr : 1; + uint8_t int1_full_flag : 1; + uint8_t int1_sign_mot : 1; + uint8_t int1_step_detector : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t int1_step_detector : 1; + uint8_t int1_sign_mot : 1; + uint8_t int1_full_flag : 1; + uint8_t int1_fifo_ovr : 1; + uint8_t int1_fth : 1; + uint8_t int1_boot : 1; + uint8_t int1_drdy_g : 1; + uint8_t int1_drdy_xl : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_int1_ctrl_t; + +#define LSM6DSL_INT2_CTRL 0x0EU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t int2_drdy_xl : 1; + uint8_t int2_drdy_g : 1; + uint8_t int2_drdy_temp : 1; + uint8_t int2_fth : 1; + uint8_t int2_fifo_ovr : 1; + uint8_t int2_full_flag : 1; + uint8_t int2_step_count_ov : 1; + uint8_t int2_step_delta : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t int2_step_delta : 1; + uint8_t int2_step_count_ov : 1; + uint8_t int2_full_flag : 1; + uint8_t int2_fifo_ovr : 1; + uint8_t int2_fth : 1; + uint8_t int2_drdy_temp : 1; + uint8_t int2_drdy_g : 1; + uint8_t int2_drdy_xl : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_int2_ctrl_t; + +#define LSM6DSL_WHO_AM_I 0x0FU +#define LSM6DSL_CTRL1_XL 0x10U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bw0_xl : 1; + uint8_t lpf1_bw_sel : 1; + uint8_t fs_xl : 2; + uint8_t odr_xl : 4; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t odr_xl : 4; + uint8_t fs_xl : 2; + uint8_t lpf1_bw_sel : 1; + uint8_t bw0_xl : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_ctrl1_xl_t; + +#define LSM6DSL_CTRL2_G 0x11U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t not_used_01 : 1; + uint8_t fs_g : 3; /* fs_g + fs_125 */ + uint8_t odr_g : 4; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t odr_g : 4; + uint8_t fs_g : 3; /* fs_g + fs_125 */ + uint8_t not_used_01 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_ctrl2_g_t; + +#define LSM6DSL_CTRL3_C 0x12U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t sw_reset : 1; + uint8_t ble : 1; + uint8_t if_inc : 1; + uint8_t sim : 1; + uint8_t pp_od : 1; + uint8_t h_lactive : 1; + uint8_t bdu : 1; + uint8_t boot : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t boot : 1; + uint8_t bdu : 1; + uint8_t h_lactive : 1; + uint8_t pp_od : 1; + uint8_t sim : 1; + uint8_t if_inc : 1; + uint8_t ble : 1; + uint8_t sw_reset : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_ctrl3_c_t; + +#define LSM6DSL_CTRL4_C 0x13U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t not_used_01 : 1; + uint8_t lpf1_sel_g : 1; + uint8_t i2c_disable : 1; + uint8_t drdy_mask : 1; + uint8_t den_drdy_int1 : 1; + uint8_t int2_on_int1 : 1; + uint8_t sleep : 1; + uint8_t den_xl_en : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t den_xl_en : 1; + uint8_t sleep : 1; + uint8_t int2_on_int1 : 1; + uint8_t den_drdy_int1 : 1; + uint8_t drdy_mask : 1; + uint8_t i2c_disable : 1; + uint8_t lpf1_sel_g : 1; + uint8_t not_used_01 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_ctrl4_c_t; + +#define LSM6DSL_CTRL5_C 0x14U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t st_xl : 2; + uint8_t st_g : 2; + uint8_t den_lh : 1; + uint8_t rounding : 3; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t rounding : 3; + uint8_t den_lh : 1; + uint8_t st_g : 2; + uint8_t st_xl : 2; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_ctrl5_c_t; + +#define LSM6DSL_CTRL6_C 0x15U + +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t ftype : 2; + uint8_t not_used_01 : 1; + uint8_t usr_off_w : 1; + uint8_t xl_hm_mode : 1; +uint8_t den_mode : + 3; /* trig_en + lvl_en + lvl2_en */ +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN +uint8_t den_mode : + 3; /* trig_en + lvl_en + lvl2_en */ + uint8_t xl_hm_mode : 1; + uint8_t usr_off_w : 1; + uint8_t not_used_01 : 1; + uint8_t ftype : 2; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_ctrl6_c_t; + +#define LSM6DSL_CTRL7_G 0x16U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t not_used_01 : 2; + uint8_t rounding_status : 1; + uint8_t not_used_02 : 1; + uint8_t hpm_g : 2; + uint8_t hp_en_g : 1; + uint8_t g_hm_mode : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t g_hm_mode : 1; + uint8_t hp_en_g : 1; + uint8_t hpm_g : 2; + uint8_t not_used_02 : 1; + uint8_t rounding_status : 1; + uint8_t not_used_01 : 2; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_ctrl7_g_t; + +#define LSM6DSL_CTRL8_XL 0x17U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t low_pass_on_6d : 1; + uint8_t not_used_01 : 1; + uint8_t hp_slope_xl_en : 1; + uint8_t input_composite : 1; + uint8_t hp_ref_mode : 1; + uint8_t hpcf_xl : 2; + uint8_t lpf2_xl_en : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t lpf2_xl_en : 1; + uint8_t hpcf_xl : 2; + uint8_t hp_ref_mode : 1; + uint8_t input_composite : 1; + uint8_t hp_slope_xl_en : 1; + uint8_t not_used_01 : 1; + uint8_t low_pass_on_6d : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_ctrl8_xl_t; + +#define LSM6DSL_CTRL9_XL 0x18U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t not_used_01 : 2; + uint8_t soft_en : 1; + uint8_t not_used_02 : 1; + uint8_t den_xl_g : 1; + uint8_t den_z : 1; + uint8_t den_y : 1; + uint8_t den_x : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t den_x : 1; + uint8_t den_y : 1; + uint8_t den_z : 1; + uint8_t den_xl_g : 1; + uint8_t not_used_02 : 1; + uint8_t soft_en : 1; + uint8_t not_used_01 : 2; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_ctrl9_xl_t; + +#define LSM6DSL_CTRL10_C 0x19U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t sign_motion_en : 1; + uint8_t pedo_rst_step : 1; + uint8_t func_en : 1; + uint8_t tilt_en : 1; + uint8_t pedo_en : 1; + uint8_t timer_en : 1; + uint8_t not_used_01 : 1; + uint8_t wrist_tilt_en : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t wrist_tilt_en : 1; + uint8_t not_used_01 : 1; + uint8_t timer_en : 1; + uint8_t pedo_en : 1; + uint8_t tilt_en : 1; + uint8_t func_en : 1; + uint8_t pedo_rst_step : 1; + uint8_t sign_motion_en : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_ctrl10_c_t; + +#define LSM6DSL_MASTER_CONFIG 0x1AU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t master_on : 1; + uint8_t iron_en : 1; + uint8_t pass_through_mode : 1; + uint8_t pull_up_en : 1; + uint8_t start_config : 1; + uint8_t not_used_01 : 1; + uint8_t data_valid_sel_fifo : 1; + uint8_t drdy_on_int1 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t drdy_on_int1 : 1; + uint8_t data_valid_sel_fifo : 1; + uint8_t not_used_01 : 1; + uint8_t start_config : 1; + uint8_t pull_up_en : 1; + uint8_t pass_through_mode : 1; + uint8_t iron_en : 1; + uint8_t master_on : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_master_config_t; + +#define LSM6DSL_WAKE_UP_SRC 0x1BU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t z_wu : 1; + uint8_t y_wu : 1; + uint8_t x_wu : 1; + uint8_t wu_ia : 1; + uint8_t sleep_state_ia : 1; + uint8_t ff_ia : 1; + uint8_t not_used_01 : 2; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_01 : 2; + uint8_t ff_ia : 1; + uint8_t sleep_state_ia : 1; + uint8_t wu_ia : 1; + uint8_t x_wu : 1; + uint8_t y_wu : 1; + uint8_t z_wu : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_wake_up_src_t; + +#define LSM6DSL_TAP_SRC 0x1CU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t z_tap : 1; + uint8_t y_tap : 1; + uint8_t x_tap : 1; + uint8_t tap_sign : 1; + uint8_t double_tap : 1; + uint8_t single_tap : 1; + uint8_t tap_ia : 1; + uint8_t not_used_01 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_01 : 1; + uint8_t tap_ia : 1; + uint8_t single_tap : 1; + uint8_t double_tap : 1; + uint8_t tap_sign : 1; + uint8_t x_tap : 1; + uint8_t y_tap : 1; + uint8_t z_tap : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_tap_src_t; + +#define LSM6DSL_D6D_SRC 0x1DU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t xl : 1; + uint8_t xh : 1; + uint8_t yl : 1; + uint8_t yh : 1; + uint8_t zl : 1; + uint8_t zh : 1; + uint8_t d6d_ia : 1; + uint8_t den_drdy : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t den_drdy : 1; + uint8_t d6d_ia : 1; + uint8_t zh : 1; + uint8_t zl : 1; + uint8_t yh : 1; + uint8_t yl : 1; + uint8_t xh : 1; + uint8_t xl : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_d6d_src_t; + +#define LSM6DSL_STATUS_REG 0x1EU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t xlda : 1; + uint8_t gda : 1; + uint8_t tda : 1; + uint8_t not_used_01 : 5; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_01 : 5; + uint8_t tda : 1; + uint8_t gda : 1; + uint8_t xlda : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_status_reg_t; + +#define LSM6DSL_OUT_TEMP_L 0x20U +#define LSM6DSL_OUT_TEMP_H 0x21U +#define LSM6DSL_OUTX_L_G 0x22U +#define LSM6DSL_OUTX_H_G 0x23U +#define LSM6DSL_OUTY_L_G 0x24U +#define LSM6DSL_OUTY_H_G 0x25U +#define LSM6DSL_OUTZ_L_G 0x26U +#define LSM6DSL_OUTZ_H_G 0x27U +#define LSM6DSL_OUTX_L_XL 0x28U +#define LSM6DSL_OUTX_H_XL 0x29U +#define LSM6DSL_OUTY_L_XL 0x2AU +#define LSM6DSL_OUTY_H_XL 0x2BU +#define LSM6DSL_OUTZ_L_XL 0x2CU +#define LSM6DSL_OUTZ_H_XL 0x2DU +#define LSM6DSL_SENSORHUB1_REG 0x2EU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub1_reg_t; + +#define LSM6DSL_SENSORHUB2_REG 0x2FU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub2_reg_t; + +#define LSM6DSL_SENSORHUB3_REG 0x30U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub3_reg_t; + +#define LSM6DSL_SENSORHUB4_REG 0x31U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub4_reg_t; + +#define LSM6DSL_SENSORHUB5_REG 0x32U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub5_reg_t; + +#define LSM6DSL_SENSORHUB6_REG 0x33U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub6_reg_t; + +#define LSM6DSL_SENSORHUB7_REG 0x34U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub7_reg_t; + +#define LSM6DSL_SENSORHUB8_REG 0x35U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub8_reg_t; + +#define LSM6DSL_SENSORHUB9_REG 0x36U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub9_reg_t; + +#define LSM6DSL_SENSORHUB10_REG 0x37U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub10_reg_t; + +#define LSM6DSL_SENSORHUB11_REG 0x38U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub11_reg_t; + +#define LSM6DSL_SENSORHUB12_REG 0x39U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub12_reg_t; + +#define LSM6DSL_FIFO_STATUS1 0x3AU +typedef struct +{ + uint8_t diff_fifo : 8; /* + FIFO_STATUS2(diff_fifo) */ +} lsm6dsl_fifo_status1_t; + +#define LSM6DSL_FIFO_STATUS2 0x3BU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t diff_fifo : 3; /* + FIFO_STATUS1(diff_fifo) */ + uint8_t not_used_01 : 1; + uint8_t fifo_empty : 1; + uint8_t fifo_full_smart : 1; + uint8_t over_run : 1; + uint8_t waterm : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t waterm : 1; + uint8_t over_run : 1; + uint8_t fifo_full_smart : 1; + uint8_t fifo_empty : 1; + uint8_t not_used_01 : 1; + uint8_t diff_fifo : 3; /* + FIFO_STATUS1(diff_fifo) */ +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_fifo_status2_t; + +#define LSM6DSL_FIFO_STATUS3 0x3CU +typedef struct +{ +uint8_t fifo_pattern : + 8; /* + FIFO_STATUS4(fifo_pattern) */ +} lsm6dsl_fifo_status3_t; + +#define LSM6DSL_FIFO_STATUS4 0x3DU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN +uint8_t fifo_pattern : + 2; /* + FIFO_STATUS3(fifo_pattern) */ + uint8_t not_used_01 : 6; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_01 : 6; +uint8_t fifo_pattern : + 2; /* + FIFO_STATUS3(fifo_pattern) */ +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_fifo_status4_t; + +#define LSM6DSL_FIFO_DATA_OUT_L 0x3EU +#define LSM6DSL_FIFO_DATA_OUT_H 0x3FU +#define LSM6DSL_TIMESTAMP0_REG 0x40U +#define LSM6DSL_TIMESTAMP1_REG 0x41U +#define LSM6DSL_TIMESTAMP2_REG 0x42U +#define LSM6DSL_STEP_TIMESTAMP_L 0x49U +#define LSM6DSL_STEP_TIMESTAMP_H 0x4AU +#define LSM6DSL_STEP_COUNTER_L 0x4BU +#define LSM6DSL_STEP_COUNTER_H 0x4CU + +#define LSM6DSL_SENSORHUB13_REG 0x4DU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub13_reg_t; + +#define LSM6DSL_SENSORHUB14_REG 0x4EU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub14_reg_t; + +#define LSM6DSL_SENSORHUB15_REG 0x4FU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub15_reg_t; + +#define LSM6DSL_SENSORHUB16_REG 0x50U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub16_reg_t; + +#define LSM6DSL_SENSORHUB17_REG 0x51U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub17_reg_t; + +#define LSM6DSL_SENSORHUB18_REG 0x52U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_sensorhub18_reg_t; + +#define LSM6DSL_FUNC_SRC1 0x53U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t sensorhub_end_op : 1; + uint8_t si_end_op : 1; + uint8_t hi_fail : 1; + uint8_t step_overflow : 1; + uint8_t step_detected : 1; + uint8_t tilt_ia : 1; + uint8_t sign_motion_ia : 1; + uint8_t step_count_delta_ia : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t step_count_delta_ia : 1; + uint8_t sign_motion_ia : 1; + uint8_t tilt_ia : 1; + uint8_t step_detected : 1; + uint8_t step_overflow : 1; + uint8_t hi_fail : 1; + uint8_t si_end_op : 1; + uint8_t sensorhub_end_op : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_func_src1_t; + +#define LSM6DSL_FUNC_SRC2 0x54U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t wrist_tilt_ia : 1; + uint8_t not_used_01 : 2; + uint8_t slave0_nack : 1; + uint8_t slave1_nack : 1; + uint8_t slave2_nack : 1; + uint8_t slave3_nack : 1; + uint8_t not_used_02 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_02 : 1; + uint8_t slave3_nack : 1; + uint8_t slave2_nack : 1; + uint8_t slave1_nack : 1; + uint8_t slave0_nack : 1; + uint8_t not_used_01 : 2; + uint8_t wrist_tilt_ia : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_func_src2_t; + +#define LSM6DSL_WRIST_TILT_IA 0x55U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t not_used_01 : 2; + uint8_t wrist_tilt_ia_zneg : 1; + uint8_t wrist_tilt_ia_zpos : 1; + uint8_t wrist_tilt_ia_yneg : 1; + uint8_t wrist_tilt_ia_ypos : 1; + uint8_t wrist_tilt_ia_xneg : 1; + uint8_t wrist_tilt_ia_xpos : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t wrist_tilt_ia_xpos : 1; + uint8_t wrist_tilt_ia_xneg : 1; + uint8_t wrist_tilt_ia_ypos : 1; + uint8_t wrist_tilt_ia_yneg : 1; + uint8_t wrist_tilt_ia_zpos : 1; + uint8_t wrist_tilt_ia_zneg : 1; + uint8_t not_used_01 : 2; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_wrist_tilt_ia_t; + +#define LSM6DSL_TAP_CFG 0x58U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t lir : 1; + uint8_t tap_z_en : 1; + uint8_t tap_y_en : 1; + uint8_t tap_x_en : 1; + uint8_t slope_fds : 1; + uint8_t inact_en : 2; + uint8_t interrupts_enable : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t interrupts_enable : 1; + uint8_t inact_en : 2; + uint8_t slope_fds : 1; + uint8_t tap_x_en : 1; + uint8_t tap_y_en : 1; + uint8_t tap_z_en : 1; + uint8_t lir : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_tap_cfg_t; + +#define LSM6DSL_TAP_THS_6D 0x59U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t tap_ths : 5; + uint8_t sixd_ths : 2; + uint8_t d4d_en : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t d4d_en : 1; + uint8_t sixd_ths : 2; + uint8_t tap_ths : 5; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_tap_ths_6d_t; + +#define LSM6DSL_INT_DUR2 0x5AU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t shock : 2; + uint8_t quiet : 2; + uint8_t dur : 4; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t dur : 4; + uint8_t quiet : 2; + uint8_t shock : 2; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_int_dur2_t; + +#define LSM6DSL_WAKE_UP_THS 0x5BU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t wk_ths : 6; + uint8_t not_used_01 : 1; + uint8_t single_double_tap : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t single_double_tap : 1; + uint8_t not_used_01 : 1; + uint8_t wk_ths : 6; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_wake_up_ths_t; + +#define LSM6DSL_WAKE_UP_DUR 0x5CU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t sleep_dur : 4; + uint8_t timer_hr : 1; + uint8_t wake_dur : 2; + uint8_t ff_dur : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t ff_dur : 1; + uint8_t wake_dur : 2; + uint8_t timer_hr : 1; + uint8_t sleep_dur : 4; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_wake_up_dur_t; + +#define LSM6DSL_FREE_FALL 0x5DU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t ff_ths : 3; + uint8_t ff_dur : 5; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t ff_dur : 5; + uint8_t ff_ths : 3; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_free_fall_t; + +#define LSM6DSL_MD1_CFG 0x5EU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t int1_timer : 1; + uint8_t int1_tilt : 1; + uint8_t int1_6d : 1; + uint8_t int1_double_tap : 1; + uint8_t int1_ff : 1; + uint8_t int1_wu : 1; + uint8_t int1_single_tap : 1; + uint8_t int1_inact_state : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t int1_inact_state : 1; + uint8_t int1_single_tap : 1; + uint8_t int1_wu : 1; + uint8_t int1_ff : 1; + uint8_t int1_double_tap : 1; + uint8_t int1_6d : 1; + uint8_t int1_tilt : 1; + uint8_t int1_timer : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_md1_cfg_t; + +#define LSM6DSL_MD2_CFG 0x5FU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t int2_iron : 1; + uint8_t int2_tilt : 1; + uint8_t int2_6d : 1; + uint8_t int2_double_tap : 1; + uint8_t int2_ff : 1; + uint8_t int2_wu : 1; + uint8_t int2_single_tap : 1; + uint8_t int2_inact_state : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t int2_inact_state : 1; + uint8_t int2_single_tap : 1; + uint8_t int2_wu : 1; + uint8_t int2_ff : 1; + uint8_t int2_double_tap : 1; + uint8_t int2_6d : 1; + uint8_t int2_tilt : 1; + uint8_t int2_iron : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_md2_cfg_t; + +#define LSM6DSL_MASTER_CMD_CODE 0x60U +typedef struct +{ + uint8_t master_cmd_code : 8; +} lsm6dsl_master_cmd_code_t; + +#define LSM6DSL_SENS_SYNC_SPI_ERROR_CODE 0x61U +typedef struct +{ + uint8_t error_code : 8; +} lsm6dsl_sens_sync_spi_error_code_t; + +#define LSM6DSL_OUT_MAG_RAW_X_L 0x66U +#define LSM6DSL_OUT_MAG_RAW_X_H 0x67U +#define LSM6DSL_OUT_MAG_RAW_Y_L 0x68U +#define LSM6DSL_OUT_MAG_RAW_Y_H 0x69U +#define LSM6DSL_OUT_MAG_RAW_Z_L 0x6AU +#define LSM6DSL_OUT_MAG_RAW_Z_H 0x6BU +#define LSM6DSL_X_OFS_USR 0x73U +#define LSM6DSL_Y_OFS_USR 0x74U +#define LSM6DSL_Z_OFS_USR 0x75U +#define LSM6DSL_SLV0_ADD 0x02U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t rw_0 : 1; + uint8_t slave0_add : 7; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t slave0_add : 7; + uint8_t rw_0 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_slv0_add_t; + +#define LSM6DSL_SLV0_SUBADD 0x03U +typedef struct +{ + uint8_t slave0_reg : 8; +} lsm6dsl_slv0_subadd_t; + +#define LSM6DSL_SLAVE0_CONFIG 0x04U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t slave0_numop : 3; + uint8_t src_mode : 1; + uint8_t aux_sens_on : 2; + uint8_t slave0_rate : 2; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t slave0_rate : 2; + uint8_t aux_sens_on : 2; + uint8_t src_mode : 1; + uint8_t slave0_numop : 3; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_slave0_config_t; + +#define LSM6DSL_SLV1_ADD 0x05U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t r_1 : 1; + uint8_t slave1_add : 7; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t slave1_add : 7; + uint8_t r_1 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_slv1_add_t; + +#define LSM6DSL_SLV1_SUBADD 0x06U +typedef struct +{ + uint8_t slave1_reg : 8; +} lsm6dsl_slv1_subadd_t; + +#define LSM6DSL_SLAVE1_CONFIG 0x07U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t slave1_numop : 3; + uint8_t not_used_01 : 2; + uint8_t write_once : 1; + uint8_t slave1_rate : 2; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t slave1_rate : 2; + uint8_t write_once : 1; + uint8_t not_used_01 : 2; + uint8_t slave1_numop : 3; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_slave1_config_t; + +#define LSM6DSL_SLV2_ADD 0x08U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t r_2 : 1; + uint8_t slave2_add : 7; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t slave2_add : 7; + uint8_t r_2 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_slv2_add_t; + +#define LSM6DSL_SLV2_SUBADD 0x09U +typedef struct +{ + uint8_t slave2_reg : 8; +} lsm6dsl_slv2_subadd_t; + +#define LSM6DSL_SLAVE2_CONFIG 0x0AU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t slave2_numop : 3; + uint8_t not_used_01 : 3; + uint8_t slave2_rate : 2; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t slave2_rate : 2; + uint8_t not_used_01 : 3; + uint8_t slave2_numop : 3; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_slave2_config_t; + +#define LSM6DSL_SLV3_ADD 0x0BU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t r_3 : 1; + uint8_t slave3_add : 7; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t slave3_add : 7; + uint8_t r_3 : 1; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_slv3_add_t; + +#define LSM6DSL_SLV3_SUBADD 0x0CU +typedef struct +{ + uint8_t slave3_reg : 8; +} lsm6dsl_slv3_subadd_t; + +#define LSM6DSL_SLAVE3_CONFIG 0x0DU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t slave3_numop : 3; + uint8_t not_used_01 : 3; + uint8_t slave3_rate : 2; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t slave3_rate : 2; + uint8_t not_used_01 : 3; + uint8_t slave3_numop : 3; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_slave3_config_t; + +#define LSM6DSL_DATAWRITE_SRC_MODE_SUB_SLV0 0x0EU +typedef struct +{ + uint8_t slave_dataw : 8; +} lsm6dsl_datawrite_src_mode_sub_slv0_t; + +#define LSM6DSL_CONFIG_PEDO_THS_MIN 0x0FU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t ths_min : 5; + uint8_t not_used_01 : 2; + uint8_t pedo_fs : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t pedo_fs : 1; + uint8_t not_used_01 : 2; + uint8_t ths_min : 5; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_config_pedo_ths_min_t; + +#define LSM6DSL_SM_THS 0x13U +#define LSM6DSL_PEDO_DEB_REG 0x14U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t deb_step : 3; + uint8_t deb_time : 5; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t deb_time : 5; + uint8_t deb_step : 3; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_pedo_deb_reg_t; + +#define LSM6DSL_STEP_COUNT_DELTA 0x15U +#define LSM6DSL_MAG_SI_XX 0x24U +#define LSM6DSL_MAG_SI_XY 0x25U +#define LSM6DSL_MAG_SI_XZ 0x26U +#define LSM6DSL_MAG_SI_YX 0x27U +#define LSM6DSL_MAG_SI_YY 0x28U +#define LSM6DSL_MAG_SI_YZ 0x29U +#define LSM6DSL_MAG_SI_ZX 0x2AU +#define LSM6DSL_MAG_SI_ZY 0x2BU +#define LSM6DSL_MAG_SI_ZZ 0x2CU +#define LSM6DSL_MAG_OFFX_L 0x2DU +#define LSM6DSL_MAG_OFFX_H 0x2EU +#define LSM6DSL_MAG_OFFY_L 0x2FU +#define LSM6DSL_MAG_OFFY_H 0x30U +#define LSM6DSL_MAG_OFFZ_L 0x31U +#define LSM6DSL_MAG_OFFZ_H 0x32U +#define LSM6DSL_A_WRIST_TILT_LAT 0x50U +#define LSM6DSL_A_WRIST_TILT_THS 0x54U +#define LSM6DSL_A_WRIST_TILT_MASK 0x59U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t not_used_01 : 2; + uint8_t wrist_tilt_mask_zneg : 1; + uint8_t wrist_tilt_mask_zpos : 1; + uint8_t wrist_tilt_mask_yneg : 1; + uint8_t wrist_tilt_mask_ypos : 1; + uint8_t wrist_tilt_mask_xneg : 1; + uint8_t wrist_tilt_mask_xpos : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t wrist_tilt_mask_xpos : 1; + uint8_t wrist_tilt_mask_xneg : 1; + uint8_t wrist_tilt_mask_ypos : 1; + uint8_t wrist_tilt_mask_yneg : 1; + uint8_t wrist_tilt_mask_zpos : 1; + uint8_t wrist_tilt_mask_zneg : 1; + uint8_t not_used_01 : 2; +#endif /* DRV_BYTE_ORDER */ +} lsm6dsl_a_wrist_tilt_mask_t; + +/** + * @defgroup LSM6DSL_Register_Union + * @brief This union group all the registers having a bit-field + * description. + * This union is useful but it's not needed by the driver. + * + * REMOVING this union you are compliant with: + * MISRA-C 2012 [Rule 19.2] -> " Union are not allowed " + * + * @{ + * + */ +typedef union +{ + lsm6dsl_func_cfg_access_t func_cfg_access; + lsm6dsl_sensor_sync_time_frame_t sensor_sync_time_frame; + lsm6dsl_sensor_sync_res_ratio_t sensor_sync_res_ratio; + lsm6dsl_fifo_ctrl1_t fifo_ctrl1; + lsm6dsl_fifo_ctrl2_t fifo_ctrl2; + lsm6dsl_fifo_ctrl3_t fifo_ctrl3; + lsm6dsl_fifo_ctrl4_t fifo_ctrl4; + lsm6dsl_fifo_ctrl5_t fifo_ctrl5; + lsm6dsl_drdy_pulse_cfg_g_t drdy_pulse_cfg_g; + lsm6dsl_int1_ctrl_t int1_ctrl; + lsm6dsl_int2_ctrl_t int2_ctrl; + lsm6dsl_ctrl1_xl_t ctrl1_xl; + lsm6dsl_ctrl2_g_t ctrl2_g; + lsm6dsl_ctrl3_c_t ctrl3_c; + lsm6dsl_ctrl4_c_t ctrl4_c; + lsm6dsl_ctrl5_c_t ctrl5_c; + lsm6dsl_ctrl6_c_t ctrl6_c; + lsm6dsl_ctrl7_g_t ctrl7_g; + lsm6dsl_ctrl8_xl_t ctrl8_xl; + lsm6dsl_ctrl9_xl_t ctrl9_xl; + lsm6dsl_ctrl10_c_t ctrl10_c; + lsm6dsl_master_config_t master_config; + lsm6dsl_wake_up_src_t wake_up_src; + lsm6dsl_tap_src_t tap_src; + lsm6dsl_d6d_src_t d6d_src; + lsm6dsl_status_reg_t status_reg; + lsm6dsl_sensorhub1_reg_t sensorhub1_reg; + lsm6dsl_sensorhub2_reg_t sensorhub2_reg; + lsm6dsl_sensorhub3_reg_t sensorhub3_reg; + lsm6dsl_sensorhub4_reg_t sensorhub4_reg; + lsm6dsl_sensorhub5_reg_t sensorhub5_reg; + lsm6dsl_sensorhub6_reg_t sensorhub6_reg; + lsm6dsl_sensorhub7_reg_t sensorhub7_reg; + lsm6dsl_sensorhub8_reg_t sensorhub8_reg; + lsm6dsl_sensorhub9_reg_t sensorhub9_reg; + lsm6dsl_sensorhub10_reg_t sensorhub10_reg; + lsm6dsl_sensorhub11_reg_t sensorhub11_reg; + lsm6dsl_sensorhub12_reg_t sensorhub12_reg; + lsm6dsl_fifo_status1_t fifo_status1; + lsm6dsl_fifo_status2_t fifo_status2; + lsm6dsl_fifo_status3_t fifo_status3; + lsm6dsl_fifo_status4_t fifo_status4; + lsm6dsl_sensorhub13_reg_t sensorhub13_reg; + lsm6dsl_sensorhub14_reg_t sensorhub14_reg; + lsm6dsl_sensorhub15_reg_t sensorhub15_reg; + lsm6dsl_sensorhub16_reg_t sensorhub16_reg; + lsm6dsl_sensorhub17_reg_t sensorhub17_reg; + lsm6dsl_sensorhub18_reg_t sensorhub18_reg; + lsm6dsl_func_src1_t func_src1; + lsm6dsl_func_src2_t func_src2; + lsm6dsl_wrist_tilt_ia_t wrist_tilt_ia; + lsm6dsl_tap_cfg_t tap_cfg; + lsm6dsl_tap_ths_6d_t tap_ths_6d; + lsm6dsl_int_dur2_t int_dur2; + lsm6dsl_wake_up_ths_t wake_up_ths; + lsm6dsl_wake_up_dur_t wake_up_dur; + lsm6dsl_free_fall_t free_fall; + lsm6dsl_md1_cfg_t md1_cfg; + lsm6dsl_md2_cfg_t md2_cfg; + lsm6dsl_master_cmd_code_t master_cmd_code; + lsm6dsl_sens_sync_spi_error_code_t sens_sync_spi_error_code; + lsm6dsl_slv0_add_t slv0_add; + lsm6dsl_slv0_subadd_t slv0_subadd; + lsm6dsl_slave0_config_t slave0_config; + lsm6dsl_slv1_add_t slv1_add; + lsm6dsl_slv1_subadd_t slv1_subadd; + lsm6dsl_slave1_config_t slave1_config; + lsm6dsl_slv2_add_t slv2_add; + lsm6dsl_slv2_subadd_t slv2_subadd; + lsm6dsl_slave2_config_t slave2_config; + lsm6dsl_slv3_add_t slv3_add; + lsm6dsl_slv3_subadd_t slv3_subadd; + lsm6dsl_slave3_config_t slave3_config; + lsm6dsl_datawrite_src_mode_sub_slv0_t + datawrite_src_mode_sub_slv0; + lsm6dsl_config_pedo_ths_min_t config_pedo_ths_min; + lsm6dsl_pedo_deb_reg_t pedo_deb_reg; + lsm6dsl_a_wrist_tilt_mask_t a_wrist_tilt_mask; + bitwise_t bitwise; + uint8_t byte; +} lsm6dsl_reg_t; + +/** + * @} + * + */ + +#ifndef __weak +#define __weak __attribute__((weak)) +#endif /* __weak */ + +/* + * These are the basic platform dependent I/O routines to read + * and write device registers connected on a standard bus. + * The driver keeps offering a default implementation based on function + * pointers to read/write routines for backward compatibility. + * The __weak directive allows the final application to overwrite + * them with a custom implementation. + */ + +int32_t lsm6dsl_read_reg(dev_ctx_t *ctx, uint8_t reg, + uint8_t *data, + uint16_t len); +int32_t lsm6dsl_write_reg(dev_ctx_t *ctx, uint8_t reg, + uint8_t *data, + uint16_t len); + +float_t lsm6dsl_from_fs2g_to_mg(int16_t lsb); +float_t lsm6dsl_from_fs4g_to_mg(int16_t lsb); +float_t lsm6dsl_from_fs8g_to_mg(int16_t lsb); +float_t lsm6dsl_from_fs16g_to_mg(int16_t lsb); + +float_t lsm6dsl_from_fs125dps_to_mdps(int16_t lsb); +float_t lsm6dsl_from_fs250dps_to_mdps(int16_t lsb); +float_t lsm6dsl_from_fs500dps_to_mdps(int16_t lsb); +float_t lsm6dsl_from_fs1000dps_to_mdps(int16_t lsb); +float_t lsm6dsl_from_fs2000dps_to_mdps(int16_t lsb); + +float_t lsm6dsl_from_lsb_to_celsius(int16_t lsb); + +typedef enum +{ + LSM6DSL_2g = 0, + LSM6DSL_16g = 1, + LSM6DSL_4g = 2, + LSM6DSL_8g = 3, + LSM6DSL_XL_FS_ND = 4, /* ERROR CODE */ +} lsm6dsl_fs_xl_t; +int32_t lsm6dsl_xl_full_scale_set(dev_ctx_t *ctx, + lsm6dsl_fs_xl_t val); +int32_t lsm6dsl_xl_full_scale_get(dev_ctx_t *ctx, + lsm6dsl_fs_xl_t *val); + +typedef enum +{ + LSM6DSL_XL_ODR_OFF = 0, + LSM6DSL_XL_ODR_12Hz5 = 1, + LSM6DSL_XL_ODR_26Hz = 2, + LSM6DSL_XL_ODR_52Hz = 3, + LSM6DSL_XL_ODR_104Hz = 4, + LSM6DSL_XL_ODR_208Hz = 5, + LSM6DSL_XL_ODR_416Hz = 6, + LSM6DSL_XL_ODR_833Hz = 7, + LSM6DSL_XL_ODR_1k66Hz = 8, + LSM6DSL_XL_ODR_3k33Hz = 9, + LSM6DSL_XL_ODR_6k66Hz = 10, + LSM6DSL_XL_ODR_1Hz6 = 11, + LSM6DSL_XL_ODR_ND = 12, /* ERROR CODE */ +} lsm6dsl_odr_xl_t; +int32_t lsm6dsl_xl_data_rate_set(dev_ctx_t *ctx, + lsm6dsl_odr_xl_t val); +int32_t lsm6dsl_xl_data_rate_get(dev_ctx_t *ctx, + lsm6dsl_odr_xl_t *val); + +typedef enum +{ + LSM6DSL_250dps = 0, + LSM6DSL_125dps = 1, + LSM6DSL_500dps = 2, + LSM6DSL_1000dps = 4, + LSM6DSL_2000dps = 6, + LSM6DSL_GY_FS_ND = 7, /* ERROR CODE */ +} lsm6dsl_fs_g_t; +int32_t lsm6dsl_gy_full_scale_set(dev_ctx_t *ctx, + lsm6dsl_fs_g_t val); +int32_t lsm6dsl_gy_full_scale_get(dev_ctx_t *ctx, + lsm6dsl_fs_g_t *val); + +typedef enum +{ + LSM6DSL_GY_ODR_OFF = 0, + LSM6DSL_GY_ODR_12Hz5 = 1, + LSM6DSL_GY_ODR_26Hz = 2, + LSM6DSL_GY_ODR_52Hz = 3, + LSM6DSL_GY_ODR_104Hz = 4, + LSM6DSL_GY_ODR_208Hz = 5, + LSM6DSL_GY_ODR_416Hz = 6, + LSM6DSL_GY_ODR_833Hz = 7, + LSM6DSL_GY_ODR_1k66Hz = 8, + LSM6DSL_GY_ODR_3k33Hz = 9, + LSM6DSL_GY_ODR_6k66Hz = 10, + LSM6DSL_GY_ODR_ND = 11, /* ERROR CODE */ +} lsm6dsl_odr_g_t; +int32_t lsm6dsl_gy_data_rate_set(dev_ctx_t *ctx, + lsm6dsl_odr_g_t val); +int32_t lsm6dsl_gy_data_rate_get(dev_ctx_t *ctx, + lsm6dsl_odr_g_t *val); + +int32_t lsm6dsl_block_data_update_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_block_data_update_get(dev_ctx_t *ctx, + uint8_t *val); + +typedef enum +{ + LSM6DSL_LSb_1mg = 0, + LSM6DSL_LSb_16mg = 1, + LSM6DSL_WEIGHT_ND = 2, +} lsm6dsl_usr_off_w_t; +int32_t lsm6dsl_xl_offset_weight_set(dev_ctx_t *ctx, + lsm6dsl_usr_off_w_t val); +int32_t lsm6dsl_xl_offset_weight_get(dev_ctx_t *ctx, + lsm6dsl_usr_off_w_t *val); + +typedef enum +{ + LSM6DSL_XL_HIGH_PERFORMANCE = 0, + LSM6DSL_XL_NORMAL = 1, + LSM6DSL_XL_PW_MODE_ND = 2, /* ERROR CODE */ +} lsm6dsl_xl_hm_mode_t; +int32_t lsm6dsl_xl_power_mode_set(dev_ctx_t *ctx, + lsm6dsl_xl_hm_mode_t val); +int32_t lsm6dsl_xl_power_mode_get(dev_ctx_t *ctx, + lsm6dsl_xl_hm_mode_t *val); + +typedef enum +{ + LSM6DSL_STAT_RND_DISABLE = 0, + LSM6DSL_STAT_RND_ENABLE = 1, + LSM6DSL_STAT_RND_ND = 2, /* ERROR CODE */ +} lsm6dsl_rounding_status_t; +int32_t lsm6dsl_rounding_on_status_set(dev_ctx_t *ctx, + lsm6dsl_rounding_status_t val); +int32_t lsm6dsl_rounding_on_status_get(dev_ctx_t *ctx, + lsm6dsl_rounding_status_t *val); + +typedef enum +{ + LSM6DSL_GY_HIGH_PERFORMANCE = 0, + LSM6DSL_GY_NORMAL = 1, + LSM6DSL_GY_PW_MODE_ND = 2, /* ERROR CODE */ +} lsm6dsl_g_hm_mode_t; +int32_t lsm6dsl_gy_power_mode_set(dev_ctx_t *ctx, + lsm6dsl_g_hm_mode_t val); +int32_t lsm6dsl_gy_power_mode_get(dev_ctx_t *ctx, + lsm6dsl_g_hm_mode_t *val); + +typedef struct +{ + lsm6dsl_wake_up_src_t wake_up_src; + lsm6dsl_tap_src_t tap_src; + lsm6dsl_d6d_src_t d6d_src; + lsm6dsl_status_reg_t status_reg; + lsm6dsl_func_src1_t func_src1; + lsm6dsl_func_src2_t func_src2; + lsm6dsl_wrist_tilt_ia_t wrist_tilt_ia; + lsm6dsl_a_wrist_tilt_mask_t a_wrist_tilt_mask; +} lsm6dsl_all_sources_t; +int32_t lsm6dsl_all_sources_get(dev_ctx_t *ctx, + lsm6dsl_all_sources_t *val); + +int32_t lsm6dsl_status_reg_get(dev_ctx_t *ctx, + lsm6dsl_status_reg_t *val); + +int32_t lsm6dsl_xl_flag_data_ready_get(dev_ctx_t *ctx, + uint8_t *val); + +int32_t lsm6dsl_gy_flag_data_ready_get(dev_ctx_t *ctx, + uint8_t *val); + +int32_t lsm6dsl_temp_flag_data_ready_get(dev_ctx_t *ctx, + uint8_t *val); + +int32_t lsm6dsl_xl_usr_offset_set(dev_ctx_t *ctx, uint8_t *buff); +int32_t lsm6dsl_xl_usr_offset_get(dev_ctx_t *ctx, uint8_t *buff); +int32_t lsm6dsl_timestamp_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_timestamp_get(dev_ctx_t *ctx, uint8_t *val); + +typedef enum +{ + LSM6DSL_LSB_6ms4 = 0, + LSM6DSL_LSB_25us = 1, + LSM6DSL_TS_RES_ND = 2, /* ERROR CODE */ +} lsm6dsl_timer_hr_t; +int32_t lsm6dsl_timestamp_res_set(dev_ctx_t *ctx, + lsm6dsl_timer_hr_t val); +int32_t lsm6dsl_timestamp_res_get(dev_ctx_t *ctx, + lsm6dsl_timer_hr_t *val); + +typedef enum +{ + LSM6DSL_ROUND_DISABLE = 0, + LSM6DSL_ROUND_XL = 1, + LSM6DSL_ROUND_GY = 2, + LSM6DSL_ROUND_GY_XL = 3, + LSM6DSL_ROUND_SH1_TO_SH6 = 4, + LSM6DSL_ROUND_XL_SH1_TO_SH6 = 5, + LSM6DSL_ROUND_GY_XL_SH1_TO_SH12 = 6, + LSM6DSL_ROUND_GY_XL_SH1_TO_SH6 = 7, + LSM6DSL_ROUND_OUT_ND = 8, /* ERROR CODE */ +} lsm6dsl_rounding_t; +int32_t lsm6dsl_rounding_mode_set(dev_ctx_t *ctx, + lsm6dsl_rounding_t val); +int32_t lsm6dsl_rounding_mode_get(dev_ctx_t *ctx, + lsm6dsl_rounding_t *val); + +int32_t lsm6dsl_temperature_raw_get(dev_ctx_t *ctx, int16_t *val); +int32_t lsm6dsl_angular_rate_raw_get(dev_ctx_t *ctx, int16_t *val); +int32_t lsm6dsl_acceleration_raw_get(dev_ctx_t *ctx, int16_t *val); + +int32_t lsm6dsl_mag_calibrated_raw_get(dev_ctx_t *ctx, + int16_t *val); + +int32_t lsm6dsl_fifo_raw_data_get(dev_ctx_t *ctx, uint8_t *buffer, + uint8_t len); + +typedef enum +{ + LSM6DSL_USER_BANK = 0, + LSM6DSL_BANK_A = 4, + LSM6DSL_BANK_B = 5, + LSM6DSL_BANK_ND = 6, /* ERROR CODE */ +} lsm6dsl_func_cfg_en_t; +int32_t lsm6dsl_mem_bank_set(dev_ctx_t *ctx, + lsm6dsl_func_cfg_en_t val); +int32_t lsm6dsl_mem_bank_get(dev_ctx_t *ctx, + lsm6dsl_func_cfg_en_t *val); + +typedef enum +{ + LSM6DSL_DRDY_LATCHED = 0, + LSM6DSL_DRDY_PULSED = 1, + LSM6DSL_DRDY_ND = 2, /* ERROR CODE */ +} lsm6dsl_drdy_pulsed_g_t; +int32_t lsm6dsl_data_ready_mode_set(dev_ctx_t *ctx, + lsm6dsl_drdy_pulsed_g_t val); +int32_t lsm6dsl_data_ready_mode_get(dev_ctx_t *ctx, + lsm6dsl_drdy_pulsed_g_t *val); + +int32_t lsm6dsl_device_id_get(dev_ctx_t *ctx, uint8_t *buff); +int32_t lsm6dsl_reset_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_reset_get(dev_ctx_t *ctx, uint8_t *val); + +typedef enum +{ + LSM6DSL_LSB_AT_LOW_ADD = 0, + LSM6DSL_MSB_AT_LOW_ADD = 1, + LSM6DSL_DATA_FMT_ND = 2, /* ERROR CODE */ +} lsm6dsl_ble_t; +int32_t lsm6dsl_data_format_set(dev_ctx_t *ctx, lsm6dsl_ble_t val); +int32_t lsm6dsl_data_format_get(dev_ctx_t *ctx, + lsm6dsl_ble_t *val); + +int32_t lsm6dsl_auto_increment_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_auto_increment_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_boot_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_boot_get(dev_ctx_t *ctx, uint8_t *val); + +typedef enum +{ + LSM6DSL_XL_ST_DISABLE = 0, + LSM6DSL_XL_ST_POSITIVE = 1, + LSM6DSL_XL_ST_NEGATIVE = 2, + LSM6DSL_XL_ST_ND = 3, /* ERROR CODE */ +} lsm6dsl_st_xl_t; +int32_t lsm6dsl_xl_self_test_set(dev_ctx_t *ctx, + lsm6dsl_st_xl_t val); +int32_t lsm6dsl_xl_self_test_get(dev_ctx_t *ctx, + lsm6dsl_st_xl_t *val); + +typedef enum +{ + LSM6DSL_GY_ST_DISABLE = 0, + LSM6DSL_GY_ST_POSITIVE = 1, + LSM6DSL_GY_ST_NEGATIVE = 3, + LSM6DSL_GY_ST_ND = 4, /* ERROR CODE */ +} lsm6dsl_st_g_t; +int32_t lsm6dsl_gy_self_test_set(dev_ctx_t *ctx, + lsm6dsl_st_g_t val); +int32_t lsm6dsl_gy_self_test_get(dev_ctx_t *ctx, + lsm6dsl_st_g_t *val); + +int32_t lsm6dsl_filter_settling_mask_set(dev_ctx_t *ctx, + uint8_t val); +int32_t lsm6dsl_filter_settling_mask_get(dev_ctx_t *ctx, + uint8_t *val); + +typedef enum +{ + LSM6DSL_USE_SLOPE = 0, + LSM6DSL_USE_HPF = 1, + LSM6DSL_HP_PATH_ND = 2, /* ERROR CODE */ +} lsm6dsl_slope_fds_t; +int32_t lsm6dsl_xl_hp_path_internal_set(dev_ctx_t *ctx, + lsm6dsl_slope_fds_t val); +int32_t lsm6dsl_xl_hp_path_internal_get(dev_ctx_t *ctx, + lsm6dsl_slope_fds_t *val); + +typedef enum +{ + LSM6DSL_XL_ANA_BW_1k5Hz = 0, + LSM6DSL_XL_ANA_BW_400Hz = 1, + LSM6DSL_XL_ANA_BW_ND = 2, /* ERROR CODE */ +} lsm6dsl_bw0_xl_t; +int32_t lsm6dsl_xl_filter_analog_set(dev_ctx_t *ctx, + lsm6dsl_bw0_xl_t val); +int32_t lsm6dsl_xl_filter_analog_get(dev_ctx_t *ctx, + lsm6dsl_bw0_xl_t *val); + +typedef enum +{ + LSM6DSL_XL_LP1_ODR_DIV_2 = 0, + LSM6DSL_XL_LP1_ODR_DIV_4 = 1, + LSM6DSL_XL_LP1_NA = 2, /* ERROR CODE */ +} lsm6dsl_lpf1_bw_sel_t; +int32_t lsm6dsl_xl_lp1_bandwidth_set(dev_ctx_t *ctx, + lsm6dsl_lpf1_bw_sel_t val); +int32_t lsm6dsl_xl_lp1_bandwidth_get(dev_ctx_t *ctx, + lsm6dsl_lpf1_bw_sel_t *val); + +typedef enum +{ + LSM6DSL_XL_LOW_LAT_LP_ODR_DIV_50 = 0x00, + LSM6DSL_XL_LOW_LAT_LP_ODR_DIV_100 = 0x01, + LSM6DSL_XL_LOW_LAT_LP_ODR_DIV_9 = 0x02, + LSM6DSL_XL_LOW_LAT_LP_ODR_DIV_400 = 0x03, + LSM6DSL_XL_LOW_NOISE_LP_ODR_DIV_50 = 0x10, + LSM6DSL_XL_LOW_NOISE_LP_ODR_DIV_100 = 0x11, + LSM6DSL_XL_LOW_NOISE_LP_ODR_DIV_9 = 0x12, + LSM6DSL_XL_LOW_NOISE_LP_ODR_DIV_400 = 0x13, + LSM6DSL_XL_LP_NA = 0x20, /* ERROR CODE */ +} lsm6dsl_input_composite_t; +int32_t lsm6dsl_xl_lp2_bandwidth_set(dev_ctx_t *ctx, + lsm6dsl_input_composite_t val); +int32_t lsm6dsl_xl_lp2_bandwidth_get(dev_ctx_t *ctx, + lsm6dsl_input_composite_t *val); + +int32_t lsm6dsl_xl_reference_mode_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_xl_reference_mode_get(dev_ctx_t *ctx, + uint8_t *val); + +typedef enum +{ + LSM6DSL_XL_HP_ODR_DIV_4 = 0x00, /* Slope filter */ + LSM6DSL_XL_HP_ODR_DIV_100 = 0x01, + LSM6DSL_XL_HP_ODR_DIV_9 = 0x02, + LSM6DSL_XL_HP_ODR_DIV_400 = 0x03, + LSM6DSL_XL_HP_NA = 0x10, /* ERROR CODE */ +} lsm6dsl_hpcf_xl_t; +int32_t lsm6dsl_xl_hp_bandwidth_set(dev_ctx_t *ctx, + lsm6dsl_hpcf_xl_t val); +int32_t lsm6dsl_xl_hp_bandwidth_get(dev_ctx_t *ctx, + lsm6dsl_hpcf_xl_t *val); + +typedef enum +{ + LSM6DSL_LP2_ONLY = 0x00, + + LSM6DSL_HP_16mHz_LP2 = 0x80, + LSM6DSL_HP_65mHz_LP2 = 0x90, + LSM6DSL_HP_260mHz_LP2 = 0xA0, + LSM6DSL_HP_1Hz04_LP2 = 0xB0, + + LSM6DSL_HP_DISABLE_LP1_LIGHT = 0x0A, + LSM6DSL_HP_DISABLE_LP1_NORMAL = 0x09, + LSM6DSL_HP_DISABLE_LP_STRONG = 0x08, + LSM6DSL_HP_DISABLE_LP1_AGGRESSIVE = 0x0B, + + LSM6DSL_HP_16mHz_LP1_LIGHT = 0x8A, + LSM6DSL_HP_65mHz_LP1_NORMAL = 0x99, + LSM6DSL_HP_260mHz_LP1_STRONG = 0xA8, + LSM6DSL_HP_1Hz04_LP1_AGGRESSIVE = 0xBB, + + LSM6DSL_HP_GY_BAND_NA = 0xFF, /* ERROR CODE */ +} lsm6dsl_lpf1_sel_g_t; +int32_t lsm6dsl_gy_band_pass_set(dev_ctx_t *ctx, + lsm6dsl_lpf1_sel_g_t val); +int32_t lsm6dsl_gy_band_pass_get(dev_ctx_t *ctx, + lsm6dsl_lpf1_sel_g_t *val); + +typedef enum +{ + LSM6DSL_SPI_4_WIRE = 0, + LSM6DSL_SPI_3_WIRE = 1, + LSM6DSL_SPI_MODE_ND = 2, /* ERROR CODE */ +} lsm6dsl_sim_t; +int32_t lsm6dsl_spi_mode_set(dev_ctx_t *ctx, lsm6dsl_sim_t val); +int32_t lsm6dsl_spi_mode_get(dev_ctx_t *ctx, lsm6dsl_sim_t *val); + +typedef enum +{ + LSM6DSL_I2C_ENABLE = 0, + LSM6DSL_I2C_DISABLE = 1, + LSM6DSL_I2C_MODE_ND = 2, /* ERROR CODE */ +} lsm6dsl_i2c_disable_t; +int32_t lsm6dsl_i2c_interface_set(dev_ctx_t *ctx, + lsm6dsl_i2c_disable_t val); +int32_t lsm6dsl_i2c_interface_get(dev_ctx_t *ctx, + lsm6dsl_i2c_disable_t *val); + +typedef struct +{ + uint8_t int1_drdy_xl : 1; + uint8_t int1_drdy_g : 1; + uint8_t int1_boot : 1; + uint8_t int1_fth : 1; + uint8_t int1_fifo_ovr : 1; + uint8_t int1_full_flag : 1; + uint8_t int1_sign_mot : 1; + uint8_t int1_step_detector : 1; + uint8_t int1_timer : 1; + uint8_t int1_tilt : 1; + uint8_t int1_6d : 1; + uint8_t int1_double_tap : 1; + uint8_t int1_ff : 1; + uint8_t int1_wu : 1; + uint8_t int1_single_tap : 1; + uint8_t int1_inact_state : 1; + uint8_t den_drdy_int1 : 1; + uint8_t drdy_on_int1 : 1; +} lsm6dsl_int1_route_t; +int32_t lsm6dsl_pin_int1_route_set(dev_ctx_t *ctx, + lsm6dsl_int1_route_t val); +int32_t lsm6dsl_pin_int1_route_get(dev_ctx_t *ctx, + lsm6dsl_int1_route_t *val); + +typedef struct +{ + uint8_t int2_drdy_xl : 1; + uint8_t int2_drdy_g : 1; + uint8_t int2_drdy_temp : 1; + uint8_t int2_fth : 1; + uint8_t int2_fifo_ovr : 1; + uint8_t int2_full_flag : 1; + uint8_t int2_step_count_ov : 1; + uint8_t int2_step_delta : 1; + uint8_t int2_iron : 1; + uint8_t int2_tilt : 1; + uint8_t int2_6d : 1; + uint8_t int2_double_tap : 1; + uint8_t int2_ff : 1; + uint8_t int2_wu : 1; + uint8_t int2_single_tap : 1; + uint8_t int2_inact_state : 1; + uint8_t int2_wrist_tilt : 1; +} lsm6dsl_int2_route_t; +int32_t lsm6dsl_pin_int2_route_set(dev_ctx_t *ctx, + lsm6dsl_int2_route_t val); +int32_t lsm6dsl_pin_int2_route_get(dev_ctx_t *ctx, + lsm6dsl_int2_route_t *val); + +typedef enum +{ + LSM6DSL_PUSH_PULL = 0, + LSM6DSL_OPEN_DRAIN = 1, + LSM6DSL_PIN_MODE_ND = 2, /* ERROR CODE */ +} lsm6dsl_pp_od_t; +int32_t lsm6dsl_pin_mode_set(dev_ctx_t *ctx, lsm6dsl_pp_od_t val); +int32_t lsm6dsl_pin_mode_get(dev_ctx_t *ctx, lsm6dsl_pp_od_t *val); + +typedef enum +{ + LSM6DSL_ACTIVE_HIGH = 0, + LSM6DSL_ACTIVE_LOW = 1, + LSM6DSL_POLARITY_ND = 2, /* ERROR CODE */ +} lsm6dsl_h_lactive_t; +int32_t lsm6dsl_pin_polarity_set(dev_ctx_t *ctx, + lsm6dsl_h_lactive_t val); +int32_t lsm6dsl_pin_polarity_get(dev_ctx_t *ctx, + lsm6dsl_h_lactive_t *val); + +int32_t lsm6dsl_all_on_int1_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_all_on_int1_get(dev_ctx_t *ctx, uint8_t *val); + +typedef enum +{ + LSM6DSL_INT_PULSED = 0, + LSM6DSL_INT_LATCHED = 1, + LSM6DSL_INT_MODE = 2, /* ERROR CODE */ +} lsm6dsl_lir_t; +int32_t lsm6dsl_int_notification_set(dev_ctx_t *ctx, + lsm6dsl_lir_t val); +int32_t lsm6dsl_int_notification_get(dev_ctx_t *ctx, + lsm6dsl_lir_t *val); + +int32_t lsm6dsl_wkup_threshold_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_wkup_threshold_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_wkup_dur_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_wkup_dur_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_gy_sleep_mode_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_gy_sleep_mode_get(dev_ctx_t *ctx, uint8_t *val); + +typedef enum +{ + LSM6DSL_PROPERTY_DISABLE = 0, + LSM6DSL_XL_12Hz5_GY_NOT_AFFECTED = 1, + LSM6DSL_XL_12Hz5_GY_SLEEP = 2, + LSM6DSL_XL_12Hz5_GY_PD = 3, + LSM6DSL_ACT_MODE_ND = 4, /* ERROR CODE */ +} lsm6dsl_inact_en_t; +int32_t lsm6dsl_act_mode_set(dev_ctx_t *ctx, + lsm6dsl_inact_en_t val); +int32_t lsm6dsl_act_mode_get(dev_ctx_t *ctx, + lsm6dsl_inact_en_t *val); + +int32_t lsm6dsl_act_sleep_dur_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_act_sleep_dur_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_tap_src_get(dev_ctx_t *ctx, + lsm6dsl_tap_src_t *val); + +int32_t lsm6dsl_tap_detection_on_z_set(dev_ctx_t *ctx, + uint8_t val); +int32_t lsm6dsl_tap_detection_on_z_get(dev_ctx_t *ctx, + uint8_t *val); + +int32_t lsm6dsl_tap_detection_on_y_set(dev_ctx_t *ctx, + uint8_t val); +int32_t lsm6dsl_tap_detection_on_y_get(dev_ctx_t *ctx, + uint8_t *val); + +int32_t lsm6dsl_tap_detection_on_x_set(dev_ctx_t *ctx, + uint8_t val); +int32_t lsm6dsl_tap_detection_on_x_get(dev_ctx_t *ctx, + uint8_t *val); + +int32_t lsm6dsl_tap_threshold_x_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_tap_threshold_x_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_tap_shock_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_tap_shock_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_tap_quiet_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_tap_quiet_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_tap_dur_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_tap_dur_get(dev_ctx_t *ctx, uint8_t *val); + +typedef enum +{ + LSM6DSL_ONLY_SINGLE = 0, + LSM6DSL_BOTH_SINGLE_DOUBLE = 1, + LSM6DSL_TAP_MODE_ND = 2, /* ERROR CODE */ +} lsm6dsl_single_double_tap_t; +int32_t lsm6dsl_tap_mode_set(dev_ctx_t *ctx, + lsm6dsl_single_double_tap_t val); +int32_t lsm6dsl_tap_mode_get(dev_ctx_t *ctx, + lsm6dsl_single_double_tap_t *val); + +typedef enum +{ + LSM6DSL_ODR_DIV_2_FEED = 0, + LSM6DSL_LPF2_FEED = 1, + LSM6DSL_6D_FEED_ND = 2, /* ERROR CODE */ +} lsm6dsl_low_pass_on_6d_t; +int32_t lsm6dsl_6d_feed_data_set(dev_ctx_t *ctx, + lsm6dsl_low_pass_on_6d_t val); +int32_t lsm6dsl_6d_feed_data_get(dev_ctx_t *ctx, + lsm6dsl_low_pass_on_6d_t *val); + +typedef enum +{ + LSM6DSL_DEG_80 = 0, + LSM6DSL_DEG_70 = 1, + LSM6DSL_DEG_60 = 2, + LSM6DSL_DEG_50 = 3, + LSM6DSL_6D_TH_ND = 4, /* ERROR CODE */ +} lsm6dsl_sixd_ths_t; +int32_t lsm6dsl_6d_threshold_set(dev_ctx_t *ctx, + lsm6dsl_sixd_ths_t val); +int32_t lsm6dsl_6d_threshold_get(dev_ctx_t *ctx, + lsm6dsl_sixd_ths_t *val); + +int32_t lsm6dsl_4d_mode_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_4d_mode_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_ff_dur_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_ff_dur_get(dev_ctx_t *ctx, uint8_t *val); + +typedef enum +{ + LSM6DSL_FF_TSH_156mg = 0, + LSM6DSL_FF_TSH_219mg = 1, + LSM6DSL_FF_TSH_250mg = 2, + LSM6DSL_FF_TSH_312mg = 3, + LSM6DSL_FF_TSH_344mg = 4, + LSM6DSL_FF_TSH_406mg = 5, + LSM6DSL_FF_TSH_469mg = 6, + LSM6DSL_FF_TSH_500mg = 7, + LSM6DSL_FF_TSH_ND = 8, /* ERROR CODE */ +} lsm6dsl_ff_ths_t; +int32_t lsm6dsl_ff_threshold_set(dev_ctx_t *ctx, + lsm6dsl_ff_ths_t val); +int32_t lsm6dsl_ff_threshold_get(dev_ctx_t *ctx, + lsm6dsl_ff_ths_t *val); + +int32_t lsm6dsl_fifo_watermark_set(dev_ctx_t *ctx, uint16_t val); +int32_t lsm6dsl_fifo_watermark_get(dev_ctx_t *ctx, uint16_t *val); + +int32_t lsm6dsl_fifo_data_level_get(dev_ctx_t *ctx, uint16_t *val); + +int32_t lsm6dsl_fifo_wtm_flag_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_fifo_pattern_get(dev_ctx_t *ctx, uint16_t *val); + +int32_t lsm6dsl_fifo_temp_batch_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_fifo_temp_batch_get(dev_ctx_t *ctx, uint8_t *val); + +typedef enum +{ + LSM6DSL_TRG_XL_GY_DRDY = 0, + LSM6DSL_TRG_STEP_DETECT = 1, + LSM6DSL_TRG_SH_DRDY = 2, + LSM6DSL_TRG_SH_ND = 3, /* ERROR CODE */ +} lsm6dsl_trigger_fifo_t; +int32_t lsm6dsl_fifo_write_trigger_set(dev_ctx_t *ctx, + lsm6dsl_trigger_fifo_t val); +int32_t lsm6dsl_fifo_write_trigger_get(dev_ctx_t *ctx, + lsm6dsl_trigger_fifo_t *val); + +int32_t lsm6dsl_fifo_pedo_and_timestamp_batch_set(dev_ctx_t *ctx, + uint8_t val); +int32_t lsm6dsl_fifo_pedo_and_timestamp_batch_get(dev_ctx_t *ctx, + uint8_t *val); + +typedef enum +{ + LSM6DSL_FIFO_XL_DISABLE = 0, + LSM6DSL_FIFO_XL_NO_DEC = 1, + LSM6DSL_FIFO_XL_DEC_2 = 2, + LSM6DSL_FIFO_XL_DEC_3 = 3, + LSM6DSL_FIFO_XL_DEC_4 = 4, + LSM6DSL_FIFO_XL_DEC_8 = 5, + LSM6DSL_FIFO_XL_DEC_16 = 6, + LSM6DSL_FIFO_XL_DEC_32 = 7, + LSM6DSL_FIFO_XL_DEC_ND = 8, /* ERROR CODE */ +} lsm6dsl_dec_fifo_xl_t; +int32_t lsm6dsl_fifo_xl_batch_set(dev_ctx_t *ctx, + lsm6dsl_dec_fifo_xl_t val); +int32_t lsm6dsl_fifo_xl_batch_get(dev_ctx_t *ctx, + lsm6dsl_dec_fifo_xl_t *val); + +typedef enum +{ + LSM6DSL_FIFO_GY_DISABLE = 0, + LSM6DSL_FIFO_GY_NO_DEC = 1, + LSM6DSL_FIFO_GY_DEC_2 = 2, + LSM6DSL_FIFO_GY_DEC_3 = 3, + LSM6DSL_FIFO_GY_DEC_4 = 4, + LSM6DSL_FIFO_GY_DEC_8 = 5, + LSM6DSL_FIFO_GY_DEC_16 = 6, + LSM6DSL_FIFO_GY_DEC_32 = 7, + LSM6DSL_FIFO_GY_DEC_ND = 8, /* ERROR CODE */ +} lsm6dsl_dec_fifo_gyro_t; +int32_t lsm6dsl_fifo_gy_batch_set(dev_ctx_t *ctx, + lsm6dsl_dec_fifo_gyro_t val); +int32_t lsm6dsl_fifo_gy_batch_get(dev_ctx_t *ctx, + lsm6dsl_dec_fifo_gyro_t *val); + +typedef enum +{ + LSM6DSL_FIFO_DS3_DISABLE = 0, + LSM6DSL_FIFO_DS3_NO_DEC = 1, + LSM6DSL_FIFO_DS3_DEC_2 = 2, + LSM6DSL_FIFO_DS3_DEC_3 = 3, + LSM6DSL_FIFO_DS3_DEC_4 = 4, + LSM6DSL_FIFO_DS3_DEC_8 = 5, + LSM6DSL_FIFO_DS3_DEC_16 = 6, + LSM6DSL_FIFO_DS3_DEC_32 = 7, + LSM6DSL_FIFO_DS3_DEC_ND = 8, /* ERROR CODE */ +} lsm6dsl_dec_ds3_fifo_t; +int32_t lsm6dsl_fifo_dataset_3_batch_set(dev_ctx_t *ctx, + lsm6dsl_dec_ds3_fifo_t val); +int32_t lsm6dsl_fifo_dataset_3_batch_get(dev_ctx_t *ctx, + lsm6dsl_dec_ds3_fifo_t *val); + +typedef enum +{ + LSM6DSL_FIFO_DS4_DISABLE = 0, + LSM6DSL_FIFO_DS4_NO_DEC = 1, + LSM6DSL_FIFO_DS4_DEC_2 = 2, + LSM6DSL_FIFO_DS4_DEC_3 = 3, + LSM6DSL_FIFO_DS4_DEC_4 = 4, + LSM6DSL_FIFO_DS4_DEC_8 = 5, + LSM6DSL_FIFO_DS4_DEC_16 = 6, + LSM6DSL_FIFO_DS4_DEC_32 = 7, + LSM6DSL_FIFO_DS4_DEC_ND = 8, /* ERROR CODE */ +} lsm6dsl_dec_ds4_fifo_t; +int32_t lsm6dsl_fifo_dataset_4_batch_set(dev_ctx_t *ctx, + lsm6dsl_dec_ds4_fifo_t val); +int32_t lsm6dsl_fifo_dataset_4_batch_get(dev_ctx_t *ctx, + lsm6dsl_dec_ds4_fifo_t *val); + +int32_t lsm6dsl_fifo_xl_gy_8bit_format_set(dev_ctx_t *ctx, + uint8_t val); +int32_t lsm6dsl_fifo_xl_gy_8bit_format_get(dev_ctx_t *ctx, + uint8_t *val); + +int32_t lsm6dsl_fifo_stop_on_wtm_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_fifo_stop_on_wtm_get(dev_ctx_t *ctx, uint8_t *val); + +typedef enum +{ + LSM6DSL_BYPASS_MODE = 0, + LSM6DSL_FIFO_MODE = 1, + LSM6DSL_STREAM_TO_FIFO_MODE = 3, + LSM6DSL_BYPASS_TO_STREAM_MODE = 4, + LSM6DSL_STREAM_MODE = 6, + LSM6DSL_FIFO_MODE_ND = 8, /* ERROR CODE */ +} lsm6dsl_fifo_mode_t; +int32_t lsm6dsl_fifo_mode_set(dev_ctx_t *ctx, + lsm6dsl_fifo_mode_t val); +int32_t lsm6dsl_fifo_mode_get(dev_ctx_t *ctx, + lsm6dsl_fifo_mode_t *val); + +typedef enum +{ + LSM6DSL_FIFO_DISABLE = 0, + LSM6DSL_FIFO_12Hz5 = 1, + LSM6DSL_FIFO_26Hz = 2, + LSM6DSL_FIFO_52Hz = 3, + LSM6DSL_FIFO_104Hz = 4, + LSM6DSL_FIFO_208Hz = 5, + LSM6DSL_FIFO_416Hz = 6, + LSM6DSL_FIFO_833Hz = 7, + LSM6DSL_FIFO_1k66Hz = 8, + LSM6DSL_FIFO_3k33Hz = 9, + LSM6DSL_FIFO_6k66Hz = 10, + LSM6DSL_FIFO_RATE_ND = 11, /* ERROR CODE */ +} lsm6dsl_odr_fifo_t; +int32_t lsm6dsl_fifo_data_rate_set(dev_ctx_t *ctx, + lsm6dsl_odr_fifo_t val); +int32_t lsm6dsl_fifo_data_rate_get(dev_ctx_t *ctx, + lsm6dsl_odr_fifo_t *val); + +typedef enum +{ + LSM6DSL_DEN_ACT_LOW = 0, + LSM6DSL_DEN_ACT_HIGH = 1, + LSM6DSL_DEN_POL_ND = 2, /* ERROR CODE */ +} lsm6dsl_den_lh_t; +int32_t lsm6dsl_den_polarity_set(dev_ctx_t *ctx, + lsm6dsl_den_lh_t val); +int32_t lsm6dsl_den_polarity_get(dev_ctx_t *ctx, + lsm6dsl_den_lh_t *val); + +typedef enum +{ + LSM6DSL_DEN_DISABLE = 0, + LSM6DSL_LEVEL_FIFO = 6, + LSM6DSL_LEVEL_LETCHED = 3, + LSM6DSL_LEVEL_TRIGGER = 2, + LSM6DSL_EDGE_TRIGGER = 4, + LSM6DSL_DEN_MODE_ND = 5, /* ERROR CODE */ +} lsm6dsl_den_mode_t; +int32_t lsm6dsl_den_mode_set(dev_ctx_t *ctx, + lsm6dsl_den_mode_t val); +int32_t lsm6dsl_den_mode_get(dev_ctx_t *ctx, + lsm6dsl_den_mode_t *val); + +typedef enum +{ + LSM6DSL_STAMP_IN_GY_DATA = 0, + LSM6DSL_STAMP_IN_XL_DATA = 1, + LSM6DSL_STAMP_IN_GY_XL_DATA = 2, + LSM6DSL_DEN_STAMP_ND = 3, /* ERROR CODE */ +} lsm6dsl_den_xl_en_t; +int32_t lsm6dsl_den_enable_set(dev_ctx_t *ctx, + lsm6dsl_den_xl_en_t val); +int32_t lsm6dsl_den_enable_get(dev_ctx_t *ctx, + lsm6dsl_den_xl_en_t *val); + +int32_t lsm6dsl_den_mark_axis_z_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_den_mark_axis_z_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_den_mark_axis_y_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_den_mark_axis_y_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_den_mark_axis_x_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_den_mark_axis_x_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_pedo_step_reset_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_pedo_step_reset_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_pedo_sens_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_pedo_sens_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_pedo_threshold_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_pedo_threshold_get(dev_ctx_t *ctx, uint8_t *val); + +typedef enum +{ + LSM6DSL_PEDO_AT_2g = 0, + LSM6DSL_PEDO_AT_4g = 1, + LSM6DSL_PEDO_FS_ND = 2, /* ERROR CODE */ +} lsm6dsl_pedo_fs_t; +int32_t lsm6dsl_pedo_full_scale_set(dev_ctx_t *ctx, + lsm6dsl_pedo_fs_t val); +int32_t lsm6dsl_pedo_full_scale_get(dev_ctx_t *ctx, + lsm6dsl_pedo_fs_t *val); + +int32_t lsm6dsl_pedo_debounce_steps_set(dev_ctx_t *ctx, + uint8_t val); +int32_t lsm6dsl_pedo_debounce_steps_get(dev_ctx_t *ctx, + uint8_t *val); + +int32_t lsm6dsl_pedo_timeout_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_pedo_timeout_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_pedo_steps_period_set(dev_ctx_t *ctx, + uint8_t *buff); +int32_t lsm6dsl_pedo_steps_period_get(dev_ctx_t *ctx, + uint8_t *buff); + +int32_t lsm6dsl_motion_sens_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_motion_sens_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_motion_threshold_set(dev_ctx_t *ctx, + uint8_t *buff); +int32_t lsm6dsl_motion_threshold_get(dev_ctx_t *ctx, + uint8_t *buff); + +int32_t lsm6dsl_tilt_sens_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_tilt_sens_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_wrist_tilt_sens_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_wrist_tilt_sens_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_tilt_latency_set(dev_ctx_t *ctx, uint8_t *buff); +int32_t lsm6dsl_tilt_latency_get(dev_ctx_t *ctx, uint8_t *buff); + +int32_t lsm6dsl_tilt_threshold_set(dev_ctx_t *ctx, uint8_t *buff); +int32_t lsm6dsl_tilt_threshold_get(dev_ctx_t *ctx, uint8_t *buff); + +int32_t lsm6dsl_tilt_src_set(dev_ctx_t *ctx, + lsm6dsl_a_wrist_tilt_mask_t *val); +int32_t lsm6dsl_tilt_src_get(dev_ctx_t *ctx, + lsm6dsl_a_wrist_tilt_mask_t *val); + +int32_t lsm6dsl_mag_soft_iron_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_mag_soft_iron_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_mag_hard_iron_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_mag_hard_iron_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_mag_soft_iron_mat_set(dev_ctx_t *ctx, + uint8_t *buff); +int32_t lsm6dsl_mag_soft_iron_mat_get(dev_ctx_t *ctx, + uint8_t *buff); + +int32_t lsm6dsl_mag_offset_set(dev_ctx_t *ctx, int16_t *val); +int32_t lsm6dsl_mag_offset_get(dev_ctx_t *ctx, int16_t *val); + +int32_t lsm6dsl_func_en_set(dev_ctx_t *ctx, uint8_t val); + +int32_t lsm6dsl_sh_sync_sens_frame_set(dev_ctx_t *ctx, + uint8_t val); +int32_t lsm6dsl_sh_sync_sens_frame_get(dev_ctx_t *ctx, + uint8_t *val); + +typedef enum +{ + LSM6DSL_RES_RATIO_2_11 = 0, + LSM6DSL_RES_RATIO_2_12 = 1, + LSM6DSL_RES_RATIO_2_13 = 2, + LSM6DSL_RES_RATIO_2_14 = 3, + LSM6DSL_RES_RATIO_ND = 4, /* ERROR CODE */ +} lsm6dsl_rr_t; +int32_t lsm6dsl_sh_sync_sens_ratio_set(dev_ctx_t *ctx, + lsm6dsl_rr_t val); +int32_t lsm6dsl_sh_sync_sens_ratio_get(dev_ctx_t *ctx, + lsm6dsl_rr_t *val); + +int32_t lsm6dsl_sh_master_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_sh_master_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_sh_pass_through_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_sh_pass_through_get(dev_ctx_t *ctx, uint8_t *val); + +typedef enum +{ + LSM6DSL_EXT_PULL_UP = 0, + LSM6DSL_INTERNAL_PULL_UP = 1, + LSM6DSL_SH_PIN_MODE = 2, /* ERROR CODE */ +} lsm6dsl_pull_up_en_t; +int32_t lsm6dsl_sh_pin_mode_set(dev_ctx_t *ctx, + lsm6dsl_pull_up_en_t val); +int32_t lsm6dsl_sh_pin_mode_get(dev_ctx_t *ctx, + lsm6dsl_pull_up_en_t *val); + +typedef enum +{ + LSM6DSL_XL_GY_DRDY = 0, + LSM6DSL_EXT_ON_INT2_PIN = 1, + LSM6DSL_SH_SYNCRO_ND = 2, /* ERROR CODE */ +} lsm6dsl_start_config_t; +int32_t lsm6dsl_sh_syncro_mode_set(dev_ctx_t *ctx, + lsm6dsl_start_config_t val); +int32_t lsm6dsl_sh_syncro_mode_get(dev_ctx_t *ctx, + lsm6dsl_start_config_t *val); + +int32_t lsm6dsl_sh_drdy_on_int1_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_sh_drdy_on_int1_get(dev_ctx_t *ctx, uint8_t *val); + +typedef struct +{ + lsm6dsl_sensorhub1_reg_t sh_byte_1; + lsm6dsl_sensorhub2_reg_t sh_byte_2; + lsm6dsl_sensorhub3_reg_t sh_byte_3; + lsm6dsl_sensorhub4_reg_t sh_byte_4; + lsm6dsl_sensorhub5_reg_t sh_byte_5; + lsm6dsl_sensorhub6_reg_t sh_byte_6; + lsm6dsl_sensorhub7_reg_t sh_byte_7; + lsm6dsl_sensorhub8_reg_t sh_byte_8; + lsm6dsl_sensorhub9_reg_t sh_byte_9; + lsm6dsl_sensorhub10_reg_t sh_byte_10; + lsm6dsl_sensorhub11_reg_t sh_byte_11; + lsm6dsl_sensorhub12_reg_t sh_byte_12; + lsm6dsl_sensorhub13_reg_t sh_byte_13; + lsm6dsl_sensorhub14_reg_t sh_byte_14; + lsm6dsl_sensorhub15_reg_t sh_byte_15; + lsm6dsl_sensorhub16_reg_t sh_byte_16; + lsm6dsl_sensorhub17_reg_t sh_byte_17; + lsm6dsl_sensorhub18_reg_t sh_byte_18; +} lsm6dsl_emb_sh_read_t; +int32_t lsm6dsl_sh_read_data_raw_get(dev_ctx_t *ctx, + lsm6dsl_emb_sh_read_t *val); + +int32_t lsm6dsl_sh_cmd_sens_sync_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_sh_cmd_sens_sync_get(dev_ctx_t *ctx, uint8_t *val); + +int32_t lsm6dsl_sh_spi_sync_error_set(dev_ctx_t *ctx, uint8_t val); +int32_t lsm6dsl_sh_spi_sync_error_get(dev_ctx_t *ctx, + uint8_t *val); + +typedef enum +{ + LSM6DSL_SLV_0 = 0, + LSM6DSL_SLV_0_1 = 1, + LSM6DSL_SLV_0_1_2 = 2, + LSM6DSL_SLV_0_1_2_3 = 3, + LSM6DSL_SLV_EN_ND = 4, /* ERROR CODE */ +} lsm6dsl_aux_sens_on_t; +int32_t lsm6dsl_sh_num_of_dev_connected_set(dev_ctx_t *ctx, + lsm6dsl_aux_sens_on_t val); +int32_t lsm6dsl_sh_num_of_dev_connected_get(dev_ctx_t *ctx, + lsm6dsl_aux_sens_on_t *val); + +typedef struct +{ + uint8_t slv0_add; + uint8_t slv0_subadd; + uint8_t slv0_data; +} lsm6dsl_sh_cfg_write_t; +int32_t lsm6dsl_sh_cfg_write(dev_ctx_t *ctx, + lsm6dsl_sh_cfg_write_t *val); + +typedef struct +{ + uint8_t slv_add; + uint8_t slv_subadd; + uint8_t slv_len; +} lsm6dsl_sh_cfg_read_t; +int32_t lsm6dsl_sh_slv0_cfg_read(dev_ctx_t *ctx, + lsm6dsl_sh_cfg_read_t *val); +int32_t lsm6dsl_sh_slv1_cfg_read(dev_ctx_t *ctx, + lsm6dsl_sh_cfg_read_t *val); +int32_t lsm6dsl_sh_slv2_cfg_read(dev_ctx_t *ctx, + lsm6dsl_sh_cfg_read_t *val); +int32_t lsm6dsl_sh_slv3_cfg_read(dev_ctx_t *ctx, + lsm6dsl_sh_cfg_read_t *val); + +typedef enum +{ + LSM6DSL_SL0_NO_DEC = 0, + LSM6DSL_SL0_DEC_2 = 1, + LSM6DSL_SL0_DEC_4 = 2, + LSM6DSL_SL0_DEC_8 = 3, + LSM6DSL_SL0_DEC_ND = 4, /* ERROR CODE */ +} lsm6dsl_slave0_rate_t; +int32_t lsm6dsl_sh_slave_0_dec_set(dev_ctx_t *ctx, + lsm6dsl_slave0_rate_t val); +int32_t lsm6dsl_sh_slave_0_dec_get(dev_ctx_t *ctx, + lsm6dsl_slave0_rate_t *val); + +typedef enum +{ + LSM6DSL_EACH_SH_CYCLE = 0, + LSM6DSL_ONLY_FIRST_CYCLE = 1, + LSM6DSL_SH_WR_MODE_ND = 2, /* ERROR CODE */ +} lsm6dsl_write_once_t; +int32_t lsm6dsl_sh_write_mode_set(dev_ctx_t *ctx, + lsm6dsl_write_once_t val); +int32_t lsm6dsl_sh_write_mode_get(dev_ctx_t *ctx, + lsm6dsl_write_once_t *val); + +typedef enum +{ + LSM6DSL_SL1_NO_DEC = 0, + LSM6DSL_SL1_DEC_2 = 1, + LSM6DSL_SL1_DEC_4 = 2, + LSM6DSL_SL1_DEC_8 = 3, + LSM6DSL_SL1_DEC_ND = 4, /* ERROR CODE */ +} lsm6dsl_slave1_rate_t; +int32_t lsm6dsl_sh_slave_1_dec_set(dev_ctx_t *ctx, + lsm6dsl_slave1_rate_t val); +int32_t lsm6dsl_sh_slave_1_dec_get(dev_ctx_t *ctx, + lsm6dsl_slave1_rate_t *val); + +typedef enum +{ + LSM6DSL_SL2_NO_DEC = 0, + LSM6DSL_SL2_DEC_2 = 1, + LSM6DSL_SL2_DEC_4 = 2, + LSM6DSL_SL2_DEC_8 = 3, + LSM6DSL_SL2_DEC_ND = 4, /* ERROR CODE */ +} lsm6dsl_slave2_rate_t; +int32_t lsm6dsl_sh_slave_2_dec_set(dev_ctx_t *ctx, + lsm6dsl_slave2_rate_t val); +int32_t lsm6dsl_sh_slave_2_dec_get(dev_ctx_t *ctx, + lsm6dsl_slave2_rate_t *val); + +typedef enum +{ + LSM6DSL_SL3_NO_DEC = 0, + LSM6DSL_SL3_DEC_2 = 1, + LSM6DSL_SL3_DEC_4 = 2, + LSM6DSL_SL3_DEC_8 = 3, + LSM6DSL_SL3_DEC_ND = 4, /* ERROR CODE */ +} lsm6dsl_slave3_rate_t; +int32_t lsm6dsl_sh_slave_3_dec_set(dev_ctx_t *ctx, + lsm6dsl_slave3_rate_t val); +int32_t lsm6dsl_sh_slave_3_dec_get(dev_ctx_t *ctx, + lsm6dsl_slave3_rate_t *val); + +/** + * @} + * + */ + +#ifdef __cplusplus +} +#endif + +#endif /* LSM6DSL_DRIVER_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ \ No newline at end of file diff --git a/Module/mmc5983/mmc5983.c b/Module/mmc5983/mmc5983.c new file mode 100644 index 0000000..8b03eed --- /dev/null +++ b/Module/mmc5983/mmc5983.c @@ -0,0 +1,343 @@ +#include "main.h" +#include "mmc5983.h" +#include "UartDebug.h" +#include "i2c.h" +#include "Algorithm.h" + +static int32_t max_in[XYZ]; +static int32_t min_in[XYZ]; +static bool InitFlag; +static bool MMC5983IntFlag; +static MMC5983Var_t MMC5983Var; + +/***************************************************************************************** +* 函数名称: MMC5983_Write_Reg +* 功能描述: MMC5983写寄存器 +* 参 数: reg 寄存器地址 + val 寄存器数据 +* 返 回 值: 成功返回true,失败返回false +*****************************************************************************************/ +static bool MMC5983_Write_Reg(uint8_t reg, uint8_t val) +{ + return I2C_MasterWriteData(M0P_I2C0, MMC5983_ADDRESS, reg, &val, 1); +} + +/***************************************************************************************** +* 函数名称: MMC5983_Read_Reg +* 功能描述: MMC5983读寄存器 +* 参 数: reg 寄存器地址 +* 返 回 值: 返回寄存器值 +*****************************************************************************************/ +static uint8_t MMC5983_Read_Reg(uint8_t reg) +{ + uint8_t res; + if(I2C_MasterReadData(M0P_I2C0, MMC5983_ADDRESS, reg, &res, 1) == false) + res = 0; + return res; +} + +/***************************************************************************************** +* 函数名称: MMC5983_Read_Buffer +* 功能描述: MMC5983读数据 +* 参 数: reg 寄存器地址 + buffer 读取数据输出缓存入口 + len 读取长度 +* 返 回 值: 成功返回true,失败返回false +*****************************************************************************************/ +static bool MMC5983_Read_Buffer(uint8_t reg, void *buffer, uint8_t len) +{ + return I2C_MasterReadData(M0P_I2C0, MMC5983_ADDRESS, reg, buffer, len); +} + +/***************************************************************************************** +* 函数名称: MMC5983StartCov +* 功能描述: MMC5983开启连续转换 +* 参 数: 无 +* 返 回 值: 无 +*****************************************************************************************/ +static void MMC5983StartCov(void) +{ + MMC5983RegCtrl2 Ctrl2Reg; //开启/关闭连续转换 + Ctrl2Reg.Byte = 0x00; + Ctrl2Reg.Bit.Cm_freq = 0x04; + Ctrl2Reg.Bit.Cmm_en = 1; //连续设1,单次设0 + Ctrl2Reg.Bit.Prd_set = 3; + Ctrl2Reg.Bit.En_prd_set = 1; //连续设1,单次设0 + MMC5983_Write_Reg(MMC5983_CTRL_2, Ctrl2Reg.Byte); +} + +/***************************************************************************************** +* 函数名称: MMC5983_Init +* 功能描述: MMC5983初始化 +* 参 数: 无 +* 返 回 值: 无 +*****************************************************************************************/ +static void MMC5983_Init(void) +{ + uint8_t id; + + id = MMC5983_Read_Reg(MMC5983_ID); + //DBG_LOG("MMC5983 id=0x%x\r\n",id); + MMC5983Var.MMC5983Delay1mSCnt = 100; + while(id != 0x30){ + if(MMC5983Var.MMC5983Delay1mSCnt <= 0) { + DBG_LOG("LEFT MMC5983 INIT Err...\r\n"); + InitFlag = false; + return; + } + } + + MMC5983RegCtrl1 Ctrl1Reg; + Ctrl1Reg.Byte = 0x00; + Ctrl1Reg.Bit.SW_RST = 1; + MMC5983_Write_Reg(MMC5983_CTRL_1, Ctrl1Reg.Byte); + MMC5983Delay(15); + + MMC5983RegCtrl2 Ctrl2Reg; //开启/关闭连续转换 + Ctrl2Reg.Byte = 0x00; + Ctrl2Reg.Bit.Cm_freq = 0x04; + Ctrl2Reg.Bit.Cmm_en = 0; //连续设1,单次设0 + Ctrl2Reg.Bit.Prd_set = 3; + Ctrl2Reg.Bit.En_prd_set = 0; //连续设1,单次设0 + MMC5983_Write_Reg(MMC5983_CTRL_2, Ctrl2Reg.Byte); + + MMC5983RegCtrl3 Ctrl3Reg; + Ctrl3Reg.Byte = 0x00; + Ctrl3Reg.Bit.St_enm = 1; + Ctrl3Reg.Bit.St_enp = 1; + MMC5983_Write_Reg(MMC5983_CTRL_3, Ctrl3Reg.Byte); + + MMC5983RegCtrl0 Ctrl0Reg; + Ctrl0Reg.Byte = 0x00; + Ctrl0Reg.Bit.TM_M = 1; + Ctrl0Reg.Bit.Auto_SR_en = 1; + Ctrl0Reg.Bit.NT_meas_done_en = 1; + MMC5983_Write_Reg(MMC5983_CTRL_0, Ctrl0Reg.Byte); + + if(InitFlag == false){ + DBG_LOG("MMC5983 INIT OK...\r\n"); + InitFlag = true; + } +} + +/***************************************************************************************** +* 函数名称: MMC5983_Read +* 功能描述: MMC5983读取原始数据 +* 参 数: MagAdcX X轴数据 + MagAdcY Y轴数据 + MagAdcZ Z轴数据 +* 返 回 值: 成功返回true,失败返回false +*****************************************************************************************/ +static bool MMC5983_Read(int32_t *MagAdcX, int32_t *MagAdcY, int32_t *MagAdcZ) +{ + static uint8_t buff[7]; + + if (MMC5983_Read_Buffer(MMC5983_X_OUT_H, buff, 7) == false) + return false; + + *MagAdcX = (buff[0] << 10) | (buff[1] << 2) | ((buff[6] & 0xC0) >> 6); + *MagAdcY = (buff[2] << 10) | (buff[3] << 2) | ((buff[6] & 0x30) >> 4); + *MagAdcZ = (buff[4] << 10) | (buff[5] << 2) | ((buff[6] & 0x0C) >> 2);// Turn the 18 bits into unsigned 32-bit value + return true; +} + +/***************************************************************************************** +* 函数名称: MMC5983_Get_Mag +* 功能描述: 外部获取MMC5983磁场强度数据 +* 参 数: mag 读取数据输出缓存入口 +* 返 回 值: 无 +*****************************************************************************************/ +void MMC5983_Get_Mag(float *mag) +{ + if(mag == NULL) + return; + + float ADVal[XYZ]; + + ADVal[X] = MMC5983Var.Mag_Original[X] - 131072.0f; + ADVal[Y] = MMC5983Var.Mag_Original[Y] - 131072.0f; + ADVal[Z] = MMC5983Var.Mag_Original[Z] - 131072.0f; + + mag[0] = (float) (ADVal[X] * MMC5983_MAG_SCALE_18BIT); + mag[1] = (float) (ADVal[Y] * MMC5983_MAG_SCALE_18BIT); + mag[2] = (float) (ADVal[Z] * MMC5983_MAG_SCALE_18BIT); +} + +/***************************************************************************************** +* 函数名称: MMC5983LoopHandler +* 功能描述: MMC5983循环处理函数 +* 参 数: 无 +* 返 回 值: 无 +*****************************************************************************************/ +extern void MmcDataProcessCallBack(float *Mag); + +void MMC5983LoopHandler(void) +{ + static int32_t mag_array[XYZ][10]; + static uint8_t magcnt; + static uint8_t TimeOutMagcnt; + + switch(MMC5983Var.Status) { + case MMC5983_STATUS_IDLE:{ + break;} + + case MMC5983_STATUS_START:{ + for(int i = 0; i < 10; i++) { + mag_array[X][i] = 0; + mag_array[Y][i] = 0; + mag_array[Z][i] = 0; + } + magcnt = 0; + TimeOutMagcnt = 0; + memset(&MMC5983Var, NULL, sizeof(MMC5983Var)); + MMC5983Var.Status = MMC5983_STATUS_DELAY; + break;} + + case MMC5983_STATUS_DELAY:{ + MMC5983StartRead(); + MMC5983Var.MMC5983Delay1mSCnt = 50; + MMC5983Var.Status = MMC5983_STATUS_WAIT_DELAY; + break;} + + case MMC5983_STATUS_WAIT_DELAY:{ + if(MMC5983Var.MMC5983Delay1mSCnt <= 0){ + MMC5983Var.Status = MMC5983_STATUS_READ; + } + break;} + + case MMC5983_STATUS_READ:{ + MMC5983Var.MMC5983Delay1mSCnt = 50; + MMC5983Var.Status = MMC5983_STATUS_WAIT_READ; + break;} + + case MMC5983_STATUS_WAIT_READ:{ + if(MMC5983Var.MMC5983Delay1mSCnt <= 0){ + MMC5983Var.Status = MMC5983_STATUS_DELAY; + TimeOutMagcnt++; + } + if(MMC5983IntFlag == true){ + MMC5983IntFlag = false; + MMC5983_Read(&mag_array[X][magcnt], &mag_array[Y][magcnt], &mag_array[Z][magcnt]); + magcnt++; + MMC5983Var.Status = MMC5983_STATUS_DELAY; + } + if(TimeOutMagcnt >= 10){ + TimeOutMagcnt = 0; + if(magcnt > 0){ + MMC5983Var.Mag_Original[X] = AverageFilter_32t(mag_array[X], magcnt); + MMC5983Var.Mag_Original[Y] = AverageFilter_32t(mag_array[Y], magcnt); + MMC5983Var.Mag_Original[Z] = AverageFilter_32t(mag_array[Z], magcnt); + magcnt = 0; + MMC5983_Get_Mag(MMC5983Var.Mag); + MmcDataProcessCallBack(MMC5983Var.Mag); + MMC5983Var.Status = MMC5983_STATUS_STOP; + } + else{ + MMC5983Var.Status = MMC5983_STATUS_STOP; +// DBG_LOG("LEFT MMC5983 TimeOut...\r\n"); + } + } + if(magcnt >= 10){ + MMC5983Var.Mag_Original[X] = AverageFilter_32t(mag_array[X], magcnt); + MMC5983Var.Mag_Original[Y] = AverageFilter_32t(mag_array[Y], magcnt); + MMC5983Var.Mag_Original[Z] = AverageFilter_32t(mag_array[Z], magcnt); + magcnt = 0; + MMC5983_Get_Mag(MMC5983Var.Mag); + MmcDataProcessCallBack(MMC5983Var.Mag); + MMC5983Var.Status = MMC5983_STATUS_STOP; + } + break;} + + case MMC5983_STATUS_STOP:{ + MMC5983Stop(); + MMC5983Var.Status = MMC5983_STATUS_IDLE; + //MMC5983Var.Status = MMC5983_STATUS_START;//持续工作 + break;} + } +} + +/***************************************************************************************** +* 函数名称: LeftMMC59831mSRoutine +* 功能描述: MMC59831ms时基循环处理函数 +* 参 数: 无 +* 返 回 值: 无 +*****************************************************************************************/ +void MMC59831mSRoutine(void) +{ + if(MMC5983Var.MMC5983Delay1mSCnt > 0) + MMC5983Var.MMC5983Delay1mSCnt--; +} + +/***************************************************************************************** +* 函数名称: LeftMMC5983Init +* 功能描述: MMC5983初始化 +* 参 数: 无 +* 返 回 值: 无 +*****************************************************************************************/ +void MMC5983Init(void) +{ + if(!InitFlag){ + MMC5983_Init(); + return; + } + + MMC5983Var.Status = MMC5983_STATUS_START; +} + +/***************************************************************************************** +* 函数名称: LeftMMC5983Start +* 功能描述: MMC5983启动 +* 参 数: 无 +* 返 回 值: 无 +*****************************************************************************************/ +void MMC5983Start(void) +{ + if(!InitFlag){ + MMC5983_Init(); + return; + } + + MMC5983Var.Status = MMC5983_STATUS_START; +} + +/***************************************************************************************** +* 函数名称: LeftMMC5983StartRead +* 功能描述: MMC5983启动读取 +* 参 数: 无 +* 返 回 值: 无 +*****************************************************************************************/ +void MMC5983StartRead(void) +{ + MMC5983_Init();//读取时重新初始化 +} + +/***************************************************************************************** +* 函数名称: MMC5983Stop +* 功能描述: MMC5983停止 +* 参 数: 无 +* 返 回 值: 无 +*****************************************************************************************/ +void MMC5983Stop(void) +{ + MMC5983RegCtrl0 Ctrl0Reg; + Ctrl0Reg.Byte = 0x00; + MMC5983_Write_Reg(MMC5983_CTRL_0, Ctrl0Reg.Byte); + + MMC5983RegStatus StatusReg; + StatusReg.Byte = MMC5983_Read_Reg(MMC5983_STATUS); + if(StatusReg.Bit.Meas_M_Done == 1){ + MMC5983_Write_Reg(MMC5983_STATUS, StatusReg.Byte); + } +} + +/***************************************************************************************** +* 函数名称: LeftMMC5983IntCallBack +* 功能描述: MMC5983中断回调 +* 参 数: 无 +* 返 回 值: 无 +*****************************************************************************************/ +void MMC5983IntCallBack(void) +{ + MMC5983IntFlag = true; +} + diff --git a/Module/mmc5983/mmc5983.h b/Module/mmc5983/mmc5983.h new file mode 100644 index 0000000..9023e88 --- /dev/null +++ b/Module/mmc5983/mmc5983.h @@ -0,0 +1,140 @@ +/** + ***************************************************************************** + * @file ak8975.h + * @author WWJ + * @version v1.0 + * @date 2019/04/09 + * @environment stm32f407 + * @brief + ***************************************************************************** +**/ + +#ifndef _MMC5983_H +#define _MMC5983_H +#include "bsp.h" + +#define X 0 +#define Y 1 +#define Z 2 +#define XYZ 3 + +#define MAX(A, B) (A > B) ? A : B; +#define MIN(A, B) (A < B) ? A : B; + +#define MMC5983_X_OUT_H 0X00 //Device ID = 0x48 +#define MMC5983_X_OUT_L 0X01 +#define MMC5983_Y_OUT_H 0X02 +#define MMC5983_Y_OUT_L 0X03 +#define MMC5983_Z_OUT_H 0X04 +#define MMC5983_Z_OUT_L 0X05 +#define MMC5983_XYZ_OUT 0X06 +#define MMC5983_TMP_OUT 0X07 +#define MMC5983_STATUS 0X08 +#define MMC5983_CTRL_0 0X09 +#define MMC5983_CTRL_1 0X0A +#define MMC5983_CTRL_2 0X0B +#define MMC5983_CTRL_3 0X0C +#define MMC5983_ID 0X2F + +#define MMC5983_ADDRESS 0x30 +#define MMC5983_MAG_SCALE_16BIT 0.24414f +#define MMC5983_MAG_SCALE_18BIT 0.061035f + +#define MMC5983Delay(x) delay_ms(x) + +typedef union { + struct { + uint8_t Meas_M_Done: 1; + uint8_t Meas_T_Done: 1; + uint8_t Res0: 2; + uint8_t OTP_Read_Done: 1; + uint8_t Res1: 3; + }Bit; + uint8_t Byte; +}MMC5983RegStatus; + +typedef union { + struct { + uint8_t TM_M: 1; + uint8_t TM_T: 1; + uint8_t NT_meas_done_en: 1; + uint8_t Set: 1; + uint8_t Reset: 1; + uint8_t Auto_SR_en: 1; + uint8_t OTP_Read: 1; + uint8_t Res0: 1; + }Bit; + uint8_t Byte; +}MMC5983RegCtrl0; + +typedef union { + struct { + uint8_t BW: 2; + uint8_t X_Inhibit: 1; + uint8_t YZ_Inhibit: 2; + uint8_t Res0: 2; + uint8_t SW_RST: 1; + }Bit; + uint8_t Byte; +}MMC5983RegCtrl1; + +typedef union { + struct { + uint8_t Cm_freq: 3; + uint8_t Cmm_en: 1; + uint8_t Prd_set: 3; + uint8_t En_prd_set: 1; + }Bit; + uint8_t Byte; +}MMC5983RegCtrl2; + +typedef union { + struct { + uint8_t Res0: 1; + uint8_t St_enp: 1; + uint8_t St_enm: 1; + uint8_t Res1: 3; + uint8_t Spi_3w: 1; + uint8_t Res2: 1; + }Bit; + uint8_t Byte; +}MMC5983RegCtrl3; + +typedef enum{ + MMC5983_STATUS_IDLE, + MMC5983_STATUS_START, + MMC5983_STATUS_DELAY, + MMC5983_STATUS_WAIT_DELAY, + MMC5983_STATUS_READ, + MMC5983_STATUS_WAIT_READ, + MMC5983_STATUS_STOP, +}MMC5983Status_m; + + +typedef struct { + MMC5983Status_m Status; + uint16_t MMC5983Delay1mSCnt; + float Mag[3]; + int32_t Mag_Original[XYZ]; +}MMC5983Var_t; + +void MMC5983LoopHandler(void); +void MMC59831mSRoutine(void); +void MMC5983Init(void); +void MMC5983Start(void); +void MMC5983Stop(void); +void MMC5983IntCallBack(void); + +void MMC5983Calib(void); +void MMC5983GetADValue(int32_t *Mag); +void MMC5983_Get_Mag(float *mag); +MMC5983Status_m GetMMC5983Status(void); +void MMC5983StartRead(void); +bool GetMMC5983CalibStatus(void); +#endif + + + +/* end of ak8975.h */ + + diff --git a/ReadMe.txt b/ReadMe.txt new file mode 100644 index 0000000..8241ce8 --- /dev/null +++ b/ReadMe.txt @@ -0,0 +1,31 @@ +璁惧鍓嶈堪锛氬缓璁暱鏃堕棿渚涚數锛岄佹鏍锋満涓嶉渶瑕佽繘鍏ヤ綆鍔熻楋紝閬垮厤璁惧閲嶅鎬у樊鐨勯棶棰樸 +璇ョ増鏈负浣庡姛鑰楃増鏈紝閲囩敤12V渚涚數锛屼紤鐪犵數娴380uA锛屽伐浣滅數娴18mA + +纭欢鐗堟湰璁板綍锛欻V4.x绯诲垪 +==>>Crack_Left_HV4.0 and Crack_Right_HV4.0 + 1銆丠7233-1锛歀DO,杈撳嚭绋冲畾鐨3.3V锛屾渶澶ц緭鍏15V + 2銆丠C32L170JATA-LQ48锛氳澶囩殑MCU涓绘帶鑺墖 + 3銆丩SM6DSLTR锛氬叚杞村姞閫熷害鑺墖 + 4銆丮MC5983MA锛氫笁杞村湴纾佽姱鐗 + 5銆丮AX3471EUA+锛氫覆鍙h浆485鑺墖 + 6銆丷a-02锛歀ORA閫氫俊鑺墖 + +纭欢鐗堟湰鍙樻洿璁板綍锛 +Crack_Left_HV4.0 ==> Crack_Left_HV4.1 Release 2024-06-21 +Crack_Right_HV4.0 ==> Crack_Right_HV4.1 Release 2024-06-21 + 1銆佽皟鏁翠簡涓诲壇鏉縁PC姣嶅骇浣嶇疆 + +==> Crack_Left_HV4.0 Release 2024-06-12 +==> Crack_Right_HV4.0 Release 2024-06-12 + 1銆佹澘妗嗘敼澶 + 2銆佽繛鎺ュ骇瀛愭崲鎴5P+4P鐨凢PC搴у瓙 + 3銆佷紶鎰熷櫒涓柇鑴氫慨鏀 + + +浠g爜鐗堟湰鍙樻洿璁板綍锛 +CrackUnit_Active_SV1.0 ==>> CrackUnit_Active_SV1.1 Release 2024-08-08 + 1銆佷娇鐢ㄤ簡MMC5983涓柇寮曡剼锛屼慨澶嶄簡椹卞姩bug + 2銆佷慨澶嶄簡鍧囧兼护娉㈠嚱鏁癰ug + +==>>CrackUnit_Active_SV1.0 Release 2024-08-01 + 璇ョ増鏈负浣庡姛鑰楃増鏈 diff --git a/driver/inc/adc.h b/driver/inc/adc.h new file mode 100644 index 0000000..f1eccb9 --- /dev/null +++ b/driver/inc/adc.h @@ -0,0 +1,470 @@ +/****************************************************************************** +* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file adc.h + ** + ** Header file for AD Converter functions + ** @link ADC Group Some description @endlink + ** + ** - 2017-06-28 Alex First Version + ** + ******************************************************************************/ + +#ifndef __ADC_H__ +#define __ADC_H__ + + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "ddl.h" + + +/* C binding of definitions if building with C++ compiler */ +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + ****************************************************************************** + ** \defgroup AdcGroup AD Converter (ADC) + ** + ******************************************************************************/ + +//@{ + +/****************************************************************************** + * Global definitions + ******************************************************************************/ +#define ADC_SCAN_CH0_EN (0x1u) /*!< SCAN妯″紡浣跨敤ADC CH0 */ +#define ADC_SCAN_CH1_EN (0x1u<<1) /*!< SCAN妯″紡浣跨敤ADC CH1 */ +#define ADC_SCAN_CH2_EN (0x1u<<2) /*!< SCAN妯″紡浣跨敤ADC CH2 */ +#define ADC_SCAN_CH3_EN (0x1u<<3) /*!< SCAN妯″紡浣跨敤ADC CH3 */ +#define ADC_SCAN_CH4_EN (0x1u<<4) /*!< SCAN妯″紡浣跨敤ADC CH4 */ +#define ADC_SCAN_CH5_EN (0x1u<<5) /*!< SCAN妯″紡浣跨敤ADC CH5 */ +#define ADC_SCAN_CH6_EN (0x1u<<6) /*!< SCAN妯″紡浣跨敤ADC CH6 */ +#define ADC_SCAN_CH7_EN (0x1u<<7) /*!< SCAN妯″紡浣跨敤ADC CH7 */ + + +/****************************************************************************** + ** Global type definitions + *****************************************************************************/ + + /** + ****************************************************************************** + ** \brief ADC杞崲妯″紡 + *****************************************************************************/ +typedef enum en_adc_mode +{ + AdcSglMode = 0u, /*!< 鍗曡緭鍏ラ氶亾鍗曟杞崲妯″紡 */ + AdcScanMode = 1u, /*!< 澶氳緭鍏ラ氶亾椤哄簭/鎻掗槦鎵弿杞崲妯″紡*/ +}en_adc_mode_t; + +/** + ****************************************************************************** + ** \brief ADC鏃堕挓鍒嗛閫夋嫨 + *****************************************************************************/ +typedef enum en_adc_clk_sel +{ + AdcMskClkDiv1 = 0u<<2, /*!< PCLK */ + AdcMskClkDiv2 = 1u<<2, /*!< 1/2 PCLK */ + AdcMskClkDiv4 = 2u<<2, /*!< 1/4 PCLK */ + AdcMskClkDiv8 = 3u<<2, /*!< 1/8 PCLK */ +} en_adc_clk_div_t; + +/** + ****************************************************************************** + ** \brief ADC鍙傝冪數鍘 + *****************************************************************************/ +typedef enum en_adc_ref_vol_sel +{ + AdcMskRefVolSelInBgr1p5 = 0u<<9, /*!<鍐呴儴鍙傝冪數鍘1.5V(SPS<=200kHz)*/ + AdcMskRefVolSelInBgr2p5 = 1u<<9, /*!<鍐呴儴鍙傝冪數鍘2.5V(avdd>3V,SPS<=200kHz)*/ + AdcMskRefVolSelExtern1 = 2u<<9, /*!<澶栭儴杈撳叆(max avdd) PB01*/ + AdcMskRefVolSelAVDD = 3u<<9, /*!>4)*10) + ((x)&0x0F)) + +#define SET_BIT(REG, BIT) ((REG) |= (BIT)) + +#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) + +#define READ_BIT(REG, BIT) ((REG) & (BIT)) + +#define CLEAR_REG(REG) ((REG) = (0x0)) + +#define WRITE_REG(REG, VAL) ((REG) = (VAL)) + +#define READ_REG(REG) ((REG)) + +#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) + +/** + ****************************************************************************** + ** Global Device Series List + ******************************************************************************/ +#define DDL_DEVICE_SERIES_HC32L17X (0u) + +/** + ****************************************************************************** + ** Global Device Package List + ******************************************************************************/ +// package definitions of HC device. +#define DDL_DEVICE_PACKAGE_HC_C (0x00u) +#define DDL_DEVICE_PACKAGE_HC_F (0x10u) +#define DDL_DEVICE_PACKAGE_HC_J (0x20u) +#define DDL_DEVICE_PACKAGE_HC_K (0x30u) + +/******************************************************************************/ +/* User Device Setting Include file */ +/******************************************************************************/ +#include "ddl_device.h" // MUST be included here! + +/******************************************************************************/ +/* Global type definitions ('typedef') */ +/******************************************************************************/ +/** + ****************************************************************************** + ** \brief Level + ** + ** Specifies levels. + ** + ******************************************************************************/ +typedef enum en_level +{ + DdlLow = 0u, ///< Low level '0' + DdlHigh = 1u ///< High level '1' +} en_level_t; + +/** + ****************************************************************************** + ** \brief Generic Flag Code + ** + ** Specifies flags. + ** + ******************************************************************************/ +typedef enum en_flag +{ + DdlClr = 0u, ///< Flag clr '0' + DdlSet = 1u ///< Flag set '1' +} en_stat_flag_t, en_irq_flag_t; +/******************************************************************************/ +/* Global variable declarations ('extern', definition in C source) */ +/******************************************************************************/ + +/******************************************************************************/ +/* Global function prototypes ('extern', definition in C source) */ +/******************************************************************************/ + +/******************************************************************************* + * Global function prototypes + ******************************************************************************/ +extern void ddl_memclr(void* pu8Address, uint32_t u32Count); +uint32_t Log2(uint32_t u32Val); +/** + ******************************************************************************* + ** This hook is part of wait loops. + ******************************************************************************/ +void delay1ms(uint32_t u32Cnt); +void delay100us(uint32_t u32Cnt); +void delay10us(uint32_t u32Cnt); +void SetBit(uint32_t addr, uint32_t offset, boolean_t bFlag); +void ClrBit(uint32_t addr, uint32_t offset); +boolean_t GetBit(uint32_t addr, uint32_t offset); +#ifdef __cplusplus +} +#endif + +#endif /* __DDL_H__ */ + +/******************************************************************************/ +/* EOF (not truncated) */ +/******************************************************************************/ + diff --git a/driver/inc/debug.h b/driver/inc/debug.h new file mode 100644 index 0000000..4f33fde --- /dev/null +++ b/driver/inc/debug.h @@ -0,0 +1,129 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file debug.h + ** + ** Headerfile for DEBUG functions + ** @link Debug Group Some description @endlink + ** + ** History: + ** - 2018-04-15 Lux First Version + ** + ******************************************************************************/ + +#ifndef __DEBUG_H__ +#define __DEBUG_H__ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "ddl.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + ****************************************************************************** + ** \defgroup DebugGroup (DEBUG) + ** + ******************************************************************************/ +//@{ + +/** + ******************************************************************************* + ** function prototypes. + ******************************************************************************/ + +/****************************************************************************** + * Global type definitions + ******************************************************************************/ +/** + ******************************************************************************* + ** \brief 璋冭瘯妯″紡涓嬪悇妯″潡宸ヤ綔鐘舵佺被鍨嬪畾涔 + ** \note + ******************************************************************************/ +typedef enum en_debug_module_active +{ + DebugMskTim0 = 0x0001u, ///< TIM0 + DebugMskTim1 = 0x0002u, ///< TIM1 + DebugMskTim2 = 0x0004u, ///< TIM2 + DebugMskLpTim0 = 0x0008u, ///< LPTIM0 + DebugMskTim4 = 0x0010u, ///< TIM4 + DebugMskTim5 = 0x0020u, ///< TIM5 + DebugMskTim6 = 0x0040u, ///< TIM6 + DebugMskPca = 0x0080u, ///< PCA + DebugMskWdt = 0x0100u, ///< WDT + DebugMskRtc = 0x0200u, ///< RTC + DebugMskTim3 = 0x0800u, ///< TIM3 + DebugMskLpTim1 = 0x1000u, ///< LPTIM1 +}en_debug_module_active_t; + +/******************************************************************************* + * Global definitions + ******************************************************************************/ + +/****************************************************************************** + * Global variable declarations ('extern', definition in C source) + ******************************************************************************/ + +/****************************************************************************** + * Global function prototypes (definition in C source) + ******************************************************************************/ +///< 鍦⊿WD璋冭瘯妯″紡涓嬶紝浣胯兘妯″潡璁℃暟鍔熻兘 +en_result_t Debug_ActiveEnable(en_debug_module_active_t enModule); +///< 鍦⊿WD璋冭瘯妯″紡涓嬶紝鏆傚仠妯″潡璁℃暟鍔熻兘 +en_result_t Debug_ActiveDisable(en_debug_module_active_t enModule); + +//@} // Debug Group + +#ifdef __cplusplus +#endif + +#endif /* __DEBUG_H__ */ +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/driver/inc/dmac.h b/driver/inc/dmac.h new file mode 100644 index 0000000..bdd93b0 --- /dev/null +++ b/driver/inc/dmac.h @@ -0,0 +1,356 @@ +/***************************************************************************** +* Copyright (C) 2016, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file dma.h +** +** A detailed description is available at +** @link DmacGroup Dmac description @endlink +** +** - 2018-03-09 1.0 Hongjh First version for Device Driver Library of Dmac. +** +******************************************************************************/ +#ifndef __DMAC_H__ +#define __DMAC_H__ + +/******************************************************************************* +* Include files +******************************************************************************/ +#include "ddl.h" + +/* C binding of definitions if building with C++ compiler */ +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + ******************************************************************************* + ** \defgroup DmacGroup Direct Memory Access Control(DMAC) + ** + ******************************************************************************/ + //@{ + + /******************************************************************************* + * Global type definitions ('typedef') + ******************************************************************************/ + /** + ******************************************************************************* + ** \brief DMA 閫氶亾 + ** + ******************************************************************************/ + typedef enum en_dma_channel + { + DmaCh0 = 0x00, ///< DMA 閫氶亾0 + DmaCh1 = 0x04, ///< DMA 閫氶亾1 + } en_dma_channel_t; + /** + ******************************************************************************* + ** \brief DMA 浼樺厛绾 + ** + ******************************************************************************/ + typedef enum en_dma_priority + { + DmaMskPriorityFix = 0x00000000, ///< DMA 鍚勯氶亾浼樺厛绾у浐瀹 (CH0>CH1) + DmaMskPriorityLoop = 0x10000000, ///< DMA 鍚勯氶亾浼樺厛绾ч噰鐢ㄨ疆璇㈡柟寮 + } en_dma_priority_t; + + /** + ******************************************************************************* + ** \brief DMA 浼犺緭鏁版嵁瀹藉害 + ** + ******************************************************************************/ + typedef enum en_dma_transfer_width + { + DmaMsk8Bit = 0x00000000, ///< 8 bit 瀛楄妭浼犺緭 + DmaMsk16Bit = 0x04000000, ///< 16 bit 鍗婂瓧浼犺緭 + DmaMsk32Bit = 0x08000000 ///< 32 bit 瀛椾紶杈 + } en_dma_transfer_width_t; + + /** + ******************************************************************************* + ** \brief DMA 浼犺緭妯″紡锛氬潡(Block)浼犺緭鎴栬呯獊鍙(Burst)浼犺緭 + ** + ******************************************************************************/ + typedef enum en_dma_transfer_mode + { + DmaMskBlock = 0x00000000, ///< 鍧(Block)浼犺緭 + DmaMskBurst = 0x10000000, ///< 绐佸彂(Burst)浼犺緭 + } en_dma_transfer_mode_t; + + /** + ******************************************************************************* + ** \brief DMA浼犺緭褰撳墠鐘舵 + ** + ******************************************************************************/ + typedef enum en_dma_stat + { + DmaDefault = 0U, ///< 鍒濆鍊 + DmaAddOverflow = 1U, ///< 浼犺緭閿欒寮曡捣涓锛堝湴鍧婧㈠嚭锛 + DmaHALT = 2U, ///< 浼犺緭鍋滄璇锋眰寮曡捣涓锛堝璁惧仠姝㈣姹傚紩璧风殑鍋滄鎴栬匛B/DE浣嶅紩璧风殑绂佹浼犺緭锛 + DmaAccSCRErr = 3U, ///< 浼犺緭閿欒寮曡捣涓锛堜紶杈撴簮鍦板潃璁块棶閿欒锛 + DmaAccDestErr = 4U, ///< 浼犺緭閿欒寮曡捣涓锛堜紶杈撶洰鐨勫湴鍧璁块棶閿欒锛 + DmaTransferComplete = 5U, ///< 鎴愬姛浼犺緭瀹屾垚 + DmaTransferPause = 7U, ///< 浼犺緭鏆傚仠 + } en_dma_stat_t; + + /** + ******************************************************************************* + ** \brief DMA婧愬湴鍧鎺у埗妯″紡锛氳嚜澧炴垨鍥哄畾 + ** + ******************************************************************************/ + typedef enum en_src_address_mode + { + DmaMskSrcAddrInc = 0x00000000, ///< 鍦板潃鑷 + DmaMskSrcAddrFix = 0x02000000, ///< 鍦板潃鍥哄畾 + } en_src_address_mode_t; + + /** + ******************************************************************************* + ** \brief DMA鐩殑鍦板潃鎺у埗妯″紡锛氳嚜澧炴垨鍥哄畾 + ** + ******************************************************************************/ + typedef enum en_dst_address_mode + { + DmaMskDstAddrInc = 0x00000000, ///< 鍦板潃鑷 + DmaMskDstAddrFix = 0x01000000, ///< 鍦板潃鍥哄畾 + } en_dst_address_mode_t; + + /** + ******************************************************************************* + ** \brief DMA CONFA:BC[3:0]鍜孋ONFA:TC[15:0]鐨勯噸杞藉姛鑳 + ** + ******************************************************************************/ + typedef enum en_bc_tc_reload_mode + { + DmaMskBcTcReloadDisable = 0x00000000, ///< 绂佹閲嶈浇 + DmaMskBcTcReloadEnable = 0x00800000, ///< 浣胯兘閲嶈浇 + } en_bc_tc_reload_mode_t; + + /** + ******************************************************************************* + ** \brief DMA婧愬湴鍧閲嶈浇鍔熻兘锛氫娇鑳芥垨绂佹 + ** + ******************************************************************************/ + typedef enum en_src_address_reload_mode + { + DmaMskSrcAddrReloadDisable = 0x00000000, ///< 绂佹DMA婧愬湴鍧閲嶈浇 + DmaMskSrcAddrReloadEnable = 0x00400000, ///< 浣胯兘DMA婧愬湴鍧閲嶈浇 + } en_src_address_reload_mode_t; + + /** + ******************************************************************************* + ** \brief DMA鐩殑鍦板潃閲嶈浇鍔熻兘锛氫娇鑳芥垨绂佹 + ** + ******************************************************************************/ + typedef enum en_dst_address_reload_mode + { + DmaMskDstAddrReloadDisable = 0x00000000, ///< 绂佹DMA鐩殑鍦板潃閲嶈浇 + DmaMskDstAddrReloadEnable = 0x00200000, ///< 浣胯兘DMA鐩殑鍦板潃閲嶈浇 + } en_dst_address_reload_mode_t; + + + + /** + ******************************************************************************* + ** \brief DMA 杩炵画浼犺緭璁剧疆 + ** + ******************************************************************************/ + typedef enum en_dma_msk + { + DmaMskOneTransfer = 0x00000000, ///< 浼犺緭涓娆★紝DMAC浼犺緭瀹屾垚鏃舵竻闄ONFA:ENS浣 + DmaMskContinuousTransfer = 0x00000001, ///< 杩炵画浼犺緭锛孌MAC浼犺緭瀹屾垚鏃朵笉娓呴櫎CONFA:ENS浣 + } en_dma_msk_t; + /** + ******************************************************************************* + ** \brief DMA 瑙﹀彂婧愰夋嫨 + ** + ******************************************************************************/ + typedef enum stc_dma_trig_sel + { + DmaSWTrig = 0U, ///< Select DMA software trig + DmaSPI0RXTrig = 64U, ///< Select DMA hardware trig 0 + DmaSPI0TXTrig = 65U, ///< Select DMA hardware trig 1 + DmaSPI1RXTrig = 66U, ///< Select DMA hardware trig 2 + DmaSPI1TXTrig = 67U, ///< Select DMA hardware trig 3 + DmaADCJQRTrig = 68U, ///< Select DMA hardware trig 4 + DmaADCSQRTrig = 69U, ///< Select DMA hardware trig 5 + DmaLCDTxTrig = 70U, ///< Select DMA hardware trig 6 + DmaUart0RxTrig = 72U, ///< Select DMA hardware trig 8 + DmaUart0TxTrig = 73U, ///< Select DMA hardware trig 9 + DmaUart1RxTrig = 74U, ///< Select DMA hardware trig 10 + DmaUart1TxTrig = 75U, ///< Select DMA hardware trig 11 + DmaLpUart0RxTrig = 76U, ///< Select DMA hardware trig 12 + DmaLpUart0TxTrig = 77U, ///< Select DMA hardware trig 13 + DmaLpUart1RxTrig = 78U, ///< Select DMA hardware trig 14 + DmaLpUart1TxTrig = 79U, ///< Select DMA hardware trig 15 + DmaDAC0Trig = 80U, ///< Select DMA hardware trig 16 + DmaDAC1Trig = 81U, ///< Select DMA hardware trig 17 + DmaTIM0ATrig = 82U, ///< Select DMA hardware trig 18 + DmaTIM0BTrig = 83U, ///< Select DMA hardware trig 19 + DmaTIM1ATrig = 84U, ///< Select DMA hardware trig 20 + DmaTIM1BTrig = 85U, ///< Select DMA hardware trig 21 + DmaTIM2ATrig = 86U, ///< Select DMA hardware trig 22 + DmaTIM2BTrig = 87U, ///< Select DMA hardware trig 23 + DmaTIM3ATrig = 88U, ///< Select DMA hardware trig 24 + DmaTIM3BTrig = 89U, ///< Select DMA hardware trig 25 + DmaTIM4ATrig = 90U, ///< Select DMA hardware trig 26 + DmaTIM4BTrig = 91U, ///< Select DMA hardware trig 27 + DmaTIM5ATrig = 92U, ///< Select DMA hardware trig 28 + DmaTIM5BTrig = 93U, ///< Select DMA hardware trig 29 + DmaTIM6ATrig = 94U, ///< Select DMA hardware trig 30 + DmaTIM6BTrig = 95U, ///< Select DMA hardware trig 31 + DmaUart2RxTrig = 96U, ///< Select DMA hardware trig 32 + DmaUart2TxTrig = 97U, ///< Select DMA hardware trig 33 + DmaUart3RxTrig = 98U, ///< Select DMA hardware trig 34 + DmaUart3TxTrig = 99U, ///< Select DMA hardware trig 35 + }en_dma_trig_sel_t; + + /** + ******************************************************************************* + ** \brief DMA閫氶亾鍒濆鍖栭厤缃粨鏋勪綋 + ** + ******************************************************************************/ + typedef struct stc_dma_cfg + { + en_dma_transfer_mode_t enMode; + + uint16_t u16BlockSize; ///< 鍧椾紶杈撲釜鏁 + uint16_t u16TransferCnt; ///< 浼犺緭鍧楁鏁 + en_dma_transfer_width_t enTransferWidth; ///< 浼犺緭鏁版嵁瀛楄妭瀹藉害 鍏蜂綋鍙傝冩灇涓惧畾涔:en_dma_transfer_width_t + + en_src_address_mode_t enSrcAddrMode; ///< DMA婧愬湴鍧鎺у埗妯″紡锛氳嚜澧炴垨鍥哄畾 + en_dst_address_mode_t enDstAddrMode; ///< DMA鐩殑鍦板潃鎺у埗妯″紡锛氳嚜澧炴垨鍥哄畾 + + en_src_address_reload_mode_t enSrcAddrReloadCtl; ///< 婧愬湴鍧閲嶈浇 鍏蜂綋鍙傝冩灇涓惧畾涔:en_src_address_reload_mode_t + en_dst_address_reload_mode_t enDestAddrReloadCtl;///< 鐩殑鍦板潃閲嶈浇 鍏蜂綋鍙傝冩灇涓惧畾涔:en_dst_address_reload_mode_t + en_bc_tc_reload_mode_t enSrcBcTcReloadCtl; ///< Bc/Tc鍊奸噸杞藉姛鑳 鍏蜂綋鍙傝冩灇涓惧畾涔:en_bc_tc_reload_mode_t + + uint32_t u32SrcAddress; ///< 婧愬湴鍧> + uint32_t u32DstAddress; ///< 鐩殑鍦板潃> + + en_dma_msk_t enTransferMode; ///DMA 杩炵画浼犺緭璁剧疆 鍏蜂綋鍙傝冩灇涓惧畾涔:en_dma_msk_t + en_dma_priority_t enPriority; ///DMA 浼樺厛绾ц瀹 鍏蜂綋鍙傝冩灇涓惧畾涔:en_dma_priority_t + en_dma_trig_sel_t enRequestNum; ///PCLK=HCLK=SystemClk=RCH4MHz +en_result_t Sysctrl_ClkDeInit(void); + +///< 绯荤粺鏃堕挓妯″潡鐨勫熀鏈姛鑳借缃 +///< 娉ㄦ剰锛氫娇鑳介渶瑕佷娇鐢ㄧ殑鏃堕挓婧愪箣鍓嶏紝蹇呴』浼樺厛璁剧疆鐩爣鍐呴儴鏃堕挓婧愮殑TRIM鍊兼垨澶栭儴鏃堕挓婧愮殑棰戠巼鑼冨洿 +en_result_t Sysctrl_ClkSourceEnable(en_sysctrl_clk_source_t enSource, boolean_t bFlag); + +///<澶栭儴鏅舵尟椹卞姩閰嶇疆锛氱郴缁熷垵濮嬪寲Sysctrl_ClkInit()涔嬪悗锛屽彲鏍规嵁闇瑕侀厤缃閮ㄦ櫠鎸殑椹卞姩鑳藉姏锛屾椂閽熷垵濮嬪寲Sysctrl_ClkInit()榛樿涓烘渶澶у; +en_result_t Sysctrl_XTHDriverCfg(en_sysctrl_xtal_driver_t enDriver); +en_result_t Sysctrl_XTLDriverCfg(en_sysctrl_xtl_amp_t enAmp, en_sysctrl_xtal_driver_t enDriver); + +///<鏃堕挓绋冲畾鍛ㄦ湡璁剧疆:绯荤粺鍒濆鍖朣ysctrl_ClkInit()涔嬪悗锛屽彲鏍规嵁闇瑕侀厤缃椂閽熷紑鍚悗鐨勭ǔ瀹氫箣闂达紝榛樿涓烘渶澶у; +en_result_t Sysctrl_SetXTHStableTime(en_sysctrl_xth_cycle_t enCycle); +en_result_t Sysctrl_SetRCLStableTime(en_sysctrl_rcl_cycle_t enCycle); +en_result_t Sysctrl_SetXTLStableTime(en_sysctrl_xtl_cycle_t enCycle); +en_result_t Sysctrl_SetPLLStableTime(en_sysctrl_pll_cycle_t enCycle); + +///<绯荤粺鏃堕挓婧愬垏鎹㈠苟鏇存柊绯荤粺鏃堕挓锛氬鏋滈渶瑕佸湪绯荤粺鏃堕挓鍒濆鍖朣ysctrl_ClkInit()涔嬪悗鍒囨崲涓婚鏃堕挓婧愶紝鍒欎娇鐢ㄨ鍑芥暟锛 +///< 鏃堕挓鍒囨崲鍓嶅悗锛屽繀椤绘牴鎹洰鏍囬鐜囧艰缃瓼lash璇荤瓑寰呭懆鏈燂紝鍙厤缃彃鍏ュ懆鏈熶负0銆1銆2锛 +///< 娉ㄦ剰!!!锛氬綋HCLK澶т簬24MHz鏃讹紝FLASH绛夊緟鍛ㄦ湡鎻掑叆蹇呴』鑷冲皯涓1,鍚﹀垯绋嬪簭杩愯鍙兘浜х敓鏈煡閿欒 +en_result_t Sysctrl_SysClkSwitch(en_sysctrl_clk_source_t enSource); + +///< 鏃堕挓婧愰鐜囪瀹氾細鏍规嵁绯荤粺鎯呭喌锛屽崟鐙缃笉鍚屾椂閽熸簮鐨勯鐜囧; +///< 鏃堕挓棰戠巼璁剧疆鍓嶏紝蹇呴』鏍规嵁鐩爣棰戠巼鍊艰缃瓼lash璇荤瓑寰呭懆鏈燂紝鍙厤缃彃鍏ュ懆鏈熶负0銆1銆2锛 +///< 鍏朵腑XTL鐨勬椂閽熺敱澶栭儴鏅舵尟鍐冲畾锛屾棤闇璁剧疆銆 +en_result_t Sysctrl_SetRCHTrim(en_sysctrl_rch_freq_t enRCHFreq); +en_result_t Sysctrl_SetRCLTrim(en_sysctrl_rcl_freq_t enRCLFreq); +en_result_t Sysctrl_SetXTHFreq(en_sysctrl_xth_freq_t enXTHFreq); +en_result_t Sysctrl_SetPLLFreq(stc_sysctrl_pll_cfg_t *pstcPLLCfg); + +///< 鏃堕挓鍒嗛璁剧疆:鏍规嵁绯荤粺鎯呭喌锛屽崟鐙缃瓾CLK銆丳CLK鐨勫垎閰嶅; +en_result_t Sysctrl_SetHCLKDiv(en_sysctrl_hclk_div_t enHCLKDiv); +en_result_t Sysctrl_SetPCLKDiv(en_sysctrl_pclk_div_t enPCLKDiv); + +///< 鏃堕挓棰戠巼鑾峰彇锛氭牴鎹郴缁熼渶瑕侊紝鑾峰彇褰撳墠HCLK鍙奝CLK鐨勯鐜囧 +uint32_t Sysctrl_GetHClkFreq(void); +uint32_t Sysctrl_GetPClkFreq(void); + +///< 澶栬闂ㄦ帶寮鍏/鐘舵佽幏鍙栵細鐢ㄤ簬鎺у埗澶栬妯″潡鐨勪娇鑳斤紝浣跨敤璇ユā鍧楃殑鍔熻兘涔嬪墠锛屽繀椤讳娇鑳借妯″潡鐨勯棬鎺ф椂閽燂紱 +en_result_t Sysctrl_SetPeripheralGate(en_sysctrl_peripheral_gate_t enPeripheral, boolean_t bFlag); +boolean_t Sysctrl_GetPeripheralGate(en_sysctrl_peripheral_gate_t enPeripheral); + +///< 绯荤粺鍔熻兘閰嶇疆锛氱敤浜庤缃叾浠栫郴缁熺浉鍏崇壒娈婂姛鑳斤紱 +en_result_t Sysctrl_SetFunc(en_sysctrl_func_t enFunc, boolean_t bFlag); + +///< RTC楂橀熸椂閽熻ˉ鍋:鐢ㄤ簬璁剧疆RTC楂橀熸椂閽熶笅鐨勯鐜囪ˉ鍋 +en_result_t Sysctrl_SetRTCAdjustClkFreq(en_sysctrl_rtc_adjust_t enRtcAdj); + +//@} // Sysctrl Group + +#ifdef __cplusplus +#endif + +#endif /* __SYSCTRL_H__ */ +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/driver/inc/timer3.h b/driver/inc/timer3.h new file mode 100644 index 0000000..fbe59fc --- /dev/null +++ b/driver/inc/timer3.h @@ -0,0 +1,781 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file timer3.h + ** + ** 鍩烘湰瀹氭椂鍣ㄦ暟鎹粨鏋勫強API澹版槑 + ** @link Timer3 Group Some description @endlink + ** + ** History: + ** - 2019-04-18 Husj First Version + ** + *****************************************************************************/ + +#ifndef __TIMER3_H__ +#define __TIMER3_H__ + +/***************************************************************************** + * Include files + *****************************************************************************/ +#include "ddl.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + ****************************************************************************** + ** \defgroup Tim3Group Timer3 (TIM3) + ** + ******************************************************************************/ +//@{ + +/******************************************************************************/ +/* Global pre-processor symbols/macros ('#define') */ +/******************************************************************************/ + +/****************************************************************************** + * Global type definitions + ******************************************************************************/ + +/** + ****************************************************************************** + ** \brief Timer3 閫氶亾瀹氫箟 + *****************************************************************************/ +typedef enum en_tim3_channel +{ + Tim3CH0 = 0u, ///< Timer3閫氶亾0 + Tim3CH1 = 1u, ///< Timer3閫氶亾1 + Tim3CH2 = 2u, ///< Timer3閫氶亾2 +}en_tim3_channel_t; + +/** + ****************************************************************************** + ** \brief 宸ヤ綔妯″紡閫夋嫨鏁版嵁绫诲瀷閲嶅畾涔 (MODE)(妯″紡0/1/23) + *****************************************************************************/ +typedef enum en_tim3_work_mode +{ + Tim3WorkMode0 = 0u, ///< 瀹氭椂鍣ㄦā寮 + Tim3WorkMode1 = 1u, ///< PWC妯″紡 + Tim3WorkMode2 = 2u, ///< 閿娇娉㈡ā寮 + Tim3WorkMode3 = 3u, ///< 涓夎娉㈡ā寮 +}en_tim3_work_mode_t; + +/** + ****************************************************************************** + ** \brief 鏋佹ф帶鍒舵暟鎹被鍨嬮噸瀹氫箟 (GATE_P)(妯″紡0) + *****************************************************************************/ +typedef enum en_tim3_m0cr_gatep +{ + Tim3GatePositive = 0u, ///< 楂樼數骞虫湁鏁 + Tim3GateOpposite = 1u, ///< 浣庣數骞虫湁鏁 +}en_tim3_m0cr_gatep_t; + +/** + ****************************************************************************** + ** \brief TIM3 棰勯櫎棰戦夋嫨 (PRS)(妯″紡0/1/23) + *****************************************************************************/ +typedef enum en_tim3_cr_timclkdiv +{ + Tim3PCLKDiv1 = 0u, ///< Div 1 + Tim3PCLKDiv2 = 1u, ///< Div 2 + Tim3PCLKDiv4 = 2u, ///< Div 4 + Tim3PCLKDiv8 = 3u, ///< Div 8 + Tim3PCLKDiv16 = 4u, ///< Div 16 + Tim3PCLKDiv32 = 5u, ///< Div 32 + Tim3PCLKDiv64 = 6u, ///< Div 64 + Tim3PCLKDiv256 = 7u, ///< Div 256 +}en_tim3_cr_timclkdiv_t; + +/** + ****************************************************************************** + ** \brief 璁℃暟/瀹氭椂鍣ㄥ姛鑳介夋嫨鏁版嵁绫诲瀷閲嶅畾涔 (CT)(妯″紡0/1/23) + *****************************************************************************/ +typedef enum en_tim3_cr_ct +{ + Tim3Timer = 0u, ///< 瀹氭椂鍣ㄥ姛鑳斤紝璁℃暟鏃堕挓涓哄唴閮≒CLK + Tim3Counter = 1u, ///< 璁℃暟鍣ㄥ姛鑳斤紝璁℃暟鏃堕挓涓哄閮‥TR +}en_tim3_cr_ct_t; + + +/** + ****************************************************************************** + ** \brief 瀹氭椂鍣ㄥ伐浣滄ā寮忔暟鎹被鍨嬮噸瀹氫箟 (MD)(妯″紡0) + *****************************************************************************/ +typedef enum en_tim3_m0cr_md +{ + Tim332bitFreeMode = 0u, ///< 32浣嶈鏁板櫒/瀹氭椂鍣 + Tim316bitArrMode = 1u, ///< 鑷姩閲嶈杞16浣嶈鏁板櫒/瀹氭椂鍣 +}en_tim3_m0cr_md_t; + +/** + ****************************************************************************** +** \brief TIM3涓柇绫诲瀷鏁版嵁绫诲瀷閲嶅畾涔(妯″紡0/1/23) + *****************************************************************************/ +typedef enum en_tim3_irq_type +{ + Tim3UevIrq = 0u, ///< 婧㈠嚭/浜嬩欢鏇存柊涓柇 + Tim3CA0Irq = 2u, ///< CH0A鎹曡幏/姣旇緝涓柇(浠呮ā寮1/23瀛樺湪) + Tim3CA1Irq = 3u, ///< CH1A鎹曡幏/姣旇緝涓柇(浠呮ā寮23瀛樺湪) + Tim3CA2Irq = 4u, ///< CH2A鎹曡幏/姣旇緝涓柇(浠呮ā寮23瀛樺湪) + Tim3CB0Irq = 5u, ///< CH0B鎹曡幏/姣旇緝涓柇(浠呮ā寮23瀛樺湪) + Tim3CB1Irq = 6u, ///< CH1B鎹曡幏/姣旇緝涓柇(浠呮ā寮23瀛樺湪) + Tim3CB2Irq = 7u, ///< CH2B鎹曡幏/姣旇緝涓柇(浠呮ā寮23瀛樺湪) + Tim3CA0E = 8u, ///< CH0A鎹曡幏鏁版嵁涓㈠け鏍囧織(浠呮ā寮23瀛樺湪)(涓嶆槸涓柇) + Tim3CA1E = 9u, ///< CH1A鎹曡幏鏁版嵁涓㈠け鏍囧織(浠呮ā寮23瀛樺湪)(涓嶆槸涓柇) + Tim3CA2E = 10u, ///< CH2A鎹曡幏鏁版嵁涓㈠け鏍囧織(浠呮ā寮23瀛樺湪)(涓嶆槸涓柇) + Tim3CB0E = 11u, ///< CH0B鎹曡幏鏁版嵁涓㈠け鏍囧織(浠呮ā寮23瀛樺湪)(涓嶆槸涓柇) + Tim3CB1E = 12u, ///< CH1B鎹曡幏鏁版嵁涓㈠け鏍囧織(浠呮ā寮23瀛樺湪)(涓嶆槸涓柇) + Tim3CB2E = 13u, ///< CH2B鎹曡幏鏁版嵁涓㈠け鏍囧織(浠呮ā寮23瀛樺湪)(涓嶆槸涓柇) + Tim3BkIrq = 14u, ///< 鍒硅溅涓柇(浠呮ā寮23瀛樺湪锛 + Tim3TrigIrq = 15u, ///< 瑙﹀彂涓柇(浠呮ā寮23瀛樺湪锛 +}en_tim3_irq_type_t; + +/** + ****************************************************************************** + ** \brief 娴嬮噺寮濮嬬粨鏉熸暟鎹被鍨嬮噸瀹氫箟 (Edg1stEdg2nd)(妯″紡1) + *****************************************************************************/ +typedef enum en_tim3_m1cr_Edge +{ + Tim3PwcRiseToRise = 0u, ///< 涓婂崌娌垮埌涓婂崌娌(鍛ㄦ湡) + Tim3PwcFallToRise = 1u, ///< 涓嬮檷娌垮埌涓婂崌娌(浣庣數骞) + Tim3PwcRiseToFall = 2u, ///< 涓婂崌娌垮埌涓嬮檷娌(楂樼數骞) + Tim3PwcFallToFall = 3u, ///< 涓嬮檷娌垮埌涓嬮檷娌(鍛ㄦ湡) +}en_tim3_m1cr_Edge_t; + +/** + ****************************************************************************** + ** \brief PWC娴嬮噺娴嬭瘯妯″紡閫夋嫨鏁版嵁绫诲瀷閲嶅畾涔 (Oneshot)(妯″紡1) + *****************************************************************************/ +typedef enum en_tim3_m1cr_oneshot +{ + Tim3PwcCycleDetect = 0u, ///< PWC寰幆娴嬮噺 + Tim3PwcOneShotDetect = 1u, ///< PWC鍗曟娴嬮噺 +}en_tim3_m1cr_oneshot_t; + +/** + ****************************************************************************** + ** \brief PWC IA0閫夋嫨鏁版嵁绫诲瀷閲嶅畾涔 (IA0S)(妯″紡1) + *****************************************************************************/ +typedef enum en_tim3_m1_mscr_ia0s +{ + Tim3IA0Input = 0u, ///< IAO杈撳叆 + Tim3XORInput = 1u, ///< IA0 ETR GATE XOR(TIM0/1/2)/IA0 IA1 IA2 XOR(TIM3) +}en_tim3_m1_mscr_ia0s_t; + +/** + ****************************************************************************** + ** \brief PWC IB0閫夋嫨鏁版嵁绫诲瀷閲嶅畾涔 (IA0S)(妯″紡1) + *****************************************************************************/ +typedef enum en_tim3_m1_mscr_ib0s +{ + Tim3IB0Input = 0u, ///< IBO杈撳叆 + Tim3TsInput = 1u, ///< 鍐呴儴瑙﹀彂TS閫夋嫨淇″彿 +}en_tim3_m1_mscr_ib0s_t; + +/** + ****************************************************************************** + ** \brief 杈撳嚭鏋佹с佽緭鍏ョ浉浣 鏁版嵁绫诲瀷閲嶅畾涔 (CCPA0/CCPB0/ETP/BKP)(妯″紡1/23) + *****************************************************************************/ +typedef enum en_tim3_port_polarity +{ + Tim3PortPositive = 0u, ///< 姝e父杈撳叆杈撳嚭 + Tim3PortOpposite = 1u, ///< 鍙嶅悜杈撳叆杈撳嚭 +}en_tim3_port_polarity_t; + +/** + ****************************************************************************** + ** \brief 婊ゆ尝閫夋嫨鏁版嵁绫诲瀷閲嶅畾涔 (FLTET/FLTA0/FLAB0)(妯″紡1/23) + *****************************************************************************/ +typedef enum en_tim3_flt +{ + Tim3FltNone = 0u, ///< 鏃犳护娉 + Tim3FltPCLKCnt3 = 4u, ///< PCLK 3涓繛缁湁鏁 + Tim3FltPCLKDiv4Cnt3 = 5u, ///< PCLK/4 3涓繛缁湁鏁 + Tim3FltPCLKDiv16Cnt3 = 6u, ///< PCLK/16 3涓繛缁湁鏁 + Tim3FltPCLKDiv64Cnt3 = 7u, ///< PCLK/64 3涓繛缁湁鏁 +}en_tim3_flt_t; + +/** + ****************************************************************************** + ** \brief 閫氶亾姣旇緝鎺у埗 鏁版嵁绫诲瀷閲嶅畾涔 (OCMA/OCMB)(妯″紡23) + *****************************************************************************/ +typedef enum en_tim3_m23_fltr_ocm +{ + Tim3ForceLow = 0u, ///< 寮哄埗涓0 + Tim3ForceHigh = 1u, ///< 寮哄埗涓1 + Tim3CMPForceLow = 2u, ///< 姣旇緝鍖归厤鏃跺己鍒朵负0 + Tim3CMPForceHigh = 3u, ///< 姣旇緝鍖归厤鏃跺己鍒朵负1 + Tim3CMPInverse = 4u, ///< 姣旇緝鍖归厤鏃剁炕杞數骞 + Tim3CMPOnePrdHigh = 5u, ///< 姣旇緝鍖归厤鏃惰緭鍑轰竴涓鏁板懆鏈熺殑楂樼數骞 + Tim3PWMMode1 = 6u, ///< 閫氶亾鎺у埗涓篜WM mode 1 + Tim3PWMMode2 = 7u, ///< 閫氶亾鎺у埗涓篜WM mode 2 +}en_tim3_m23_fltr_ocm_t; + +/** + ****************************************************************************** + ** \brief 涓讳粠妯″紡TS鏁版嵁绫诲瀷閲嶅畾涔 (TS)(妯″紡1/23) + *****************************************************************************/ +typedef enum en_tim3_mscr_ts +{ + Tim3Ts0ETR = 0u, ///< ETR澶栭儴杈撳叆婊ゆ尝鍚庣殑鐩镐綅閫夋嫨淇″彿 + Tim3Ts1TIM0TRGO = 1u, ///< Timer0鐨凾RGO杈撳嚭淇″彿 + Tim3Ts2TIM1TRGO = 2u, ///< Timer1鐨凾RGO杈撳嚭淇″彿 + Tim3Ts3TIM2TRGO = 3u, ///< Timer2鐨凾RGO杈撳嚭淇″彿 + Tim3Ts4TIM3TRGO = 4u, ///< Timer3鐨凾RGO杈撳嚭淇″彿 + //Tim3Ts5IA0ED = 5u, ///< 鏃犳晥 + Tim3Ts6IAFP = 6u, ///< CH0A 澶栭儴杈撹緭鍏ユ护娉㈠悗鐨勭浉浣嶉夋嫨淇″彿 + Tim3Ts7IBFP = 7u, ///< CH0B 澶栭儴杈撹緭鍏ユ护娉㈠悗鐨勭浉浣嶉夋嫨淇 +}en_tim3_mscr_ts_t; + +/** + ****************************************************************************** + ** \brief PWM杈撳嚭妯″紡閫夋嫨鏁版嵁绫诲瀷閲嶅畾涔 (COMP)(妯″紡23) + *****************************************************************************/ +typedef enum en_tim3_m23cr_comp +{ + Tim3IndependentPWM = 0u, ///< 鐙珛PWM杈撳嚭 + Tim3ComplementaryPWM = 1u, ///< 浜掕ˉPWM杈撳嚭 +}en_tim3_m23cr_comp_t; + +/** + ****************************************************************************** + ** \brief 璁℃暟鏂瑰悜閫夋嫨鏁版嵁绫诲瀷閲嶅畾涔 (DIR)(妯″紡23) + *****************************************************************************/ +typedef enum en_tim3_m23cr_dir +{ + Tim3CntUp = 0u, ///< 鍚戜笂璁℃暟 + Tim3CntDown = 1u, ///< 鍚戜笅璁℃暟 +}en_tim3_m23cr_dir_t; + +/** + ****************************************************************************** + ** \brief 璁℃暟鏂瑰悜閫夋嫨鏁版嵁绫诲瀷閲嶅畾涔 (PWM2S)(妯″紡23) + *****************************************************************************/ +typedef enum en_tim3_m23cr_pwm2s +{ + Tim3DoublePointCmp = 0u, ///< 鍙岀偣姣旇緝浣胯兘锛屼娇鐢–CRA,CCRB姣旇緝鎺у埗OCREFA杈撳嚭 + Tim3SinglePointCmp = 1u, ///< 鍗曠偣姣旇緝浣胯兘锛屼娇鐢–CRA姣旇緝鎺у埗OCREFA杈撳嚭 +}en_tim3_m23cr_pwm2s_t; + +/** + ****************************************************************************** + ** \brief GATE鍦≒WM浜掕ˉ妯″紡涓嬫崟鑾锋垨姣旇緝鍔熻兘 閫夋嫨鏁版嵁绫诲瀷閲嶅畾涔 (CSG)(妯″紡23) + *****************************************************************************/ +typedef enum en_tim3_m23cr_csg +{ + Tim3PWMCompGateCmpOut = 0u, ///< 鍦≒WM浜掕ˉ妯″紡涓嬶紝Gate浣滀负姣旇緝杈撳嚭 + Tim3PWMCompGateCapIn = 1u, ///< 鍦≒WM浜掕ˉ妯″紡涓嬶紝Gate浣滀负鎹曡幏杈撳叆 +}en_tim3_m23cr_csg_t; + + +/** + ****************************************************************************** + ** \brief 姣旇緝鎹曡幏瀵勫瓨鍣 鏁版嵁绫诲瀷閲嶅畾涔 (CCR0A,CCR0B)(妯″紡23) + *****************************************************************************/ +typedef enum en_tim3_m23_ccrx +{ + Tim3CCR0A = 0u, ///< CCR0A姣旇緝鎹曡幏瀵勫瓨鍣 + Tim3CCR0B = 1u, ///< CCR0B姣旇緝鎹曡幏瀵勫瓨鍣 + Tim3CCR1A = 2u, ///< CCR1A姣旇緝鎹曡幏瀵勫瓨鍣 + Tim3CCR1B = 3u, ///< CCR1B姣旇緝鎹曡幏瀵勫瓨鍣 + Tim3CCR2A = 4u, ///< CCR2A姣旇緝鎹曡幏瀵勫瓨鍣 + Tim3CCR2B = 5u, ///< CCR2B姣旇緝鎹曡幏瀵勫瓨鍣 +}en_tim3_m23_ccrx_t; + +/** + ****************************************************************************** + ** \brief OCREF娓呴櫎婧 閫夋嫨鏁版嵁绫诲瀷閲嶅畾涔 (OCCS)(妯″紡23) + *****************************************************************************/ +typedef enum en_tim3_m23ce_occs +{ + Tim3OC_Ref_Clr = 0u, ///< 鏉ヨ嚜VC鐨凮C_Ref_Clr + Tim3ETRf = 1u, ///< 澶栭儴ETRf +}en_tim3_m23ce_occs_t; + +/** + ****************************************************************************** + ** \brief 姣旇緝鍖归厤涓柇妯″紡 閫夋嫨鏁版嵁绫诲瀷閲嶅畾涔 (CIS/CISB)(妯″紡23) + *****************************************************************************/ +typedef enum en_tim3_m23_cisa_cisb +{ + Tim3CmpIntNone = 0u, ///< 鏃犳瘮杈冨尮閰嶄腑鏂 + Tim3CmpIntRise = 1u, ///< 姣旇緝鍖归厤涓婂崌娌夸腑鏂 + Tim3CmpIntFall = 2u, ///< 姣旇緝鍖归厤涓嬮檷娌夸腑鏂 + Tim3CmpIntRiseFall = 3u, ///< 姣旇緝鍖归厤涓婂崌娌夸笅闄嶆部涓柇 +}en_tim3_m23_cisa_cisb_t; + +/** + ****************************************************************************** + ** \brief TIM3绔彛鎺у埗 - 鍒硅溅鏃禖Hx杈撳嚭鐘舵佹帶鍒(BKSA/BKSB)(妯″紡23) + ** + ** \note + ******************************************************************************/ +typedef enum en_tim3_m23_crchx_bks +{ + Tim3CHxBksHiZ = 0u, ///< 鍒硅溅浣胯兘鏃讹紝CHx绔彛杈撳嚭楂橀樆鎬 + Tim3CHxBksNorm = 1u, ///< 鍒硅溅浣胯兘鏃讹紝CHx绔彛姝e父杈撳嚭 + Tim3CHxBksLow = 2u, ///< 鍒硅溅浣胯兘鏃讹紝CHx绔彛杈撳嚭浣庣數骞 + Tim3CHxBksHigh = 3u, ///< 鍒硅溅浣胯兘鏃讹紝CHx绔彛杈撳嚭楂樼數骞 +}en_tim3_m23_crchx_bks_t; + +/** + ****************************************************************************** +** \brief TIM3绔彛鎺у埗 - CHx涓婂崌娌夸笅闄嶆部鎹曡幏(CRx/CFx)(妯″紡23) + ** + ** \note + ******************************************************************************/ +typedef enum en_tim3_m23_crch0_cfx_crx +{ + Tim3CHxCapNone = 0u, ///< CHx閫氶亾鎹曡幏绂佹 + Tim3CHxCapRise = 1u, ///< CHx閫氶亾涓婂崌娌挎崟鑾蜂娇鑳 + Tim3CHxCapFall = 2u, ///< CHx閫氶亾涓嬮檷娌挎崟鑾蜂娇鑳 + Tim3CHxCapFallRise = 3u, ///< CHx閫氶亾涓婂崌娌夸笅闄嶆部鎹曡幏閮戒娇鑳 +}en_tim3_m23_crch0_cfx_crx_t; + +/** + ****************************************************************************** +** \brief TIM3绔彛鎺у埗 - CHx姣旇緝鎹曡幏妯″紡(CSA/CSB)(妯″紡23) + ** + ** \note + ******************************************************************************/ +typedef enum en_tim3_m23_crch0_csa_csb +{ + Tim3CHxCmpMode = 0u, ///< CHx閫氶亾璁剧疆涓烘瘮杈冩ā寮 + Tim3CHxCapMode = 1u, ///< CHx閫氶亾璁剧疆涓烘崟鑾锋ā寮 +}en_tim3_m23_crch0_csa_csb_t; + +/** + ****************************************************************************** + ** \brief 姣旇緝妯″紡涓 DMA姣旇緝瑙﹀彂閫夋嫨 鏁版嵁绫诲瀷閲嶅畾涔 (CCDS)(妯″紡23) + *****************************************************************************/ +typedef enum en_tim3_m23_mscr_ccds +{ + Tim3CmpTrigDMA = 0u, ///< 姣旇緝鍖归厤瑙﹀彂DMA + Tim3UEVTrigDMA = 1u, ///< 浜嬩欢鏇存柊浠f浛姣旇緝鍖归厤瑙﹀彂DMA +}en_tim3_m23_mscr_ccds_t; + +/** + ****************************************************************************** + ** \brief 涓讳粠妯″紡閫夋嫨 鏁版嵁绫诲瀷閲嶅畾涔 (MSM)(妯″紡23) + *****************************************************************************/ +typedef enum en_tim3_m23_mscr_msm +{ + Tim3SlaveMode = 0u, ///< 浠庢ā寮 + Tim3MasterMode = 1u, ///< 涓绘ā寮 +}en_tim3_m23_mscr_msm_t; + +/** + ****************************************************************************** + ** \brief 瑙﹀彂涓绘ā寮忚緭鍑烘簮 鏁版嵁绫诲瀷閲嶅畾涔 (MMS)(妯″紡23) + *****************************************************************************/ +typedef enum en_tim3_m23_mscr_mms +{ + Tim3MasterUG = 0u, ///< UG(杞欢鏇存柊)婧 + Tim3MasterCTEN = 1u, ///< CTEN婧 + Tim3MasterUEV = 2u, ///< UEV鏇存柊婧 + Tim3MasterCMPSO = 3u, ///< 姣旇緝鍖归厤閫夋嫨杈撳嚭婧 + Tim3MasterOCA0Ref = 4u, ///< OCA0_Ref婧 + Tim3MasterOCB0Ref = 5u, ///< OCB0_Ref婧 + //Tim3MasterOCB0Ref = 6u, + //Tim3MasterOCB0Ref = 7u, +}en_tim3_m23_mscr_mms_t; + +/** + ****************************************************************************** + ** \brief 瑙﹀彂浠庢ā寮忛夋嫨 鏁版嵁绫诲瀷閲嶅畾涔 (SMS)(妯″紡23) + *****************************************************************************/ +typedef enum en_tim3_m23_mscr_sms +{ + Tim3SlaveIClk = 0u, ///< 浣跨敤鍐呴儴鏃堕挓 + Tim3SlaveResetTIM = 1u, ///< 澶嶄綅鍔熻兘 + Tim3SlaveTrigMode = 2u, ///< 瑙﹀彂妯″紡 + Tim3SlaveEClk = 3u, ///< 澶栭儴鏃堕挓妯″紡 + Tim3SlaveCodeCnt1 = 4u, ///< 姝d氦缂栫爜璁℃暟妯″紡1 + Tim3SlaveCodeCnt2 = 5u, ///< 姝d氦缂栫爜璁℃暟妯″紡2 + Tim3SlaveCodeCnt3 = 6u, ///< 姝d氦缂栫爜璁℃暟妯″紡3 + Tim3SlaveGateCtrl = 7u, ///< 闂ㄦ帶鍔熻兘 +}en_tim3_m23_mscr_sms_t; + +/** + ****************************************************************************** + ** \brief 瀹氭椂鍣ㄨ繍琛屾帶鍒舵暟鎹被鍨嬮噸瀹氫箟 (CTEN) + *****************************************************************************/ +typedef enum en_tim3_start +{ + Tim3CTENDisable = 0u, ///< 鍋滄 + Tim3CTENEnable = 1u, ///< 杩愯 +}en_tim3_start_t; + +/** + ****************************************************************************** + ** \brief TIM3 mode0 閰嶇疆缁撴瀯浣撳畾涔(妯″紡0) + *****************************************************************************/ +typedef struct stc_tim3_mode0_cfg +{ + en_tim3_work_mode_t enWorkMode; ///< 宸ヤ綔妯″紡璁剧疆 + en_tim3_m0cr_gatep_t enGateP; ///< 闂ㄦ帶鏋佹ф帶鍒 + boolean_t bEnGate; ///< 闂ㄦ帶浣胯兘 + en_tim3_cr_timclkdiv_t enPRS; ///< 棰勯櫎棰戦厤缃 + boolean_t bEnTog; ///< 缈昏浆杈撳嚭浣胯兘 + en_tim3_cr_ct_t enCT; ///< 瀹氭椂/璁℃暟鍔熻兘閫夋嫨 + en_tim3_m0cr_md_t enCntMode; ///< 璁℃暟妯″紡閰嶇疆 +}stc_tim3_mode0_cfg_t; + +/** + ****************************************************************************** + ** \brief TIM3 mode1 閰嶇疆缁撴瀯浣撳畾涔(妯″紡1) + *****************************************************************************/ +typedef struct stc_tim3_mode1_cfg +{ + en_tim3_work_mode_t enWorkMode; ///< 宸ヤ綔妯″紡璁剧疆 + en_tim3_cr_timclkdiv_t enPRS; ///< 棰勯櫎棰戦厤缃 + en_tim3_cr_ct_t enCT; ///< 瀹氭椂/璁℃暟鍔熻兘閫夋嫨 + en_tim3_m1cr_oneshot_t enOneShot; ///< 鍗曟娴嬮噺/寰幆娴嬮噺閫夋嫨 +}stc_tim3_mode1_cfg_t; + +/** + ****************************************************************************** + ** \brief PWC杈撳叆閰嶇疆缁撴瀯浣撳畾涔(妯″紡1) + *****************************************************************************/ +typedef struct stc_tim3_pwc_input_cfg +{ + en_tim3_mscr_ts_t enTsSel; ///< 瑙﹀彂杈撳叆婧愰夋嫨 + en_tim3_m1_mscr_ia0s_t enIA0Sel; ///< CHA0杈撳叆閫夋嫨 + en_tim3_m1_mscr_ib0s_t enIB0Sel; ///< CHB0杈撳叆閫夋嫨 + en_tim3_port_polarity_t enETRPhase; ///< ETR鐩镐綅閫夋嫨 + en_tim3_flt_t enFltETR; ///< ETR婊ゆ尝璁剧疆 + en_tim3_flt_t enFltIA0; ///< CHA0婊ゆ尝璁剧疆 + en_tim3_flt_t enFltIB0; ///< CHB0婊ゆ尝璁剧疆 +}stc_tim3_pwc_input_cfg_t; + +/** + ****************************************************************************** + ** \brief TIM3 mode23 閰嶇疆缁撴瀯浣撳畾涔(妯″紡23) + *****************************************************************************/ +typedef struct stc_tim3_mode23_cfg +{ + en_tim3_work_mode_t enWorkMode; ///< 宸ヤ綔妯″紡璁剧疆 + en_tim3_m23cr_dir_t enCntDir; ///< 璁℃暟鏂瑰悜 + en_tim3_cr_timclkdiv_t enPRS; ///< 鏃堕挓棰勯櫎棰戦厤缃 + en_tim3_cr_ct_t enCT; ///< 瀹氭椂/璁℃暟鍔熻兘閫夋嫨 + en_tim3_m23cr_comp_t enPWMTypeSel; ///< PWM妯″紡閫夋嫨锛堢嫭绔/浜掕ˉ锛 + en_tim3_m23cr_pwm2s_t enPWM2sSel; ///< OCREFA鍙岀偣姣旇緝鍔熻兘閫夋嫨 + boolean_t bOneShot; ///< 鍗曟瑙﹀彂妯″紡浣胯兘/绂佹 + boolean_t bURSSel; ///< 鏇存柊婧愰夋嫨 +}stc_tim3_mode23_cfg_t; + +/** + ****************************************************************************** + ** \brief GATE鍦≒WM浜掕ˉ妯″紡涓嬫崟鑾锋垨姣旇緝鍔熻兘 閰嶇疆缁撴瀯浣撳畾涔(妯″紡23) + *****************************************************************************/ +typedef struct stc_tim3_m23_gate_cfg +{ + en_tim3_m23cr_csg_t enGateFuncSel; ///< Gate姣旇緝銆佹崟鑾峰姛鑳介夋嫨 + boolean_t bGateRiseCap; ///< GATE浣滀负鎹曡幏鍔熻兘鏃讹紝涓婃部鎹曡幏鏈夋晥鎺у埗 + boolean_t bGateFallCap; ///< GATE浣滀负鎹曡幏鍔熻兘鏃讹紝涓嬫部鎹曡幏鏈夋晥鎺у埗 +}stc_tim3_m23_gate_cfg_t; + +/** + ****************************************************************************** + ** \brief CHA/CHB閫氶亾姣旇緝鎺у埗 閰嶇疆缁撴瀯浣撳畾涔(妯″紡23) + *****************************************************************************/ +typedef struct stc_tim3_m23_compare_cfg +{ + en_tim3_m23_crch0_csa_csb_t enCHxACmpCap; ///< CH0A姣旇緝/鎹曡幏鍔熻兘閫夋嫨 + en_tim3_m23_fltr_ocm_t enCHxACmpCtrl; ///< CH0A閫氶亾姣旇緝鎺у埗 + en_tim3_port_polarity_t enCHxAPolarity; ///< CH0A杈撳嚭鏋佹ф帶鍒 + boolean_t bCHxACmpBufEn; ///< 姣旇緝A缂撳瓨鍔熻兘 浣胯兘/绂佹 + en_tim3_m23_cisa_cisb_t enCHxACmpIntSel; ///< CHA姣旇緝鍖归厤涓柇閫夋嫨 + + en_tim3_m23_crch0_csa_csb_t enCHxBCmpCap; ///< CH0B姣旇緝/鎹曡幏鍔熻兘閫夋嫨 + en_tim3_m23_fltr_ocm_t enCHxBCmpCtrl; ///< CH0B閫氶亾姣旇緝鎺у埗 + en_tim3_port_polarity_t enCHxBPolarity; ///< CH0B杈撳嚭鏋佹ф帶鍒 + boolean_t bCHxBCmpBufEn; ///< 姣旇緝B缂撳瓨鍔熻兘 浣胯兘/绂佹 + en_tim3_m23_cisa_cisb_t enCHxBCmpIntSel; ///< CHB0姣旇緝鍖归厤涓柇閫夋嫨 +}stc_tim3_m23_compare_cfg_t; + +/** + ****************************************************************************** + ** \brief CHA/CHB閫氶亾鎹曡幏鎺у埗 閰嶇疆缁撴瀯浣撳畾涔(妯″紡23) + *****************************************************************************/ +typedef struct stc_tim3_m23_input_cfg +{ + en_tim3_m23_crch0_csa_csb_t enCHxACmpCap; ///< CH0A姣旇緝/鎹曡幏鍔熻兘閫夋嫨 + en_tim3_m23_crch0_cfx_crx_t enCHxACapSel; ///< CH0A鎹曡幏杈规部閫夋嫨 + en_tim3_flt_t enCHxAInFlt; ///< CH0A閫氶亾鎹曡幏婊ゆ尝鎺у埗 + en_tim3_port_polarity_t enCHxAPolarity; ///< CH0A杈撳叆鐩镐綅 + + en_tim3_m23_crch0_csa_csb_t enCHxBCmpCap; ///< CH0A姣旇緝/鎹曡幏鍔熻兘閫夋嫨 + en_tim3_m23_crch0_cfx_crx_t enCHxBCapSel; ///< CH0B鎹曡幏杈规部閫夋嫨 + en_tim3_flt_t enCHxBInFlt; ///< CH0B閫氶亾鎹曡幏婊ゆ尝鎺у埗 + en_tim3_port_polarity_t enCHxBPolarity; ///< CH0B杈撳叆鐩镐綅 + +}stc_tim3_m23_input_cfg_t; + +/** + ****************************************************************************** + ** \brief ETR杈撳叆鐩镐綅婊ゆ尝閰嶇疆缁撴瀯浣撳畾涔(妯″紡23) + *****************************************************************************/ +typedef struct stc_tim3_m23_etr_input_cfg +{ + en_tim3_port_polarity_t enETRPolarity; ///< ETR杈撳叆鏋佹ц缃 + en_tim3_flt_t enETRFlt; ///< ETR婊ゆ尝璁剧疆 +}stc_tim3_m23_etr_input_cfg_t; + +/** + ****************************************************************************** + ** \brief 鍒硅溅BK杈撳叆鐩镐綅婊ゆ尝閰嶇疆缁撴瀯浣撳畾涔(妯″紡23) + *****************************************************************************/ +typedef struct stc_tim3_m23_bk_input_cfg +{ + boolean_t bEnBrake; ///< 鍒硅溅浣胯兘 + boolean_t bEnVCBrake; ///< 浣胯兘VC鍒硅溅 + boolean_t bEnSafetyBk; ///< 浣胯兘safety鍒硅溅 + boolean_t bEnBKSync; ///< TIM0/TIM1/TIM2鍒硅溅鍚屾浣胯兘 + en_tim3_m23_crchx_bks_t enBkCH0AStat; ///< 鍒硅溅鏃禖HA绔彛鐘舵佽缃 + en_tim3_m23_crchx_bks_t enBkCH0BStat; ///< 鍒硅溅鏃禖HB绔彛鐘舵佽缃 + en_tim3_m23_crchx_bks_t enBkCH1AStat; ///< 鍒硅溅鏃禖HA绔彛鐘舵佽缃 + en_tim3_m23_crchx_bks_t enBkCH1BStat; ///< 鍒硅溅鏃禖HB绔彛鐘舵佽缃 + en_tim3_m23_crchx_bks_t enBkCH2AStat; ///< 鍒硅溅鏃禖HA绔彛鐘舵佽缃 + en_tim3_m23_crchx_bks_t enBkCH2BStat; ///< 鍒硅溅鏃禖HB绔彛鐘舵佽缃 + en_tim3_port_polarity_t enBrakePolarity; ///< 鍒硅溅BK杈撳叆鏋佹ц缃 + en_tim3_flt_t enBrakeFlt; ///< 鍒硅溅BK婊ゆ尝璁剧疆 +}stc_tim3_m23_bk_input_cfg_t; + +/** + ****************************************************************************** +** \brief 姝诲尯鍔熻兘閰嶇疆缁撴瀯浣撳畾涔(妯″紡23) + *****************************************************************************/ +typedef struct stc_tim3_m23_dt_cfg +{ + boolean_t bEnDeadTime; ///< 鍒硅溅鏃禖HA绔彛鐘舵佽缃 + uint8_t u8DeadTimeValue; ///< 鍒硅溅鏃禖HA绔彛鐘舵佽缃 +}stc_tim3_m23_dt_cfg_t; + +/** + ****************************************************************************** + ** \brief 瑙﹀彂ADC閰嶇疆缁撴瀯浣撳畾涔(妯″紡23) + *****************************************************************************/ +typedef struct stc_tim3_m23_adc_trig_cfg +{ + boolean_t bEnTrigADC; ///< 瑙﹀彂ADC鍏ㄥ眬鎺у埗 + boolean_t bEnUevTrigADC; ///< 浜嬩欢鏇存柊瑙﹀彂ADC + boolean_t bEnCH0ACmpTrigADC; ///< CH0A姣旇緝鍖归厤瑙﹀彂ADC + boolean_t bEnCH0BCmpTrigADC; ///< CH0B姣旇緝鍖归厤瑙﹀彂ADC + boolean_t bEnCH1ACmpTrigADC; ///< CH0A姣旇緝鍖归厤瑙﹀彂ADC + boolean_t bEnCH1BCmpTrigADC; ///< CH0B姣旇緝鍖归厤瑙﹀彂ADC + boolean_t bEnCH2ACmpTrigADC; ///< CH0A姣旇緝鍖归厤瑙﹀彂ADC + boolean_t bEnCH2BCmpTrigADC; ///< CH0B姣旇緝鍖归厤瑙﹀彂ADC +}stc_tim3_m23_adc_trig_cfg_t; + +/** + ****************************************************************************** + ** \brief DMA瑙﹀彂 閰嶇疆缁撴瀯浣撳畾涔(妯″紡23) + *****************************************************************************/ +typedef struct stc_tim3_m23_trig_dma_cfg +{ + boolean_t bUevTrigDMA; ///< 鏇存柊 瑙﹀彂DMA浣胯兘 + boolean_t bTITrigDMA; ///< Trig 瑙﹀彂DMA鍔熻兘 + boolean_t bCmpA0TrigDMA; ///< CH0A鎹曡幏姣旇緝瑙﹀彂DMA浣胯兘 + boolean_t bCmpB0TrigDMA; ///< CH0B鎹曡幏姣旇緝瑙﹀彂DMA浣胯兘 + boolean_t bCmpA1TrigDMA; ///< CH1A鎹曡幏姣旇緝瑙﹀彂DMA浣胯兘 + boolean_t bCmpB1TrigDMA; ///< CH1B鎹曡幏姣旇緝瑙﹀彂DMA浣胯兘 + boolean_t bCmpA2TrigDMA; ///< CH2A鎹曡幏姣旇緝瑙﹀彂DMA浣胯兘 + boolean_t bCmpB2TrigDMA; ///< CH2B鎹曡幏姣旇緝瑙﹀彂DMA浣胯兘 + en_tim3_m23_mscr_ccds_t enCmpUevTrigDMA; ///< 姣旇緝妯″紡涓婦MA姣旇緝瑙﹀彂閫夋嫨 +}stc_tim3_m23_trig_dma_cfg_t; + +/** + ****************************************************************************** + ** \brief 涓讳粠妯″紡 閰嶇疆缁撴瀯浣撳畾涔(妯″紡23) + *****************************************************************************/ +typedef struct stc_tim3_m23_master_slave_cfg +{ + en_tim3_m23_mscr_msm_t enMasterSlaveSel; ///< 涓讳粠妯″紡閫夋嫨 + en_tim3_m23_mscr_mms_t enMasterSrc; ///< 涓绘ā寮忚Е鍙戞簮閫夋嫨 + en_tim3_m23_mscr_sms_t enSlaveModeSel; ///< 浠庢ā寮忛夋嫨 + en_tim3_mscr_ts_t enTsSel; ///< 瑙﹀彂杈撳叆婧愰夋嫨 +}stc_tim3_m23_master_slave_cfg_t; + +/** + ****************************************************************************** + ** \brief OCREF娓呴櫎鍔熻兘 閰嶇疆缁撴瀯浣撳畾涔(妯″紡23) + *****************************************************************************/ +typedef struct stc_tim3_m23_OCREF_Clr_cfg +{ + en_tim3_m23ce_occs_t enOCRefClrSrcSel; ///< OCREF娓呴櫎婧愰夋嫨 + boolean_t bVCClrEn; ///< 鏄惁浣胯兘鏉ヨ嚜VC鐨凮CREF_Clr +}stc_tim3_m23_OCREF_Clr_cfg_t; + +/****************************************************************************** + * Global variable declarations ('extern', definition in C source) + *****************************************************************************/ + +/****************************************************************************** + * Global function prototypes (definition in C source) + *****************************************************************************/ +//涓柇鐩稿叧鍑芥暟 + +//涓柇鏍囧織鑾峰彇 +boolean_t Tim3_GetIntFlag(en_tim3_irq_type_t enTim3Irq); +//涓柇鏍囧織娓呴櫎 +en_result_t Tim3_ClearIntFlag(en_tim3_irq_type_t enTim3Irq); +//鎵鏈変腑鏂爣蹇楁竻闄 +en_result_t Tim3_ClearAllIntFlag(void); +//妯″紡0涓柇浣胯兘 +en_result_t Tim3_Mode0_EnableIrq(void); +//妯″紡1涓柇浣胯兘 +en_result_t Tim3_Mode1_EnableIrq (en_tim3_irq_type_t enTim3Irq); +//妯″紡2涓柇浣胯兘 +en_result_t Tim3_Mode23_EnableIrq (en_tim3_irq_type_t enTim3Irq); +//妯″紡0涓柇绂佹 +en_result_t Tim3_Mode0_DisableIrq(void); +//妯″紡1涓柇绂佹 +en_result_t Tim3_Mode1_DisableIrq (en_tim3_irq_type_t enTim3Irq); +//妯″紡2涓柇绂佹 +en_result_t Tim3_Mode23_DisableIrq (en_tim3_irq_type_t enTim3Irq); + + +//妯″紡0鍒濆鍖栧強鐩稿叧鍔熻兘鎿嶄綔 + +//timer閰嶇疆鍙婂垵濮嬪寲 +en_result_t Tim3_Mode0_Init(stc_tim3_mode0_cfg_t* pstcCfg); +//timer 鍚姩/鍋滄 +en_result_t Tim3_M0_Run(void); +en_result_t Tim3_M0_Stop(void); +//閲嶈浇鍊艰缃 +en_result_t Tim3_M0_ARRSet(uint16_t u16Data); +//16浣嶈鏁板艰缃/鑾峰彇 +en_result_t Tim3_M0_Cnt16Set(uint16_t u16Data); +uint16_t Tim3_M0_Cnt16Get(void); +//32浣嶈鏁板艰缃/鑾峰彇 +en_result_t Tim3_M0_Cnt32Set(uint32_t u32Data); +uint32_t Tim3_M0_Cnt32Get(void); +//绔彛杈撳嚭浣胯兘/绂佹璁惧畾 +en_result_t Tim3_M0_Enable_Output(boolean_t bEnOutput); +//缈昏浆浣胯兘/绂佹锛堜綆鐢靛钩锛夎瀹 +en_result_t Tim3_M0_EnTOG(boolean_t bEnTOG); + +//妯″紡1鍒濆鍖栧強鐩稿叧鍔熻兘鎿嶄綔 + +//timer閰嶇疆鍙婂垵濮嬪寲 +en_result_t Tim3_Mode1_Init(stc_tim3_mode1_cfg_t* pstcCfg); +//PWC 杈撳叆閰嶇疆 +en_result_t Tim3_M1_Input_Cfg(stc_tim3_pwc_input_cfg_t* pstcCfg); +//PWC娴嬮噺杈规部璧峰缁撴潫閫夋嫨 +en_result_t Tim3_M1_PWC_Edge_Sel(en_tim3_m1cr_Edge_t enEdgeSel); +//timer 鍚姩/鍋滄 +en_result_t Tim3_M1_Run(void); +en_result_t Tim3_M1_Stop(void); +//16浣嶈鏁板艰缃/鑾峰彇 +en_result_t Tim3_M1_Cnt16Set(uint16_t u16Data); +uint16_t Tim3_M1_Cnt16Get(void); +//鑴夊啿瀹藉害娴嬮噺缁撴灉鏁板艰幏鍙 +uint16_t Tim3_M1_PWC_CapValueGet(void); + + +//妯″紡23鍒濆鍖栧強鐩稿叧鍔熻兘鎿嶄綔 + +//timer閰嶇疆鍙婂垵濮嬪寲 +en_result_t Tim3_Mode23_Init(stc_tim3_mode23_cfg_t* pstcCfg); +//timer 鍚姩/鍋滄 +en_result_t Tim3_M23_Run(void); +en_result_t Tim3_M23_Stop(void); +//PWM杈撳嚭浣胯兘 +en_result_t Tim3_M23_EnPWM_Output(boolean_t bEnOutput, boolean_t bEnAutoOutput); +//閲嶈浇鍊艰缃 +en_result_t Tim3_M23_ARRSet(uint16_t u16Data, boolean_t bArrBufEn); +//16浣嶈鏁板艰缃/鑾峰彇 +en_result_t Tim3_M23_Cnt16Set(uint16_t u16Data); +uint16_t Tim3_M23_Cnt16Get(void); +//姣旇緝鎹曡幏瀵勫瓨鍣–CR0A/CCR0B璁剧疆/璇诲彇 +en_result_t Tim3_M23_CCR_Set(en_tim3_m23_ccrx_t enCCRSel, uint16_t u16Data); +uint16_t Tim3_M23_CCR_Get(en_tim3_m23_ccrx_t enCCRSel); +//PWM浜掕ˉ杈撳嚭妯″紡涓嬶紝GATE鍔熻兘閫夋嫨 +en_result_t Tim3_M23_GateFuncSel(stc_tim3_m23_gate_cfg_t* pstcCfg); +//涓讳粠妯″紡閰嶇疆 +en_result_t Tim3_M23_MasterSlave_Set(stc_tim3_m23_master_slave_cfg_t* pstcCfg); +//CH0A/CH0B姣旇緝閫氶亾鎺у埗 +en_result_t Tim3_M23_PortOutput_Cfg(en_tim3_channel_t enTim3Chx, stc_tim3_m23_compare_cfg_t* pstcCfg); +//CH0A/CH0B杈撳叆鎺у埗 +en_result_t Tim3_M23_PortInput_Cfg(en_tim3_channel_t enTim3Chx, stc_tim3_m23_input_cfg_t* pstcCfg); +//ERT杈撳叆鎺у埗 +en_result_t Tim3_M23_ETRInput_Cfg(stc_tim3_m23_etr_input_cfg_t* pstcCfg); +//鍒硅溅BK杈撳叆鎺у埗 +en_result_t Tim3_M23_BrakeInput_Cfg(stc_tim3_m23_bk_input_cfg_t* pstcBkCfg); +//瑙﹀彂ADC鎺у埗 +en_result_t Tim3_M23_TrigADC_Cfg(stc_tim3_m23_adc_trig_cfg_t* pstcCfg); +//姝诲尯鍔熻兘 +en_result_t Tim3_M23_DT_Cfg(stc_tim3_m23_dt_cfg_t* pstcCfg); +//閲嶅鍛ㄦ湡璁剧疆 +en_result_t Tim3_M23_SetValidPeriod(uint8_t u8ValidPeriod); +//OCREF娓呴櫎鍔熻兘 +en_result_t Tim3_M23_OCRefClr(stc_tim3_m23_OCREF_Clr_cfg_t* pstcCfg); +//浣胯兘DMA浼犺緭 +en_result_t Tim3_M23_EnDMA(stc_tim3_m23_trig_dma_cfg_t* pstcCfg); +//鎹曡幏姣旇緝A杞欢瑙﹀彂 +en_result_t Tim3_M23_EnSwTrigCapCmpA(en_tim3_channel_t enTim3Chx); +//鎹曡幏姣旇緝B杞欢瑙﹀彂 +en_result_t Tim3_M23_EnSwTrigCapCmpB(en_tim3_channel_t enTim3Chx); +//杞欢鏇存柊浣胯兘 +en_result_t Tim3_M23_EnSwUev(void); +//杞欢瑙﹀彂浣胯兘 +en_result_t Tim3_M23_EnSwTrig(void); +//杞欢鍒硅溅浣胯兘 +en_result_t Tim3_M23_EnSwBk(void); + + +//@} // Tim3Group + +#ifdef __cplusplus +#endif + + +#endif /* __BT_H__ */ +/****************************************************************************** + * EOF (not truncated) + *****************************************************************************/ + + diff --git a/driver/inc/trim.h b/driver/inc/trim.h new file mode 100644 index 0000000..5b8e7ef --- /dev/null +++ b/driver/inc/trim.h @@ -0,0 +1,184 @@ +/****************************************************************************** +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/*****************************************************************************/ +/** \file trim.h + ** + ** TRIM 鏁版嵁缁撴瀯鍙夾PI澹版槑 + ** + ** + ** History: + ** - 2018-04-21 Lux V1.0 + ** + *****************************************************************************/ + +#ifndef __TRIM_H__ +#define __TRIM_H__ + +/***************************************************************************** + * Include files + *****************************************************************************/ +#include "ddl.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + ****************************************************************************** + ** \defgroup TrimGroup Clock Trimming (TRIM) + ** + ******************************************************************************/ +//@{ + +/****************************************************************************** + ** Global pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global type definitions + ******************************************************************************/ + + /** + ****************************************************************************** + ** \brief 鐩戞祴妯″紡浣胯兘鏋氫妇閲嶅畾涔 (MON_EN) + *****************************************************************************/ +typedef enum en_trim_monitor +{ + TrimMonDisable = 0u, ///< 绂佹 + TrimMonEnable = 0x40u, ///< 浣胯兘 +}en_trim_monitor_t; + + /** + ****************************************************************************** + ** \brief 寰呮牎鍑/鐩戞祴鏃堕挓閫夋嫨鏋氫妇閲嶅畾涔 (CALCLK_SEL) + *****************************************************************************/ +typedef enum en_trim_calclksel +{ + TrimCalMskRCH = 0x000u, ///< RCH + TrimCalMskXTH = 0x010u, ///< XTH + TrimCalMskRCL = 0x020u, ///< RCL + TrimCalMskXTL = 0x030u, ///< XTL + TrimCalMskPLL = 0x100u, ///< PLL +}en_trim_calclksel_t; + +/** + ****************************************************************************** + ** \brief 鍙傝冩椂閽熼夋嫨鏋氫妇閲嶅畾涔 (REFCLK_SEL) + *****************************************************************************/ +typedef enum en_trim_refclksel +{ + TrimRefMskRCH = 0x0u, ///< RCH + TrimRefMskXTH = 0x2u, ///< XTH + TrimRefMskRCL = 0x4u, ///< RCL + TrimRefMskXTL = 0x6u, ///< XTL + TrimRefMskIRC10K = 0x8u, ///< IRC10K + TrimRefMskExtClk = 0xau, ///< 澶栭儴杈撳叆鏃堕挓 +}en_trim_refclksel_t; + +/** + ****************************************************************************** + ** \brief 涓柇鏍囧織绫诲瀷鏋氫妇閲嶅畾涔 + *****************************************************************************/ +typedef enum en_trim_inttype +{ + TrimStop = 0x01u, ///< 鍙傝冭鏁板櫒鍋滄鏍囧織 + TrimCalCntOf = 0x02u, ///< 鏍″噯璁℃暟鍣ㄦ孩鍑烘爣蹇 + TrimXTLFault = 0x04u, ///< XTL 澶辨晥鏍囧織 + TrimXTHFault = 0x08u, ///< XTH 澶辨晥鏍囧織 + TrimPLLFault = 0x10u, ///< PLL 澶辨晥鏍囧織 +}en_trim_inttype_t; + +/** + ****************************************************************************** + ** \brief TRIM 閰嶇疆缁撴瀯浣撳畾涔 + *****************************************************************************/ +typedef struct stc_trim_cfg +{ + en_trim_monitor_t enMON; ///< 鐩戞祴妯″紡浣胯兘 + en_trim_calclksel_t enCALCLK; ///< 鏍″噯鏃堕挓閫夋嫨 + uint32_t u32CalCon; ///< 鏍″噯璁℃暟鍣ㄦ孩鍑哄奸厤缃 + en_trim_refclksel_t enREFCLK; ///< 鍙傝冩椂閽熼夋嫨 + uint32_t u32RefCon; ///< 鍙傝冭鏁板櫒鍒濆奸厤缃 +}stc_trim_cfg_t; + +/****************************************************************************** + * Global variable declarations ('extern', definition in C source) + *****************************************************************************/ + +/****************************************************************************** + * Global function prototypes (definition in C source) + *****************************************************************************/ +///<<鍔熻兘閰嶇疆鍙婃搷浣滃嚱鏁 +///IFR&enAdcIrq) + { + return TRUE; + } + else + { + return FALSE; + } +} + +/** + * \brief + * 鑾峰彇ADC涓柇鐘舵 + * + * \param [in] enAdcIrq ADC涓柇绫诲瀷 @ref en_adc_irq_type_t + * + * \retval Null + */ +void Adc_ClrIrqStatus(en_adc_irq_type_t enAdcIrq) +{ + M0P_ADC->ICR &= ~(uint32_t)enAdcIrq; +} + +/** + * \brief + * ADC涓柇浣胯兘 + * + * \param 鏃 + * + * \retval 鏃 + */ +void Adc_EnableIrq(void) +{ + M0P_ADC->CR0_f.IE = 1u; +} + +/** + * \brief + * ADC涓柇绂佹 + * + * \param 鏃 + * + * \retval 鏃 + */ +void Adc_DisableIrq(void) +{ + M0P_ADC->CR0_f.IE = 0u; +} + +/** + * \brief + * ADC鍒濆鍖 + * + * \param [in] pstcAdcCfg ADC閰嶇疆鎸囬拡 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + */ +en_result_t Adc_Init(stc_adc_cfg_t* pstcAdcCfg) +{ + if (NULL == pstcAdcCfg) + { + return ErrorInvalidParameter; + } + + M0P_ADC->CR0 = 0x1u; ///< ADC 浣胯兘 + delay10us(2); + + M0P_ADC->CR0 |= (uint32_t)pstcAdcCfg->enAdcClkDiv | + (uint32_t)pstcAdcCfg->enAdcRefVolSel | + (uint32_t)pstcAdcCfg->enAdcOpBuf | + (uint32_t)pstcAdcCfg->enAdcSampCycleSel | + (uint32_t)pstcAdcCfg->enInRef; + + M0P_ADC->CR1_f.MODE = pstcAdcCfg->enAdcMode; + M0P_ADC->CR1_f.ALIGN = pstcAdcCfg->enAdcAlign; + + return Ok; +} + + +/** + * \brief + * ADC鍗曟杞崲澶栭儴涓柇瑙﹀彂婧愰厤缃 + * + * \param [in] enAdcTrigSel 瑙﹀彂婧 + * + * \retval en_result_t Null + */ +void Adc_SglExtTrigCfg(en_adc_trig_sel_t enAdcTrigSel, boolean_t bValue) +{ + if(TRUE == bValue) + { + M0P_ADC->EXTTRIGGER0 |= (uint32_t)enAdcTrigSel; + } + else + { + M0P_ADC->EXTTRIGGER0 &= ~(uint32_t)enAdcTrigSel; + } + +} + +/** + * \brief + * ADC椤哄簭鎵弿杞崲澶栭儴涓柇瑙﹀彂婧愰厤缃 + * + * \param [in] enAdcTrigSel 瑙﹀彂婧 + * \param [in] TRUE or FALSE + * + * \retval en_result_t Null + */ +void Adc_SqrExtTrigCfg(en_adc_trig_sel_t enAdcTrigSel, boolean_t bValue) +{ + if(TRUE == bValue) + { + M0P_ADC->EXTTRIGGER0 |= (uint32_t)enAdcTrigSel; + } + else + { + M0P_ADC->EXTTRIGGER0 &= ~(uint32_t)enAdcTrigSel; + } + +} + +/** + * \brief + * ADC鎻掗槦鎵弿杞崲澶栭儴涓柇瑙﹀彂婧愰厤缃 + * + * \param [in] enAdcTrigSel 瑙﹀彂婧 + * \param [in] TRUE or FALSE + * + * \retval en_result_t Null + */ +void Adc_JqrExtTrigCfg(en_adc_trig_sel_t enAdcTrigSel, boolean_t bValue) +{ + if(TRUE == bValue) + { + M0P_ADC->EXTTRIGGER1 |= (uint32_t)enAdcTrigSel; + } + else + { + M0P_ADC->EXTTRIGGER1 &= ~(uint32_t)enAdcTrigSel; + } + +} + + +/** + * \brief + * ADC 鍗曟杞崲寮濮 + * + * \param 鏃 + * + * \retval 鏃 + */ + +void Adc_SGL_Start(void) +{ + M0P_ADC->SGLSTART = 1u; +} + +/** + * \brief + * ADC 鍗曟杞崲鍋滄 + * + * \param 鏃 + * + * \retval 鏃 + */ +void Adc_SGL_Stop(void) +{ + M0P_ADC->SGLSTART = 0u; +} + +/** + * \brief + * ADC 鍗曟杞崲涓鐩磋浆鎹㈠紑濮 + * + * \param 鏃 + * + * \retval 鏃 + */ + +void Adc_SGL_Always_Start(void) +{ + M0P_ADC->ALLSTART = 1u; +} + +/** + * \brief + * ADC 鍗曟杞崲涓鐩磋浆鎹㈠仠姝 + * + * \param 鏃 + * + * \retval 鏃 + */ + +void Adc_SGL_Always_Stop(void) +{ + M0P_ADC->ALLSTART = 0u; +} + +/** + * \brief + * ADC 椤哄簭鎵弿杞崲寮濮 + * + * \param 鏃 + * + * \retval 鏃 + */ + +void Adc_SQR_Start(void) +{ + M0P_ADC->SQRSTART = 1u; +} + +/** + * \brief + * ADC 椤哄簭鎵弿杞崲鍋滄 + * + * \param 鏃 + * + * \retval 鏃 + */ +void Adc_SQR_Stop(void) +{ + M0P_ADC->SQRSTART = 0u; +} +/** + * \brief + * ADC 鎻掗槦鎵弿杞崲寮濮 + * + * \param 鏃 + * + * \retval 鏃 + */ + +void Adc_JQR_Start(void) +{ + M0P_ADC->JQRSTART = 1u; +} + +/** + * \brief + * ADC 鎻掗槦鎵弿杞崲鍋滄 + * + * \param 鏃 + * + * \retval 鏃 + */ +void Adc_JQR_Stop(void) +{ + M0P_ADC->JQRSTART = 0u; +} + +/** + * \brief + * ADC浣胯兘 + * + * \param 鏃 + * + * \retval 鏃 + */ +void Adc_Enable(void) +{ + M0P_ADC->CR0_f.EN = 1u; +} + +/** + * \brief + * ADC闄よ兘 + * + * \param 鏃 + * + * \retval 鏃 + */ +void Adc_Disable(void) +{ + M0P_ADC->CR0_f.EN = 0u; +} + +/** + * \brief + * 閰嶇疆椤哄簭鎵弿杞崲妯″紡 + * + * \param [in] pstcAdcCfg ADC閰嶇疆鎸囬拡 + * \param [in] pstcAdcNormCfg 杩炵画杞崲妯″紡閰嶇疆鎸囬拡 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + */ +en_result_t Adc_SqrModeCfg(stc_adc_sqr_cfg_t* pstcAdcSqrCfg) +{ + if ((NULL == pstcAdcSqrCfg) || (pstcAdcSqrCfg->u8SqrCnt > 16)) + { + return ErrorInvalidParameter; + } + + M0P_ADC->CR1_f.RACCCLR = 0; //ADC杞崲缁撴灉绱姞瀵勫瓨鍣紙ADC_ResultAcc锛夋竻闆 + M0P_ADC->CR1_f.RACCEN = pstcAdcSqrCfg->enResultAcc; + M0P_ADC->CR1_f.DMASQR = pstcAdcSqrCfg->bSqrDmaTrig; + + M0P_ADC->SQR2_f.CNT = pstcAdcSqrCfg->u8SqrCnt - 1; + + return Ok; +} + +/** + * \brief + * 閰嶇疆鎻掗槦鎵弿杞崲妯″紡 + * + * \param [in] pstcAdcCfg ADC閰嶇疆鎸囬拡 + * \param [in] pstcAdcNormCfg 鎵弿杞崲妯″紡閰嶇疆鎸囬拡 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + */ +en_result_t Adc_JqrModeCfg(stc_adc_jqr_cfg_t* pstcAdcJqrCfg) +{ + if ((NULL == pstcAdcJqrCfg) || (pstcAdcJqrCfg->u8JqrCnt > 4)) + { + return ErrorInvalidParameter; + } + + M0P_ADC->CR1_f.DMASQR = pstcAdcJqrCfg->bJqrDmaTrig; + + M0P_ADC->JQR_f.CNT = pstcAdcJqrCfg->u8JqrCnt - 1; + + return Ok; +} + +/** + * \brief + * 閰嶇疆鍗曟杞崲閫氶亾 + * + * \param [in]enstcAdcSampCh 杞崲閫氶亾 + * + * \retval en_result_t Ok: 鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + */ +en_result_t Adc_CfgSglChannel( en_adc_samp_ch_sel_t enstcAdcSampCh) +{ + M0P_ADC->CR0_f.SGLMUX = enstcAdcSampCh; + + return Ok; +} + +/** + * \brief + * 閰嶇疆椤哄簭鎵弿杞崲閫氶亾 + * + * \param [in]enstcAdcSqrChMux 椤哄簭鎵弿杞崲閫氶亾椤哄簭 + * \param [in]enstcAdcSampCh 杞崲閫氶亾 + * + * \retval en_result_t Ok: 鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + */ +en_result_t Adc_CfgSqrChannel(en_adc_sqr_chmux_t enstcAdcSqrChMux, en_adc_samp_ch_sel_t enstcAdcSampCh) +{ + en_result_t enResult = Ok; + + switch(enstcAdcSqrChMux) + { + case AdcSQRCH0MUX: + M0P_ADC->SQR0_f.CH0MUX = enstcAdcSampCh; + break; + case AdcSQRCH1MUX: + M0P_ADC->SQR0_f.CH1MUX = enstcAdcSampCh; + break; + case AdcSQRCH2MUX: + M0P_ADC->SQR0_f.CH2MUX = enstcAdcSampCh; + break; + case AdcSQRCH3MUX: + M0P_ADC->SQR0_f.CH3MUX = enstcAdcSampCh; + break; + case AdcSQRCH4MUX: + M0P_ADC->SQR0_f.CH4MUX = enstcAdcSampCh; + break; + case AdcSQRCH5MUX: + M0P_ADC->SQR0_f.CH5MUX = enstcAdcSampCh; + break; + case AdcSQRCH6MUX: + M0P_ADC->SQR1_f.CH6MUX = enstcAdcSampCh; + break; + case AdcSQRCH7MUX: + M0P_ADC->SQR1_f.CH7MUX = enstcAdcSampCh; + break; + case AdcSQRCH8MUX: + M0P_ADC->SQR1_f.CH8MUX = enstcAdcSampCh; + break; + case AdcSQRCH9MUX: + M0P_ADC->SQR1_f.CH9MUX = enstcAdcSampCh; + break; + case AdcSQRCH10MUX: + M0P_ADC->SQR1_f.CH10MUX = enstcAdcSampCh; + break; + case AdcSQRCH11MUX: + M0P_ADC->SQR1_f.CH11MUX = enstcAdcSampCh; + break; + case AdcSQRCH12MUX: + M0P_ADC->SQR2_f.CH12MUX = enstcAdcSampCh; + break; + case AdcSQRCH13MUX: + M0P_ADC->SQR2_f.CH13MUX = enstcAdcSampCh; + break; + case AdcSQRCH14MUX: + M0P_ADC->SQR2_f.CH14MUX = enstcAdcSampCh; + break; + case AdcSQRCH15MUX: + M0P_ADC->SQR2_f.CH15MUX = enstcAdcSampCh; + break; + default: + enResult = ErrorInvalidParameter; + break; + + } + + return enResult; +} +/** + * \brief + * 閰嶇疆鎻掗槦鎵弿杞崲閫氶亾 + * + * \param [in]enstcAdcSqrChMux 鎻掗槦鎵弿杞崲閫氶亾椤哄簭 + * \param [in]enstcAdcSampCh 杞崲閫氶亾 + * + * \retval en_result_t Ok: 鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + */ +en_result_t Adc_CfgJqrChannel(en_adc_jqr_chmux_t enstcAdcJqrChMux, en_adc_samp_ch_sel_t enstcAdcSampCh) +{ + en_result_t enResult = Ok; + + switch(enstcAdcJqrChMux) + { + case AdcJQRCH0MUX: + M0P_ADC->JQR_f.CH0MUX = enstcAdcSampCh; + break; + case AdcJQRCH1MUX: + M0P_ADC->JQR_f.CH1MUX = enstcAdcSampCh; + break; + case AdcJQRCH2MUX: + M0P_ADC->JQR_f.CH2MUX = enstcAdcSampCh; + break; + case AdcJQRCH3MUX: + M0P_ADC->JQR_f.CH3MUX = enstcAdcSampCh; + break; + default: + enResult = ErrorInvalidParameter; + break; + } + + return enResult; +} + +/** + * \brief + * 鑾峰彇閲囨牱鍊 + * + * + * \retval en_result_t 閲囨牱鍊 + */ +uint32_t Adc_GetSglResult(void) +{ + return M0P_ADC->RESULT; +} + +/** + * \brief + * 鑾峰彇閲囨牱鍊 + * + * \param [in] enstcAdcSqrChMux 椤哄簭鎵弿閫氶亾搴忓彿 @ref en_adc_sqr_chmux_t + * + * \retval en_result_t 閲囨牱鍊 + */ +uint32_t Adc_GetSqrResult(en_adc_sqr_chmux_t enstcAdcSqrChMux) +{ + volatile uint32_t *BaseSqrResultAddress = &(M0P_ADC->SQRRESULT0); + + return *(BaseSqrResultAddress + enstcAdcSqrChMux); + +} + +/** + * \brief + * 鑾峰彇鎻掗槦鎵弿閲囨牱鍊 + * + * \param [in] enstcAdcJqrChMux 鎻掗槦鎵弿閫氶亾搴忓彿@ref en_adc_jqr_chmux_t + * + * \retval en_result_t 閲囨牱鍊 + */ +uint32_t Adc_GetJqrResult(en_adc_jqr_chmux_t enstcAdcJqrChMux) +{ + volatile uint32_t *BaseJqrResultAddress = &(M0P_ADC->JQRRESULT0); + + return *(BaseJqrResultAddress + enstcAdcJqrChMux); + +} + +/** + * \brief + * 鑾峰彇绱姞閲囨牱鍊 + * + * + * \retval en_result_t 绱姞閲囨牱缁撴灉 + */ +uint32_t Adc_GetAccResult(void) +{ + return M0P_ADC->RESULTACC; + +} + +/** + * \brief + * 娓呴浂绱姞閲囨牱鍊 + * + * \param 鏃 + * + * \retval 鏃 + */ +void Adc_ClrAccResult(void) +{ + M0P_ADC->CR1_f.RACCCLR = 0u; +} + +/** + * \brief + * ADC姣旇緝浣胯兘(姣旇緝涓柇) + * + * \param [in] pstcAdcIrqCfg ADC姣旇緝閰嶇疆 @ref stc_adc_threshold_cfg_t + * + * \retval 鏃 + */ + +void Adc_ThresholdCfg(stc_adc_threshold_cfg_t* pstcAdcThrCfg) +{ + M0P_ADC->HT = pstcAdcThrCfg->u32AdcHighThd; + M0P_ADC->LT = pstcAdcThrCfg->u32AdcLowThd; + + M0P_ADC->CR1_f.THCH = pstcAdcThrCfg->enSampChSel; + + M0P_ADC->CR1_f.REGCMP = pstcAdcThrCfg->bAdcRegCmp; + M0P_ADC->CR1_f.HTCMP = pstcAdcThrCfg->bAdcHtCmp; + M0P_ADC->CR1_f.LTCMP = pstcAdcThrCfg->bAdcLtCmp; + +} + + +//@} // AdcGroup + + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/driver/src/adt.c b/driver/src/adt.c new file mode 100644 index 0000000..5bcf38f --- /dev/null +++ b/driver/src/adt.c @@ -0,0 +1,1657 @@ +/****************************************************************************** +* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file adt.c + ** + ** Low Voltage Detect driver API. + ** @link Lvd Group Some description @endlink + ** + ** - 2019-04-19 Husj First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adt.h" + +/** + ****************************************************************************** + ** \addtogroup AdtGroup + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define IS_VALID_ADT_STATE(x) ( AdtCMAF == (x)||\ + AdtCMBF == (x)||\ + AdtCMCF == (x)||\ + AdtCMDF == (x)||\ + AdtOVFF == (x)||\ + AdtUDFF == (x)||\ + AdtDTEF == (x)||\ + AdtCMSAUF == (x)||\ + AdtCMSADF == (x)||\ + AdtCMSBUF == (x)||\ + AdtCMSBDF == (x)||\ + AdtCntDir == (x) ) +#define ADTIM_HW_STASTPCLR_EN 31 +#define ADTIM_HW_STASTPCLR_DIS 0x7FFFFFFF +#define ADTIM_SS_TIM4 1 +#define ADTIM_SS_TIM5 2 +#define ADTIM_SS_TIM6 4 +#define ADTIM_PORT_BKE_NUM 15 +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') * + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/****************************************************************************** + * Local variable definitions ('static') + ******************************************************************************/ + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + *****************************************************************************/ + + + +/***************************************************************** + * \brief + * 閰嶇疆涓柇 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtIrq 涓柇绫诲瀷 + * \param [in] bEn 涓柇浣胯兘/绂佹 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + ****************************************************************/ +en_result_t Adt_CfgIrq(M0P_ADTIM_TypeDef *ADTx, + en_adt_irq_type_t enAdtIrq, + boolean_t bEn) +{ + uint32_t u32Val; + + u32Val = ADTx->ICONR; + if (bEn) + { + u32Val |= 1u<ICONR = u32Val; + return Ok; +} + +/******************************************************************* + * \brief + * 鑾峰彇涓柇鏍囧織 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtIrq 涓柇绫诲瀷 + * + * + * \retval TRUE/FALSE + * + *****************************************************************/ +boolean_t Adt_GetIrqFlag(M0P_ADTIM_TypeDef *ADTx, + en_adt_irq_type_t enAdtIrq) +{ + uint32_t u32Val; + boolean_t bEn; + + ASSERT(IS_VALID_ADT_UNIT(enAdtUnit)); + + u32Val = ADTx->IFR; + bEn = (u32Val>>enAdtIrq) & 0x1; + + return bEn; +} + +/**************************************************************** + * \brief + * 娓呴櫎涓柇鏍囧織 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtIrq 涓柇绫诲瀷 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + ****************************************************************/ +en_result_t Adt_ClearIrqFlag(M0P_ADTIM_TypeDef *ADTx, + en_adt_irq_type_t enAdtIrq) +{ + ADTx->ICLR = ~(1u<ICLR = 0; + return Ok; +} + +/************************************************************** + * \brief + * 閰嶇疆纭欢閫掑姞浜嬩欢 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtHwCntUp 纭欢閫掑姞浜嬩欢 + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * + ****************************************************************/ +en_result_t Adt_CfgHwCntUp(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_cnt_t enAdtHwCntUp) +{ + uint32_t u32Val; + + + if (AdtHwCntMax <= enAdtHwCntUp) + { + return ErrorInvalidParameter; + } + + u32Val = ADTx->HCUPR; + ADTx->HCUPR = u32Val | (1u<HCUPR = 0; + return Ok; +} + + +/********************************************************** + * \brief + * 閰嶇疆纭欢閫掑噺浜嬩欢 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtHwCntDwn 纭欢閫掑噺浜嬩欢 + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + ***********************************************************/ +en_result_t Adt_CfgHwCntDwn(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_cnt_t enAdtHwCntDwn) +{ + uint32_t u32Val; + + + if(AdtHwCntMax <= enAdtHwCntDwn) + { + return ErrorInvalidParameter; + } + + u32Val = ADTx->HCDOR; + ADTx->HCDOR = u32Val | (1u<HCDOR = 0; + return Ok; +} + +/****************************************************************** + * \brief + * 閰嶇疆纭欢鍚姩浜嬩欢 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtHwStart 纭欢鍚姩浜嬩欢 + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + *******************************************************************/ +en_result_t Adt_CfgHwStart(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwStart) +{ + uint32_t u32Val; + + + if(AdtHwTrigEnd <= enAdtHwStart) + { + return ErrorInvalidParameter; + } + u32Val = ADTx->HSTAR; + ADTx->HSTAR = u32Val | (1u<HSTAR = 0; + return Ok; +} + +/********************************************************************* + * \brief + * 浣胯兘纭欢鍚姩 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * + *********************************************************************/ +en_result_t Adt_EnableHwStart(M0P_ADTIM_TypeDef *ADTx) +{ + uint32_t u32Val; + + u32Val = ADTx->HSTAR; + ADTx->HSTAR = u32Val | (1u<HSTAR; + ADTx->HSTAR = u32Val & ADTIM_HW_STASTPCLR_DIS; + return Ok; +} + +/**************************************************************** + * \brief + * 閰嶇疆纭欢鍋滄浜嬩欢 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtHwStop 纭欢鍋滄浜嬩欢 + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + ***************************************************************/ +en_result_t Adt_CfgHwStop(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwStop) +{ + uint32_t u32Val; + + if(AdtHwTrigEnd <= enAdtHwStop) + { + return ErrorInvalidParameter; + } + + u32Val = ADTx->HSTPR; + ADTx->HSTPR = u32Val | (1u<HSTPR = 0; + return Ok; +} + +/************************************************************* + * \brief + * 浣胯兘纭欢鍋滄 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * + **********************************************************/ +en_result_t Adt_EnableHwStop(M0P_ADTIM_TypeDef *ADTx) +{ + uint32_t u32Val; + + u32Val = ADTx->HSTPR; + ADTx->HSTPR = u32Val | (1u<HSTPR; + ADTx->HSTPR = u32Val & ADTIM_HW_STASTPCLR_DIS; + return Ok; +} + +/************************************************************************** + * \brief + * 閰嶇疆纭欢娓呴浂浜嬩欢 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtHwClear 纭欢娓呴浂浜嬩欢 + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + *************************************************************************/ +en_result_t Adt_CfgHwClear(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwClear) +{ + uint32_t u32Val; + + + if(AdtHwTrigEnd <= enAdtHwClear) + { + return ErrorInvalidParameter; + } + + u32Val = ADTx->HCELR; + ADTx->HCELR = u32Val | (1u<HCELR = 0; + return Ok; +} + +/*************************************************************************** + * \brief + * 浣胯兘纭欢娓呴浂 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * + *************************************************************************/ +en_result_t Adt_EnableHwClear(M0P_ADTIM_TypeDef *ADTx) +{ + uint32_t u32Val; + + u32Val = ADTx->HCELR; + ADTx->HCELR = u32Val | (1u<HCELR; + ADTx->HCELR = u32Val & ADTIM_HW_STASTPCLR_DIS; + return Ok; +} + +/******************************************************************* + * \brief + * 閰嶇疆纭欢鎹曡幏A浜嬩欢 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtHwCaptureA 纭欢鎹曡幏A浜嬩欢閫夋嫨 + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + *******************************************************************/ +en_result_t Adt_CfgHwCaptureA(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwCaptureA) +{ + uint32_t u32Val; + + + if(AdtHwTrigEnd <= enAdtHwCaptureA) + { + return ErrorInvalidParameter; + } + + u32Val = ADTx->HCPAR; + ADTx->HCPAR = u32Val | (1u<PCONR_f.CAPCA = 1; + return Ok; +} + +/************************************************************************ + * \brief + * 娓呴櫎纭欢鎹曡幏A浜嬩欢 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * + ***********************************************************************/ +en_result_t Adt_ClearHwCaptureA(M0P_ADTIM_TypeDef *ADTx) +{ + ADTx->HCPAR = 0; + return Ok; +} + +/********************************************************************* + * \brief + * 閰嶇疆纭欢鎹曡幏B浜嬩欢 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtHwCaptureB 纭欢鎹曡幏B浜嬩欢閫夋嫨 + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + ********************************************************************/ +en_result_t Adt_CfgHwCaptureB(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwCaptureB) +{ + uint32_t u32Val; + + + if(AdtHwTrigEnd <= enAdtHwCaptureB) + { + return ErrorInvalidParameter; + } + + u32Val = ADTx->HCPBR; + ADTx->HCPBR = u32Val | (1u<PCONR_f.CAPCB = 1; + return Ok; +} + +/******************************************************************** + * \brief + * 娓呴櫎纭欢鎹曡幏B浜嬩欢 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * + *******************************************************************/ +en_result_t Adt_ClearHwCaptureB(M0P_ADTIM_TypeDef *ADTx) +{ + ADTx->HCPBR = 0; + return Ok; +} + +/***************************************************************** + * \brief + * 杞欢鍚屾寮濮 + * + * \param [in] pstcAdtSwSyncStart 杞欢鍚屾寮濮嬫寚閽 + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + ***************************************************************/ +en_result_t Adt_SwSyncStart(stc_adt_sw_sync_t* pstcAdtSwSyncStart) +{ + uint32_t u32Val = 0; + + if (NULL == pstcAdtSwSyncStart) + { + return ErrorInvalidParameter; + } + + if (pstcAdtSwSyncStart->bAdTim4) + { + u32Val |= ADTIM_SS_TIM4; + } + if (pstcAdtSwSyncStart->bAdTim5) + { + u32Val |= ADTIM_SS_TIM5; + } + if (pstcAdtSwSyncStart->bAdTim6) + { + u32Val |= ADTIM_SS_TIM6; + } + + M0P_ADTIM4->SSTAR = u32Val; + return Ok; +} + +/*************************************************************** + * \brief + * 杞欢鍚屾鍋滄 + * + * \param [in] pstcAdtSwSyncStop 杞欢鍚屾鍋滄鎸囬拡 + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + ***************************************************************/ +en_result_t Adt_SwSyncStop(stc_adt_sw_sync_t* pstcAdtSwSyncStop) +{ + uint32_t u32Val = 0; + + if (NULL == pstcAdtSwSyncStop) + { + return ErrorInvalidParameter; + } + + if (pstcAdtSwSyncStop->bAdTim4) + { + u32Val |= ADTIM_SS_TIM4; + } + if (pstcAdtSwSyncStop->bAdTim5) + { + u32Val |= ADTIM_SS_TIM5; + } + if (pstcAdtSwSyncStop->bAdTim6) + { + u32Val |= ADTIM_SS_TIM6; + } + + M0P_ADTIM4->SSTPR = u32Val; + return Ok; +} + +/***************************************************************** + * \brief + * 杞欢鍚屾娓呴浂 + * + * \param [in] pstcAdtSwSyncClear 杞欢鍚屾娓呴浂鎸囬拡 + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + *******************************************************************/ +en_result_t Adt_SwSyncClear(stc_adt_sw_sync_t* pstcAdtSwSyncClear) +{ + uint32_t u32Val = 0; + + if (NULL == pstcAdtSwSyncClear) + { + return ErrorInvalidParameter; + } + + if (pstcAdtSwSyncClear->bAdTim4) + { + u32Val |= ADTIM_SS_TIM4; + } + if (pstcAdtSwSyncClear->bAdTim5) + { + u32Val |= ADTIM_SS_TIM5; + } + if (pstcAdtSwSyncClear->bAdTim6) + { + u32Val |= ADTIM_SS_TIM6; + } + + M0P_ADTIM4->SCLRR = u32Val; + return Ok; +} + +/******************************************************************* + * \brief + * 鑾峰彇杞欢鍚屾杩愯鐘舵 + * + * \param [in] pstcAdtSwSyncState ADV Timer杞欢鍚屾杩愯鐘舵佹寚閽 + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + *******************************************************************/ +en_result_t Adt_GetSwSyncState(stc_adt_sw_sync_t* pstcAdtSwSyncState) +{ + if (NULL == pstcAdtSwSyncState) + { + return ErrorInvalidParameter; + } + + if (M0P_ADTIM4->SSTAR & ADTIM_SS_TIM4) + { + pstcAdtSwSyncState->bAdTim4 = TRUE; + } + else + { + pstcAdtSwSyncState->bAdTim4 = FALSE; + } + if (M0P_ADTIM4->SSTAR & ADTIM_SS_TIM5) + { + pstcAdtSwSyncState->bAdTim5 = TRUE; + } + else + { + pstcAdtSwSyncState->bAdTim5 = FALSE; + } + if (M0P_ADTIM4->SSTAR & ADTIM_SS_TIM6) + { + pstcAdtSwSyncState->bAdTim6 = TRUE; + } + else + { + pstcAdtSwSyncState->bAdTim6 = FALSE; + } + return Ok; +} + +/************************************************************************ + * \brief + * AOS瑙﹀彂閰嶇疆 + * + * \param [in] pstcAdtAosTrigCfg 瑙﹀彂閰嶇疆鎸囬拡 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + ************************************************************************/ +en_result_t Adt_AosTrigCfg(stc_adt_aos_trig_cfg_t* pstcAdtAosTrigCfg) +{ + if (NULL == pstcAdtAosTrigCfg) + { + return ErrorInvalidParameter; + } + + M0P_ADTIM4->ITRIG_f.IAOS0S = pstcAdtAosTrigCfg->enAos0TrigSrc; + M0P_ADTIM4->ITRIG_f.IAOS1S = pstcAdtAosTrigCfg->enAos1TrigSrc; + M0P_ADTIM4->ITRIG_f.IAOS2S = pstcAdtAosTrigCfg->enAos2TrigSrc; + M0P_ADTIM4->ITRIG_f.IAOS3S = pstcAdtAosTrigCfg->enAos3TrigSrc; + return Ok; +} + +/********************************************************************** + * \brief + * 涓柇瑙﹀彂閰嶇疆 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] pstcAdtIrqTrigCfg 瑙﹀彂閰嶇疆鎸囬拡 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + ***********************************************************************/ +en_result_t Adt_IrqTrigCfg(M0P_ADTIM_TypeDef *ADTx, + stc_adt_irq_trig_cfg_t* pstcAdtIrqTrigCfg) +{ + if(NULL == pstcAdtIrqTrigCfg) + { + return ErrorInvalidParameter; + } + + ADTx->CR_f.CMAE = pstcAdtIrqTrigCfg->bAdtCntMatchATrigEn; + ADTx->CR_f.CMBE = pstcAdtIrqTrigCfg->bAdtCntMatchBTrigEn; + ADTx->CR_f.CMCE = pstcAdtIrqTrigCfg->bAdtCntMatchCTrigEn; + ADTx->CR_f.CMDE = pstcAdtIrqTrigCfg->bAdtCntMatchDTrigEn; + ADTx->CR_f.OVFE = pstcAdtIrqTrigCfg->bAdtOverFlowTrigEn; + ADTx->CR_f.UDFE = pstcAdtIrqTrigCfg->bAdtUnderFlowTrigEn; + ADTx->CR_f.DMA_G_CMA = pstcAdtIrqTrigCfg->bAdtCntMatchATrigDmaEn; + ADTx->CR_f.DMA_G_CMB = pstcAdtIrqTrigCfg->bAdtCntMatchBTrigDmaEn; + ADTx->CR_f.DMA_G_CMC = pstcAdtIrqTrigCfg->bAdtCntMatchCTrigDmaEn; + ADTx->CR_f.DMA_G_CMD = pstcAdtIrqTrigCfg->bAdtCntMatchDTrigDmaEn; + ADTx->CR_f.DMA_G_OVF = pstcAdtIrqTrigCfg->bAdtOverFlowTrigDmaEn; + ADTx->CR_f.DMA_G_UDF = pstcAdtIrqTrigCfg->bAdtUnderFlowTrigDmaEn; + ADTx->CR_f.DMA_S_CMA = pstcAdtIrqTrigCfg->bAdtSpecilMatchATrigDmaEn; + ADTx->CR_f.DMA_S_CMB = pstcAdtIrqTrigCfg->bAdtSpecilMatchBTrigDmaEn; + + return Ok; +} + +/************************************************************************* + * \brief + * 绔彛瑙﹀彂閰嶇疆 + * + * \param [in] enAdtTrigPort 瑙﹀彂绔彛 + * \param [in] pstcAdtPortTrigCfg 瑙﹀彂閰嶇疆鎸囬拡 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + *************************************************************************/ +en_result_t Adt_PortTrigCfg(en_adt_trig_port_t enAdtTrigPort, + stc_adt_port_trig_cfg_t* pstcAdtPortTrigCfg) +{ + if (NULL == pstcAdtPortTrigCfg) + { + return ErrorInvalidParameter; + } + + switch (enAdtTrigPort) + { + case AdtTrigA: + M0P_ADTIM4->TTRIG_f.TRIGAS = pstcAdtPortTrigCfg->enTrigSrc; + M0P_ADTIM4->FCONR_f.NOFIENTA = pstcAdtPortTrigCfg->bFltEn; + M0P_ADTIM4->FCONR_f.NOFICKTA = pstcAdtPortTrigCfg->enFltClk; + break; + + case AdtTrigB: + M0P_ADTIM4->TTRIG_f.TRIGBS = pstcAdtPortTrigCfg->enTrigSrc; + M0P_ADTIM4->FCONR_f.NOFIENTB = pstcAdtPortTrigCfg->bFltEn; + M0P_ADTIM4->FCONR_f.NOFICKTB = pstcAdtPortTrigCfg->enFltClk; + break; + + case AdtTrigC: + M0P_ADTIM4->TTRIG_f.TRIGCS = pstcAdtPortTrigCfg->enTrigSrc; + M0P_ADTIM4->FCONR_f.NOFIENTC = pstcAdtPortTrigCfg->bFltEn; + M0P_ADTIM4->FCONR_f.NOFICKTC = pstcAdtPortTrigCfg->enFltClk; + break; + + case AdtTrigD: + M0P_ADTIM4->TTRIG_f.TRIGDS = pstcAdtPortTrigCfg->enTrigSrc; + M0P_ADTIM4->FCONR_f.NOFIENTD = pstcAdtPortTrigCfg->bFltEn; + M0P_ADTIM4->FCONR_f.NOFICKTD = pstcAdtPortTrigCfg->enFltClk; + break; + + default: + return ErrorInvalidParameter; + } + + return Ok; +} + +/*********************************************************************** + * \brief + * CHxX绔彛閰嶇疆 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtCHxXPort CHxX绔彛 + * \param [in] pstcAdtCHxXCfg CHxX绔彛閰嶇疆鎸囬拡 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + *********************************************************************/ +en_result_t Adt_CHxXPortCfg(M0P_ADTIM_TypeDef *ADTx, + en_adt_CHxX_port_t enAdtCHxXPort, + stc_adt_CHxX_port_cfg_t* pstcAdtCHxXCfg) +{ + if(NULL == pstcAdtCHxXCfg) + { + return ErrorInvalidParameter; + } + + switch (enAdtCHxXPort) + { + case AdtCHxA: + ADTx->PCONR_f.CAPCA = pstcAdtCHxXCfg->enCap; + ADTx->PCONR_f.STACA = pstcAdtCHxXCfg->enStaOut; + ADTx->PCONR_f.STPCA = pstcAdtCHxXCfg->enStpOut; + ADTx->PCONR_f.STASTPSA = pstcAdtCHxXCfg->enStaStp; + ADTx->PCONR_f.CMPCA = pstcAdtCHxXCfg->enCmpc; + ADTx->PCONR_f.PERCA = pstcAdtCHxXCfg->enPerc; + ADTx->PCONR_f.OUTENA = pstcAdtCHxXCfg->bOutEn; + ADTx->PCONR_f.DISSELA = pstcAdtCHxXCfg->enDisSel; + ADTx->PCONR_f.DISVALA = pstcAdtCHxXCfg->enDisVal; + ADTx->FCONR_f.NOFIENGA = pstcAdtCHxXCfg->bFltEn; + ADTx->FCONR_f.NOFICKGA = pstcAdtCHxXCfg->enFltClk; + break; + + case AdtCHxB: + ADTx->PCONR_f.CAPCB = pstcAdtCHxXCfg->enCap; + ADTx->PCONR_f.STACB = pstcAdtCHxXCfg->enStaOut; + ADTx->PCONR_f.STPCB = pstcAdtCHxXCfg->enStpOut; + ADTx->PCONR_f.STASTPSB = pstcAdtCHxXCfg->enStaStp; + ADTx->PCONR_f.CMPCB = pstcAdtCHxXCfg->enCmpc; + ADTx->PCONR_f.PERCB = pstcAdtCHxXCfg->enPerc; + ADTx->PCONR_f.OUTENB = pstcAdtCHxXCfg->bOutEn; + ADTx->PCONR_f.DISSELB = pstcAdtCHxXCfg->enDisSel; + ADTx->PCONR_f.DISVALB = pstcAdtCHxXCfg->enDisVal; + ADTx->FCONR_f.NOFIENGB = pstcAdtCHxXCfg->bFltEn; + ADTx->FCONR_f.NOFICKGB = pstcAdtCHxXCfg->enFltClk; + break; + + default: + return ErrorInvalidParameter; + } + + return Ok; +} + +/************************************************************************ + * \brief + * 浣胯兘绔彛鍒硅溅 + * + * \param [in] port 绔彛 + * \param [in] pstcAdtBrkPtCfg 绔彛鍒硅溅閰嶇疆鎸囬拡 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + ************************************************************************/ +en_result_t Adt_EnableBrakePort(uint8_t port, stc_adt_break_port_cfg_t* pstcAdtBrkPtCfg) +{ + uint32_t u32Val; + + if (NULL == pstcAdtBrkPtCfg) + { + return ErrorInvalidParameter; + } + + u32Val = M0P_ADTIM4->PTBKP; + u32Val &= ~(1u<PTBKP = u32Val | (pstcAdtBrkPtCfg->enPol<PTBKS; + M0P_ADTIM4->PTBKS = u32Val | (1u<PTBKS = 0; +} + +/********************************************************************* + * \brief + * 鏃犳晥鏉′欢3閰嶇疆 + * + * \param [in] pstcAdtDisable3 鏃犳晥鏉′欢3閰嶇疆鎸囬拡 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + ********************************************************************/ +en_result_t Adt_Disable3Cfg(stc_adt_disable_3_cfg_t* pstcAdtDisable3) +{ + uint8_t i; + + if (NULL == pstcAdtDisable3) + { + return ErrorInvalidParameter; + } + + Adt_ClearBrakePort(); + for (i = 0; i <= ADTIM_PORT_BKE_NUM; i++) + { + if (TRUE == pstcAdtDisable3->stcBrkPtCfg[i].bPortEn) + { + Adt_EnableBrakePort(i, &pstcAdtDisable3->stcBrkPtCfg[i]); + } + } + + M0P_ADTIM4->AOSSR_f.BFILTEN = pstcAdtDisable3->bFltEn; + M0P_ADTIM4->AOSSR_f.BFILTS = pstcAdtDisable3->enFltClk; + + return Ok; +} + +/********************************************************************* + * \brief 杞欢鍒硅溅 Enable/Disable(浠呴傜敤浜庢棤鏁堟潯浠3浣胯兘鐨勬儏鍐典笅) + * + * \param [in] bSwBrk 杞欢鍒硅溅浣胯兘/绂佹 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + ********************************************************************/ +en_result_t Adt_SwBrake(boolean_t bSwBrk) +{ + M0P_ADTIM4->AOSSR_f.SOFTBK = bSwBrk; + + return Ok; +} + +/******************************************************************* + * \brief + * 鑾峰彇绔彛鍒硅溅鏍囧織 + * + * \param none + * + * \retval TRUE or FALSE + ******************************************************************/ +boolean_t Adt_GetPortBrakeFlag(void) +{ + return M0P_ADTIM4->AOSSR_f.FBRAKE; +} + +/****************************************************************** + * \brief + * 娓呴櫎绔彛鍒硅溅鏍囧織 + * + * \param none + * + * \retval none + ******************************************************************/ +void Adt_ClearPortBrakeFlag(void) +{ + M0P_ADTIM4->AOSCL_f.FBRAKE = 0; +} + +/******************************************************************** + * \brief + * 鏃犳晥鏉′欢1閰嶇疆 + * + * \param [in] pstcAdtDisable1 鏃犳晥鏉′欢1閰嶇疆鎸囬拡 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + ********************************************************************/ +en_result_t Adt_Disable1Cfg(stc_adt_disable_1_cfg_t* pstcAdtDisable1) +{ + + if (NULL == pstcAdtDisable1) + { + return ErrorInvalidParameter; + } + + M0P_ADTIM4->AOSSR_f.SMH2 = pstcAdtDisable1->bTim6OutSH; + M0P_ADTIM4->AOSSR_f.SMH1 = pstcAdtDisable1->bTim5OutSH; + M0P_ADTIM4->AOSSR_f.SMH0 = pstcAdtDisable1->bTim4OutSH; + M0P_ADTIM4->AOSSR_f.SML2 = pstcAdtDisable1->bTim6OutSL; + M0P_ADTIM4->AOSSR_f.SML1 = pstcAdtDisable1->bTim5OutSL; + M0P_ADTIM4->AOSSR_f.SML0 = pstcAdtDisable1->bTim4OutSL; + + return Ok; +} + +/******************************************************************** + * \brief + * 鑾峰彇鍚岄珮鍚屼綆鍒硅溅鏍囧織 + * + * \param none + * + * \retval TRUE or FALSE + ********************************************************************/ +boolean_t Adt_GetSameBrakeFlag(void) +{ + return M0P_ADTIM4->AOSSR_f.FSAME; +} + +/********************************************************************* + * \brief + * 娓呴櫎鍚岄珮鍚屼綆鍒硅溅鏍囧織 + * + * \param none + * + * \retval none + *********************************************************************/ +void Adt_ClearSameBrakeFlag(void) +{ + M0P_ADTIM4->AOSCL_f.FSAME = 0; +} + +/******************************************************************** + * \brief + * PWM灞曢閰嶇疆 + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] pstcAdtPwmDitherCfg PWM灞曢閰嶇疆鎸囬拡 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + *********************************************************************/ +en_result_t Adt_PwmDitherCfg(M0P_ADTIM_TypeDef *ADTx, stc_adt_pwm_dither_cfg_t* pstcAdtPwmDitherCfg) +{ + + + if (NULL == pstcAdtPwmDitherCfg) + { + return ErrorInvalidParameter; + } + + ADTx->CR_f.DITENS = pstcAdtPwmDitherCfg->enAdtPDType; + ADTx->CR_f.DITENB = pstcAdtPwmDitherCfg->bTimxBPDEn; + ADTx->CR_f.DITENA = pstcAdtPwmDitherCfg->bTimxAPDEn; + + return Ok; +} + +/********************************************************************** + * \brief + * ADT鍒濆鍖 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] pstcAdtBaseCntCfg 璁℃暟閰嶇疆鎸囬拡 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + **********************************************************************/ +en_result_t Adt_Init(M0P_ADTIM_TypeDef *ADTx, stc_adt_basecnt_cfg_t* pstcAdtBaseCntCfg) +{ + + + if(NULL == pstcAdtBaseCntCfg) + { + return ErrorInvalidParameter; + } + + if (AdtTriangleModeB < pstcAdtBaseCntCfg->enCntMode) + { + return ErrorInvalidParameter; + } + + ADTx->GCONR_f.MODE = pstcAdtBaseCntCfg->enCntMode; + ADTx->GCONR_f.DIR = pstcAdtBaseCntCfg->enCntDir; + ADTx->GCONR_f.CKDIV = pstcAdtBaseCntCfg->enCntClkDiv; + + return Ok; +} + +/************************************************************************ + * \brief + * ADT Deinit + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + ***********************************************************************/ +en_result_t Adt_DeInit(M0P_ADTIM_TypeDef *ADTx) +{ + ADTx->GCONR_f.START = 0; + ADTx->CNTER = 0; + ADTx->PCONR = 0; + ADTx->GCONR = 0x00000100; + ADTx->DCONR = 0; + ADTx->ICONR = 0; + ADTx->BCONR = 0; + ADTx->FCONR = 0; + ADTx->VPERR = 0; + ADTx->PERAR = 0xFFFF; + ADTx->PERBR = 0xFFFF; + ADTx->GCMAR = 0xFFFF; + ADTx->GCMBR = 0xFFFF; + ADTx->GCMCR = 0xFFFF; + ADTx->GCMDR = 0xFFFF; + ADTx->DTDAR = 0xFFFF; + ADTx->DTUAR = 0xFFFF; + ADTx->HSTAR = 0; + ADTx->HSTPR = 0; + ADTx->HCELR = 0; + ADTx->HCPAR = 0; + ADTx->HCPBR = 0; + ADTx->HCUPR = 0; + ADTx->HCDOR = 0; + ADTx->SSTAR = 0; + ADTx->SSTPR = 0; + ADTx->SCLRR = 0; + ADTx->IFR = 0; + ADTx->CR = 0x00000300; + ADTx->AOSSR = 0; + ADTx->AOSCL = 0; + ADTx->PTBKS = 0; + ADTx->PTBKP = 0; + ADTx->TTRIG = 0; + ADTx->ITRIG = 0; + + return Ok; +} + +/*********************************************************************** + * \brief + * 寮濮嬭鏁 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + ***********************************************************************/ +en_result_t Adt_StartCount(M0P_ADTIM_TypeDef *ADTx) +{ + + ADTx->GCONR_f.START = 1; + + return Ok; +} + +/*********************************************************************** + * \brief + * 鍋滄璁℃暟 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + **********************************************************************/ +en_result_t Adt_StopCount(M0P_ADTIM_TypeDef *ADTx) +{ + ADTx->GCONR_f.START = 0; + + return Ok; +} + +/******************************************************************** + * \brief + * 璁剧疆璁℃暟鍊 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] u16Value 璁℃暟鍊 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + *******************************************************************/ +en_result_t Adt_SetCount(M0P_ADTIM_TypeDef *ADTx, uint16_t u16Value) +{ + ADTx->CNTER_f.CNT = u16Value; + return Ok; +} + +/******************************************************************** + * \brief + * 鑾峰彇璁℃暟鍊 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * + * + * \retval uint16_t u16Value: 褰撳墠璁℃暟鍊 + * + *******************************************************************/ +uint16_t Adt_GetCount(M0P_ADTIM_TypeDef *ADTx) +{ + uint16_t u16Value; + + ASSERT(IS_VALID_ADT_UNIT(enAdtUnit)); + + u16Value = ADTx->CNTER_f.CNT; + + return u16Value; +} + +/************************************************************************** + * \brief + * 娓呴櫎璁℃暟鍊 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + **************************************************************************/ +en_result_t Adt_ClearCount(M0P_ADTIM_TypeDef *ADTx) +{ + ADTx->CNTER_f.CNT = 0; + return Ok; +} + +/************************************************************************* + * \brief + * 鑾峰彇鏈夋晥鍛ㄦ湡璁℃暟鍊 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * + * \retval uint8_t u8TempCnt: 鏈夋晥鍛ㄦ湡鍊 + * + *************************************************************************/ +uint8_t Adt_GetVperNum(M0P_ADTIM_TypeDef *ADTx) +{ + uint8_t u8TempCnt; + + + ASSERT(IS_VALID_ADT_UNIT(enAdtUnit)); + + u8TempCnt = ADTx->STFLR_f.VPERNUM; + + return u8TempCnt; +} + +/************************************************************************* + * \brief + * 鑾峰彇鐘舵佹爣蹇 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) +* \param [in] enstate 鐘舵佹爣蹇楃被鍨 + * + * \retval TURE/FALSE + * + *************************************************************************/ +boolean_t Adt_GetState(M0P_ADTIM_TypeDef *ADTx, en_adt_state_type_t enstate) +{ + + + ASSERT(IS_VALID_ADT_UNIT(enAdtUnit)); + ASSERT(IS_VALID_ADT_STATE(enstate)); + + return GetBit(((uint32_t)&ADTx->STFLR), enstate); +} + +/*********************************************************************** + * \brief + * 閰嶇疆璁℃暟鍛ㄦ湡 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] u16Period 璁℃暟鍛ㄦ湡鍊 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + ***********************************************************************/ +en_result_t Adt_SetPeriod(M0P_ADTIM_TypeDef *ADTx, uint16_t u16Period) +{ + ADTx->PERAR = u16Period; + + return Ok; +} + +/*********************************************************************** + * \brief + * 閰嶇疆璁℃暟鍛ㄦ湡缂撳啿 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] u16PeriodBuf 璁℃暟鍛ㄦ湡缂撳啿鍊 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + ***********************************************************************/ +en_result_t Adt_SetPeriodBuf(M0P_ADTIM_TypeDef *ADTx, uint16_t u16PeriodBuf) +{ + ADTx->PERBR = u16PeriodBuf; + ADTx->BCONR_f.BENP = 1u; + + return Ok; +} + +/********************************************************************** + * \brief + * 娓呴櫎璁℃暟鍛ㄦ湡缂撳啿 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + **********************************************************************/ +en_result_t Adt_ClearPeriodBuf(M0P_ADTIM_TypeDef *ADTx) +{ + ADTx->BCONR_f.BENP = 0; + ADTx->PERBR = 0; + + return Ok; +} + +/*********************************************************************** + * \brief + * 閰嶇疆鏈夋晥璁℃暟鍛ㄦ湡 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] pstcAdtValidPerCfg 鏈夋晥璁℃暟鍛ㄦ湡閰嶇疆鎸囬拡 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + ***********************************************************************/ +en_result_t Adt_SetValidPeriod(M0P_ADTIM_TypeDef *ADTx, + stc_adt_validper_cfg_t* pstcAdtValidPerCfg) +{ + + + if(NULL == pstcAdtValidPerCfg) + { + return ErrorInvalidParameter; + } + + ADTx->VPERR_f.PCNTS = pstcAdtValidPerCfg->enValidCnt; + ADTx->VPERR_f.PCNTE = pstcAdtValidPerCfg->enValidCdt; + ADTx->VPERR_f.GEPERID = pstcAdtValidPerCfg->bPeriodD; + ADTx->VPERR_f.GEPERIC = pstcAdtValidPerCfg->bPeriodC; + ADTx->VPERR_f.GEPERIB = pstcAdtValidPerCfg->bPeriodB; + ADTx->VPERR_f.GEPERIA = pstcAdtValidPerCfg->bPeriodA; + + return Ok; +} + +/************************************************************************ + * \brief + * 閰嶇疆姣旇緝杈撳嚭璁℃暟鍩哄噯鍊 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtCompare 閫氱敤姣旇緝鍩哄噯瀵勫瓨鍣 + * \param [in] u16Compare 姣旇緝鍩哄噯鍊 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + *************************************************************************/ +en_result_t Adt_SetCompareValue(M0P_ADTIM_TypeDef *ADTx, + en_adt_compare_t enAdtCompare, + uint16_t u16Compare) +{ + if (AdtCompareA == enAdtCompare) + { + ADTx->GCMAR = u16Compare; + } + else if (AdtCompareB == enAdtCompare) + { + ADTx->GCMBR = u16Compare; + } + else if (AdtCompareC == enAdtCompare) + { + ADTx->GCMCR = u16Compare; + } + else if (AdtCompareD == enAdtCompare) + { + ADTx->GCMDR = u16Compare; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/************************************************************************ + * \brief + * 閰嶇疆涓撶敤姣旇緝璁℃暟鍩哄噯鍊 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtSpclCmp 涓撶敤姣旇緝鍩哄噯鍊煎瘎瀛樺櫒 + * \param [in] u16SpclCmp 姣旇緝鍩哄噯鍊 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + *************************************************************************/ +en_result_t Adt_SetSpecilCompareValue(M0P_ADTIM_TypeDef *ADTx, + en_adt_special_compare_t enAdtSpclCmp, + uint16_t u16SpclCmp) +{ + if (AdtSpclCompA == enAdtSpclCmp) + { + ADTx->SCMAR_f.SCMA = u16SpclCmp; + } + else if (AdtSpclCompB == enAdtSpclCmp) + { + ADTx->SCMBR_f.SCMB = u16SpclCmp; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/********************************************************************** + * \brief + * 閰嶇疆閫氱敤姣旇緝鍊/鎹曡幏鍊肩紦瀛樹紶閫 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtCHxXPort TIMxX閫氶亾 + * \param [in] bCompareBufEn 閫氱敤姣旇緝鍊肩紦瀛樹紶閫佷娇鑳 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + **********************************************************************/ +en_result_t Adt_EnableValueBuf(M0P_ADTIM_TypeDef *ADTx, + en_adt_CHxX_port_t enAdtCHxXPort, + boolean_t bCompareBufEn) +{ + if (AdtCHxA == enAdtCHxXPort) + { + ADTx->BCONR_f.BENA = bCompareBufEn; + } + else if (AdtCHxB == enAdtCHxXPort) + { + ADTx->BCONR_f.BENB = bCompareBufEn; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/*********************************************************************** + * \brief + * 娓呴櫎姣旇緝杈撳嚭璁℃暟鍊/鎹曡幏鍊肩紦瀛 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtCHxXPort TIMxX閫氶亾 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + **********************************************************************/ +en_result_t Adt_ClearValueBuf(M0P_ADTIM_TypeDef *ADTx, + en_adt_CHxX_port_t enAdtCHxXPort) +{ + if (AdtCHxA == enAdtCHxXPort) + { + ADTx->GCMCR = 0; + } + else if (AdtCHxB == enAdtCHxXPort) + { + ADTx->GCMDR = 0; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/*********************************************************************** + * \brief + * 鑾峰彇鎹曡幏鍊 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtCHxXPort TIMxX閫氶亾 + * \param [in] pu16Capture 鎹曡幏鍊兼寚閽 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + ***********************************************************************/ +en_result_t Adt_GetCaptureValue(M0P_ADTIM_TypeDef *ADTx, + en_adt_CHxX_port_t enAdtCHxXPort, + uint16_t* pu16Capture) +{ + if (AdtCHxA == enAdtCHxXPort) + { + *pu16Capture = ADTx->GCMAR_f.GCMA; + } + else if (AdtCHxB == enAdtCHxXPort) + { + *pu16Capture = ADTx->GCMBR_f.GCMB; + } + else + { + return ErrorInvalidParameter; + } + return Ok; +} + +/********************************************************************** + * \brief + * 鑾峰彇鎹曡幏缂撳瓨鍊 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] enAdtCHxXPort TIMxX閫氶亾 + * \param [in] pu16CaptureBuf 鎹曡幏缂撳瓨鍊兼寚閽 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + ***********************************************************************/ +en_result_t Adt_GetCaptureBuf(M0P_ADTIM_TypeDef *ADTx, + en_adt_CHxX_port_t enAdtCHxXPort, + uint16_t* pu16CaptureBuf) +{ + if (AdtCHxA == enAdtCHxXPort) + { + *pu16CaptureBuf = ADTx->GCMCR_f.GCMC; + } + else if (AdtCHxB == enAdtCHxXPort) + { + *pu16CaptureBuf = ADTx->GCMDR_f.GCMD; + } + else + { + return ErrorInvalidParameter; + } + return Ok; +} + +/*********************************************************************** + * \brief + * 璁剧疆姝诲尯鏃堕棿涓婂熀鍑嗗 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] u16Value 姝诲尯鏃堕棿涓婂熀鍑嗗 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + ************************************************************************/ +en_result_t Adt_SetDTUA(M0P_ADTIM_TypeDef *ADTx, + uint16_t u16Value) +{ + ADTx->DTUAR = u16Value; + + return Ok; +} + +/*********************************************************************** + * \brief + * 璁剧疆姝诲尯鏃堕棿涓嬪熀鍑嗗 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] u16Value 姝诲尯鏃堕棿涓嬪熀鍑嗗 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + ***********************************************************************/ +en_result_t Adt_SetDTDA(M0P_ADTIM_TypeDef *ADTx, + uint16_t u16Value) +{ + ADTx->DTDAR = u16Value; + + return Ok; +} + +/****************************************************************** + * \brief + * 閰嶇疆姝诲尯鏃堕棿鍔熻兘 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] bDTEn 姝诲尯鍔熻兘浣胯兘 + * \param [in] bEqual DTDAR鐨勫煎拰DTUAR鐨勫艰嚜鍔ㄧ浉绛 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + *****************************************************************/ +en_result_t Adt_CfgDT(M0P_ADTIM_TypeDef *ADTx, + boolean_t bDTEn, + boolean_t bEqual) +{ + ADTx->DCONR_f.DTCEN = bDTEn; + ADTx->DCONR_f.SEPA = bEqual; + + return Ok; +} + +/************************************************************************* + * \brief + * Z鐩歌緭鍏ュ睆钄借缃 + * + * \param [in] ADTx ADV Timer閫氶亾閫夋嫨(M0P_ADTIM4銆丮0P_ADTIM5銆丮0P_ADTIM6) + * \param [in] pstcAdtZMaskCfg Z鐩歌緭鍏ュ睆钄藉姛鑳介厤缃寚閽 + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * + *************************************************************************/ +en_result_t Adt_CfgZMask(M0P_ADTIM_TypeDef *ADTx, stc_adt_zmask_cfg_t* pstcAdtZMaskCfg) +{ + if(NULL == pstcAdtZMaskCfg) + { + return ErrorInvalidParameter; + } + + ADTx->GCONR_f.ZMSK = pstcAdtZMaskCfg->enZMaskCycle; + ADTx->GCONR_f.ZMSKPOS = pstcAdtZMaskCfg->bFltPosCntMaksEn; + ADTx->GCONR_f.ZMSKREV = pstcAdtZMaskCfg->bFltRevCntMaksEn; + + return Ok; +} + +//@} // AdtGroup + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/driver/src/aes.c b/driver/src/aes.c new file mode 100644 index 0000000..63fb2e7 --- /dev/null +++ b/driver/src/aes.c @@ -0,0 +1,206 @@ +/****************************************************************************** +*Copyright(C)2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file aes.c + ** + ** Common API of AES. + ** @link AesGroup Some description @endlink + ** + ** - 2019-04-16 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "aes.h" +/** + ******************************************************************************* + ** \addtogroup AesGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + * \brief + * AES 鍔犲瘑 + * + * \param [in] pstcAesCfg AES 閰嶇疆缁撴瀯浣 @ref stc_aes_cfg_t + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + */ +en_result_t AES_Encrypt(stc_aes_cfg_t* pstcAesCfg) +{ + if (NULL == pstcAesCfg) + { + return ErrorInvalidParameter; + } + + M0P_AES->CR_f.KEYSIZE = pstcAesCfg->enKeyLen; + + //Key cfg + M0P_AES->KEY0 = pstcAesCfg->pu32Key[0]; + M0P_AES->KEY1 = pstcAesCfg->pu32Key[1]; + M0P_AES->KEY2 = pstcAesCfg->pu32Key[2]; + M0P_AES->KEY3 = pstcAesCfg->pu32Key[3]; + + if(AesKey192 == pstcAesCfg->enKeyLen) + { + M0P_AES->KEY4 = pstcAesCfg->pu32Key[4]; + M0P_AES->KEY5 = pstcAesCfg->pu32Key[5]; + } + + if(AesKey256 == pstcAesCfg->enKeyLen) + { + M0P_AES->KEY4 = pstcAesCfg->pu32Key[4]; + M0P_AES->KEY5 = pstcAesCfg->pu32Key[5]; + M0P_AES->KEY6 = pstcAesCfg->pu32Key[6]; + M0P_AES->KEY7 = pstcAesCfg->pu32Key[7]; + } + + //Data cfg + M0P_AES->DATA0 = pstcAesCfg->pu32Plaintext[0]; + M0P_AES->DATA1 = pstcAesCfg->pu32Plaintext[1]; + M0P_AES->DATA2 = pstcAesCfg->pu32Plaintext[2]; + M0P_AES->DATA3 = pstcAesCfg->pu32Plaintext[3]; + + M0P_AES->CR_f.MODE = 0;//Encry + M0P_AES->CR_f.START = 1; + while(M0P_AES->CR_f.START == 1) + { + ; + } + pstcAesCfg->pu32Cipher[0] = M0P_AES->DATA0; + pstcAesCfg->pu32Cipher[1] = M0P_AES->DATA1; + pstcAesCfg->pu32Cipher[2] = M0P_AES->DATA2; + pstcAesCfg->pu32Cipher[3] = M0P_AES->DATA3; + return Ok; +} + + +/** + * \brief + * AES 瑙e瘑 + * + * \param [in] pstcAesCfg AES 閰嶇疆缁撴瀯浣 @ref stc_aes_cfg_t + * + * \retval en_result_t Ok: 閰嶇疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥鍙傛暟 + */ +en_result_t AES_Decrypt(stc_aes_cfg_t* pstcAesCfg) +{ + if (NULL == pstcAesCfg) + { + return ErrorInvalidParameter; + } + + M0P_AES->CR_f.KEYSIZE = pstcAesCfg->enKeyLen; + + //Key cfg + M0P_AES->KEY0 = pstcAesCfg->pu32Key[0]; + M0P_AES->KEY1 = pstcAesCfg->pu32Key[1]; + M0P_AES->KEY2 = pstcAesCfg->pu32Key[2]; + M0P_AES->KEY3 = pstcAesCfg->pu32Key[3]; + + if(AesKey192 == pstcAesCfg->enKeyLen) + { + M0P_AES->KEY4 = pstcAesCfg->pu32Key[4]; + M0P_AES->KEY5 = pstcAesCfg->pu32Key[5]; + } + + if(AesKey256 == pstcAesCfg->enKeyLen) + { + M0P_AES->KEY4 = pstcAesCfg->pu32Key[4]; + M0P_AES->KEY5 = pstcAesCfg->pu32Key[5]; + M0P_AES->KEY6 = pstcAesCfg->pu32Key[6]; + M0P_AES->KEY7 = pstcAesCfg->pu32Key[7]; + } + + //Data cfg + M0P_AES->DATA0 = pstcAesCfg->pu32Cipher[0]; + M0P_AES->DATA1 = pstcAesCfg->pu32Cipher[1]; + M0P_AES->DATA2 = pstcAesCfg->pu32Cipher[2]; + M0P_AES->DATA3 = pstcAesCfg->pu32Cipher[3]; + + M0P_AES->CR_f.MODE = 1;//UnEncry + M0P_AES->CR_f.START = 1; + while(M0P_AES->CR_f.START == 1) + { + ; + } + pstcAesCfg->pu32Plaintext[0] = M0P_AES->DATA0; + pstcAesCfg->pu32Plaintext[1] = M0P_AES->DATA1; + pstcAesCfg->pu32Plaintext[2] = M0P_AES->DATA2; + pstcAesCfg->pu32Plaintext[3] = M0P_AES->DATA3; + return Ok; +} + +//@} // AesGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/driver/src/bgr.c b/driver/src/bgr.c new file mode 100644 index 0000000..c500c87 --- /dev/null +++ b/driver/src/bgr.c @@ -0,0 +1,143 @@ +/****************************************************************************** +*Copyright(C)2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file bgr.c + ** + ** Common API of bgr. + ** @link flashGroup Some description @endlink + ** + ** - 2018-05-08 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "bgr.h" +/** + ******************************************************************************* + ** \addtogroup FlashGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ***************************************************************************** + ** \brief BGR 浣胯兘 + ** + ** + ** \retval Null + *****************************************************************************/ +void Bgr_BgrEnable(void) +{ + M0P_BGR->CR |= 0x1u; + + delay10us(2); +} + +/** + ***************************************************************************** + ** \brief BGR 绂佹 + ** + ** + ** \retval Null + *****************************************************************************/ +void Bgr_BgrDisable(void) +{ + M0P_BGR->CR &= 0x2u; +} + +/** + ***************************************************************************** + ** \brief BGR 娓╁害浼犳劅鍣ㄤ娇鑳(闇瑕佸厛寮鍚疊GR) + ** + ** + ** \retval Null + *****************************************************************************/ +void Bgr_TempSensorEnable(void) +{ + M0P_BGR->CR |= 0x2u; + + delay10us(2); +} + +/** + ***************************************************************************** + ** \brief BGR 娓╁害浼犳劅鍣ㄧ姝 + ** + ** + ** \retval Null + *****************************************************************************/ +void Bgr_TempSensorDisable(void) +{ + M0P_BGR->CR &= 0x1u; +} + + +//@} // BgrGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/driver/src/bt.c b/driver/src/bt.c new file mode 100644 index 0000000..27ecd1d --- /dev/null +++ b/driver/src/bt.c @@ -0,0 +1,1381 @@ +/****************************************************************************** +*Copyright(C)2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file bt.c + ** + ** Common API of base timer. + ** @link btGroup Some description @endlink + ** + ** - 2019-04-15 Husj First Version + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "bt.h" +/** + ******************************************************************************* + ** \addtogroup BtGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define IS_VALID_TIM(x) (TIM0 == (x) ||\ + TIM1 == (x) ||\ + TIM2 == (x)) + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ***************************************************************************** + ** \brief Base Timer 涓柇鏍囧織鑾峰彇(妯″紡0/1/23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] enBtIrq 涓柇绫诲瀷 + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +boolean_t Bt_GetIntFlag(en_bt_unit_t enUnit, en_bt_irq_type_t enBtIrq) +{ + boolean_t bRetVal = FALSE; + uint32_t u32Val; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + u32Val = pstcM0PBt->IFR; + bRetVal = (u32Val>>enBtIrq) & 0x1; + + return bRetVal; +} + +/** + ***************************************************************************** + ** \brief Base Timer 涓柇鏍囧織娓呴櫎(妯″紡0/1/23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] enBtIrq 涓柇绫诲瀷 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_ClearIntFlag(en_bt_unit_t enUnit, en_bt_irq_type_t enBtIrq) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->ICLR = ~(1u<ICLR = 0; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 涓柇浣胯兘(妯″紡0) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Mode0_EnableIrq(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE0_TypeDef *pstcM0PBt = (M0P_TIM0_MODE0_TypeDef *)((uint32_t)M0P_TIM0_MODE0+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M0CR_f.UIE = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 涓柇绂佹(妯″紡0) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Mode0_DisableIrq(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE0_TypeDef *pstcM0PBt = (M0P_TIM0_MODE0_TypeDef *)((uint32_t)M0P_TIM0_MODE0+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M0CR_f.UIE = FALSE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 涓柇浣胯兘(妯″紡1) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] enBtIrq 涓柇绫诲瀷 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Mode1_EnableIrq (en_bt_unit_t enUnit, en_bt_irq_type_t enBtIrq) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE1_TypeDef *pstcM0PBt = (M0P_TIM0_MODE1_TypeDef *)((uint32_t)M0P_TIM0_MODE1+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enBtIrq) + { + case BtUevIrq: + pstcM0PBt->M1CR_f.UIE = TRUE; + break; + case BtCA0Irq: + pstcM0PBt->CR0_f.CIEA = TRUE; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 涓柇绂佹(妯″紡1) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] enBtIrq 涓柇绫诲瀷 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Mode1_DisableIrq (en_bt_unit_t enUnit, en_bt_irq_type_t enBtIrq) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE1_TypeDef *pstcM0PBt = (M0P_TIM0_MODE1_TypeDef *)((uint32_t)M0P_TIM0_MODE1+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + + switch (enBtIrq) + { + case BtUevIrq: + pstcM0PBt->M1CR_f.UIE = FALSE; + break; + case BtCA0Irq: + pstcM0PBt->CR0_f.CIEA = FALSE; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 涓柇浣胯兘(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] enBtIrq 涓柇绫诲瀷 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Mode23_EnableIrq (en_bt_unit_t enUnit, en_bt_irq_type_t enBtIrq) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + + switch (enBtIrq) + { + case BtUevIrq: + pstcM0PBt->M23CR_f.UIE = TRUE; + break; + case BtCA0Irq: + pstcM0PBt->CRCH0_f.CIEA = TRUE; + break; + case BtCB0Irq: + pstcM0PBt->CRCH0_f.CIEB = TRUE; + break; + case BtBkIrq: + pstcM0PBt->M23CR_f.BIE = TRUE; + break; + case BtTrigIrq: + pstcM0PBt->M23CR_f.TIE = TRUE; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 涓柇绂佹(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] enBtIrq 涓柇绫诲瀷 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Mode23_DisableIrq (en_bt_unit_t enUnit, en_bt_irq_type_t enBtIrq) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + + switch (enBtIrq) + { + case BtUevIrq: + pstcM0PBt->M23CR_f.UIE = FALSE; + break; + case BtCA0Irq: + pstcM0PBt->CRCH0_f.CIEA = FALSE; + break; + case BtCB0Irq: + pstcM0PBt->CRCH0_f.CIEB = FALSE; + break; + case BtBkIrq: + pstcM0PBt->M23CR_f.BIE = FALSE; + break; + case BtTrigIrq: + pstcM0PBt->M23CR_f.TIE = FALSE; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 鍒濆鍖栭厤缃(妯″紡0) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Mode0_Init(en_bt_unit_t enUnit, stc_bt_mode0_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + volatile M0P_TIM0_MODE0_TypeDef *pstcM0PBt = (M0P_TIM0_MODE0_TypeDef *)((uint32_t)M0P_TIM0_MODE0+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M0CR_f.MODE = pstcCfg->enWorkMode; + pstcM0PBt->M0CR_f.GATEP = pstcCfg->enGateP; + pstcM0PBt->M0CR_f.GATE = pstcCfg->bEnGate; + pstcM0PBt->M0CR_f.PRS = pstcCfg->enPRS; + pstcM0PBt->M0CR_f.TOGEN = pstcCfg->bEnTog; + pstcM0PBt->M0CR_f.CT = pstcCfg->enCT; + pstcM0PBt->M0CR_f.MD = pstcCfg->enCntMode; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 鍚姩杩愯(妯″紡0) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M0_Run(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE0_TypeDef *pstcM0PBt = (M0P_TIM0_MODE0_TypeDef *)((uint32_t)M0P_TIM0_MODE0+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M0CR_f.CTEN = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 鍋滄杩愯(妯″紡0) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M0_Stop(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE0_TypeDef *pstcM0PBt = (M0P_TIM0_MODE0_TypeDef *)((uint32_t)M0P_TIM0_MODE0+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M0CR_f.CTEN = FALSE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 缈昏浆杈撳嚭浣胯兘/绂佹锛堜綆鐢靛钩锛夎瀹(妯″紡0) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] bEnTOG 缈昏浆杈撳嚭璁惧畾 TRUE:浣胯兘, FALSE:绂佹 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M0_EnTOG_Output(en_bt_unit_t enUnit, boolean_t bEnTOG) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE0_TypeDef *pstcM0PBt = (M0P_TIM0_MODE0_TypeDef *)((uint32_t)M0P_TIM0_MODE0+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M0CR_f.TOGEN = bEnTOG; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 绔彛杈撳嚭浣胯兘/绂佹璁惧畾(妯″紡0) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] bEnOutput 绔彛杈撳嚭璁惧畾 TRUE:浣胯兘, FALSE:绂佹 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M0_Enable_Output(en_bt_unit_t enUnit, boolean_t bEnOutput) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE0_TypeDef *pstcM0PBt = (M0P_TIM0_MODE0_TypeDef *)((uint32_t)M0P_TIM0_MODE0+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->DTR_f.MOE = bEnOutput; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 16浣嶈鏁板櫒鍒濆艰缃(妯″紡0) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] u16Data 16浣嶅垵鍊 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M0_Cnt16Set(en_bt_unit_t enUnit, uint16_t u16Data) +{ + en_result_t enResult = Ok; + + volatile M0P_TIM0_MODE0_TypeDef *pstcM0PBt = (M0P_TIM0_MODE0_TypeDef *)((uint32_t)M0P_TIM0_MODE0+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->CNT_f.CNT = u16Data; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 16浣嶈鏁板艰幏鍙(妯″紡0) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval 16bits璁℃暟鍊 + *****************************************************************************/ +uint16_t Bt_M0_Cnt16Get(en_bt_unit_t enUnit) +{ + uint16_t u16CntData = 0; + + volatile M0P_TIM0_MODE0_TypeDef *pstcM0PBt = (M0P_TIM0_MODE0_TypeDef *)((uint32_t)M0P_TIM0_MODE0+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + u16CntData = pstcM0PBt->CNT_f.CNT; + + return u16CntData; +} + +/** + ***************************************************************************** + ** \brief Base Timer 閲嶈浇鍊艰缃(妯″紡0) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] u16Data 16bits閲嶈浇鍊 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M0_ARRSet(en_bt_unit_t enUnit, uint16_t u16Data) +{ + en_result_t enResult = Ok; + + volatile M0P_TIM0_MODE0_TypeDef *pstcM0PBt = (M0P_TIM0_MODE0_TypeDef *)((uint32_t)M0P_TIM0_MODE0+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->ARR_f.ARR = u16Data; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 32浣嶈鏁板櫒鍒濆艰缃(妯″紡0) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] u32Data 32浣嶅垵鍊 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M0_Cnt32Set(en_bt_unit_t enUnit, uint32_t u32Data) +{ + en_result_t enResult = Ok; + + volatile M0P_TIM0_MODE0_TypeDef *pstcM0PBt = (M0P_TIM0_MODE0_TypeDef *)((uint32_t)M0P_TIM0_MODE0+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->CNT32_f.CNT32 = u32Data; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 32浣嶈鏁板艰幏鍙(妯″紡0) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval 32bits璁℃暟鍊 + *****************************************************************************/ +uint32_t Bt_M0_Cnt32Get(en_bt_unit_t enUnit) +{ + uint32_t u32CntData = 0; + + volatile M0P_TIM0_MODE0_TypeDef *pstcM0PBt = (M0P_TIM0_MODE0_TypeDef *)((uint32_t)M0P_TIM0_MODE0+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + u32CntData = pstcM0PBt->CNT32_f.CNT32; + + return u32CntData; +} + +/** + ***************************************************************************** + ** \brief Base Timer 鍒濆鍖栭厤缃(妯″紡1) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Mode1_Init(en_bt_unit_t enUnit, stc_bt_mode1_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + volatile M0P_TIM0_MODE1_TypeDef *pstcM0PBt = (M0P_TIM0_MODE1_TypeDef *)((uint32_t)M0P_TIM0_MODE1+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M1CR_f.MODE = pstcCfg->enWorkMode; + pstcM0PBt->M1CR_f.PRS = pstcCfg->enPRS; + pstcM0PBt->M1CR_f.CT = pstcCfg->enCT; + pstcM0PBt->M1CR_f.ONESHOT = pstcCfg->enOneShot; + + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer PWC 杈撳叆閰嶇疆(妯″紡1) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M1_Input_Cfg(en_bt_unit_t enUnit, stc_bt_pwc_input_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE1_TypeDef *pstcM0PBt = (M0P_TIM0_MODE1_TypeDef *)((uint32_t)M0P_TIM0_MODE1+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->MSCR_f.TS = pstcCfg->enTsSel; + pstcM0PBt->MSCR_f.IA0S = pstcCfg->enIA0Sel; + pstcM0PBt->MSCR_f.IB0S = pstcCfg->enIB0Sel; + pstcM0PBt->FLTR_f.ETP = pstcCfg->enETRPhase; + pstcM0PBt->FLTR_f.FLTET = pstcCfg->enFltETR; + pstcM0PBt->FLTR_f.FLTA0 = pstcCfg->enFltIA0; + pstcM0PBt->FLTR_f.FLTB0 = pstcCfg->enFltIB0; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer PWC娴嬮噺杈规部璧峰缁撴潫閫夋嫨(妯″紡1) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] enEdgeSel pwc娴嬮噺璧峰缁堟鐢靛钩 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M1_PWC_Edge_Sel(en_bt_unit_t enUnit,en_bt_m1cr_Edge_t enEdgeSel) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE1_TypeDef *pstcM0PBt = (M0P_TIM0_MODE1_TypeDef *)((uint32_t)M0P_TIM0_MODE1+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enEdgeSel) + { + case 0: ///< 涓婂崌娌垮埌涓婂崌娌(鍛ㄦ湡) + pstcM0PBt->M1CR_f.EDG1ST = 0; //涓婂崌娌 + pstcM0PBt->M1CR_f.EDG2ND = 0; //涓婂崌娌 + break; + case 1: ///< 涓嬮檷娌垮埌涓婂崌娌(浣庣數骞) + pstcM0PBt->M1CR_f.EDG1ST = 1; //涓嬮檷娌 + pstcM0PBt->M1CR_f.EDG2ND = 0; //涓婂崌娌 + break; + case 2: ///< 涓婂崌娌垮埌涓嬮檷娌(楂樼數骞) + pstcM0PBt->M1CR_f.EDG1ST = 0; //涓婂崌娌 + pstcM0PBt->M1CR_f.EDG2ND = 1; //涓嬮檷娌 + break; + case 3: ///< 涓嬮檷娌垮埌涓嬮檷娌(鍛ㄦ湡) + pstcM0PBt->M1CR_f.EDG1ST = 1; //涓嬮檷娌 + pstcM0PBt->M1CR_f.EDG2ND = 1; //涓嬮檷娌 + break; + default: + ; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 鍚姩杩愯(妯″紡1) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M1_Run(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE1_TypeDef *pstcM0PBt = (M0P_TIM0_MODE1_TypeDef *)((uint32_t)M0P_TIM0_MODE1+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M1CR_f.CTEN = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 鍋滄杩愯(妯″紡1) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M1_Stop(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE1_TypeDef *pstcM0PBt = (M0P_TIM0_MODE1_TypeDef *)((uint32_t)M0P_TIM0_MODE1+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M1CR_f.CTEN = FALSE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 16浣嶈鏁板櫒鍒濆艰缃(妯″紡1) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] u16Data 16浣嶅垵鍊 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M1_Cnt16Set(en_bt_unit_t enUnit, uint16_t u16Data) +{ + en_result_t enResult = Ok; + + volatile M0P_TIM0_MODE1_TypeDef *pstcM0PBt = (M0P_TIM0_MODE1_TypeDef *)((uint32_t)M0P_TIM0_MODE1+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->CNT_f.CNT = u16Data; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 16浣嶈鏁板艰幏鍙(妯″紡1) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval 16bits璁℃暟鍊 + *****************************************************************************/ +uint16_t Bt_M1_Cnt16Get(en_bt_unit_t enUnit) +{ + uint16_t u16CntData = 0; + + volatile M0P_TIM0_MODE1_TypeDef *pstcM0PBt = (M0P_TIM0_MODE1_TypeDef *)((uint32_t)M0P_TIM0_MODE1+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + u16CntData = pstcM0PBt->CNT_f.CNT; + + return u16CntData; +} + +/** + ***************************************************************************** + ** \brief Base Timer 鑴夊啿瀹藉害娴嬮噺缁撴灉鏁板艰幏鍙(妯″紡1) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval 16bits鑴夊啿瀹藉害娴嬮噺缁撴灉 + *****************************************************************************/ +uint16_t Bt_M1_PWC_CapValueGet(en_bt_unit_t enUnit) +{ + uint16_t u16CapData = 0; + + volatile M0P_TIM0_MODE1_TypeDef *pstcM0PBt = (M0P_TIM0_MODE1_TypeDef *)((uint32_t)M0P_TIM0_MODE1+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + u16CapData = pstcM0PBt->CCR0A_f.CCR0A; + + return u16CapData; +} + +/** + ***************************************************************************** + ** \brief Base Timer 鍒濆鍖栭厤缃(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Mode23_Init(en_bt_unit_t enUnit, stc_bt_mode23_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M23CR_f.MODE = pstcCfg->enWorkMode; + + pstcM0PBt->M23CR_f.PRS = pstcCfg->enPRS; + pstcM0PBt->M23CR_f.CT = pstcCfg->enCT; + pstcM0PBt->M23CR_f.COMP = pstcCfg->enPWMTypeSel; + pstcM0PBt->M23CR_f.PWM2S = pstcCfg->enPWM2sSel; + pstcM0PBt->M23CR_f.ONESHOT = pstcCfg->bOneShot; + pstcM0PBt->M23CR_f.URS = pstcCfg->bURSSel; + pstcM0PBt->M23CR_f.DIR = pstcCfg->enCntDir; + + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer PWM杈撳嚭浣胯兘/绂佹(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] bEnOutput PWM杈撳嚭浣胯兘/绂佹璁惧畾 + ** \param [in] bEnAutoOutput PWM鑷姩杈撳嚭浣胯兘/绂佹璁惧畾 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_EnPWM_Output(en_bt_unit_t enUnit, boolean_t bEnOutput, boolean_t bEnAutoOutput) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->DTR_f.MOE = bEnOutput; + pstcM0PBt->DTR_f.AOE = bEnAutoOutput; + + return enResult; +} + + +/** + ***************************************************************************** + ** \brief Base Timer 鍚姩杩愯(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_Run(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M23CR_f.CTEN = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 鍋滄杩愯(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_Stop(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M23CR_f.CTEN = FALSE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 閲嶈浇鍊艰缃(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] u16Data 16bits閲嶈浇鍊 + ** \param [in] bArrBufEn ARR閲嶈浇缂撳瓨浣胯兘TRUE/绂佹FALSE + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_ARRSet(en_bt_unit_t enUnit, uint16_t u16Data, boolean_t bArrBufEn) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->ARR_f.ARR = u16Data; + pstcM0PBt->M23CR_f.BUFPEN = bArrBufEn; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 16浣嶈鏁板櫒鍒濆艰缃(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] u16Data 16浣嶅垵鍊 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_Cnt16Set(en_bt_unit_t enUnit, uint16_t u16Data) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->CNT_f.CNT = u16Data; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 16浣嶈鏁板艰幏鍙(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval 16bits璁℃暟鍊 + *****************************************************************************/ +uint16_t Bt_M23_Cnt16Get(en_bt_unit_t enUnit) +{ + uint16_t u16CntData = 0; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + u16CntData = pstcM0PBt->CNT_f.CNT; + + return u16CntData; +} + +/** + ***************************************************************************** + ** \brief Base Timer 姣旇緝鎹曡幏瀵勫瓨鍣–CR0A/CCR0B璁剧疆(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] enCCRSel CCR0A/CCR0B璁惧畾 + ** \param [in] u16Data CCR0A/CCR0B 16浣嶅垵濮嬪 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_CCR_Set(en_bt_unit_t enUnit, en_bt_m23_ccrx_t enCCRSel, uint16_t u16Data) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + if(BtCCR0A == enCCRSel) + { + pstcM0PBt->CCR0A_f.CCR0A = u16Data; + } + else if(BtCCR0B == enCCRSel) + { + pstcM0PBt->CCR0B_f.CCR0B = u16Data; + } + else + { + enResult = Error; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 姣旇緝鎹曡幏瀵勫瓨鍣–CR0A/CCR0B璇诲彇(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] enCCRSel CCR0A/CCR0B璁惧畾 + ** + ** \retval 16bitsCCR0A鎹曡幏鍊 + *****************************************************************************/ +uint16_t Bt_M23_CCR_Get(en_bt_unit_t enUnit, en_bt_m23_ccrx_t enCCRSel) +{ + uint16_t u16Data = 0; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + if(BtCCR0A == enCCRSel) + { + u16Data = pstcM0PBt->CCR0A_f.CCR0A; + } + else if(BtCCR0B == enCCRSel) + { + u16Data = pstcM0PBt->CCR0B_f.CCR0B; + } + else + { + u16Data = 0; + } + + return u16Data; +} + +/** + ***************************************************************************** + ** \brief Base Timer PWM浜掕ˉ杈撳嚭妯″紡涓嬶紝GATE鍔熻兘閫夋嫨(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_GateFuncSel(en_bt_unit_t enUnit,stc_bt_m23_gate_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M23CR_f.CSG = pstcCfg->enGateFuncSel; + pstcM0PBt->M23CR_f.CRG = pstcCfg->bGateRiseCap; + pstcM0PBt->M23CR_f.CFG = pstcCfg->bGateFallCap; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 涓讳粠妯″紡閰嶇疆(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_MasterSlave_Set(en_bt_unit_t enUnit, stc_bt_m23_master_slave_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->MSCR_f.MSM = pstcCfg->enMasterSlaveSel; + pstcM0PBt->MSCR_f.MMS = pstcCfg->enMasterSrc; + pstcM0PBt->MSCR_f.SMS = pstcCfg->enSlaveModeSel; + pstcM0PBt->MSCR_f.TS = pstcCfg->enTsSel; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer CH0A/CH0B姣旇緝閫氶亾杈撳嚭鎺у埗(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_PortOutput_Cfg(en_bt_unit_t enUnit, stc_bt_m23_compare_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->CRCH0_f.CSA = 0; + pstcM0PBt->FLTR_f.OCMA0_FLTA0 = pstcCfg->enCH0ACmpCtrl; + pstcM0PBt->FLTR_f.CCPA0 = pstcCfg->enCH0APolarity; + pstcM0PBt->CRCH0_f.BUFEA = pstcCfg->bCh0ACmpBufEn; + pstcM0PBt->M23CR_f.CIS = pstcCfg->enCh0ACmpIntSel; + + pstcM0PBt->CRCH0_f.CSB = 0; + pstcM0PBt->FLTR_f.OCMB0_FLTB0 = pstcCfg->enCH0BCmpCtrl; + pstcM0PBt->FLTR_f.CCPB0 = pstcCfg->enCH0BPolarity; + pstcM0PBt->CRCH0_f.BUFEB = pstcCfg->bCH0BCmpBufEn; + pstcM0PBt->CRCH0_f.CISB = pstcCfg->enCH0BCmpIntSel; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer CH0A/CH0B杈撳叆鎺у埗(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_PortInput_Cfg(en_bt_unit_t enUnit, stc_bt_m23_input_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->CRCH0_f.CSA = 1; + pstcM0PBt->CRCH0_f.CFA_CRA_BKSA = pstcCfg->enCH0ACapSel; + pstcM0PBt->FLTR_f.OCMA0_FLTA0 = pstcCfg->enCH0AInFlt; + pstcM0PBt->FLTR_f.CCPA0 = pstcCfg->enCH0APolarity; + + pstcM0PBt->CRCH0_f.CSB = 1; + pstcM0PBt->CRCH0_f.CFB_CRB_BKSB = pstcCfg->enCH0BCapSel; + pstcM0PBt->FLTR_f.OCMB0_FLTB0 = pstcCfg->enCH0BInFlt; + pstcM0PBt->FLTR_f.CCPB0 = pstcCfg->enCH0BPolarity; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer ERT杈撳叆鎺у埗(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_ETRInput_Cfg(en_bt_unit_t enUnit, stc_bt_m23_etr_input_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->FLTR_f.ETP = pstcCfg->enETRPolarity; + pstcM0PBt->FLTR_f.FLTET = pstcCfg->enETRFlt; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 鍒硅溅BK杈撳叆鎺у埗(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_BrakeInput_Cfg(en_bt_unit_t enUnit, stc_bt_m23_bk_input_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->DTR_f.BKE = pstcCfg->bEnBrake; + pstcM0PBt->DTR_f.VCE = pstcCfg->bEnVCBrake; + pstcM0PBt->DTR_f.SAFEEN = pstcCfg->bEnSafetyBk; + pstcM0PBt->DTR_f.BKSEL = pstcCfg->bEnBKSync; + pstcM0PBt->CRCH0_f.CFA_CRA_BKSA = pstcCfg->enBkCH0AStat; + pstcM0PBt->CRCH0_f.CFB_CRB_BKSB = pstcCfg->enBkCH0BStat; + pstcM0PBt->FLTR_f.BKP = pstcCfg->enBrakePolarity; + pstcM0PBt->FLTR_f.FLTBK = pstcCfg->enBrakeFlt; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 瑙﹀彂ADC鎺у埗(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_TrigADC_Cfg(en_bt_unit_t enUnit, stc_bt_m23_adc_trig_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->ADTR_f.ADTE = pstcCfg->bEnTrigADC; + pstcM0PBt->ADTR_f.UEVE = pstcCfg->bEnUevTrigADC; + pstcM0PBt->ADTR_f.CMA0E = pstcCfg->bEnCH0ACmpTrigADC; + pstcM0PBt->ADTR_f.CMB0E = pstcCfg->bEnCH0BCmpTrigADC; + + return enResult; +} + +/** + ***************************************************************************** +** \brief Base Timer 姝诲尯鍔熻兘(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_DT_Cfg(en_bt_unit_t enUnit, stc_bt_m23_dt_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->DTR_f.DTEN = pstcCfg->bEnDeadTime; + pstcM0PBt->DTR_f.DTR = pstcCfg->u8DeadTimeValue; + + return enResult; +} + +/** + ***************************************************************************** +** \brief Base Timer 閲嶅鍛ㄦ湡璁剧疆(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] u8ValidPeriod 閲嶅鍛ㄦ湡鍊 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_SetValidPeriod(en_bt_unit_t enUnit, uint8_t u8ValidPeriod) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->RCR_f.RCR = u8ValidPeriod; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer OCREF娓呴櫎鍔熻兘(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_OCRefClr(en_bt_unit_t enUnit, stc_bt_m23_OCREF_Clr_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M23CR_f.OCCS = pstcCfg->enOCRefClrSrcSel; + pstcM0PBt->M23CR_f.OCCE = pstcCfg->bVCClrEn; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 浣胯兘DMA浼犺緭(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_EnDMA(en_bt_unit_t enUnit, stc_bt_m23_trig_dma_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M23CR_f.UDE = pstcCfg->bUevTrigDMA; + pstcM0PBt->M23CR_f.TDE = pstcCfg->bTITrigDMA; + pstcM0PBt->CRCH0_f.CDEA = pstcCfg->bCmpATrigDMA; + pstcM0PBt->CRCH0_f.CDEB = pstcCfg->bCmpBTrigDMA; + pstcM0PBt->MSCR_f.CCDS = pstcCfg->enCmpUevTrigDMA; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 鎹曡幏姣旇緝A杞欢瑙﹀彂(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_EnSwTrigCapCmpA(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->CRCH0_f.CCGA = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 鎹曡幏姣旇緝B杞欢瑙﹀彂(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_EnSwTrigCapCmpB(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->CRCH0_f.CCGB = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 杞欢鏇存柊浣胯兘(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_EnSwUev(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M23CR_f.UG = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 杞欢瑙﹀彂浣胯兘(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_EnSwTrig(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M23CR_f.TG = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 杞欢鍒硅溅浣胯兘(妯″紡23) + ** + ** + ** \param [in] enUnit Timer閫氶亾閫夋嫨锛圱IM0銆乀IM1銆乀IM2锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_M23_EnSwBk(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + volatile M0P_TIM0_MODE23_TypeDef *pstcM0PBt = (M0P_TIM0_MODE23_TypeDef *)((uint32_t)M0P_TIM0_MODE23+0x100*enUnit); + ASSERT(IS_VALID_TIM(enUnit)); + + pstcM0PBt->M23CR_f.BG = TRUE; + + return enResult; +} + +//@} // BtGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/driver/src/crc.c b/driver/src/crc.c new file mode 100644 index 0000000..aab257f --- /dev/null +++ b/driver/src/crc.c @@ -0,0 +1,438 @@ +/****************************************************************************** +*Copyright(C)2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file crc.c + ** + ** Common API of crc. + ** @link crcGroup Some description @endlink + ** + ** - 2017-05-16 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "crc.h" +/** + ******************************************************************************* + ** \addtogroup CrcGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ***************************************************************************** + ** \brief CRC16 缂栫爜(瀛楄妭濉厖鏂瑰紡) + ** + ** 璇ュ嚱鏁颁富瑕佺敤浜庣敓鎴怌RC16缂栫爜. + ** + ** \param [in] pu8Data 寰呯紪鐮佹暟鎹寚閽堬紙瀛楄妭鏂瑰紡杈撳叆锛 + ** \param [in] u32Len 寰呯紪鐮佹暟鎹暱搴︼紙瀛楄妭鏁帮級 + ** + ** \retval CRC16 CRC16缂栫爜鍊. + *****************************************************************************/ +uint16_t CRC16_Get8(uint8_t* pu8Data, uint32_t u32Len) +{ + uint32_t u32Index = 0; + + M0P_CRC->CR_f.CR = 0; + M0P_CRC->RESULT = 0xFFFF; + for(u32Index = 0;u32IndexDATA))) = pu8Data[u32Index]; + } + + return (M0P_CRC->RESULT_f.RESULT); +} + +/** + ***************************************************************************** + ** \brief CRC16 缂栫爜(鍗婂瓧濉厖鏂瑰紡) + ** + ** 璇ュ嚱鏁颁富瑕佺敤浜庣敓鎴怌RC16缂栫爜. + ** + ** \param [in] pu16Data 寰呯紪鐮佹暟鎹寚閽堬紙鍗婂瓧鏂瑰紡杈撳叆锛 + ** \param [in] u32Len 寰呯紪鐮佹暟鎹暱搴︼紙鍗婂瓧鏁帮級 + ** + ** \retval CRC16 CRC16缂栫爜鍊. + *****************************************************************************/ +uint16_t CRC16_Get16(uint16_t* pu16Data, uint32_t u32Len) +{ + uint32_t u32Index = 0; + + M0P_CRC->CR_f.CR = 0; + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA))) = pu16Data[u32Index]; + } + + return (M0P_CRC->RESULT_f.RESULT); +} + +/** + ***************************************************************************** + ** \brief CRC16 缂栫爜(瀛楀~鍏呮柟寮) + ** + ** 璇ュ嚱鏁颁富瑕佺敤浜庣敓鎴怌RC16缂栫爜. + ** + ** \param [in] pu32Data 寰呯紪鐮佹暟鎹寚閽堬紙瀛楁柟寮忚緭鍏ワ級 + ** \param [in] u32Len 寰呯紪鐮佹暟鎹暱搴︼紙瀛楁暟锛 + ** + ** \retval CRC16 CRC16缂栫爜鍊. + *****************************************************************************/ +uint16_t CRC16_Get32(uint32_t* pu32Data, uint32_t u32Len) +{ + uint32_t u32Index = 0; + + M0P_CRC->CR_f.CR = 0; + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA_f.DATA = pu32Data[u32Index]; + } + + return (M0P_CRC->RESULT_f.RESULT); +} + +/** + ***************************************************************************** + ** \brief CRC16 鏍¢獙(瀛楄妭濉厖鏂瑰紡) + ** + ** 璇ュ嚱鏁颁富瑕佺敤浜庡鏁版嵁鍙奀RC16鍊艰繘琛屾牎楠. + ** + ** \param [in] pu8Data 寰呮牎楠屾暟鎹寚閽堬紙瀛楄妭鏂瑰紡杈撳叆锛 + ** \param [in] u32Len 寰呮牎楠屾暟鎹暱搴︼紙瀛楄妭鏁帮級 + ** \param [in] u16CRC 寰呮牎楠孋RC16鍊 + ** + ** \retval Ok CRC鏍¢獙姝g‘ + ** \retval Error CRC鏍¢獙閿欒 + *****************************************************************************/ +en_result_t CRC16_Check8(uint8_t* pu8Data, uint32_t u32Len, uint16_t u16CRC) +{ + en_result_t enResult = Ok; + uint32_t u32Index = 0; + + M0P_CRC->CR_f.CR = 0; + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA))) = pu8Data[u32Index]; + } + + *((volatile uint8_t*)(&(M0P_CRC->DATA))) = (uint8_t)((((uint32_t)u16CRC)>>0)&0xFF); + *((volatile uint8_t*)(&(M0P_CRC->DATA))) = (uint8_t)(((uint32_t)u16CRC>>8)&0xFF); + + enResult = M0P_CRC->CR_f.FLAG ? Ok : Error; + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief CRC16 鏍¢獙(鍗婂瓧濉厖鏂瑰紡) + ** + ** 璇ュ嚱鏁颁富瑕佺敤浜庡鏁版嵁鍙奀RC16鍊艰繘琛屾牎楠. + ** + ** \param [in] pu16Data 寰呮牎楠屾暟鎹寚閽堬紙鍗婂瓧鏂瑰紡杈撳叆锛 + ** \param [in] u32Len 寰呮牎楠屾暟鎹暱搴︼紙鍗婂瓧鏁帮級 + ** \param [in] u16CRC 寰呮牎楠孋RC16鍊 + ** + ** \retval Ok CRC鏍¢獙姝g‘ + ** \retval Error CRC鏍¢獙閿欒 + *****************************************************************************/ +en_result_t CRC16_Check16(uint16_t* pu16Data, uint32_t u32Len, uint16_t u16CRC) +{ + en_result_t enResult = Ok; + uint32_t u32Index = 0; + + M0P_CRC->CR_f.CR = 0; + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA))) = pu16Data[u32Index]; + } + + *((volatile uint16_t*)(&(M0P_CRC->DATA))) = u16CRC; + + enResult = M0P_CRC->CR_f.FLAG ? Ok : Error; + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief CRC16 鏍¢獙(瀛楀~鍏呮柟寮) + ** + ** 璇ュ嚱鏁颁富瑕佺敤浜庡鏁版嵁鍙奀RC16鍊艰繘琛屾牎楠. + ** + ** \param [in] pu32Data 寰呮牎楠屾暟鎹寚閽堬紙瀛楁柟寮忚緭鍏ワ級 + ** \param [in] u32Len 寰呮牎楠屾暟鎹暱搴︼紙瀛楁暟锛 + ** \param [in] u16CRC 寰呮牎楠孋RC16鍊 + ** + ** \retval Ok CRC鏍¢獙姝g‘ + ** \retval Error CRC鏍¢獙閿欒 + *****************************************************************************/ +en_result_t CRC16_Check32(uint32_t* pu32Data, uint32_t u32Len, uint16_t u16CRC) +{ + en_result_t enResult = Ok; + uint32_t u32Index = 0; + + M0P_CRC->CR_f.CR = 0; + M0P_CRC->RESULT_f.RESULT = 0xFFFFFFFFu; + for (u32Index=0; u32IndexDATA))) = pu32Data[u32Index]; + } + + *((volatile uint16_t*)(&(M0P_CRC->DATA))) = ((uint16_t)u16CRC); + + enResult = M0P_CRC->CR_f.FLAG ? Ok : Error; + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief CRC16 缂栫爜(瀛楄妭濉厖鏂瑰紡) + ** + ** 璇ュ嚱鏁颁富瑕佺敤浜庣敓鎴怌RC16缂栫爜. + ** + ** \param [in] pu8Data 寰呯紪鐮佹暟鎹寚閽堬紙瀛楄妭鏂瑰紡杈撳叆锛 + ** \param [in] u32Len 寰呯紪鐮佹暟鎹暱搴︼紙瀛楄妭鏁帮級 + ** + ** \retval CRC16 CRC16缂栫爜鍊. + *****************************************************************************/ +uint32_t CRC32_Get8(uint8_t* pu8Data, uint32_t u32Len) +{ + uint32_t u32Index = 0; + + M0P_CRC->CR_f.CR = 1; + M0P_CRC->RESULT = 0xFFFFFFFFu; + for(u32Index = 0;u32IndexDATA))) = pu8Data[u32Index]; + } + + return (M0P_CRC->RESULT_f.RESULT); +} + +/** + ***************************************************************************** + ** \brief CRC16 缂栫爜(鍗婂瓧濉厖鏂瑰紡) + ** + ** 璇ュ嚱鏁颁富瑕佺敤浜庣敓鎴怌RC16缂栫爜. + ** + ** \param [in] pu16Data 寰呯紪鐮佹暟鎹寚閽堬紙鍗婂瓧鏂瑰紡杈撳叆锛 + ** \param [in] u32Len 寰呯紪鐮佹暟鎹暱搴︼紙鍗婂瓧鏁帮級 + ** + ** \retval CRC16 CRC16缂栫爜鍊. + *****************************************************************************/ +uint32_t CRC32_Get16(uint16_t* pu16Data, uint32_t u32Len) +{ + uint32_t u32Index = 0; + + M0P_CRC->CR_f.CR = 1; + M0P_CRC->RESULT_f.RESULT = 0xFFFFFFFFu; + for (u32Index=0; u32IndexDATA))) = pu16Data[u32Index]; + } + + return (M0P_CRC->RESULT_f.RESULT); +} + +/** + ***************************************************************************** + ** \brief CRC16 缂栫爜(瀛楀~鍏呮柟寮) + ** + ** 璇ュ嚱鏁颁富瑕佺敤浜庣敓鎴怌RC16缂栫爜. + ** + ** \param [in] pu32Data 寰呯紪鐮佹暟鎹寚閽堬紙瀛楁柟寮忚緭鍏ワ級 + ** \param [in] u32Len 寰呯紪鐮佹暟鎹暱搴︼紙瀛楁暟锛 + ** + ** \retval CRC16 CRC16缂栫爜鍊. + *****************************************************************************/ +uint32_t CRC32_Get32(uint32_t* pu32Data, uint32_t u32Len) +{ + uint32_t u32Index = 0; + + M0P_CRC->CR_f.CR = 1; + M0P_CRC->RESULT_f.RESULT = 0xFFFFFFFFu; + for (u32Index=0; u32IndexDATA_f.DATA = pu32Data[u32Index]; + } + + return (M0P_CRC->RESULT_f.RESULT); +} + +/** + ***************************************************************************** + ** \brief CRC16 鏍¢獙(瀛楄妭濉厖鏂瑰紡) + ** + ** 璇ュ嚱鏁颁富瑕佺敤浜庡鏁版嵁鍙奀RC16鍊艰繘琛屾牎楠. + ** + ** \param [in] pu8Data 寰呮牎楠屾暟鎹寚閽堬紙瀛楄妭鏂瑰紡杈撳叆锛 + ** \param [in] u32Len 寰呮牎楠屾暟鎹暱搴︼紙瀛楄妭鏁帮級 + ** \param [in] u16CRC 寰呮牎楠孋RC16鍊 + ** + ** \retval Ok CRC鏍¢獙姝g‘ + ** \retval Error CRC鏍¢獙閿欒 + *****************************************************************************/ +en_result_t CRC32_Check8(uint8_t* pu8Data, uint32_t u32Len, uint32_t u32CRC) +{ + en_result_t enResult = Ok; + uint32_t u32Index = 0; + + M0P_CRC->CR_f.CR = 1; + M0P_CRC->RESULT_f.RESULT = 0xFFFFFFFFu; + for (u32Index=0; u32IndexDATA))) = pu8Data[u32Index]; + } + + *((volatile uint8_t*)(&(M0P_CRC->DATA))) = (uint8_t)((u32CRC>>0)&0xFF); + *((volatile uint8_t*)(&(M0P_CRC->DATA))) = (uint8_t)((u32CRC>>8)&0xFF); + *((volatile uint8_t*)(&(M0P_CRC->DATA))) = (uint8_t)((u32CRC>>16)&0xFF); + *((volatile uint8_t*)(&(M0P_CRC->DATA))) = (uint8_t)((u32CRC>>24)&0xFF); + + enResult = M0P_CRC->CR_f.FLAG ? Ok : Error; + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief CRC16 鏍¢獙(鍗婂瓧濉厖鏂瑰紡) + ** + ** 璇ュ嚱鏁颁富瑕佺敤浜庡鏁版嵁鍙奀RC16鍊艰繘琛屾牎楠. + ** + ** \param [in] pu16Data 寰呮牎楠屾暟鎹寚閽堬紙鍗婂瓧鏂瑰紡杈撳叆锛 + ** \param [in] u32Len 寰呮牎楠屾暟鎹暱搴︼紙鍗婂瓧鏁帮級 + ** \param [in] u16CRC 寰呮牎楠孋RC16鍊 + ** + ** \retval Ok CRC鏍¢獙姝g‘ + ** \retval Error CRC鏍¢獙閿欒 + *****************************************************************************/ +en_result_t CRC32_Check16(uint16_t* pu16Data, uint32_t u32Len, uint32_t u32CRC) +{ + en_result_t enResult = Ok; + uint32_t u32Index = 0; + + M0P_CRC->CR_f.CR = 1; + M0P_CRC->RESULT_f.RESULT = 0xFFFFFFFFu; + for (u32Index=0; u32IndexDATA))) = pu16Data[u32Index]; + } + + *((volatile uint16_t*)(&(M0P_CRC->DATA))) = (uint16_t)((u32CRC>>0)&0xFFFF); + *((volatile uint16_t*)(&(M0P_CRC->DATA))) = (uint16_t)((u32CRC>>16)&0xFFFF); + + + enResult = M0P_CRC->CR_f.FLAG ? Ok : Error; + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief CRC16 鏍¢獙(瀛楀~鍏呮柟寮) + ** + ** 璇ュ嚱鏁颁富瑕佺敤浜庡鏁版嵁鍙奀RC16鍊艰繘琛屾牎楠. + ** + ** \param [in] pu32Data 寰呮牎楠屾暟鎹寚閽堬紙瀛楁柟寮忚緭鍏ワ級 + ** \param [in] u32Len 寰呮牎楠屾暟鎹暱搴︼紙瀛楁暟锛 + ** \param [in] u16CRC 寰呮牎楠孋RC16鍊 + ** + ** \retval Ok CRC鏍¢獙姝g‘ + ** \retval Error CRC鏍¢獙閿欒 + *****************************************************************************/ +en_result_t CRC32_Check32(uint32_t* pu32Data, uint32_t u32Len, uint32_t u32CRC) +{ + en_result_t enResult = Ok; + uint32_t u32Index = 0; + + M0P_CRC->CR_f.CR = 1; + M0P_CRC->RESULT_f.RESULT = 0xFFFFFFFFu; + for (u32Index=0; u32IndexDATA))) = pu32Data[u32Index]; + } + + *((volatile uint32_t*)(&(M0P_CRC->DATA))) = u32CRC; + + enResult = M0P_CRC->CR_f.FLAG ? Ok : Error; + + return (enResult); +} +//@} // CrcGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/driver/src/dac.c b/driver/src/dac.c new file mode 100644 index 0000000..9fb01fa --- /dev/null +++ b/driver/src/dac.c @@ -0,0 +1,253 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file dac.c + ** + ** dac driver API. + ** + ** - 2019-04-10 First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "dac.h" + +/** + ****************************************************************************** + ** \addtogroup AdcGroup + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/****************************************************************************** + * Local variable definitions ('static') + ******************************************************************************/ + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + *****************************************************************************/ + +/** +****************************************************************************** + ** \brief 浣胯兘鐩稿叧閫氶亾鐨凞MA DMA_CR0涓殑DMAEN0 + ** + ** @param NewState : TRUE 鎴栬 FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Dac_DmaCmd(boolean_t NewState) +{ + SetBit((uint32_t)(&(M0P_DAC->CR0)), 12, NewState); +} + +/** +****************************************************************************** + ** \brief 閰嶇疆DAC鐨凞MA涓嬫孩涓柇锛 DMA_CR0涓殑DMAUDRIE0 + ** + ** @param NewState : TRUE 鎴栬 FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Dac_DmaITCfg(boolean_t NewState) +{ + SetBit((uint32_t)(&(M0P_DAC->CR0)), 13, NewState); +} + +/** +****************************************************************************** + ** \brief 鑾峰彇DAC鐨凞MA涓嬫孩涓柇鏍囧織浣嶇姸鎬侊紝 DMA_SR涓殑DMAUDR0 + ** + ** @param 鏃 + ** \retval TRUE 鎴 FALSE + ** +******************************************************************************/ +boolean_t Dac_GetITStatus(void) +{ + return GetBit((uint32_t)(&(M0P_DAC->SR)), 13); +} + +/** +****************************************************************************** + ** \brief 閰嶇疆DAC鐨勪娇鑳戒笌绂佹锛 DMA_CR0涓殑EN0 + ** + ** @param NewState : TRUE 鎴栬 FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Dac_Cmd(boolean_t NewState) +{ + SetBit((uint32_t)(&(M0P_DAC->CR0)), 0, NewState); +} + +/** +****************************************************************************** + ** \brief 杞欢瑙﹀彂瀵勫瓨鍣紝瑙﹀彂DAC杞崲 DMA_SWTRIGR涓殑SWTRIG0 + ** + ** @param 鏃 + ** \retval 鏃 + ** +******************************************************************************/ +void Dac_SoftwareTriggerCmd(void) +{ + SetBit((uint32_t)(&(M0P_DAC->SWTRIGR)), 0, 1); +} + +/** +****************************************************************************** +** \brief 鍒濆鍖朌AC0 + ** + ** @param DAC_InitStruct : 鐢ㄤ簬鍒濆鍖朌AC0鐨勭粨鏋勪綋 + ** \retval 鏃 + ** +******************************************************************************/ +void Dac_Init(stc_dac_cfg_t* DAC_InitStruct) +{ + M0P_DAC->CR0_f.BOFF0 = DAC_InitStruct->boff_t; + M0P_DAC->CR0_f.TEN0 = DAC_InitStruct->ten_t; + M0P_DAC->CR0_f.TSEL0 = DAC_InitStruct->tsel_t; + M0P_DAC->CR0_f.WAVE0 = DAC_InitStruct->wave_t; + M0P_DAC->CR0_f.MAMP0 = DAC_InitStruct->mamp_t; + M0P_DAC->CR0_f.SREF0 = DAC_InitStruct->sref_t; + + if(DAC_InitStruct->align == DacLeftAlign) + { + M0P_DAC->DHR12L0_f.DHR0 = DAC_InitStruct->dhr12; + } + else if(DAC_InitStruct->align == DacRightAlign) + { + M0P_DAC->DHR12R0_f.DHR0 = DAC_InitStruct->dhr12; + } + else + { + M0P_DAC->DHR8R0_f.DHR0 = DAC_InitStruct->dhr8; + } +} + +/** +****************************************************************************** +** \brief 鍚慏AC0鐨勬暟鎹繚鎸佸瘎瀛樺櫒鍐欐暟鎹 + ** + ** @param DAC_Channel: Dac_0 + ** @param DAC_Align : Right_Align 涓嶭eft_Align + ** @param DAC_Bit : Bit8 涓嶣it12 + ** @param Data : 鎵瑕佸彂閫佺殑鏁版嵁 + ** \retval 鏃 + ** +******************************************************************************/ +void Dac_SetChannelData(en_align_t DAC_Align, en_bitno_t DAC_Bit, uint16_t Data) +{ + if(DAC_Align == DacRightAlign) + { + if(DAC_Bit == DacBit8) + { + M0P_DAC->DHR8R0_f.DHR0 = (uint8_t)Data; + } + else if(DAC_Bit == DacBit12) + { + M0P_DAC->DHR12R0_f.DHR0 = Data; + } + else + { + return; + } + } + else if(DAC_Align == DacLeftAlign) + { + if(DAC_Bit == DacBit8) + { + return; + } + else if(DAC_Bit == DacBit12) + { + M0P_DAC->DHR12L0_f.DHR0 = Data; + } + else + { + return; + } + } + else + { + return; + } +} + + + +/** +****************************************************************************** + ** \brief 鑾峰彇DAC鏁版嵁杈撳嚭瀵勫瓨鍣―AC_DOR0 + ** + ** @param 鏃 + ** \retval DAC_DOR0鐨勫 + ** +******************************************************************************/ +uint16_t Dac_GetDataOutputValue(void) +{ + uint16_t tmp; + + tmp = M0P_DAC->DOR0_f.DOR0; + return tmp&0x0fff; +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/driver/src/ddl.c b/driver/src/ddl.c new file mode 100644 index 0000000..f2457e4 --- /dev/null +++ b/driver/src/ddl.c @@ -0,0 +1,250 @@ +/******************************************************************************* +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl.c + ** + ** Common API of DDL. + ** @link ddlGroup Some description @endlink + ** + ** - 2019-03-03 + ** + ******************************************************************************/ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "ddl.h" + +/** + ****************************************************************************** + ** \addtogroup DDL Common Functions + ******************************************************************************/ +//@{ + +/******************************************************************************/ +/* Local pre-processor symbols/macros ('#define') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Global variable definitions (declared in header file with 'extern') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local type definitions ('typedef') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local variable definitions ('static') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local function prototypes ('static') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Function implementation - global ('extern') and local ('static') */ +/******************************************************************************/ +#ifndef __DEBUG +#define __DEBUG +//#define __CC_ARM +#endif + +uint32_t Log2(uint32_t u32Val) +{ + uint32_t u32V1 = 0; + + if(0u == u32Val) + { + return 0; + } + + while(u32Val > 1u) + { + u32V1++; + u32Val /=2; + } + + return u32V1; +} + + +/** + ******************************************************************************* + ** \brief Memory clear function for DDL_ZERO_STRUCT() + ******************************************************************************/ +void ddl_memclr(void *pu8Address, uint32_t u32Count) +{ + uint8_t *pu8Addr = (uint8_t *)pu8Address; + + if(NULL == pu8Addr) + { + return; + } + + while (u32Count--) + { + *pu8Addr++ = 0; + } +} + +/** + * \brief delay1ms + * delay approximately 1ms. + * \param [in] u32Cnt + * \retval void + */ +void delay1ms(uint32_t u32Cnt) +{ + uint32_t u32end; + + SysTick->LOAD = 0xFFFFFF; + SysTick->VAL = 0; + SysTick->CTRL = SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk; + + while(u32Cnt-- > 0) + { + SysTick->VAL = 0; + u32end = 0x1000000 - SystemCoreClock/1000; + while(SysTick->VAL > u32end) + { + ; + } + } + + SysTick->CTRL = (SysTick->CTRL & (~SysTick_CTRL_ENABLE_Msk)); +} + +/** + * \brief delay100us + * delay approximately 100us. + * \param [in] u32Cnt + * \retval void + */ +void delay100us(uint32_t u32Cnt) +{ + uint32_t u32end; + + SysTick->LOAD = 0xFFFFFF; + SysTick->VAL = 0; + SysTick->CTRL = SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk; + + while(u32Cnt-- > 0) + { + SysTick->VAL = 0; + + u32end = 0x1000000 - SystemCoreClock/10000; + while(SysTick->VAL > u32end) + { + ; + } + } + + SysTick->CTRL = (SysTick->CTRL & (~SysTick_CTRL_ENABLE_Msk)); +} + +/** + * \brief delay10us + * delay approximately 10us. + * \param [in] u32Cnt + * \retval void + */ +void delay10us(uint32_t u32Cnt) +{ + uint32_t u32end; + + SysTick->LOAD = 0xFFFFFF; + SysTick->VAL = 0; + SysTick->CTRL = SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk; + + while(u32Cnt-- > 0) + { + SysTick->VAL = 0; + + u32end = 0x1000000 - SystemCoreClock/100000; + while(SysTick->VAL > u32end) + { + ; + } + } + + SysTick->CTRL = (SysTick->CTRL & (~SysTick_CTRL_ENABLE_Msk)); +} + +/** + * \brief set register bit + * + * \param [in] addr + * \param [in] offset + * \retval void + */ +void SetBit(uint32_t addr, uint32_t offset, boolean_t bFlag) +{ + if(TRUE == bFlag) + { + *((volatile uint32_t *)(addr)) |= ((1UL)<<(offset)); + } + else + { + *((volatile uint32_t *)(addr)) &= (~(1UL<<(offset))); + } + + +} + + +/** + * \brief get register bit + * + * \param [in] addr + * \param [in] offset + * \retval void + */ +boolean_t GetBit(uint32_t addr, uint32_t offset) +{ + return ((((*((volatile uint32_t *)(addr))) >> (offset)) & 1u) > 0) ? TRUE : FALSE; +} +//@} // DDL Functions + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/driver/src/debug.c b/driver/src/debug.c new file mode 100644 index 0000000..c7fb0fc --- /dev/null +++ b/driver/src/debug.c @@ -0,0 +1,119 @@ +/****************************************************************************** +*Copyright(C)2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file debug.c + ** + ** Common API of debug. + ** @link flashGroup Some description @endlink + ** + ** - 2018-05-08 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "debug.h" +/** + ******************************************************************************* + ** \addtogroup FlashGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ***************************************************************************** + ** \brief 璋冭瘯妯″紡涓嬫ā鍧楀姛鑳借鏁颁娇鑳 + ** + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +en_result_t Debug_ActiveEnable(en_debug_module_active_t enModule) +{ + M0P_DEBUG_ACTIVE->DEBUG_ACTIVE &= ~(uint32_t)enModule; + + return Ok; +} + +/** + ***************************************************************************** + ** \brief 璋冭瘯妯″紡涓嬫ā鍧楀姛鑳借鏁版殏鍋 + ** + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +en_result_t Debug_ActiveDisable(en_debug_module_active_t enModule) +{ + M0P_DEBUG_ACTIVE->DEBUG_ACTIVE |= (uint32_t)enModule; + + return Ok; +} + + +//@} // BgrGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/driver/src/dmac.c b/driver/src/dmac.c new file mode 100644 index 0000000..7bb6234 --- /dev/null +++ b/driver/src/dmac.c @@ -0,0 +1,624 @@ +/****************************************************************************** +* Copyright (C) 2016, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file dmac.c +** +** A detailed description is available at +** @link DmacGroup Dmac description @endlink +** +** - 2018-03-09 1.0 Hongjh First version for Device Driver Library of Dmac. +** +******************************************************************************/ + +/******************************************************************************* +* Include files +******************************************************************************/ +#include "dmac.h" + +/** +******************************************************************************* +** \addtogroup DmacGroup +******************************************************************************/ +//@{ + +/******************************************************************************* +* Local type definitions ('typedef') +******************************************************************************/ + +/******************************************************************************* +* Local pre-processor symbols/macros ('#define') +******************************************************************************/ + +/******************************************************************************/ +/* DMA */ +/******************************************************************************/ + +/************** Bits definition for DMA_CONFBx(x=0~1) register *************/ +#define DMA_TRANSFER_WIDTH_Pos (26U) /*!< DMAC_CONFBx: ERR_IE Position */ +#define DMA_TRANSFER_WIDTH_Msk (0x03U << DMA_TRANSFER_WIDTH_Pos) /*!< DMAC_CONFBx: ERR_IE Mask 0x0C000000 */ + +/************** Bits definition for DMA_CONFBx(x=0~1) register *************/ +#define DMA_ERR_IE_Pos (20U) /*!< DMAC_CONFBx: ERR_IE Position */ +#define DMA_ERR_IE_Msk (0x01U << DMA_ERR_IE_Pos) /*!< DMAC_CONFBx: ERR_IE Mask 0x00000010 */ + +/************** Bits definition for DMA_CONFBx(x=0~1) register *************/ +#define DMA_FIS_IE_Pos (19U) /*!< DMAC_CONFBx: FIS_IE Position */ +#define DMA_FIS_IE_Msk (0x01U << DMA_FIS_IE_Pos) /*!< DMAC_CONFBx: FIS_IE Mask 0x00000010 */ + +/************** Bits definition for DMA_CONFBx(x=0~1) register *************/ +#define DMA_STAT_Pos (16U) /*!< DMAC_CONFBx: STAT Position */ +#define DMA_STAT_Msk (0x07U << DMA_STAT_Pos) /*!< DMAC_CONFBx: STAT Mask 0x00070000 */ + +/************** Bits definition for DMA_CONFBx(x=0~1) register *************/ +#define DMA_TRANSFER_RELOAD_Pos (0U) /*!< DMAC_CONFBx: MSK Position */ +#define DMA_TRANSFER_RELOAD_Msk (0x01U << DMA_TRANSFER_RELOAD_Pos) /*!< DMAC_CONFBx: MSK Mask 0x00000010 */ + +/************** Bits definition for DMA_CONFAx(x=0~1) register *************/ +#define DMA_CH_ENABLE_Pos (31U) /*!< DMAC_CONFAx: ENS Position */ +#define DMA_CH_ENABLE_Msk (0x01U << DMA_CH_ENABLE_Pos) /*!< DMAC_CONFAx: ENS Mask 0x80000000 */ + +/************** Bits definition for DMA_CONFAx(x=0~1) register *************/ +#define DMA_CH_PAUSE_Pos (30U) /*!< DMAC_CONFAx: PAS Position */ +#define DMA_CH_PAUSE_Msk (0x01U << DMA_CH_PAUSE_Pos) /*!< DMAC_CONFAx: PAS Mask 0x40000000 */ + +/************** Bits definition for DMA_CONFAx(x=0~1) register *************/ +#define DMA_SOFTWARE_START_Pos (29U) /*!< DMAC_CONFAx: ENS Position */ +#define DMA_SOFTWARE_START_Msk (0x01U << DMA_SOFTWARE_START_Pos) /*!< DMAC_CONFAx: ENS Mask 0x20000000 */ + +/************** Bits definition for DMA_CONFAx(x=0~1) register *************/ +#define DMA_TRI_SEL_Pos (22U) /*!< DMAC_CONFAx: TRISEL Position */ +#define DMA_TRI_SEL_Msk (0x7FU << DMA_TRI_SEL_Pos) /*!< DMAC_CONFAx: TRISEL Mask 0x1FC00000 */ + +/************** Bits definition for DMA_CONFAx(x=0~1) register *************/ +#define DMA_BC_SEL_Pos (16U) /*!< DMAC_CONFAx: TRISEL Position */ +#define DMA_BC_SEL_Msk (0x0FU << DMA_BC_SEL_Pos) /*!< DMAC_CONFAx: TRISEL Mask 0x000F0000 */ + +/************** Bits definition for DMA_CONFAx(x=0~1) register *************/ +#define DMA_TC_SEL_Pos (0U) /*!< DMAC_CONFAx: TRISEL Position */ +#define DMA_TC_SEL_Msk (0xFFFFU << DMA_TC_SEL_Pos) /*!< DMAC_CONFAx: TRISEL Mask 0x0000FFFF */ + +/************** Bits definition for DMA_CONF register *************/ +#define DMA_ENABLE_Pos (31U) /*!< DMAC_CONF: TRISEL Position */ +#define DMA_ENABLE_Msk (0x01U << DMA_ENABLE_Pos) /*!< DMAC_CONF: TRISEL Mask 0x80000000 */ + +/************** Bits definition for DMA_CONF register *************/ +#define DMA_PRIORITY_Pos (28U) /*!< DMAC_CONF: TRISEL Position */ +#define DMA_PRIORITY_Msk (0x01U << DMA_PRIORITY_Pos) /*!< DMAC_CONF: TRISEL Mask 0x10000000 */ + + +/*! Dmac閫氶亾鍙傛暟鏈夋晥鎬ф鏌. */ +#define IS_VALID_CH(x) \ +( (DmaCh0 == (x)) || \ + (DmaCh1 == (x))) + +/*! DMA 浼犺緭鏁版嵁瀹藉害锛屽弬鏁版湁鏁堟ф鏌. */ +#define IS_VALID_TRN_WIDTH(x) \ +( (DmaMsk8Bit == (x)) || \ + (DmaMsk16Bit == (x)) || \ + (DmaMsk32Bit == (x))) + +/*! DMA婧愬湴鍧鎺у埗妯″紡锛屽弬鏁版湁鏁堟ф鏌. */ +#define IS_VALID_SRC_ADDR_MODE(x) \ +( (DmaMskSrcAddrFix == (x)) || \ + (DmaMskSrcAddrInc == (x))) + +/*! DMA鐩殑鍦板潃鎺у埗妯″紡锛屽弬鏁版湁鏁堟ф鏌. */ +#define IS_VALID_DST_ADDR_MODE(x) \ +( (DmaMskDstAddrFix == (x)) || \ + (DmaMskDstAddrInc == (x))) + +/*! DMA 浼樺厛绾, 鍙傛暟鏈夋晥鎬ф鏌. */ +#define IS_VALID_PRIO_MODE(x) \ +( (DmaMskPriorityFix == (x)) || \ + (DmaMskPriorityLoop == (x))) + +/*! DMA 浼犺緭妯″紡锛屽弬鏁版湁鏁堟ф鏌. */ +#define IS_VALID_TRANSFER_MODE(x) \ +( (DmaMskOneTransfer == (x)) || \ + (DmaMskContinuousTransfer == (x))) + +/*! 鍧椾紶杈撳ぇ灏忥紝鍙傛暟鏈夋晥鎬ф鏌. */ +#define IS_VALID_BLKSIZE(x) ((!((x) & ~(DMA_BC_SEL_Msk >> DMA_BC_SEL_Pos)))&&((x)>0)) + +/*! 鍧椾紶杈撴鏁帮紝鍙傛暟鏈夋晥鎬ф鏌. */ +#define IS_VALID_TRNCNT(x) (!((x) & ~(DMA_TC_SEL_Msk >> DMA_TC_SEL_Pos))) + +/******************************************************************************* +* Global variable definitions (declared in header file with 'extern') +******************************************************************************/ + +/******************************************************************************* +* Local function prototypes ('static') +******************************************************************************/ + +/******************************************************************************* +* Local variable definitions ('static') +******************************************************************************/ + +/******************************************************************************* +* Function implementation - global ('extern') and local ('static') +******************************************************************************/ + +/** +******************************************************************************* +** \brief 鍒濆鍖朌MAC閫氶亾 +** +** \param [in] enCh 鎸囧畾閫氶亾. +** \param [in] pstcCfg DMAC閫氶亾鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡. +** +** \retval Ok 鍒濆鍖栨垚鍔. +** \retval ErrorInvalidParameter pstcCfg鏄┖鎸囬拡. +** +** \note None +** +******************************************************************************/ +en_result_t Dma_InitChannel(en_dma_channel_t enCh, stc_dma_cfg_t* pstcCfg) +{ + ASSERT(IS_VALID_CH(enCh)); + ASSERT(NULL != pstcCfg); + ASSERT(IS_VALID_BLKSIZE(pstcCfg->u16BlockSize)); + ASSERT(IS_VALID_TRNCNT(pstcCfg->u16TransferCnt)); + ASSERT(IS_VALID_TRN_WIDTH(pstcCfg->enTransferWidth)); + ASSERT(IS_VALID_SRC_ADDR_MODE(pstcCfg->enSrcAddrMode)); + ASSERT(IS_VALID_DST_ADDR_MODE(pstcCfg->enDstAddrMode)); + ASSERT(IS_VALID_PRIO_MODE(pstcCfg->enPriority)); + ASSERT(IS_VALID_TRANSFER_MODE(pstcCfg->enTransferMode)); + + /* 妫鏌ラ氶亾鍊兼湁鏁堟у拰pstcCfg鏄惁绌烘寚閽 */ + if (NULL == pstcCfg) + { + return ErrorInvalidParameter; + } + + *(&M0P_DMAC->CONFB0+enCh) = 0; + *(&M0P_DMAC->CONFB0+enCh) = (uint32_t)pstcCfg->enMode | + (uint32_t)pstcCfg->enTransferWidth | + (uint32_t)pstcCfg->enSrcAddrMode | + (uint32_t)pstcCfg->enDstAddrMode | + (uint32_t)pstcCfg->enSrcAddrReloadCtl | + (uint32_t)pstcCfg->enDestAddrReloadCtl| + (uint32_t)pstcCfg->enSrcBcTcReloadCtl | + (uint32_t)pstcCfg->enTransferMode; + + /*棣栧厛鎶奣RI_SEL[6:0] BC[3:0] TC[15:0]杩欎簺浣嶆竻闆讹紝鐒跺悗鍐嶈祴鍊*/ + *(&M0P_DMAC->CONFA0+enCh) &= ((uint32_t)~(DMA_TRI_SEL_Msk | DMA_BC_SEL_Msk | DMA_TC_SEL_Msk)); + *(&M0P_DMAC->CONFA0+enCh) |= (uint32_t)(pstcCfg->u16TransferCnt - 1) | + ((uint32_t)(pstcCfg->u16BlockSize - 1)<<16)| + (uint32_t)(pstcCfg->enRequestNum<<22); + + M0P_DMAC->CONF |= (uint32_t)(pstcCfg->enPriority); + + *(&M0P_DMAC->SRCADR0+enCh) = (uint32_t)(pstcCfg->u32SrcAddress); + *(&M0P_DMAC->DSTADR0+enCh) = (uint32_t)(pstcCfg->u32DstAddress); + + return Ok; +} +/** +******************************************************************************* +** \brief DMA妯″潡浣胯兘鍑芥暟锛屼娇鑳芥墍鏈夐氶亾鐨勬搷浣滐紝姣忎釜閫氶亾鎸夌収鍚勮嚜璁剧疆宸ヤ綔. +** +** \param None +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_Enable(void) +{ + M0P_DMAC->CONF |= DMA_ENABLE_Msk; +} + +/** +******************************************************************************* +** \brief DMA妯″潡鍔熻兘绂佹鍑芥暟锛屾墍鏈夐氶亾绂佹宸ヤ綔. +** +** \param None +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_Disable(void) +{ + M0P_DMAC->CONF &= (~DMA_ENABLE_Msk); +} +/** +******************************************************************************* +** \brief 瑙﹀彂鎸囧畾DMA閫氶亾杞欢浼犺緭鍔熻兘. +** +** \param [杈撳叆] enCh 鎸囧畾dma閫氶亾. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_SwStart(en_dma_channel_t enCh) +{ + *(&M0P_DMAC->CONFA0+enCh) |= DMA_SOFTWARE_START_Msk; +} + +/** +******************************************************************************* +** \brief 鍋滄鎸囧畾DMA閫氶亾杞欢浼犺緭鍔熻兘. +** +** \param [杈撳叆] enCh 鎸囧畾dma閫氶亾. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_SwStop(en_dma_channel_t enCh) +{ + *(&M0P_DMAC->CONFA0+enCh) &= (~DMA_SOFTWARE_START_Msk); +} +/** +******************************************************************************* +** \brief 浣胯兘鎸囧畾dma閫氶亾鐨勶紙浼犺緭瀹屾垚锛変腑鏂. +** +** \param [杈撳叆] enCh 鎸囧畾dma閫氶亾. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_EnableChannelIrq(en_dma_channel_t enCh) +{ + *(&M0P_DMAC->CONFB0+enCh) |= DMA_FIS_IE_Msk; +} + +/** +******************************************************************************* +** \brief 绂佺敤鎸囧畾dma閫氶亾鐨勶紙浼犺緭瀹屾垚锛変腑鏂. +** +** \param [杈撳叆] enCh 鎸囧畾dma閫氶亾. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_DisableChannelIrq(en_dma_channel_t enCh) +{ + *(&M0P_DMAC->CONFB0+enCh) &= (~DMA_FIS_IE_Msk); +} +/** +******************************************************************************* +** \brief 浣胯兘鎸囧畾dma閫氶亾鐨勶紙浼犺緭閿欒锛変腑鏂.. +** +** \param [杈撳叆] enCh 鎸囧畾dma閫氶亾. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_EnableChannelErrIrq(en_dma_channel_t enCh) +{ + *(&M0P_DMAC->CONFB0+enCh) |= DMA_ERR_IE_Msk; +} + +/** +******************************************************************************* +** \brief 绂佺敤鎸囧畾dma閫氶亾鐨勶紙浼犺緭閿欒锛変腑鏂.. +** +** \param [杈撳叆] enCh 鎸囧畾dma閫氶亾. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_DisableChannelErrIrq(en_dma_channel_t enCh) +{ + *(&M0P_DMAC->CONFB0+enCh) &= (~DMA_ERR_IE_Msk); +} + +/** +******************************************************************************* +** \brief 浣胯兘鎸囧畾dma閫氶亾 +** +** \param [杈撳叆] enCh 鎸囧畾dma閫氶亾. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_EnableChannel(en_dma_channel_t enCh) +{ + *(&M0P_DMAC->CONFA0+enCh) |= DMA_CH_ENABLE_Msk; +} + +/** +******************************************************************************* +** \brief 绂佺敤鎸囧畾dma閫氶亾 +** +** \param [杈撳叆] enCh 鎸囧畾dma閫氶亾. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_DisableChannel(en_dma_channel_t enCh) +{ + *(&M0P_DMAC->CONFA0+enCh) &= (~DMA_CH_ENABLE_Msk); +} + +/** +******************************************************************************* +** \brief 璁惧畾鎸囧畾閫氶亾鐨勫潡(Block)灏哄 +** +** \param [杈撳叆] enCh 鎸囧畾閫氶亾 +** \param [杈撳叆] u16BlkSize 鍧(Block)灏哄. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_SetBlockSize(en_dma_channel_t enCh, uint16_t u16BlkSize) +{ + volatile uint32_t *pReg = (&M0P_DMAC->CONFA0+enCh); + + *pReg = ((*pReg) & ((uint32_t)~DMA_BC_SEL_Msk)) | ((((uint32_t)u16BlkSize-1)&0x0f)<CONFA0+enCh); + + *pReg = ((*pReg)&((uint32_t)~DMA_TC_SEL_Msk))|(((uint32_t)(u16TrnCnt-1)<CONFB0+enCh) |= DMA_TRANSFER_RELOAD_Msk; +} + +/** +******************************************************************************* +** \brief 绂佹鎸囧畾閫氶亾杩炵画浼犺緭锛屽嵆DMAC鍦ㄤ紶杈撳畬鎴愭椂娓呴櫎. +** +** \param [杈撳叆] enCh 鎸囧畾閫氶亾. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_DisableContinusTranfer(en_dma_channel_t enCh) +{ + *(&M0P_DMAC->CONFB0+enCh) &= (~DMA_TRANSFER_RELOAD_Msk); +} +/** +******************************************************************************* +** \brief 鏆傚仠鎵鏈塪ma閫氶亾. +** +** \param None +** +** \retval None. +** +** \note None +** +******************************************************************************/ +void Dma_HaltTranfer(void) +{ + M0P_DMAC->CONF_f.HALT = 0x1; +} +/** +******************************************************************************* +** \brief 鎭㈠锛堜箣鍓嶆殏鍋滅殑锛夋墍鏈塪ma閫氶亾. +** +** \param None +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_RecoverTranfer(void) +{ + M0P_DMAC->CONF_f.HALT = 0x0; +} +/** +******************************************************************************* +** \brief 鏆傚仠鎸囧畾dma閫氶亾. +** +** \param [杈撳叆] enCh 鎸囧畾閫氶亾. +** +** \retval void +** +** \note None +** +******************************************************************************/ +void Dma_PauseChannelTranfer(en_dma_channel_t enCh) +{ + *(&M0P_DMAC->CONFA0+enCh) |= DMA_CH_PAUSE_Msk; +} +/** +******************************************************************************* +** \brief 鎭㈠锛堜箣鍓嶆殏瀹氱殑锛夋寚瀹歞ma閫氶亾. +** +** \param [杈撳叆] enCh 鎸囧畾閫氶亾. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_RecoverChannelTranfer(en_dma_channel_t enCh) +{ + *(&M0P_DMAC->CONFA0+enCh) &= (~DMA_CH_PAUSE_Msk); +} +/** +******************************************************************************* +** \brief 璁惧畾鎸囧畾閫氶亾浼犺緭鏁版嵁瀹藉害. +** +** \param [杈撳叆] enCh 鎸囧畾dma閫氶亾. +** \param [杈撳叆] enWidth 鎸囧畾鏁版嵁瀹藉害. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_SetTransferWidth(en_dma_channel_t enCh, en_dma_transfer_width_t enWidth) +{ + volatile uint32_t *pReg = (&M0P_DMAC->CONFA0+enCh); + + *pReg = ((*pReg)&((uint32_t)~DMA_TRANSFER_WIDTH_Msk))|((uint32_t)enWidth); +} +/** +******************************************************************************* +** \brief 璁惧畾dma閫氶亾浼樺厛绾. +** +** \param [杈撳叆] enPrio 閫氶亾浼樺厛绾ц瀹氬弬鏁. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_SetChPriority(en_dma_priority_t enPrio) +{ + M0P_DMAC->CONF = ((M0P_DMAC->CONF)&((uint32_t)~DMA_PRIORITY_Msk))|((uint32_t)enPrio); +} +/** +******************************************************************************* +** \brief 鑾峰彇鎸囧畾DMA閫氶亾鐨勭姸鎬. +** +** \param [杈撳叆] enCh 鎸囧畾dma閫氶亾. +** +** \retval en_dma_stat_t DMA浼犺緭褰撳墠鐘舵 +** +** \note None +** +******************************************************************************/ +en_dma_stat_t Dma_GetStat(en_dma_channel_t enCh) +{ + return (en_dma_stat_t)((*(&M0P_DMAC->CONFB0+enCh)&(DMA_STAT_Msk))>>DMA_STAT_Pos); +} +/** +******************************************************************************* +** \brief 娓呴櫎鎸囧畾DMA閫氶亾鐨勭姸鎬佸. +** +** \param [杈撳叆] enCh 鎸囧畾dma閫氶亾. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_ClrStat(en_dma_channel_t enCh) +{ + *(&M0P_DMAC->CONFB0+enCh) &= (~DMA_STAT_Msk); +} + + +/** +******************************************************************************* +** \brief 璁惧畾鎸囧畾閫氶亾婧愬湴鍧 +** +** \param [杈撳叆] enCh 鎸囧畾dma閫氶亾. +** \param [杈撳叆] u32Address 浼犺緭婧愬湴鍧. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_SetSourceAddress(en_dma_channel_t enCh, uint32_t u32Address) +{ + *(&M0P_DMAC->SRCADR0+enCh) = u32Address; +} + +/** +******************************************************************************* +** \brief 璁惧畾鎸囧畾閫氶亾鐩爣鍦板潃. +** +** \param [杈撳叆] enCh 鎸囧畾dma閫氶亾. +** \param [杈撳叆] u32Address 浼犺緭鐩爣鍦板潃. +** +** \retval None +** +** \note None +** +******************************************************************************/ +void Dma_SetDestinationAddress(en_dma_channel_t enCh, uint32_t u32Address) +{ + *(&M0P_DMAC->DSTADR0+enCh) = u32Address; +} + +//@} // DmacGroup + +/******************************************************************************* +* EOF (not truncated) +******************************************************************************/ diff --git a/driver/src/flash.c b/driver/src/flash.c new file mode 100644 index 0000000..22d436a --- /dev/null +++ b/driver/src/flash.c @@ -0,0 +1,696 @@ +/****************************************************************************** +*Copyright(C)2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file flash.c + ** + ** Common API of flash. + ** @link flashGroup Some description @endlink + ** + ** - 2018-05-08 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "flash.h" +/** + ******************************************************************************* + ** \addtogroup FlashGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define FLASH_END_ADDR (0x0001FFFFu) +#define FLASH_BYPASS() M0P_FLASH->BYPASS = 0x5A5A;\ + M0P_FLASH->BYPASS = 0xA5A5; +#define FLASH_IE_TRUE (0x03) +#define FLASH_IE_FALSE (0x00) + +#define FLASH_TIMEOUT_INIT (0xFFFFFFu) +#define FLASH_TIMEOUT_PGM (0xFFFFFFu) +#define FLASH_TIMEOUT_ERASE (0xFFFFFFu) + +#define FLASH_LOCK_ALL (0u) +#define FLASH_UNLOCK_ALL (0xFFFFFFFFu) +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ +/** + ****************************************************************************** + ** \brief FLASH OP + ** + ** Flash 鎿嶄綔鎺у埗鏁版嵁绫诲瀷閲嶅畾涔 + ******************************************************************************/ +typedef enum en_flash_op +{ + Read = 0u, ///<璇婚厤缃 + Program = 1u, ///<缂栫▼閰嶇疆鍊 + SectorErase = 2u, ///<鎵囧尯鎿﹂櫎閰嶇疆鍊 + ChipErase = 3u, ///<鍏ㄧ墖鎿﹂櫎閰嶇疆鍊 +} en_flash_op_t; + +/** + ****************************************************************************** + ** \brief FLASH 缂栫▼鏃堕棿鍙傛暟閰嶇疆 + ** + ** FLASH缂栫▼鏃堕棿鍙傛暟閰嶇疆鏁扮粍瀹氫箟 (4MHz) + ******************************************************************************/ +const uint32_t pu32PcgTimer4M[] = { + 0x20u, //Tnvs + 0x17u, //Tpgs + 0x1Bu, //Tprog + 0x4650u, //Tserase + 0x222E0u, //Tmerase + 0x18u, //Tprcv + 0xF0u, //Tsrcv + 0x3E8u //Tmrcv + }; +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ***************************************************************************** + ** \brief Flash涓柇鏍囧織鑾峰彇 + ** + ** + ** \param [in] enFlashIntType Flash涓柇绫诲瀷 + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +boolean_t Flash_GetIntFlag(en_flash_int_type_t enFlashIntType) +{ + boolean_t bRetVal = FALSE; + + if(M0P_FLASH->IFR & enFlashIntType) + { + bRetVal = TRUE; + } + + return bRetVal; +} + +/** + ***************************************************************************** + ** \brief Flash涓柇鏍囧織娓呴櫎 + ** + ** + ** \param [in] enFlashIntType Flash涓柇绫诲瀷 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Flash_ClearIntFlag(en_flash_int_type_t enFlashIntType) +{ + en_result_t enResult = Error; + + M0P_FLASH->ICLR &= ~(uint32_t)enFlashIntType; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Flash涓柇浣胯兘 + ** + ** + ** \param [in] enFlashIntType Flash涓柇绫诲瀷 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Flash_EnableIrq (en_flash_int_type_t enFlashIntType) +{ + en_result_t enResult = Error; + + FLASH_BYPASS(); + M0P_FLASH->CR_f.IE |= enFlashIntType; + + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Flash涓柇绂佹 + ** + ** + ** \param [in] enFlashIntType Flash涓柇绫诲瀷 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Flash_DisableIrq(en_flash_int_type_t enFlashIntType) +{ + en_result_t enResult = Error; + + FLASH_BYPASS(); + M0P_FLASH->CR_f.IE &= ~(uint32_t)enFlashIntType; + + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief FLASH 鍒濆鍖栧嚱鏁扳斺斾腑鏂湇鍔$▼搴忋佺紪绋嬫椂闂撮厤缃強浣庡姛鑰楁ā寮 + ** + ** 璇ュ嚱鏁扮敤浜庨厤缃腑鏂湇鍔″嚱鏁般佷綆鍔熻楁ā寮忋佹牴鎹郴缁熸椂閽熼厤缃瓼LASH缂栫▼鏃堕棿鐩稿叧瀵勫瓨鍣. + ** + ** \param [in] u8FreqCfg FLASH缂栫▼鏃堕挓棰戠巼閰嶇疆(鏍规嵁HCLK鐨勯鐜囬夋嫨閰嶇疆鍊)锛 + ** 1 - 4MHz; + ** 2 - 8MHz; + ** 4 - 16MHz; + ** 6 - 24MHz; + ** 8 - 32MHz; + ** 12 - 48MHz; + ** other - 鏃犳晥鍊 + ** \param [in] bDpstbEn TRUE - 褰撶郴缁熻繘鍏eepSleep妯″紡锛孎LASH杩涘叆浣庡姛鑰楁ā寮; + ** FALSE - 褰撶郴缁熻繘鍏eepSleep妯″紡锛孎LASH涓嶈繘鍏ヤ綆鍔熻楁ā寮; + ** + ** \retval Ok 鎿嶄綔鎴愬姛. + ** \retval ErrorInvalidParameter 鍙傛暟鏃犳晥. + ** \retval ErrorUninitialized 鍒濆鍖栧け璐ャ + *****************************************************************************/ +en_result_t Flash_Init(uint8_t u8FreqCfg, boolean_t bDpstbEn) +{ + uint32_t u32Index = 0; + volatile uint32_t u32TimeOut = FLASH_TIMEOUT_INIT; + en_result_t enResult = Ok; + uint32_t u32PrgTimer[8] = {0}; + volatile uint32_t *pu32PrgTimerReg = (volatile uint32_t*)M0P_FLASH; + + if ((1 != u8FreqCfg) && (2 != u8FreqCfg) && + (4 != u8FreqCfg) && (6 != u8FreqCfg) && + (8 != u8FreqCfg) && (12 != u8FreqCfg)) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + M0P_FLASH->CR_f.DPSTB_EN = bDpstbEn; + + //flash鏃堕棿鍙傛暟閰嶇疆鍊艰绠 + for(u32Index=0; u32Index<8; u32Index++) + { + u32PrgTimer[u32Index] = u8FreqCfg * pu32PcgTimer4M[u32Index]; + } + + //flash鏃堕棿鍙傛暟瀵勫瓨鍣ㄩ厤缃 + for(u32Index=0; u32Index<8; u32Index++) + { + u32TimeOut = FLASH_TIMEOUT_INIT; + while(pu32PrgTimerReg[u32Index] != u32PrgTimer[u32Index]) + { + if(u32TimeOut--) + { + FLASH_BYPASS(); + pu32PrgTimerReg[u32Index] = u32PrgTimer[u32Index]; + } + else + { + return ErrorUninitialized; + } + } + } + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 瀛楄妭鍐 + ** + ** 鐢ㄤ簬鍚慒LASH鍐欏叆1瀛楄妭鏁版嵁. + ** + ** \param [in] u32Addr Flash鍦板潃 + ** \param [in] u8Data 1瀛楄妭鏁版嵁 + ** + ** \retval Ok 鍐欏叆鎴愬姛. + ** \retval ErrorInvalidParameter FLASH鍦板潃鏃犳晥 + ** \retval ErrorTimeout 鎿嶄綔瓒呮椂 + *****************************************************************************/ +en_result_t Flash_WriteByte(uint32_t u32Addr, uint8_t u8Data) +{ + en_result_t enResult = Ok; + volatile uint32_t u32TimeOut = FLASH_TIMEOUT_PGM; + + if (FLASH_END_ADDR < u32Addr) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + //busy? + u32TimeOut = FLASH_TIMEOUT_PGM; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //set OP + u32TimeOut = FLASH_TIMEOUT_PGM; + while(Program != M0P_FLASH->CR_f.OP) + { + if(u32TimeOut--) + { + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = Program; + } + else + { + return ErrorTimeout; + } + } + + //Flash 瑙i攣 + Flash_UnlockAll(); + + //write data + *((volatile uint8_t*)u32Addr) = u8Data; + + //busy? + u32TimeOut = FLASH_TIMEOUT_PGM; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 鍔犻攣 + Flash_LockAll(); + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 鍗婂瓧鍐 + ** + ** 鐢ㄤ簬鍚慒LASH鍐欏叆鍗婂瓧锛2瀛楄妭锛夋暟鎹. + ** + ** \param [in] u32Addr Flash鍦板潃 + ** \param [in] u16Data 鍗婂瓧锛2瀛楄妭锛夋暟鎹 + ** + ** \retval Ok 鍐欏叆鎴愬姛. + ** \retval ErrorInvalidParameter FLASH鍦板潃鏃犳晥 + ** \retval ErrorTimeout 鎿嶄綔瓒呮椂 + *****************************************************************************/ +en_result_t Flash_WriteHalfWord(uint32_t u32Addr, uint16_t u16Data) +{ + en_result_t enResult = Ok; + volatile uint32_t u32TimeOut = FLASH_TIMEOUT_PGM; + + if (FLASH_END_ADDR < u32Addr) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + //busy? + u32TimeOut = FLASH_TIMEOUT_PGM; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //set OP + u32TimeOut = FLASH_TIMEOUT_PGM; + while(Program != M0P_FLASH->CR_f.OP) + { + if(u32TimeOut--) + { + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = Program; + } + else + { + return ErrorTimeout; + } + } + + //Flash 瑙i攣 + Flash_UnlockAll(); + + //write data + *((volatile uint16_t*)u32Addr) = u16Data; + + //busy? + u32TimeOut = FLASH_TIMEOUT_PGM; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 鍔犻攣 + Flash_LockAll(); + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 瀛楀啓 + ** + ** 鐢ㄤ簬鍚慒LASH鍐欏叆1涓瓧鐨勬暟鎹. + ** + ** \param [in] u32Addr Flash鍦板潃 + ** \param [in] u32Data 1涓瓧鏁版嵁 + ** + ** \retval Ok 鍐欏叆鎴愬姛. + ** \retval ErrorInvalidParameter FLASH鍦板潃鏃犳晥 + ** \retval ErrorTimeout 鎿嶄綔瓒呮椂 + *****************************************************************************/ +en_result_t Flash_WriteWord(uint32_t u32Addr, uint32_t u32Data) +{ + en_result_t enResult = Ok; + volatile uint32_t u32TimeOut = FLASH_TIMEOUT_PGM; + + if (FLASH_END_ADDR < u32Addr) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + //busy? + u32TimeOut = FLASH_TIMEOUT_PGM; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 瑙i攣 + Flash_UnlockAll(); + + //set OP + u32TimeOut = FLASH_TIMEOUT_PGM; + while(Program != M0P_FLASH->CR_f.OP) + { + if(u32TimeOut--) + { + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = Program; + } + else + { + return ErrorTimeout; + } + } + + //write data + *((volatile uint32_t*)u32Addr) = u32Data; + + //busy? + u32TimeOut = FLASH_TIMEOUT_PGM; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 鍔犻攣 + Flash_LockAll(); + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 鎵囧尯鎿﹂櫎 + ** + ** FLASH 鎵囧尯鎿﹂櫎. + ** + ** \param [in] u32SectorAddr 鎵鎿﹂櫎鎵囧尯鍐呯殑鍦板潃 + ** + ** \retval Ok 鎿﹂櫎鎴愬姛. + ** \retval ErrorInvalidParameter FLASH鍦板潃鏃犳晥 + ** \retval ErrorTimeout 鎿嶄綔瓒呮椂 + *****************************************************************************/ +en_result_t Flash_SectorErase(uint32_t u32SectorAddr) +{ + en_result_t enResult = Ok; + volatile uint32_t u32TimeOut = FLASH_TIMEOUT_ERASE; + + if (FLASH_END_ADDR < u32SectorAddr) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + //busy? + u32TimeOut = FLASH_TIMEOUT_ERASE; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 瑙i攣 + Flash_UnlockAll(); + + //set OP + u32TimeOut = FLASH_TIMEOUT_ERASE; + while(SectorErase != M0P_FLASH->CR_f.OP) + { + if(u32TimeOut--) + { + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = SectorErase; + } + else + { + return ErrorTimeout; + } + } + + //write data + *((volatile uint8_t*)u32SectorAddr) = 0; + + //busy? + u32TimeOut = FLASH_TIMEOUT_ERASE; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 鍔犻攣 + Flash_LockAll(); + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 鍏ㄧ墖鎿﹂櫎(璇ュ嚱鏁颁粎闄怰AM涓繍琛岋紒锛侊紒) + ** + ** FLASH 鍏ㄧ墖鎿﹂櫎. + ** + ** + ** \retval Ok 鎿﹂櫎鎴愬姛. + ** \retval ErrorTimeout 鎿嶄綔瓒呮椂 + ** + *****************************************************************************/ +en_result_t Flash_ChipErase(void) +{ + en_result_t enResult = Ok; + volatile uint32_t u32TimeOut = FLASH_TIMEOUT_ERASE; + + //busy? + u32TimeOut = FLASH_TIMEOUT_ERASE; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //set OP + u32TimeOut = FLASH_TIMEOUT_ERASE; + while(ChipErase != M0P_FLASH->CR_f.OP) + { + if(u32TimeOut--) + { + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = ChipErase; + } + else + { + return ErrorTimeout; + } + } + + //Flash 瑙i攣 + Flash_UnlockAll(); + + //write data + *((volatile uint8_t*)0) = 0; + + //busy? + u32TimeOut = FLASH_TIMEOUT_ERASE; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 鍔犻攣 + Flash_LockAll(); + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 缂栫▼淇濇姢鍔犻攣 + ** + ** + ** \retval Null + *****************************************************************************/ +void Flash_LockAll(void) +{ + FLASH_BYPASS(); + M0P_FLASH->SLOCK0 = FLASH_LOCK_ALL; + FLASH_BYPASS(); + M0P_FLASH->SLOCK1 = FLASH_LOCK_ALL; + +} + +/** + ***************************************************************************** + ** \brief FLASH 缂栫▼淇濇姢瑙i攣 + ** + ** + ** \retval Null + *****************************************************************************/ +void Flash_UnlockAll(void) +{ + + FLASH_BYPASS(); + M0P_FLASH->SLOCK0 = FLASH_UNLOCK_ALL; + FLASH_BYPASS(); + M0P_FLASH->SLOCK1 = FLASH_UNLOCK_ALL; + +} + +/** + ***************************************************************************** + ** \brief FLASH 璇荤瓑寰呭懆鏈熻缃 + ** + ** \param [in] enWaitCycle 鎻掑叆FLASH璇荤瓑寰呭懆鏈熸暟鏋氫妇绫诲瀷 + ** + ** \retval Ok 瑙i攣鎴愬姛 + ** \retval ErrorInvalidParameter 鍙傛暟閿欒 + *****************************************************************************/ +en_result_t Flash_WaitCycle(en_flash_waitcycle_t enWaitCycle) +{ + en_result_t enResult = Ok; + + FLASH_BYPASS(); + M0P_FLASH->CR_f.WAIT = enWaitCycle; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief FLASH LOCK 璁剧疆 + ** + ** \param [in] enLock @ref en_flash_lock_t + ** \param [in] u32LockValue 32bits锛屽搴攂it=0锛氬姞閿侊紝瀵瑰簲Sector涓嶅厑璁告摝鍐欙紱瀵瑰簲bit=1锛氳В閿併 + ** \note 鍔犺В閿佽寖鍥碨ector锛歔enLock*128 + i*4, enLock*128 + i*4+3] + ** (i琛ㄧずu32LockValue鐨刡it浣嶇疆锛0~31) + ** 渚嬪锛歟nLock = FlashLock1, u32LockValue = 0x00000002, + ** 鍒欏姞瑙i攣鑼冨洿涓猴細[Sector128,Sector131] + ** \retval Ok 瑙i攣鎴愬姛 + ** \retval ErrorInvalidParameter 鍙傛暟閿欒 + *****************************************************************************/ +en_result_t Flash_LockSet(en_flash_lock_t enLock, uint32_t u32LockValue) +{ + FLASH_BYPASS(); + *((&M0P_FLASH->SLOCK0) + enLock) = u32LockValue; + + return Ok; +} +//@} // FlashGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/driver/src/gpio.c b/driver/src/gpio.c new file mode 100644 index 0000000..e639cc4 --- /dev/null +++ b/driver/src/gpio.c @@ -0,0 +1,582 @@ +/****************************************************************************** +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file Gpio.c + ** + ** GPIO driver API. + ** @link Driver Group Some description @endlink + ** + ** - 2018-04-22 1.0 Lux First version + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "gpio.h" + +/** + ******************************************************************************* + ** \addtogroup GpioGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define IS_VALID_PIN(port,pin) ( ) +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') * + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ******************************************************************************* + ** \brief GPIO 鍒濆鍖 + ** + ** \param [in] enPort IO Port鍙 + ** \param [in] enPin IO Pin鑴 + ** \param [in] pstcGpioCfg IO 閰嶇疆缁撴瀯浣撴寚閽 + ** + ** \retval Ok 璁剧疆鎴愬姛 + ** 鍏朵粬鍊 璁剧疆澶辫触 + ******************************************************************************/ +en_result_t Gpio_Init(en_gpio_port_t enPort, en_gpio_pin_t enPin, stc_gpio_cfg_t *pstcGpioCfg) +{ + //閰嶇疆涓洪粯璁ゅ,GPIO鍔熻兘 + SetBit((uint32_t)&M0P_GPIO->PAADS + enPort, enPin, FALSE); + *((uint32_t*)(((uint32_t)(&(M0P_GPIO->PA00_SEL)) + enPort) + (((uint32_t)enPin)<<2))) = GpioAf0; + + //榛樿杈撳嚭鍊奸厤缃 + SetBit(((uint32_t)&M0P_GPIO->PAOUT + enPort), enPin, pstcGpioCfg->bOutputVal); + //鏂瑰悜閰嶇疆 + SetBit(((uint32_t)&M0P_GPIO->PADIR + enPort), enPin, (boolean_t)(pstcGpioCfg->enDir)); + //椹卞姩鑳藉姏閰嶇疆 + SetBit(((uint32_t)&M0P_GPIO->PADR + enPort), enPin, (boolean_t)(pstcGpioCfg->enDrv)); + //涓婃媺/涓嬫媺閰嶇疆 + SetBit(((uint32_t)&M0P_GPIO->PAPU + enPort), enPin, (boolean_t)(pstcGpioCfg->enPu)); + SetBit(((uint32_t)&M0P_GPIO->PAPD + enPort), enPin, (boolean_t)(pstcGpioCfg->enPd)); + //寮婕忚緭鍑哄姛鑳 + SetBit(((uint32_t)&M0P_GPIO->PAOD + enPort), enPin, (boolean_t)(pstcGpioCfg->enOD)); + + M0P_GPIO->CTRL2_f.AHB_SEL = pstcGpioCfg->enCtrlMode; + + return Ok; +} + + + +/** + ******************************************************************************* + ** \brief GPIO IO杈撳叆鍊艰幏鍙 + ** + ** \param [in] enPort IO Port鍙 + ** \param [in] enPin IO Pin鑴 + ** + ** \retval boolean_t IO鐢靛钩楂樹綆 + ******************************************************************************/ +boolean_t Gpio_GetInputIO(en_gpio_port_t enPort, en_gpio_pin_t enPin) +{ + return GetBit(((uint32_t)&M0P_GPIO->PAIN + enPort), enPin); +} + +/** + ******************************************************************************* + ** \brief GPIO IO Port杈撳叆鏁版嵁鑾峰彇 + ** + ** \param [in] enPort IO Port + ** + ** \retval boolean_t IO Port鏁版嵁 + ******************************************************************************/ +uint16_t Gpio_GetInputData(en_gpio_port_t enPort) +{ + return (uint16_t)(*((uint32_t *)((uint32_t)&M0P_GPIO->PAIN + enPort))); +} + +/** + ******************************************************************************* + ** \brief GPIO IO杈撳嚭鍊煎啓鍏 + ** + ** \param [in] enPort IO Port鍙 + ** \param [in] enPin IO Pin鑴 + ** \param [out] bVal 杈撳嚭鍊 + ** + ** \retval en_result_t Ok 璁剧疆鎴愬姛 + ** 鍏朵粬鍊 璁剧疆澶辫触 + ******************************************************************************/ +en_result_t Gpio_WriteOutputIO(en_gpio_port_t enPort, en_gpio_pin_t enPin, boolean_t bVal) +{ + SetBit(((uint32_t)&M0P_GPIO->PAOUT + enPort), enPin, bVal); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO IO杈撳嚭鍊艰幏鍙 + ** + ** \param [in] enPort IO Port鍙 + ** \param [in] enPin IO Pin鑴 + ** + ** \retval boolean_t IO鐢靛钩楂樹綆 + ******************************************************************************/ +boolean_t Gpio_ReadOutputIO(en_gpio_port_t enPort, en_gpio_pin_t enPin) +{ + return GetBit(((uint32_t)&M0P_GPIO->PAOUT + enPort), enPin); +} + +/** + ******************************************************************************* + ** \brief GPIO IO Port璁剧疆锛屽彲鍚屾椂璁剧疆涓缁凱ort涓殑澶氫釜PIN + ** + ** \param [in] enPort IO Port + ** \param [in] u16ValMsk 璇ort鐨16涓狿IN鎺╃爜鍊,灏嗛渶瑕佽缃殑PIN瀵瑰簲鐨刡it鍐1鏈夋晥 + ** + ** \retval boolean_t IO Port鏁版嵁 + ******************************************************************************/ +en_result_t Gpio_SetPort(en_gpio_port_t enPort, uint16_t u16ValMsk) +{ + *((uint16_t*)(((uint32_t)&(M0P_GPIO->PABSET)) + enPort)) = u16ValMsk; + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO IO璁剧疆 + ** + ** \param [in] enPort IO Port鍙 + ** \param [in] enPin IO Pin鑴 + ** + ** \retval en_result_t Ok 璁剧疆鎴愬姛 + ** 鍏朵粬鍊 璁剧疆澶辫触 + ******************************************************************************/ +en_result_t Gpio_SetIO(en_gpio_port_t enPort, en_gpio_pin_t enPin) +{ + SetBit(((uint32_t)&M0P_GPIO->PABSET + enPort), enPin, TRUE); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO IO Port娓呴浂锛屽彲鍚屾椂娓呴浂涓缁凱ort涓殑澶氫釜PIN + ** + ** \param [in] enPort IO Port + ** \param [in] u16ValMsk 璇ort鐨16涓狿IN鎺╃爜鍊,灏嗛渶瑕佹竻闆剁殑PIN瀵瑰簲鐨刡it鍐1鏈夋晥 + ** + ** \retval boolean_t IO Port鏁版嵁 + ******************************************************************************/ +en_result_t Gpio_ClrPort(en_gpio_port_t enPort, uint16_t u16ValMsk) +{ + *((uint16_t*)(((uint32_t)&(M0P_GPIO->PABCLR)) + enPort)) = u16ValMsk; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO IO娓呴浂 + ** + ** \param [in] enPort IO Port鍙 + ** \param [in] enPin IO Pin鑴 + ** + ** \retval en_result_t Ok 璁剧疆鎴愬姛 + ** 鍏朵粬鍊 璁剧疆澶辫触 + ******************************************************************************/ +en_result_t Gpio_ClrIO(en_gpio_port_t enPort, en_gpio_pin_t enPin) +{ + SetBit(((uint32_t)&M0P_GPIO->PABCLR + enPort), enPin, TRUE); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO IO Port缃綅/娓呴浂锛屽彲鍚屾椂缃綅/娓呴浂涓缁凱ort涓殑澶氫釜PIN + ** + ** \param [in] enPort IO Port + ** \param [in] u32ValMsk 楂16bits琛ㄧず璇ort鐨16涓狿IN缃綅鎺╃爜鍊, + ** 浣16bits琛ㄧず璇ort鐨16涓狿IN娓呴浂鎺╃爜鍊, + ** 灏嗛渶瑕佽缃殑PIN瀵瑰簲鐨刡it鍐1,鍚屼竴涓狿IN鐨勬帺鐮佸悓鏃朵负1,鍒欒PIN娓呴浂銆 + ** + ** \retval en_result_t Ok 璁剧疆鎴愬姛 + ** 鍏朵粬鍊 璁剧疆澶辫触 + ******************************************************************************/ +en_result_t Gpio_SetClrPort(en_gpio_port_t enPort, uint32_t u32ValMsk) +{ + *((uint32_t*)(((uint32_t)&(M0P_GPIO->PABSETCLR)) + enPort)) = u32ValMsk; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO IO閰嶇疆涓烘ā鎷熷姛鑳芥ā寮 + ** + ** \param [in] enPort IO Port鍙 + ** \param [in] enPin IO Pin鑴 + ** + ** \retval Ok 璁剧疆鎴愬姛 + ** 鍏朵粬鍊 璁剧疆澶辫触 + ******************************************************************************/ +en_result_t Gpio_SetAnalogMode(en_gpio_port_t enPort, en_gpio_pin_t enPin) +{ + SetBit((uint32_t)&M0P_GPIO->PAADS + enPort, enPin, TRUE); + + return Ok; +} + +/** + ******************************************************************************* +** \brief GPIO IO澶嶇敤鍔熻兘璁剧疆 + ** + ** \param [in] enPort IO Port鍙 + ** \param [in] enPin IO Pin鑴 + ** \param [in] enAf 澶嶇敤鍔熻兘鏋氫妇绫诲瀷閫夋嫨 + ** \retval Ok 璁剧疆鎴愬姛 + ** 鍏朵粬鍊 璁剧疆澶辫触 + ******************************************************************************/ +en_result_t Gpio_SetAfMode(en_gpio_port_t enPort, en_gpio_pin_t enPin, en_gpio_af_t enAf) +{ + *((uint32_t*)(((uint32_t)(&(M0P_GPIO->PA00_SEL)) + enPort) + (((uint32_t)enPin)<<2))) = enAf; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO IO澶嶇敤鍔熻兘璁剧疆 + ** + ** \param [in] PinMux 澶嶇敤鍔熻兘瀹忓畾涔 + ** \retval Null + ** + ******************************************************************************/ +void Gpio_SetAfMode_Lite(GpioPinMux PinMux) +{ + *((uint32_t*)(((uint32_t)(&(M0P_GPIO->PA00_SEL)) + ((PinMux>>16u)&0xFFFFu)) + (((uint32_t)((PinMux>>8u)&0xFFu))<<2))) = (uint32_t)(PinMux&0x7u); +} + +/** + ******************************************************************************* + ** \brief GPIO IO涓柇浣胯兘 + ** + ** \param [in] enPort IO Port鍙 + ** \param [in] enPin IO Pin鑴 + ** \param [in] enType 涓柇浣胯兘绫诲瀷 + ** + ** \retval Ok 璁剧疆鎴愬姛 + ******************************************************************************/ +en_result_t Gpio_EnableIrq(en_gpio_port_t enPort, en_gpio_pin_t enPin, en_gpio_irqtype_t enType) +{ + uint32_t u32PieAddr; + + u32PieAddr = ((uint32_t)((&M0P_GPIO->PAHIE) + enType)) + enPort; + + SetBit(u32PieAddr, enPin, TRUE); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO IO涓柇鍏抽棴 + ** + ** \param [in] enPort IO Port鍙 + ** \param [in] enPin IO Pin鑴 + ** \param [in] enType 涓柇浣胯兘绫诲瀷 + ** + ** \retval Ok 璁剧疆鎴愬姛 + ******************************************************************************/ +en_result_t Gpio_DisableIrq(en_gpio_port_t enPort, en_gpio_pin_t enPin, en_gpio_irqtype_t enType) +{ + uint32_t u32PieAddr; + + u32PieAddr = ((uint32_t)((&M0P_GPIO->PAHIE) + enType)) + enPort; + + SetBit(u32PieAddr, enPin, FALSE); + + return Ok; +} + + +/** + ******************************************************************************* + ** \brief GPIO 鑾峰緱IO涓柇鐘舵 + ** + ** \param [in] u8Port IO Port鍙 + ** \param [in] u8Pin IO Pin鑴 + ** + ** \retval IO涓柇鐘舵佸紑鍏 + ******************************************************************************/ +boolean_t Gpio_GetIrqStatus(en_gpio_port_t enPort, en_gpio_pin_t enPin) +{ + return GetBit((uint32_t)&M0P_GPIO->PA_STAT + enPort, enPin); +} + +/** + ******************************************************************************* + ** \brief GPIO 娓呴櫎IO涓柇鐘舵 + ** + ** \param [in] u8Port IO Port鍙 + ** \param [in] u8Pin IO Pin鑴 + ** + ** \retval Ok 璁剧疆鎴愬姛 + ******************************************************************************/ +en_result_t Gpio_ClearIrq(en_gpio_port_t enPort, en_gpio_pin_t enPin) +{ + SetBit((uint32_t)&M0P_GPIO->PA_ICLR + enPort, enPin, FALSE); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 绔彛杈呭姪鍔熻兘閰嶇疆鈥斺斾腑鏂ā寮忛厤缃 + ** + ** \param [in] enIrqMode 绔彛涓柇妯″紡锛堟繁搴︿紤鐪犳槸鍚﹀搷搴斾腑鏂級 + ** + ** \retval Ok 璁剧疆鎴愬姛 + ******************************************************************************/ +en_result_t Gpio_SfIrqModeCfg(en_gpio_sf_irqmode_t enIrqMode) +{ + M0P_GPIO->CTRL0_f.IESEL = enIrqMode; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 绔彛杈呭姪鍔熻兘閰嶇疆鈥斺擨R杈撳嚭鏋佹ч厤缃 + ** + ** \param [in] enIrPolMode IR杈撳嚭鏋佹ч厤缃灇涓 + ** + ** \retval Ok 璁剧疆鎴愬姛 + ******************************************************************************/ +en_result_t Gpio_SfIrPolCfg(en_gpio_sf_irpol_t enIrPolMode) +{ + M0P_GPIO->CTRL1_f.IR_POL = enIrPolMode; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 绔彛杈呭姪鍔熻兘閰嶇疆鈥斺擧CLK杈撳嚭閰嶇疆 + ** + ** \param [in] enGate HCLK杈撳嚭浣胯兘 + ** \param [in] enDiv 杈撳嚭鍒嗛鏋氫妇鍊 + ** + ** \retval Ok 璁剧疆鎴愬姛 + ******************************************************************************/ +en_result_t Gpio_SfHClkOutputCfg(en_gpio_sf_hclkout_g_t enGate, en_gpio_sf_hclkout_div_t enDiv) +{ + M0P_GPIO->CTRL1_f.HCLK_EN = enGate; + M0P_GPIO->CTRL1_f.HCLK_SEL = enDiv; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 绔彛杈呭姪鍔熻兘閰嶇疆鈥斺擯CLK杈撳嚭閰嶇疆 + ** + ** \param [in] enGate PCLK杈撳嚭浣胯兘 + ** \param [in] enDiv 杈撳嚭鍒嗛鏋氫妇鍊 + ** + ** \retval Ok 璁剧疆鎴愬姛 + ******************************************************************************/ +en_result_t Gpio_SfPClkOutputCfg(en_gpio_sf_pclkout_g_t enGate, en_gpio_sf_pclkout_div_t enDiv) +{ + M0P_GPIO->CTRL1_f.PCLK_EN = enGate; + M0P_GPIO->CTRL1_f.PCLK_SEL = enDiv; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 绔彛杈呭姪鍔熻兘閰嶇疆鈥斺斿閮ㄦ椂閽熻緭鍏ユ潵婧愰厤缃 + ** + ** \param [in] enExtClk 澶栭儴鏃堕挓淇″彿鏉ユ簮閫夋嫨鏋氫妇 + ** + ** \retval Ok 璁剧疆鎴愬姛 + ******************************************************************************/ +en_result_t Gpio_SfExtClkCfg(en_gpio_sf_ssn_extclk_t enExtClk) +{ + M0P_GPIO->CTRL1_f.EXT_CLK_SEL = enExtClk; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 绔彛杈呭姪鍔熻兘閰嶇疆鈥斺擲SN 閫氶亾淇″彿鏉ユ簮閰嶇疆 + ** + ** \param [in] enSpi SSN SPI閫氶亾閫夋嫨鏋氫妇 + ** \param [in] enSsn SSN 淇″彿鏉ユ簮閫夋嫨鏋氫妇 + ** + ** \retval Ok 璁剧疆鎴愬姛 + ******************************************************************************/ +en_result_t Gpio_SfSsnCfg(en_gpio_sf_ssnspi_t enSpi, en_gpio_sf_ssn_extclk_t enSsn) +{ + //SPI0 + if(enSpi == GpioSpi0) + { + M0P_GPIO->CTRL1_f.SSN0_SEL = enSsn; + } + //SPI1 + if(enSpi == GpioSpi1) + { + M0P_GPIO->CTRL2_f.SSN1_SEL = enSsn; + } + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 绔彛杈呭姪鍔熻兘閰嶇疆鈥斺擳imer 闂ㄦ帶杈撳叆閰嶇疆 + ** + ** \param [in] enTimG Timer绫诲瀷閫夋嫨鏋氫妇 + ** \param [in] enSf Timer浜掕仈鍔熻兘閫夋嫨鏋氫妇 + ** + ** \retval Ok 璁剧疆鎴愬姛 + ******************************************************************************/ +en_result_t Gpio_SfTimGCfg(en_gpio_sf_tim_g_t enTimG, en_gpio_sf_t enSf) +{ + if(enTimG&0x20u) + { + enTimG &= ~0x20u; + M0P_GPIO->PCAS &= (uint32_t)(~(0x07U<PCAS |= (uint32_t)(enSf<TIMGS &= (uint32_t)(~(0x07U<TIMGS |= (uint32_t)(enSf<PCAS &= (uint32_t)(~(0x07U<PCAS |= (uint32_t)(enSf<TIMES &= (uint32_t)(~(0x07U<TIMES |= (uint32_t)(enSf<TIMCPS &= (uint32_t)(~(0x07u<TIMCPS |= (uint32_t)(enSf<PCAS &= (uint32_t)(~(0x07u<PCAS |= (uint32_t)(enSf<TM = u8Tm; + + enRet = Ok; + return enRet; + } + /** + ****************************************************************************** + ** \brief I2C鍔熻兘璁剧疆鐩稿叧鍑芥暟 + ** + ** \param [in] enFunc鍔熻兘鍙傛暟 + ** + ** \retval enRet 鎴愬姛鎴栧け璐 + ** + ******************************************************************************/ +en_result_t I2C_SetFunc(M0P_I2C_TypeDef* I2Cx, en_i2c_func_t enFunc) +{ + en_result_t enRet = Error; + + SetBit((uint32_t)&I2Cx->CR, enFunc, TRUE); + + enRet = Ok; + return enRet; +} + /** + ****************************************************************************** + ** \brief I2C鍔熻兘娓呴櫎鐩稿叧鍑芥暟 + ** + ** \param [in] enFunc鍔熻兘鍙傛暟 + ** + ** \retval enRet 鎴愬姛鎴栧け璐 + ** + ******************************************************************************/ + en_result_t I2C_ClearFunc(M0P_I2C_TypeDef* I2Cx, en_i2c_func_t enFunc) + { + en_result_t enRet = Error; + + SetBit((uint32_t)&I2Cx->CR, enFunc, FALSE); + + enRet = Ok; + return enRet; + } + /** + ****************************************************************************** + ** \brief I2C鑾峰彇涓柇鏍囪鍑芥暟 + ** + ** \param 鏃 + ** + ** \retval bIrq涓柇鏍囪 + ** + ******************************************************************************/ +boolean_t I2C_GetIrq(M0P_I2C_TypeDef* I2Cx) +{ + if(I2Cx->CR&0x8) + { + return TRUE; + } + else + { + return FALSE; + } +} +/** + ****************************************************************************** + ** \brief I2C娓呴櫎涓柇鏍囪鍑芥暟 + ** + ** \param 鏃 + ** + ** \retval bIrq涓柇鏍囪 + ** + ******************************************************************************/ +en_result_t I2C_ClearIrq(M0P_I2C_TypeDef* I2Cx) +{ + en_result_t enRet = Error; + + I2Cx->CR &= ~0x8u; + + enRet = Ok; + return enRet; +} + /** + ****************************************************************************** + ** \brief I2C鑾峰彇鐩稿叧鐘舵 + ** + ** \param 鏃 + ** + ** \retval I2C鐘舵 + ** + ******************************************************************************/ +uint8_t I2C_GetState(M0P_I2C_TypeDef* I2Cx) +{ + uint8_t u8State = 0; + + u8State = I2Cx->STAT; + + return u8State; +} + +/** + ****************************************************************************** + ** \brief 瀛楄妭鏁版嵁鍐欏嚱鏁 + ** + ** \param u8Data鍐欐暟鎹 + ** + ** \retval 鍐欐暟鎹槸鍚︽垚鍔 + ** + ******************************************************************************/ +en_result_t I2C_WriteByte(M0P_I2C_TypeDef* I2Cx, uint8_t u8Data) +{ + en_result_t enRet = Error; + + I2Cx->DATA = u8Data; + + enRet = Ok; + return enRet; +} +/** + ****************************************************************************** + ** \brief 瀛楄妭鏁版嵁璇诲嚱鏁 + ** + ** \param 鏃 + ** + ** \retval 璇诲彇鏁版嵁 + ** + ******************************************************************************/ +uint8_t I2C_ReadByte(M0P_I2C_TypeDef* I2Cx) +{ + uint8_t u8Data = 0; + + u8Data = I2Cx->DATA; + + return u8Data; +} + +/** + ****************************************************************************** + ** \brief I2C妯″潡鍒濆鍖 + ** + ** \param pstcI2CCfg鍒濆鍖栭厤缃粨鏋勪綋 + ** + ** \retval 鍒濆鍖栨槸鍚︽垚鍔 + ** + ******************************************************************************/ +en_result_t I2C_Init(M0P_I2C_TypeDef* I2Cx, stc_i2c_cfg_t *pstcI2CCfg) +{ + en_result_t enRet = Error; + uint8_t u8Tm; + + if(M0P_I2C0 == I2Cx) + { + M0P_RESET->PERI_RESET0 &= ~(uint32_t)0x10u; + M0P_RESET->PERI_RESET0 |= (uint32_t)0x10u; + } + else + { + M0P_RESET->PERI_RESET0 &= ~(uint32_t)0x20u; + M0P_RESET->PERI_RESET0 |= (uint32_t)0x20u; + } + + I2Cx->CR = 0; + I2Cx->CR = pstcI2CCfg->enMode; + + if((pstcI2CCfg->u32Baud<<4) > pstcI2CCfg->u32Pclk) + { + return Error; + } + + if(I2cMasterMode == pstcI2CCfg->enMode) + { + I2Cx->TMRUN = TRUE; + ///< Fsck = Fpclk/8*(Tm+1) + u8Tm = ((pstcI2CCfg->u32Pclk / pstcI2CCfg->u32Baud) >> 3) - 1; + if(9 > u8Tm) + { + I2C_SetFunc(I2Cx,I2cHlm_En); + } + enRet = I2C_SetBaud(I2Cx, u8Tm); + } + else + { + I2Cx->TMRUN = FALSE; + pstcI2CCfg->u8SlaveAddr = (uint8_t)(((uint32_t)pstcI2CCfg->u8SlaveAddr<<1)|(pstcI2CCfg->bGc)); + I2Cx->ADDR = pstcI2CCfg->u8SlaveAddr; + } + + return enRet; +} +/** + ****************************************************************************** + ** \brief I2C妯″潡鎺ユ敹鎸囧畾闀垮害鍑芥暟 + ** + ** \param u8SlaveAddr浠庢満璁惧鍦板潃锛寀8Addr浠庢満鍐呭瓨鍦板潃锛宲u8Data璇绘暟鎹瓨鏀剧紦瀛橈紝u32Len璇绘暟鎹暱搴 + ** + ** \retval 璇绘暟鎹槸鍚︽垚鍔 + ** + ******************************************************************************/ + boolean_t I2C_MasterReadData(M0P_I2C_TypeDef* I2CX,uint8_t u8SlaveAddr,uint8_t u8Addr,uint8_t *pu8Data,uint32_t u32Len) +{ + boolean_t enRet = FALSE; + uint8_t u8i=0,u8State; + + I2C_SetFunc(I2CX,I2cStart_En);//寮濮 + + while(1) + { + while(0 == I2C_GetIrq(I2CX))//鑾峰彇涓柇鏍囪鍑芥暟 + {;} + u8State = I2C_GetState(I2CX);//鑾峰彇i2c鐩稿叧鐘舵 + switch(u8State) + { + case 0x08: ///< 涓昏澶囧悜鎬荤嚎宸插彂鍑轰簡涓涓捣濮嬫潯浠 + I2C_ClearFunc(I2CX,I2cStart_En); + I2C_WriteByte(I2CX,(u8SlaveAddr << 1)); + break; + case 0x18: ///< 涓昏澶囧悜鎬荤嚎宸插彂鍑轰簡涓涓粠璁惧鍦板潃锛堝啓鏂瑰悜锛夊苟涓旀帴鏀跺埌浠庤澶囩殑搴旂瓟 + I2C_WriteByte(I2CX,u8Addr); ///< 鍙戦佷粠鏈哄唴瀛樺湴鍧 + break; + case 0x28: ///< 宸插彂閫佹暟鎹紝鎺ユ敹鍒癆CK, 姝ゅ鏄凡鍙戦佷粠鏈哄唴瀛樺湴鍧u8Addr骞舵帴鏀跺埌ACK + I2C_SetFunc(I2CX,I2cStart_En); ///< 鍙戦侀噸澶嶈捣濮嬫潯浠 + break; + case 0x10: ///< 涓昏澶囧悜鎬荤嚎宸插彂鍑轰簡涓涓噸澶嶇殑璧峰鏉′欢 + I2C_ClearFunc(I2CX,I2cStart_En); + I2C_WriteByte(I2CX,(u8SlaveAddr << 1) | 0x01);///< 鍙戦丼LA+R锛屽紑濮嬩粠浠庢満璇诲彇鏁版嵁 + break; + case 0x40: ///< 宸插彂閫丼LA+R锛屽苟鎺ユ敹鍒癆CK + if(u32Len>1) + { + I2C_SetFunc(I2CX,I2cAck_En); ///< 浣胯兘涓绘満搴旂瓟鍔熻兘 + } + break; + case 0x50: ///< 宸叉帴鏀舵暟鎹瓧鑺傦紝骞跺凡杩斿洖ACK淇″彿 + pu8Data[u8i++] = I2C_ReadByte(I2CX); + if(u8i==u32Len-1) + { + I2C_ClearFunc(I2CX,I2cAck_En); ///< 宸叉帴鏀跺埌鍊掓暟绗簩涓瓧鑺傦紝鍏抽棴ACK搴旂瓟鍔熻兘 + } + break; + case 0x58: ///< 宸叉帴鏀跺埌鏈鍚庝竴涓暟鎹紝NACK宸茶繑鍥 + pu8Data[u8i++] = I2C_ReadByte(I2CX); + I2C_SetFunc(I2CX,I2cStop_En); ///< 鍙戦佸仠姝㈡潯浠 + break; + case 0x38: ///< 鍦ㄥ彂閫佸湴鍧鎴栨暟鎹椂锛屼徊瑁佷涪澶 + I2C_SetFunc(I2CX,I2cStart_En); ///< 褰撴荤嚎绌洪棽鏃跺彂璧疯捣濮嬫潯浠 + break; + case 0x48: ///< 鍙戦丼LA+R鍚庯紝鏀跺埌涓涓狽ACK + I2C_SetFunc(I2CX,I2cStop_En); ///< 鍙戦佸仠姝㈡潯浠 + I2C_SetFunc(I2CX,I2cStart_En); ///< 鍙戦佽捣濮嬫潯浠 + break; + default: + I2C_SetFunc(I2CX,I2cStart_En); ///< 鍏朵粬閿欒鐘舵侊紝閲嶆柊鍙戦佽捣濮嬫潯浠 + break; + } + I2C_ClearIrq(I2CX); ///< 娓呴櫎涓柇鐘舵佹爣蹇椾綅 + if(u8i==u32Len) ///< 鏁版嵁鍏ㄩ儴璇诲彇瀹屾垚锛岃烦鍑簑hile寰幆 + { + break; + } + } + enRet = TRUE; + return enRet; +} +/** + ****************************************************************************** + ** \brief I2C妯″潡涓绘満鍙戦佹寚瀹氶暱搴﹀嚱鏁 + ** + ** \param u8SlaveAddr浠庢満璁惧鍦板潃锛寀8Addr浠庢満鍐呭瓨鍦板潃锛宲u8Data鍐欐暟鎹紝u32Len鍐欐暟鎹暱搴 + ** + ** \retval 鍐欐暟鎹槸鍚︽垚鍔 + ** + ******************************************************************************/ +boolean_t I2C_MasterWriteData(M0P_I2C_TypeDef* I2CX,uint8_t u8SlaveAddr,uint8_t u8Addr,uint8_t *pu8Data,uint32_t u32Len) +{ + boolean_t enRet = FALSE; + uint8_t u8i=0,u8State, u8Flag=FALSE; + I2C_SetFunc(I2CX,I2cStart_En); + while(1) + { + while(0 == I2C_GetIrq(I2CX)) + {;} + u8State = I2C_GetState(I2CX); + switch(u8State) + { + case 0x08: ///< 宸插彂閫佽捣濮嬫潯浠 + I2C_ClearFunc(I2CX,I2cStart_En); + I2C_WriteByte(I2CX,(u8SlaveAddr << 1)); ///< 浠庤澶囧湴鍧鍙戦 + break; + case 0x18: ///< 宸插彂閫丼LA+W锛屽苟鎺ユ敹鍒癆CK + I2C_WriteByte(I2CX,u8Addr); ///< 浠庤澶囧唴瀛樺湴鍧鍙戦 + break; + case 0x28: ///< 涓婁竴娆″彂閫佹暟鎹悗鎺ユ敹鍒癆CK + if (u8i < u32Len) + { + I2C_WriteByte(I2CX,pu8Data[u8i++]); ///< 缁х画鍙戦佹暟鎹 + }else + { + I2C_SetFunc(I2CX,I2cStop_En); ///< 鍑哄仠姝㈡潯浠 + u8Flag = TRUE; + } + break; + case 0x38: ///< 涓婁竴娆″湪SLA+璇绘垨鍐欐椂涓㈠け浠茶 + I2C_SetFunc(I2CX,I2cStart_En); ///< 褰揑2C鎬荤嚎绌洪棽鏃跺彂閫佽捣濮嬫潯浠 + break; + case 0x30: ///< 宸插彂閫両2Cx_DATA涓殑鏁版嵁锛屾敹鍒癗ACK锛屽皢浼犺緭涓涓猄TOP鏉′欢 + I2C_SetFunc(I2CX,I2cStop_En); ///< 鍙戦佸仠姝㈡潯浠 + break; + default: + break; + } + + I2C_ClearIrq(I2CX); ///< 娓呴櫎涓柇鐘舵佹爣蹇椾綅 + + if(u8Flag == TRUE) ///< 鏁版嵁鍙戦佸畬鎴 + { + break; + } + } + enRet = TRUE; + return enRet; +} +//@} // I2cGroup diff --git a/driver/src/lcd.c b/driver/src/lcd.c new file mode 100644 index 0000000..dfbab6e --- /dev/null +++ b/driver/src/lcd.c @@ -0,0 +1,289 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file lcd.c + ** + ** lcd driver API. + ** + ** - 2019-04-02 First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "lcd.h" + + +/** + ****************************************************************************** + ** \addtogroup AdcGroup + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/****************************************************************************** + * Local variable definitions ('static') + ******************************************************************************/ + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + *****************************************************************************/ + +/** +****************************************************************************** + ** \brief 鑾峰彇LCD涓柇鏍囧織浣岻NTF + ** + ** @param 鏃 + ** \retval 鏃 + ** +******************************************************************************/ +boolean_t Lcd_GetItStatus(void) +{ + return (((M0P_LCD->CR1)>>11)&0x01)? TRUE : FALSE; +} + +/** +****************************************************************************** + ** \brief 娓呴櫎涓柇鏍囧織浣岻NTF + ** + ** @param 鏃 + ** \retval 鏃 + ** +******************************************************************************/ +void Lcd_ClearItPendingBit(void) +{ + SetBit((uint32_t)(&(M0P_LCD->INTCLR)), 10, 0); +} + +/** +****************************************************************************** + ** \brief 鏍规嵁LCD鏄剧ず妯″紡鑾峰彇绔彛閰嶇疆 + ** + ** \param pstcSegComPara锛氭樉绀烘柟寮忥紝 stcSegCom鑾峰彇绔彛鍙傛暟 + ** + ** \retval enRet 鎴愬姛鎴栧け璐 + ** +******************************************************************************/ +en_result_t Lcd_GetSegCom(stc_lcd_segcompara_t *pstcSegComPara,stc_lcd_segcom_t *pstcSegCom) +{ + en_result_t enRet = Error; + pstcSegCom->stc_seg32_51_com0_8_t.seg32_51_com0_8 = 0xffffffffu; + pstcSegCom->u32Seg0_31 = 0xffffffffu; + if(pstcSegComPara->u8MaxSeg>51) + { + return ErrorInvalidParameter; + } + switch(pstcSegComPara->LcdBiasSrc) + { + case LcdInResHighPower: + case LcdInResLowPower: + case LcdInResMidPower: + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Mux = 1; + break; + case LcdExtCap: + case LcdExtRes: + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Mux = 0; + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Seg32_35 = 0; + break; + default: + return ErrorInvalidParameter; + } + switch(pstcSegComPara->LcdDuty) + { + case LcdStatic: + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Com0_3 = (~1u)&0x0fu; + break; + case LcdDuty2: + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Com0_3 = (~3u)&0x0fu; + break; + case LcdDuty3: + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Com0_3 = (~7u)&0x0fu; + break; + case LcdDuty4: + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Com0_3 = (~15u)&0x0fu; + break; + case LcdDuty6: + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Com0_3 = 0; + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Seg39Com4 = 0; + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Seg38Com5 = 0; + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Seg37Com6 = 1; + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Seg36Com7 = 1; + break; + case LcdDuty8: + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Com0_3 = 0; + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Seg39Com4 = 0; + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Seg38Com5 = 0; + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Seg37Com6 = 0; + pstcSegCom->stc_seg32_51_com0_8_t.segcom_bit.Seg36Com7 = 0; + break; + default: + return ErrorInvalidParameter; + } + enRet = Ok; + return enRet; +} + +/** +****************************************************************************** + ** \brief LCD COMSEG绔彛閰嶇疆锛屼娇鐢ㄨ鍑芥暟涔嬪墠闇瑕佸厛浣胯兘鐩稿簲鐨凷eg + ** + ** \param [in] pstcSegCom绔彛閰嶇疆缁撴瀯浣 + ** + ** \retval enRet 鎴愬姛鎴栧け璐 + ** +******************************************************************************/ +void Lcd_SetSegCom(stc_lcd_segcom_t *pstcSegCom) +{ + M0P_LCD->POEN0 = pstcSegCom->u32Seg0_31; + M0P_LCD->POEN1 = pstcSegCom->stc_seg32_51_com0_8_t.seg32_51_com0_8; +} + +/** +****************************************************************************** + ** \brief LCD妯″潡鍒濆鍖栧嚱鏁 + ** + ** \param stcLcdCfg閰嶇疆鍒濆鍖栫粨鏋勪綋 + ** + ** \retval 鏃 + ** +******************************************************************************/ +void Lcd_Init(stc_lcd_cfg_t *pstcLcdCfg) +{ + M0P_LCD->CR0_f.BSEL = pstcLcdCfg->LcdBiasSrc; + M0P_LCD->CR0_f.DUTY = pstcLcdCfg->LcdDuty; + M0P_LCD->CR0_f.BIAS = pstcLcdCfg->LcdBias; + M0P_LCD->CR0_f.CPCLK = pstcLcdCfg->LcdCpClk; + M0P_LCD->CR0_f.LCDCLK = pstcLcdCfg->LcdScanClk; + M0P_LCD->CR1_f.MODE = pstcLcdCfg->LcdMode; + M0P_LCD->CR1_f.CLKSRC = pstcLcdCfg->LcdClkSrc; + M0P_LCD->CR0_f.EN = pstcLcdCfg->LcdEn; +} + +/** +****************************************************************************** + ** \brief 娑叉櫠鍏ㄦ樉 + ** + ** \param 鏃 + ** + ** \retval 鏃 + ** +******************************************************************************/ +void Lcd_FullDisp(void) +{ + uint8_t tmp; + volatile uint32_t *ram = NULL; + ram = &M0P_LCD->RAM0; + for(tmp=0;tmp<16;tmp++) + { + *ram = 0xffffffffu; + ram++; + } +} + +/** +****************************************************************************** + ** \brief 娓呭睆 + ** + ** \param 鏃 + ** + ** \retval 鏃 + ** +******************************************************************************/ +void Lcd_ClearDisp(void) +{ + uint8_t tmp; + volatile uint32_t *ram = NULL; + ram = &M0P_LCD->RAM0; + for(tmp=0;tmp<16;tmp++) + { + *ram = 0; + ram++; + } +} + +/** + ****************************************************************************** + ** \brief LCD RAM 0-f瀵勫瓨鍣ㄨ缃嚱鏁 + ** + ** \param u8Row RAM鍦板潃绱㈠紩锛岃寖鍥达細0-15锛寀8Data鍐欏叆瀵勫瓨鍣ㄦ暟鍊 + ** + ** \retval enRet 鎴愬姛鎴栧け璐 + ** + ******************************************************************************/ +en_result_t Lcd_WriteRam(uint8_t u8Row,uint32_t u32Data) +{ + en_result_t enRet = Error; + volatile uint32_t *ram = NULL; + ram = (volatile uint32_t*)&M0P_LCD->RAM0; + + if (u8Row > 15) + { + enRet = ErrorInvalidParameter; + return enRet; + } + + ram += u8Row; + *ram = u32Data; + enRet = Ok; + return enRet; +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/driver/src/lpm.c b/driver/src/lpm.c new file mode 100644 index 0000000..93bcf7a --- /dev/null +++ b/driver/src/lpm.c @@ -0,0 +1,122 @@ +/****************************************************************************** +*Copyright(C)2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file lpm.c + ** + ** Common API of lpm. + ** @link LpmGroup Some description @endlink + ** + ** - 2017-06-06 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "lpm.h" +/** + ******************************************************************************* + ** \addtogroup LpmGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ***************************************************************************** + ** \brief 杩涘叆娣卞害鐫$湢妯″紡 + ** + ** \input bOnExit - TRUE:褰撻鍑哄紓甯稿鐞嗗悗锛岃嚜鍔ㄥ啀娆¤繘鍏ヤ紤鐪狅紱 + ** FALSE锛氬敜閱掑悗涓嶅啀鑷姩杩涘叆浼戠湢 + ** + ** \retval NULL + *****************************************************************************/ +void Lpm_GotoDeepSleep(boolean_t bOnExit) +{ + SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; + SCB->SCR |= 1u<SCR &= ~SCB_SCR_SLEEPDEEP_Msk; + SCB->SCR |= 1u<CR)), 10, NewStatus); +} + +/** +****************************************************************************** + ** \brief 瀹氭椂鍣↙PTIMx鐨勫惎鍔/鍋滄鎺у埗 + ** @param Lptimx : LPTIM0 鎴朙PTIM1 + ** @param NewStatus : TRUE 鎴 FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Lptim_Cmd(M0P_LPTIMER_TypeDef* Lptimx, boolean_t NewStatus) +{ + SetBit((uint32_t)(&(Lptimx->CR)), 0, NewStatus); +} + +/** +****************************************************************************** + ** \brief 瀹氭椂鍣↙PTIMx鐨勪腑鏂爣蹇椾綅鑾峰彇 + ** @param Lptimx : LPTIM0 鎴朙PTIM1 + ** \retval TRUE 鎴 FALSE + ** +******************************************************************************/ +boolean_t Lptim_GetItStatus(M0P_LPTIMER_TypeDef* Lptimx) +{ + return GetBit((uint32_t)(&(Lptimx->IFR)), 0); +} + +/** +****************************************************************************** + ** \brief 瀹氭椂鍣↙PTIMx鐨勪腑鏂爣蹇椾綅娓呴櫎 + ** @param Lptimx : LPTIM0 鎴朙PTIM1 + ** \retval 鏃 + ** +******************************************************************************/ +void Lptim_ClrItStatus(M0P_LPTIMER_TypeDef* Lptimx) +{ + SetBit((uint32_t)(&(Lptimx->ICLR)), 0, 0); +} + +/** +****************************************************************************** + ** \brief 瀹氭椂鍣↙PTIMx鐨勫垵濮嬪寲閰嶇疆 + ** @param Lptimx : LPTIM0 鎴朙PTIM1 + ** @param InitStruct : 鍒濆鍖朙PTIMx鐨勭粨鏋勪綋 + ** \retval en_result_t绫诲瀷鏁版嵁 + ** +******************************************************************************/ +en_result_t Lptim_Init(M0P_LPTIMER_TypeDef* Lptimx, stc_lptim_cfg_t* InitStruct) +{ + uint16_t u16TimeOut; + u16TimeOut = 1000; + Lptimx->CR_f.PRS = InitStruct->enPrs; + Lptimx->CR_f.TCK_SEL = InitStruct->enTcksel; + Lptimx->CR_f.GATE_P = InitStruct->enGatep; + Lptimx->CR_f.GATE = InitStruct->enGate; + Lptimx->CR_f.TOG_EN = InitStruct->enTogen; + Lptimx->CR_f.CT = InitStruct->enCt; + Lptimx->CR_f.MD = InitStruct->enMd; + while(u16TimeOut--) + { + if(Lptimx->CR_f.WT_FLAG) + { + break; + } + } + if(u16TimeOut == 0) + { + return ErrorTimeout; + } + Lptimx->ARR_f.ARR = InitStruct->u16Arr; + return Ok; +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ diff --git a/driver/src/lpuart.c b/driver/src/lpuart.c new file mode 100644 index 0000000..5e8828f --- /dev/null +++ b/driver/src/lpuart.c @@ -0,0 +1,409 @@ +/************************************************************************************* +* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file lpuart.c + ** + ** LPUART function driver API. + ** @link SampleGroup Some description @endlink + ** + ** - 2017-05-17 1.0 CJ First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "lpuart.h" +/** + ****************************************************************************** + ** \addtogroup LPUartGroup + ******************************************************************************/ +//@{ +/******************************************************************************/ +/* Local pre-processor symbols/macros ('#define') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local function prototypes ('static') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local variable definitions ('static') */ +/******************************************************************************/ + +/** + ****************************************************************************** + ** \brief LPUART閫氫俊涓柇浣胯兘鍑芥暟璁剧疆 + ** + ** \param [in] LPUARTx閫氶亾鍙凤紝enIrqSel鍙戦乷r鎺ユ敹涓柇浣胯兘 + ** + ** \retval OK閰嶇疆鎴愬姛 + **\retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t LPUart_EnableIrq(M0P_LPUART_TypeDef* LPUARTx, en_lpuart_irq_sel_t enIrqSel) +{ + + SetBit((uint32_t)(&(LPUARTx->SCON)), enIrqSel, TRUE); + + return Ok; +} +/** + ****************************************************************************** + ** \brief LPUART閫氫俊涓柇绂佹鍑芥暟璁剧疆 + ** + ** \param [in] LPUARTx閫氶亾鍙凤紝enIrqSel鍙戦乷r鎺ユ敹涓柇绂佹 + ** + ** \retval OK閰嶇疆鎴愬姛 + **\retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t LPUart_DisableIrq(M0P_LPUART_TypeDef* LPUARTx, en_lpuart_irq_sel_t enIrqSel) +{ + + SetBit((uint32_t)(&(LPUARTx->SCON)), enIrqSel, FALSE); + + return Ok; +} +/** + ****************************************************************************** + ** \brief lpuart閫氫俊鏃堕挓婧愰夋嫨 + ** + ** \param [in] LPUARTx閫氶亾鍙凤紝enClk 鏃堕挓婧愰夐」 + ** + ** \retval Ok 璁剧疆鎴愬姛 + **\retval ErrorInvalidParameter璁剧疆澶辫触 + ******************************************************************************/ +en_result_t LPUart_SelSclk(M0P_LPUART_TypeDef* LPUARTx, en_lpuart_sclksel_t enSclk) +{ + ASSERT(IS_VALID_CLK(enSclk)); + + LPUARTx->SCON_f.SCLKSEL = enSclk; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief LPUART閫氶亾澶氫富鏈烘ā寮忛厤缃 + ** + ** \param [in] LPUARTx閫氶亾鍙凤紝stcMultiCfg澶氫富鏈烘ā寮忕粨鏋 + ** + ** \retval OK閰嶇疆鎴愬姛 + **\retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t LPUart_SetMultiMode(M0P_LPUART_TypeDef* LPUARTx, stc_lpuart_multimode_t* pstcMultiCfg) +{ + + if(NULL != pstcMultiCfg) + { + LPUARTx->SCON_f.ADRDET = TRUE; + LPUARTx->SADDR = pstcMultiCfg->u8SlaveAddr; + LPUARTx->SADEN = pstcMultiCfg->u8SaddEn; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + ****************************************************************************** + ** \brief LPUART鍗曠嚎鍗婂弻宸ユā寮忎娇鑳 + ** + ** \param [in] LPUARTx 閫氶亾鍙 + ** + ** \retval Null + ******************************************************************************/ +void LPUart_HdModeEnable(M0P_LPUART_TypeDef* LPUARTx) +{ + LPUARTx->SCON_f.HDSEL = TRUE; +} + + +/** + ****************************************************************************** + ** \brief LPUART鍗曠嚎鍗婂弻宸ユā寮忓叧闂 + ** + ** \param [in] LPUARTx 閫氶亾鍙 + ** + ** \retval Null + ******************************************************************************/ +void LPUart_HdModeDisable(M0P_LPUART_TypeDef* LPUARTx) +{ + LPUARTx->SCON_f.HDSEL = FALSE; +} + +/** + ****************************************************************************** + ** \brief LPUART閫氶亾澶氭満妯″紡鍙戦佹暟鎹/鍦板潃甯ч厤缃甌B8 + ** + ** \param [in] LPUARTx 閫氶亾鍙 + ** \param [in] TRUE-TB8涓哄湴鍧甯ф爣蹇楋紱FALSE-TB8涓烘暟鎹抚鏍囧織锛 + ** + ** \retval Null + ******************************************************************************/ +void LPUart_SetTb8(M0P_LPUART_TypeDef* LPUARTx, boolean_t bTB8Value) +{ + LPUARTx->SCON_f.B8CONT = bTB8Value; + +} + +/** + ****************************************************************************** + ** \brief 鑾峰彇RB8鏁板 + ** + ** \param [in] LPUARTx 閫氶亾鍙 + ** + ** \retval RB8 + **\retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +boolean_t LPUart_GetRb8(M0P_LPUART_TypeDef* LPUARTx) +{ + return (LPUARTx->SBUF_f.DATA8); +} +/** + ****************************************************************************** + ** \brief LPUART閫氶亾澶氫富鏈烘ā寮忎粠鏈哄湴鍧閰嶇疆鍑芥暟 + ** + ** \param [in] LPUARTx 閫氶亾鍙凤紝addr鍦板潃 + ** + ** \retval OK閰嶇疆鎴愬姛 + **\retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t LPUart_SetSaddr(M0P_LPUART_TypeDef* LPUARTx,uint8_t u8Addr) +{ + LPUARTx->SADDR = u8Addr; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief LPUART閫氶亾鍙戦佹垨鎺ユ敹绛夊姛鑳戒娇鑳借缃 + ** + ** \param [in] u8Idx閫氶亾鍙凤紝enFunc鍔熻兘 + ** + ** \retval OK閰嶇疆鎴愬姛 + **\retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t LPUart_EnableFunc(M0P_LPUART_TypeDef* LPUARTx, en_lpuart_func_t enFunc) +{ + SetBit((uint32_t)(&(LPUARTx->SCON)), enFunc, TRUE); + + return Ok; +} + +/** + ****************************************************************************** + ** \brief LPUART閫氶亾鍙戦佹垨鎺ユ敹绛夊姛鑳界姝㈣缃 + ** + ** \param [in] u8Idx閫氶亾鍙凤紝enFunc鍔熻兘 + ** + ** \retval OK閰嶇疆鎴愬姛 + **\retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t LPUart_DisableFunc(M0P_LPUART_TypeDef* LPUARTx, en_lpuart_func_t enFunc) +{ + SetBit((uint32_t)(&(LPUARTx->SCON)), enFunc, FALSE); + + return Ok; +} + +/** + ****************************************************************************** + ** \brief LPUART閫氶亾閫氫俊鐘舵佽幏鍙 + ** + ** \param [in] u8Idx閫氶亾鍙 + ** + ** \retval 鐘舵佸 + ******************************************************************************/ +uint8_t LPUart_GetIsr(M0P_LPUART_TypeDef* LPUARTx) +{ + return (LPUARTx->ISR); +} + +/** + ****************************************************************************** + ** \brief LPUART閫氶亾閫氫俊鐘舵佽幏鍙 + ** + ** \param [in] u8Idx閫氶亾鍙凤紝enStatus鑾峰彇鍝釜鐘舵 + ** + ** \retval 鐘舵佸 + **\retval ErrorInvalidParameter鑾峰彇澶辫触 + ******************************************************************************/ +boolean_t LPUart_GetStatus(M0P_LPUART_TypeDef* LPUARTx,en_lpuart_status_t enStatus) +{ + boolean_t bStatus = FALSE; + + ASSERT(IS_VALID_STATUS(enStatus)); + + bStatus = GetBit((uint32_t)(&(LPUARTx->ISR)), enStatus); + + return bStatus; +} + +/** + ****************************************************************************** + ** \brief LPUART閫氶亾閫氫俊鐘舵佸叏閮ㄦ竻闄 + ** + ** \param [in] u8Idx閫氶亾鍙 + ** + ** \retval OK + ******************************************************************************/ +en_result_t LPUart_ClrIsr(M0P_LPUART_TypeDef* LPUARTx) +{ + LPUARTx->ICR = 0u; + return Ok; +} + +/** + ****************************************************************************** + ** \brief LPUART閫氶亾閫氫俊鐘舵佹竻闄 + ** + ** \param [in] u8Idx閫氶亾鍙凤紝enStatus娓呴櫎鍝釜鐘舵 + ** + ** \retval 鐘舵佸 + **\retval ErrorInvalidParameter娓呴櫎澶辫触 + ******************************************************************************/ +en_result_t LPUart_ClrStatus(M0P_LPUART_TypeDef* LPUARTx,en_lpuart_status_t enStatus) +{ + ASSERT(IS_VALID_STATUS(enStatus)); + + SetBit((uint32_t)(&(LPUARTx->ICR)), enStatus, FALSE); + + return Ok; +} + +/** + ****************************************************************************** + ** \brief LPUART閫氶亾鍙戦佹暟鎹嚱鏁,鏌ヨ鏂瑰紡璋冪敤姝ゅ嚱鏁帮紝涓柇鏂瑰紡鍙戦佷笉閫傜敤 + ** + ** \param [in] u8Idx閫氶亾鍙凤紝Data鍙戦佹暟鎹 + ** + ** \retval Ok鍙戦佹垚鍔 + **\retval ErrorInvalidParameter鍙戦佸け璐 + ******************************************************************************/ +en_result_t LPUart_SendData(M0P_LPUART_TypeDef* LPUARTx, uint8_t u8Data) +{ + while(FALSE == LPUart_GetStatus(LPUARTx,LPUartTxe)) + {} + LPUARTx->SBUF_f.DATA = u8Data; + while(FALSE == LPUart_GetStatus(LPUARTx,LPUartTC)) + {} + LPUart_ClrStatus(LPUARTx,LPUartTC); + return Ok; +} + +/** + ****************************************************************************** + ** \brief LPUART閫氶亾鍙戦佹暟鎹嚱鏁,涓柇鏂瑰紡璋冪敤姝ゅ嚱鏁 + ** + ** \param [in] u8Idx閫氶亾鍙凤紝Data鍙戦佹暟鎹 + ** + ** \retval Ok鍙戦佹垚鍔 + **\retval ErrorInvalidParameter鍙戦佸け璐 + ******************************************************************************/ +en_result_t LPUart_SendDataIt(M0P_LPUART_TypeDef* LPUARTx, uint8_t u8Data) +{ + LPUARTx->SBUF_f.DATA = u8Data; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief LPUART閫氶亾鎺ユ敹鏁版嵁鍑芥暟 + ** + ** \param [in] u8Idx閫氶亾鍙 + ** + ** \retval 鎺ユ敹鏁版嵁 + **\retval ErrorInvalidParameter鎺ユ敹澶辫触 + ******************************************************************************/ +uint8_t LPUart_ReceiveData(M0P_LPUART_TypeDef* LPUARTx) +{ + return (LPUARTx->SBUF_f.DATA); +} + +/** + ****************************************************************************** + ** \brief LPUART閫氶亾鍒濆鍖栧嚱鏁 + ** + ** \param [in] u8Idx閫氶亾鍙凤紝pstcCfg鍒濆鍖栫粨鏋勪綋 @ref stc_lpuart_cfg_t + ** + ** \retval OK閰嶇疆鎴愬姛 + **\retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t LPUart_Init(M0P_LPUART_TypeDef* LPUARTx,stc_lpuart_cfg_t* pstcCfg) +{ + en_result_t enRet = Error; + const uint32_t u32Over[3] = {0x4, 0x3, 0x2}; + uint16_t u16OverShift; + float32_t f32Scnt=0; + + if(NULL == pstcCfg) + { + return ErrorInvalidParameter; + } + + LPUARTx->SCON = 0; + + LPUARTx->SCON = (uint32_t)pstcCfg->enStopBit | + (uint32_t)pstcCfg->enMmdorCk | + (uint32_t)pstcCfg->stcBaud.enSclkDiv | + (uint32_t)pstcCfg->stcBaud.enSclkSel | + (uint32_t)pstcCfg->enRunMode; + + if((LPUartMskMode1 == pstcCfg->enRunMode) || (LPUartMskMode3 == pstcCfg->enRunMode)) + { + u16OverShift = u32Over[pstcCfg->stcBaud.enSclkDiv/LPUartMsk8Or16Div]; + f32Scnt = (float32_t)(pstcCfg->stcBaud.u32Sclk)/(float32_t)(pstcCfg->stcBaud.u32Baud<SCNT = (uint16_t)(float32_t)(f32Scnt + 0.5f); + LPUart_EnableFunc(LPUARTx,LPUartRenFunc); ///<浣胯兘鏀跺彂 + } + + + + enRet = Ok; + return enRet; +} +//@} // LPUartGroup diff --git a/driver/src/lvd.c b/driver/src/lvd.c new file mode 100644 index 0000000..c41a48a --- /dev/null +++ b/driver/src/lvd.c @@ -0,0 +1,216 @@ +/****************************************************************************** +* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file lvd.c + ** + ** Low Voltage Detect driver API. + ** @link Lvd Group Some description @endlink + ** + ** - 2017-06-28 Alex First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "lvd.h" + +/** + ****************************************************************************** + ** \addtogroup LvdGroup + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +#define IS_VALID_INPUT(x) ( (x) <= LvdInputPB07 ) + +#define IS_VALID_THRESHOLD(x) ( (x) <= LvdTH3p3V ) + +#define IS_VALID_FILTER(x) ( (x) <= LvdFilter29ms ) + +#define IS_VALID_IRQTYPE(x) ( (x) <= LvdIrqFall ) + + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') * + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ +// static void LvdEnableNvic(void); +// static void LvdDisableNvic(void); +// static en_result_t LvdEnable(en_lvd_type_t enType, boolean_t bFlag); + +/****************************************************************************** + * Local variable definitions ('static') + ******************************************************************************/ + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + *****************************************************************************/ +/** + * \brief + * 浣胯兘LVD涓柇 + * + * \param [in] enType LVD涓柇绫诲瀷 + * + * \retval en_result_t Ok: 璁剧疆鎴愬姛 + * \retval en_result_t ErrorInvalidParameter: 鏃犳晥绫诲瀷 + */ +void Lvd_EnableIrq(void) +{ + M0P_LVD->CR_f.IE = TRUE; +} + +/** + * \brief + * 闄よ兘LVD涓柇 + * + * \param 鏃 + * + * \retval 鏃 + */ +void Lvd_DisableIrq(void) +{ + M0P_LVD->CR_f.IE = FALSE; +} + +/** + * \brief + * LVD鍒濆鍖 + * + * \param [in] pstcCfg LVD閰嶇疆鎸囬拡 + * + * \retval 鏃 + */ +void Lvd_Init(stc_lvd_cfg_t *pstcCfg) +{ + M0P_LVD->CR = 0; + + M0P_LVD->CR = (uint32_t)pstcCfg->enAct | + (uint32_t)pstcCfg->enFilter | + (uint32_t)pstcCfg->enFilterTime | + (uint32_t)pstcCfg->enInputSrc | + (uint32_t)pstcCfg->enIrqType | + (uint32_t)pstcCfg->enThreshold; +} + +/** + * \brief + * 浣胯兘LVD + * + * \param 鏃 + * + * \retval 鏃 + * + */ +void Lvd_Enable(void) +{ + M0P_LVD->CR_f.LVDEN = 1u; +} + +/** + * \brief + * 闄よ兘LVD + * + * \param 鏃 + * + * \retval 鏃 + */ +void Lvd_Disable(void) +{ + M0P_LVD->CR_f.LVDEN = 0u; +} + +/** + * \brief + * 鑾峰彇LVD涓柇鏍囧織 + * + * \param 鏃 + * + * \retval boolean_t 涓柇鏍囧織 + */ +boolean_t Lvd_GetIrqStat(void) +{ + return M0P_LVD->IFR_f.INTF; + +} + +/** + * \brief + * 娓呴櫎LVD涓柇鏍囧織 + * + * \param 鏃 + * + * \retval 鏃 + */ +void Lvd_ClearIrq(void) +{ + M0P_LVD->IFR_f.INTF = 0u; +} + +/** + * \brief + * 鑾峰彇Filter缁撴灉 + * + * \param 鏃 + * + * \retval boolean_t Fliter缁撴灉 + */ +boolean_t Lvd_GetFilterResult(void) +{ + return (boolean_t)M0P_LVD->IFR_f.FILTER; +} +//@} // LvdGroup + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/driver/src/opa.c b/driver/src/opa.c new file mode 100644 index 0000000..142db0a --- /dev/null +++ b/driver/src/opa.c @@ -0,0 +1,153 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file opa.c + ** + ** opa driver API. + ** @link opa Group Some description @endlink + ** + ** - 2019-04-11 First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "opa.h" + +/** + ****************************************************************************** + ** \addtogroup OPAGroup + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/****************************************************************************** + * Local variable definitions ('static') + ******************************************************************************/ + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + *****************************************************************************/ + +/** +****************************************************************************** + ** \brief OPA 閫氶亾浣胯兘 + ** + ** \param NewStatus : TRUE FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Opa_Cmd(boolean_t NewStatus) +{ + SetBit((uint32_t)(&(M0P_OPA->CR0)), 0, NewStatus); +} + +void Opa_CmdBuf(boolean_t NewStatus) +{ + SetBit((uint32_t)(&(M0P_OPA->CR0)), 2, NewStatus); +} + +/** +****************************************************************************** + ** \brief OPA闆剁偣鏍″噯閰嶇疆 + ** + ** \param InitZero : + ** \retval 鏃 + ** +******************************************************************************/ +void Opa_SetZero(stc_opa_zcfg_t* InitZero) +{ + M0P_OPA->CR0_f.AZEN = InitZero->bAzen; + M0P_OPA->CR1_f.CLK_SW_SET = InitZero->bClk_sw_set; + M0P_OPA->CR1_f.AZ_PULSE = InitZero->bAz_pulse; + M0P_OPA->CR1_f.TRIGGER = InitZero->bTrigger; + M0P_OPA->CR1_f.ADCTR_EN = InitZero->bAdctr_en; +} + +/** +****************************************************************************** + ** \brief 浣胯兘杈撳嚭OUTX + ** + ** \param onex : en_opa_oenx_t瀹氫箟鐨勫厓绱 + ** \retval 鏃 + ** +******************************************************************************/ +void Opa_CmdOnex(en_opa_oenx_t onex, boolean_t NewState) +{ + SetBit((uint32_t)(&(M0P_OPA->CR0)), onex, NewState); //浣胯兘OP3杈撳嚭X浣胯兘 +} + +/** +****************************************************************************** + ** \brief 閰嶇疆鏍¢浂鐩稿叧鐨勪綅 + ** + ** \param CtrlBit : en_opa_set0ctrl_t瀹氫箟鐨勫厓绱 + ** \param NewState: TRUE 鎴 FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Opa_ZeroBitCtrl(en_opa_set0ctrl_t CtrlBit, boolean_t NewState) +{ + SetBit((uint32_t)(&(M0P_OPA->CR1)), CtrlBit, NewState); +} +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/driver/src/pca.c b/driver/src/pca.c new file mode 100644 index 0000000..39de82d --- /dev/null +++ b/driver/src/pca.c @@ -0,0 +1,555 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file pca.c + ** + ** pca driver API. + ** @link pcnt Group Some description @endlink + ** + ** - 2019-04-09 First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "pca.h" + +/** + ****************************************************************************** + ** \addtogroup PCNTGroup + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/****************************************************************************** + * Local variable definitions ('static') + ******************************************************************************/ + +/** +****************************************************************************** + ** \brief 鑾峰彇涓柇婧愮殑鏍囧織浣 + ** @param IT_Src : 涓柇婧愭爣蹇椾綅 + ** \retval FALSE 鎴朤RUE + ** +******************************************************************************/ +boolean_t Pca_GetItStatus(en_pca_ccficlr_t It_Src) +{ + return (((M0P_PCA->CCON)>>It_Src) & 1) > 0? TRUE : FALSE; +} + +/** +****************************************************************************** + ** \brief 娓呴櫎涓柇婧愮殑鏍囧織浣 + ** @param IT_Src : 涓柇婧愭爣蹇椾綅 + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_ClrItStatus(en_pca_ccficlr_t It_Src) +{ + M0P_PCA->ICLR &= ~(uint32_t)(1<CCON)), 6, NewStatus); +} + +/** +****************************************************************************** + ** \brief PCA 绌洪棽妯″紡IDLE涓嬶紝PCA鏄惁鍋滄宸ヤ綔璁剧疆 + ** @param NewStatus : TRUE 鎴 FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_SetCidl(boolean_t NewStatus) +{ + SetBit((uint32_t)(&(M0P_PCA->CMOD)), 7, NewStatus); +} + +/** +****************************************************************************** + ** \brief PCA 妯″潡4鐨勭湅闂ㄧ嫍浣胯兘鎺у埗 + ** @param NewStatus : TRUE 鎴 FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_Set4Wdte(boolean_t NewStatus) +{ + SetBit((uint32_t)(&(M0P_PCA->CMOD)), 6, NewStatus); +} + +/** +****************************************************************************** + ** \brief PCA 璁℃暟鍣ㄤ腑鏂帶鍒禤CA_CMOD涓瑿FIE锛屽搴旂殑鎺у埗涓柇浣峆CA_CCON涓殑CF涓嶱CA_ICLR涓殑CF + ** @param NewStatus : TRUE 鎴 FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_ConfPcaIt(boolean_t NewStatus) +{ + SetBit((uint32_t)(&(M0P_PCA->CMOD)), 0, NewStatus); +} + +/** +****************************************************************************** + ** \brief PCA 姣旇緝鎹曡幏涓柇浣胯兘鎺у埗 PCA_CCAPMx鐨凜CIE + ** @param Modulex : pca_module0~4 + ** @param NewStatus : TRUE 鎴 FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_ConfModulexIt(en_pca_module_t Modulex, boolean_t NewStatus) +{ + switch(Modulex) + { + case PcaModule0: + SetBit((uint32_t)(&(M0P_PCA->CCAPM0)), 0, NewStatus); + break; + case PcaModule1: + SetBit((uint32_t)(&(M0P_PCA->CCAPM1)), 0, NewStatus); + break; + case PcaModule2: + SetBit((uint32_t)(&(M0P_PCA->CCAPM2)), 0, NewStatus); + break; + case PcaModule3: + SetBit((uint32_t)(&(M0P_PCA->CCAPM3)), 0, NewStatus); + break; + case PcaModule4: + SetBit((uint32_t)(&(M0P_PCA->CCAPM4)), 0, NewStatus); + break; + default: + break; + } +} + +/** +****************************************************************************** + ** \brief PCA 妯″潡0鐨勫垵濮嬪寲 + ** @param InitStruct : PCA鍒濆鍖栭厤缃殑缁撴瀯浣 + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_M0Init(stc_pcacfg_t* InitStruct) +{ + M0P_PCA->CMOD_f.CPS = InitStruct->pca_clksrc; + M0P_PCA->CMOD_f.CIDL = InitStruct->pca_cidl; + M0P_PCA->CCAPM0_f.ECOM = InitStruct->pca_ecom; + M0P_PCA->CCAPM0_f.CAPP = InitStruct->pca_capp; + M0P_PCA->CCAPM0_f.CAPN = InitStruct->pca_capn; + M0P_PCA->CCAPM0_f.MAT = InitStruct->pca_mat; + M0P_PCA->CCAPM0_f.TOG = InitStruct->pca_tog; + M0P_PCA->CCAPM0_f.PWM = InitStruct->pca_pwm; + M0P_PCA->EPWM_f.EPWM = InitStruct->pca_epwm; + if(InitStruct->pca_pwm == PcaPwm8bitEnable) + { + M0P_PCA->CCAP0L_f.CCAP0 = InitStruct->pca_ccapl; + M0P_PCA->CCAP0H_f.CCAP0 = InitStruct->pca_ccaph; + } + else + { + M0P_PCA->CCAP0_f.CCAP0 = InitStruct->pca_ccap; + } + M0P_PCA->CARR_f.CARR = InitStruct->pca_carr; +} + +/** +****************************************************************************** + ** \brief PCA 妯″潡1鐨勫垵濮嬪寲 + ** @param InitStruct : PCA鍒濆鍖栭厤缃殑缁撴瀯浣 + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_M1Init(stc_pcacfg_t* InitStruct) +{ + M0P_PCA->CMOD_f.CPS = InitStruct->pca_clksrc; + M0P_PCA->CMOD_f.CIDL = InitStruct->pca_cidl; + M0P_PCA->CCAPM1_f.ECOM = InitStruct->pca_ecom; + M0P_PCA->CCAPM1_f.CAPP = InitStruct->pca_capp; + M0P_PCA->CCAPM1_f.CAPN = InitStruct->pca_capn; + M0P_PCA->CCAPM1_f.MAT = InitStruct->pca_mat; + M0P_PCA->CCAPM1_f.TOG = InitStruct->pca_tog; + M0P_PCA->CCAPM1_f.PWM = InitStruct->pca_pwm; + M0P_PCA->EPWM_f.EPWM = InitStruct->pca_epwm; + if(InitStruct->pca_pwm == PcaPwm8bitEnable) + { + M0P_PCA->CCAP1L_f.CCAP1 = InitStruct->pca_ccapl; + M0P_PCA->CCAP1H_f.CCAP1 = InitStruct->pca_ccaph; + } + else + { + M0P_PCA->CCAP1_f.CCAP1 = InitStruct->pca_ccap; + } + M0P_PCA->CARR_f.CARR = InitStruct->pca_carr; +} + +/** +****************************************************************************** + ** \brief PCA 妯″潡2鐨勫垵濮嬪寲 + ** @param InitStruct : PCA鍒濆鍖栭厤缃殑缁撴瀯浣 + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_M2Init(stc_pcacfg_t* InitStruct) +{ + M0P_PCA->CMOD_f.CPS = InitStruct->pca_clksrc; + M0P_PCA->CMOD_f.CIDL = InitStruct->pca_cidl; + M0P_PCA->CCAPM2_f.ECOM = InitStruct->pca_ecom; + M0P_PCA->CCAPM2_f.CAPP = InitStruct->pca_capp; + M0P_PCA->CCAPM2_f.CAPN = InitStruct->pca_capn; + M0P_PCA->CCAPM2_f.MAT = InitStruct->pca_mat; + M0P_PCA->CCAPM2_f.TOG = InitStruct->pca_tog; + M0P_PCA->CCAPM2_f.PWM = InitStruct->pca_pwm; + M0P_PCA->EPWM_f.EPWM = InitStruct->pca_epwm; + if(InitStruct->pca_pwm == PcaPwm8bitEnable) + { + M0P_PCA->CCAP2L_f.CCAP2 = InitStruct->pca_ccapl; + M0P_PCA->CCAP2H_f.CCAP2 = InitStruct->pca_ccaph; + } + else + { + M0P_PCA->CCAP2_f.CCAP2 = InitStruct->pca_ccap; + } + M0P_PCA->CARR_f.CARR = InitStruct->pca_carr; +} + +/** +****************************************************************************** + ** \brief PCA 妯″潡3鐨勫垵濮嬪寲 + ** @param InitStruct : PCA鍒濆鍖栭厤缃殑缁撴瀯浣 + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_M3Init(stc_pcacfg_t* InitStruct) +{ + M0P_PCA->CMOD_f.CPS = InitStruct->pca_clksrc; + M0P_PCA->CMOD_f.CIDL = InitStruct->pca_cidl; + M0P_PCA->CCAPM3_f.ECOM = InitStruct->pca_ecom; + M0P_PCA->CCAPM3_f.CAPP = InitStruct->pca_capp; + M0P_PCA->CCAPM3_f.CAPN = InitStruct->pca_capn; + M0P_PCA->CCAPM3_f.MAT = InitStruct->pca_mat; + M0P_PCA->CCAPM3_f.TOG = InitStruct->pca_tog; + M0P_PCA->CCAPM3_f.PWM = InitStruct->pca_pwm; + M0P_PCA->EPWM_f.EPWM = InitStruct->pca_epwm; + if(InitStruct->pca_pwm == PcaPwm8bitEnable) + { + M0P_PCA->CCAP3L_f.CCAP3 = InitStruct->pca_ccapl; + M0P_PCA->CCAP3H_f.CCAP3 = InitStruct->pca_ccaph; + } + else + { + M0P_PCA->CCAP3_f.CCAP3 = InitStruct->pca_ccap; + } + M0P_PCA->CARR_f.CARR = InitStruct->pca_carr; +} + +/** +****************************************************************************** + ** \brief PCA 妯″潡4鐨勫垵濮嬪寲 + ** @param InitStruct : PCA鍒濆鍖栭厤缃殑缁撴瀯浣 + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_M4Init(stc_pcacfg_t* InitStruct) +{ + M0P_PCA->CMOD_f.CPS = InitStruct->pca_clksrc; + M0P_PCA->CMOD_f.CIDL = InitStruct->pca_cidl; + M0P_PCA->CCAPM4_f.ECOM = InitStruct->pca_ecom; + M0P_PCA->CCAPM4_f.CAPP = InitStruct->pca_capp; + M0P_PCA->CCAPM4_f.CAPN = InitStruct->pca_capn; + M0P_PCA->CCAPM4_f.MAT = InitStruct->pca_mat; + M0P_PCA->CCAPM4_f.TOG = InitStruct->pca_tog; + M0P_PCA->CCAPM4_f.PWM = InitStruct->pca_pwm; + M0P_PCA->EPWM_f.EPWM = InitStruct->pca_epwm; + if(InitStruct->pca_pwm == PcaPwm8bitEnable) + { + M0P_PCA->CCAP4L_f.CCAP4 = InitStruct->pca_ccapl; + M0P_PCA->CCAP4H_f.CCAP4 = InitStruct->pca_ccaph; + } + else + { + M0P_PCA->CCAP4_f.CCAP4 = InitStruct->pca_ccap; + } + M0P_PCA->CARR_f.CARR = InitStruct->pca_carr; +} + +/** +****************************************************************************** + ** \brief PCA 璇诲彇CNT瀵勫瓨鍣ㄧ殑鏁板 + ** @param 鏃 + ** \retval CNT鐨勪綆鍗婂瓧鍊 + ** +******************************************************************************/ +uint16_t Pca_GetCnt(void) +{ + return (uint16_t)(M0P_PCA->CNT); +} + +/** +****************************************************************************** + ** \brief PCA 鍚慍NT瀵勫瓨鍣ㄥ啓鍏ユ暟鍊 + ** @param cnt : 鎵瑕佸啓鍏ョ殑鏁板 + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_SetCnt(uint16_t cnt) +{ + if(GetBit((uint32_t)(&(M0P_PCA->CCON)), 6)==TRUE) + { + Pca_StartPca(FALSE); + M0P_PCA->CNT_f.CNT = cnt; + Pca_StartPca(TRUE); + } + else + { + M0P_PCA->CNT_f.CNT = cnt; + } + +} + +/** +****************************************************************************** + ** \brief PCA 杩斿洖鎸囧畾閫氶亾姣旇緝楂橀熻緭鍑烘爣蹇楀瘎瀛樺櫒鐨勫 + ** @param Modulex : 閫氶亾鍙穢=0銆1銆2銆3銆4 + ** \retval TRUE 鎴 FALSE + ** +******************************************************************************/ +boolean_t Pca_GetOut(en_pca_module_t Modulex) +{ + return GetBit((uint32_t)(&(M0P_PCA->CCAPO)), Modulex); +} + +/** +****************************************************************************** + ** \brief PCA 璁剧疆姣旇緝鎹曡幏16浣嶅瘎瀛樺櫒CCAPx鏁板 + ** @param Modulex : 閫氶亾鍙穢=0銆1銆2銆3銆4 + ** @param Value: 鎵瑕佽缃殑鍊 + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_SetCcap(en_pca_module_t Modulex, uint16_t Value) +{ + switch(Modulex) + { + case 0: + M0P_PCA->CCAP0_f.CCAP0 = Value; + break; + case 1: + M0P_PCA->CCAP1_f.CCAP1 = Value; + break; + case 2: + M0P_PCA->CCAP2_f.CCAP2 = Value; + break; + case 3: + M0P_PCA->CCAP3_f.CCAP3 = Value; + break; + case 4: + M0P_PCA->CCAP4_f.CCAP4 = Value; + break; + default: + break; + } +} + +/** +****************************************************************************** + ** \brief PCA 璇诲彇姣旇緝鎹曡幏16浣嶅瘎瀛樺櫒CCAPx鏁板 + ** @param Modulex : 閫氶亾鍙穢=0銆1銆2銆3銆4 + ** \retval CCAPx鐨勫硷紝x=0銆1銆2銆3銆4 + ** +******************************************************************************/ +uint16_t Pca_GetCcap(en_pca_module_t Modulex) +{ + uint16_t tmp; + switch(Modulex) + { + case 0: + tmp = M0P_PCA->CCAP0_f.CCAP0; + break; + case 1: + tmp = M0P_PCA->CCAP1_f.CCAP1; + break; + case 2: + tmp = M0P_PCA->CCAP2_f.CCAP2; + break; + case 3: + tmp = M0P_PCA->CCAP3_f.CCAP3; + break; + case 4: + tmp = M0P_PCA->CCAP4_f.CCAP4; + break; + default: + break; + } + return tmp; +} + +/** +****************************************************************************** + ** \brief PCA 璁剧疆鑷姩閲嶈杞藉瘎瀛樺櫒鏁板 + ** @param 鏃 + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_SetCarr(uint16_t Value) +{ + M0P_PCA->CARR_f.CARR = Value; +} + +/** +****************************************************************************** + ** \brief PCA 鑾峰彇鑷姩閲嶈杞藉瘎瀛樺櫒鏁板 + ** @param 鏃 + ** \retval 鏃 + ** +******************************************************************************/ +uint16_t Pca_GetCarr(void) +{ + return M0P_PCA->CARR_f.CARR; +} + +/** +****************************************************************************** + ** \brief PCA 璁剧疆姣旇緝鎹曡幏瀵勫瓨鍣ㄧ殑楂8浣嶅拰浣8浣 + ** @param Modulex : 閫氶亾鍙穢=0銆1銆2銆3銆4 + ** @param ValueH : 瑕佸啓鍏ラ珮8浣嶇殑鏁板 + ** @param ValueL : 瑕佸啓鍏ヤ綆8浣嶇殑鏁板 + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_SetCcapHL(en_pca_module_t Modulex, uint8_t ValueH, uint8_t ValueL) +{ + switch(Modulex) + { + case 0: + M0P_PCA->CCAP0H_f.CCAP0 = ValueH; + M0P_PCA->CCAP0L_f.CCAP0 = ValueL; + break; + case 1: + M0P_PCA->CCAP1H_f.CCAP1 = ValueH; + M0P_PCA->CCAP1L_f.CCAP1 = ValueL; + break; + case 2: + M0P_PCA->CCAP2H_f.CCAP2 = ValueH; + M0P_PCA->CCAP2L_f.CCAP2 = ValueL; + break; + case 3: + M0P_PCA->CCAP3H_f.CCAP3 = ValueH; + M0P_PCA->CCAP3L_f.CCAP3 = ValueL; + break; + case 4: + M0P_PCA->CCAP4H_f.CCAP4 = ValueH; + M0P_PCA->CCAP4L_f.CCAP4 = ValueL; + break; + default: + break; + } +} + +/** +****************************************************************************** + ** \brief PCA 璇诲彇姣旇緝鎹曡幏瀵勫瓨鍣ㄧ殑楂8浣嶅拰浣8浣 + ** @param Modulex : 閫氶亾鍙穢=0銆1銆2銆3銆4 + ** @param ValueH : CCAPx楂8浣嶇殑鏁板 + ** @param ValueL : CCAPx浣8浣嶇殑鏁板 + ** \retval 鏃 + ** +******************************************************************************/ +void Pca_GetCcapHL(en_pca_module_t Modulex, uint8_t *ValueH, uint8_t *ValueL) +{ + switch(Modulex) + { + case 0: + *ValueH = M0P_PCA->CCAP0H_f.CCAP0; + *ValueL = M0P_PCA->CCAP0L_f.CCAP0; + break; + case 1: + *ValueH = M0P_PCA->CCAP1H_f.CCAP1; + *ValueL = M0P_PCA->CCAP1L_f.CCAP1; + break; + case 2: + *ValueH = M0P_PCA->CCAP2H_f.CCAP2; + *ValueL = M0P_PCA->CCAP2L_f.CCAP2; + break; + case 3: + *ValueH = M0P_PCA->CCAP3H_f.CCAP3; + *ValueL = M0P_PCA->CCAP3L_f.CCAP3; + break; + case 4: + *ValueH = M0P_PCA->CCAP4H_f.CCAP4; + *ValueL = M0P_PCA->CCAP4L_f.CCAP4; + break; + default: + break; + } +} +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + + + + diff --git a/driver/src/pcnt.c b/driver/src/pcnt.c new file mode 100644 index 0000000..cdcf160 --- /dev/null +++ b/driver/src/pcnt.c @@ -0,0 +1,316 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file pcnt.c + ** + ** pcnt driver API. + ** @link pcnt Group Some description @endlink + ** + ** - 2019-04-08 First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "pcnt.h" + +/** + ****************************************************************************** + ** \addtogroup PCNTGroup + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/****************************************************************************** + * Local variable definitions ('static') + ******************************************************************************/ + + +/** +****************************************************************************** + ** \brief PCNT鐨勫惎鍔ㄥ拰鍋滄鎺у埗 + ** @param NewState : Run_Enable 鎴栬 Run_Disable + ** @param NewState : FALSE鎴栬匱RUE + ** \retval 鏃 + ** +******************************************************************************/ +boolean_t Pcnt_Cmd(boolean_t NewState) +{ + SetBit((uint32_t)(&(M0P_PCNT->RUN)), 0, NewState); + return GetBit((uint32_t)(&(M0P_PCNT->RUN)), 0); +} + + +/** +****************************************************************************** + ** \brief 灏咮UF涓殑鍊煎悓姝ュ埌CNT + ** @param value : 瑕佸悓姝ュ埌TOP鐨勬暟鍊 + ** \retval ok 鎴 ErrorTimeout + ** +******************************************************************************/ +en_result_t Pcnt_SetB2T(uint16_t value) +{ + uint16_t u16TimeOut; + + u16TimeOut = 1000; + M0P_PCNT->BUF = value; + M0P_PCNT->CMD_f.B2T = 1; + + while(u16TimeOut--) + { + if(M0P_PCNT->SR2_f.B2T == FALSE) + { + break; + } + } + if(u16TimeOut == 0) + { + return ErrorTimeout; + } + return Ok; +} + +/** +****************************************************************************** + ** \brief 灏咮UF涓殑鍊煎悓姝ュ埌CNT + ** @param value : 瑕佸悓姝ュ埌CNT鐨勬暟鍊 + ** \retval ok 鎴 ErrorTimeout + ** +******************************************************************************/ +en_result_t Pcnt_SetB2C(uint16_t value) +{ + uint16_t u16TimeOut; + u16TimeOut = 1000; + M0P_PCNT->BUF = value; + M0P_PCNT->CMD_f.B2C = 1; + + while(u16TimeOut--) + { + if(M0P_PCNT->SR2_f.B2C == FALSE) + { + break; + } + } + if(u16TimeOut == 0) + { + return ErrorTimeout; + } + return Ok; +} + +/** +****************************************************************************** + ** \brief 灏員OP涓殑鍊煎悓姝ュ埌CNT + ** @param value : 瑕佸悓姝ュ埌CNT鐨勬暟鍊 + ** \retval ok 鎴 ErrorTimeout + ** +******************************************************************************/ +en_result_t Pcnt_SetT2C(void) +{ + uint16_t u16TimeOut; + u16TimeOut = 1000; + M0P_PCNT->CMD_f.T2C = 1; + while(u16TimeOut--) + { + if(M0P_PCNT->SR2_f.T2C == FALSE) + { + break; + } + } + if(u16TimeOut == 0) + { + return ErrorTimeout; + } + return Ok; +} + + +/** +****************************************************************************** + ** \brief 璧嬪糂UF + ** @param value : 瑕佽祴鍊肩粰BUF鐨勬暟鍊 + ** \retval 鏃 + ** +******************************************************************************/ +void Pcnt_SetBuf(uint16_t value) +{ + M0P_PCNT->TOP_f.TOP = value; +} + +/** +****************************************************************************** + ** \brief 鍒濆鍖 + ** @param start : 瑕佸悓姝ュ埌TOP鐨勬暟鍊 + ** @param end : 瑕佸悓姝ュ埌CNT鐨勬暟鍊 + ** \retval ok 鎴 ErrorTimeout + ** +******************************************************************************/ +void Pcnt_Init(stc_pcnt_initstruct_t* InitStruct) +{ + M0P_PCNT->CTRL_f.S1P = InitStruct->Pcnt_S1Sel; + M0P_PCNT->CTRL_f.S0P = InitStruct->Pcnt_S0Sel; + M0P_PCNT->CTRL_f.CLKSEL = InitStruct->Pcnt_Clk; + M0P_PCNT->CTRL_f.MODE = InitStruct->Pcnt_Mode; + if(InitStruct->Pcnt_Mode == PcntDoubleMode)//濡傛灉鏄弻閫氶亾姝d氦鑴夊啿璁℃暟妯″紡 + { + M0P_PCNT->SR1_f.DIR = InitStruct->Pcnt_Dir; + } + else + { + M0P_PCNT->CTRL_f.DIR = InitStruct->Pcnt_Dir; + } + M0P_PCNT->FLT_f.EN = InitStruct->Pcnt_FltEn; + M0P_PCNT->FLT_f.DEBTOP = InitStruct->Pcnt_DebTop; + M0P_PCNT->FLT_f.CLKDIV = InitStruct->Pcnt_ClkDiv; + M0P_PCNT->TOCR_f.EN = InitStruct->Pcnt_TocrEn; + M0P_PCNT->TOCR_f.TH = InitStruct->Pcnt_TocrTh; + + M0P_PCNT->DBG_f.DBG = InitStruct->Pcnt_Dbg; +} + +/** +****************************************************************************** + ** \brief 閰嶇疆涓柇婧愮殑浣胯兘 + ** @param IT_Src : 涓柇婧愬啀PCNT_IEN鍐呴儴鐨勪綅浣嶇疆 + ** @param NewState : FALSE 鎴朤RUE + ** \retval 鏃 + ** +******************************************************************************/ +void Pcnt_ItCfg(en_pcnt_itfce_t IT_Src, boolean_t NewState) +{ + if(NewState == TRUE) + { + M0P_PCNT->IEN |= (uint32_t)(1<IEN &= ~(uint32_t)(1<IFR >> IT_Src) & 1u) > 0 ? TRUE : FALSE; +} + +/** +****************************************************************************** + ** \brief 娓呴櫎涓柇婧愮殑鏍囧織浣 + ** @param IT_Src : 涓柇婧愭爣蹇椾綅 + ** \retval 鏃 + ** +******************************************************************************/ +void Pcnt_ClrItStatus(en_pcnt_itfce_t IT_Src) +{ + M0P_PCNT->ICR &= ~(uint32_t)(1<<(uint32_t)IT_Src); +} + + +/** +****************************************************************************** + ** \brief 鑾峰彇PCNT_CNT瀵勫瓨鍣ㄧ殑鏁板 + ** @param 鏃 + ** \retval PCNT_CNT鏁板 + ** +******************************************************************************/ +uint16_t Pcnt_GetCnt(void) +{ + return (uint16_t)(M0P_PCNT->CNT); +} + +/** +****************************************************************************** + ** \brief 鑾峰彇PCNT_TOP瀵勫瓨鍣ㄧ殑鏁板 + ** @param 鏃 + ** \retval PCNT_TOP鏁板 + ** +******************************************************************************/ +uint16_t Pcnt_GetTop(void) +{ + return (uint16_t)(M0P_PCNT->TOP); +} + +/** +****************************************************************************** + ** \brief 鑾峰彇PCNT_BUF瀵勫瓨鍣ㄧ殑鏁板 + ** @param 鏃 + ** \retval PCNT_BUF鏁板 + ** +******************************************************************************/ +uint16_t Pcnt_GetBuf(void) +{ + return (uint16_t)(M0P_PCNT->BUF); +} + +//@} // Group +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/driver/src/ram.c b/driver/src/ram.c new file mode 100644 index 0000000..44081b6 --- /dev/null +++ b/driver/src/ram.c @@ -0,0 +1,156 @@ +/****************************************************************************** +*Copyright(C)2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file ram.c + ** + ** Common API of ram. + ** @link RamGroup Some description @endlink + ** + ** - 2018-05-08 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "ram.h" +/** + ******************************************************************************* + ** \addtogroup ramGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ***************************************************************************** + ** \brief Ram濂囧伓鏍¢獙鍑洪敊鍦板潃鑾峰彇 + ** + ** + ** \retval ERROR ADDRESS + *****************************************************************************/ +uint32_t Ram_ErrAddrGet(void) +{ + return M0P_RAM->ERRADDR; +} + +/** + ***************************************************************************** + ** \brief Ram涓柇鏍囧織鑾峰彇 + ** + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +boolean_t Ram_GetIntFlag(void) +{ + if(M0P_RAM->IFR & 0x1) + { + return TRUE; + } + else + { + return FALSE; + } +} + +/** + ***************************************************************************** + ** \brief Ram涓柇鏍囧織娓呴櫎 + ** + ** + ** \retval Null + *****************************************************************************/ +void Ram_ClearIntFlag(void) +{ + M0P_RAM->ICLR = 0u; +} + +/** + ***************************************************************************** + ** \brief Ram涓柇浣胯兘 + ** + ** \retval Null + *****************************************************************************/ +void Ram_EnableIrq (void) +{ + M0P_RAM->CR |= 0x2u; +} + +/** + ***************************************************************************** + ** \brief ram涓柇绂佹 + ** + ** \retval Null + *****************************************************************************/ +void Ram_DisableIrq(void) +{ + M0P_RAM->CR &= 0x1; +} + + +//@} // RamGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/driver/src/reset.c b/driver/src/reset.c new file mode 100644 index 0000000..41d0321 --- /dev/null +++ b/driver/src/reset.c @@ -0,0 +1,184 @@ +/****************************************************************************** +*Copyright(C)2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file reset.c + ** + ** Common API of reset. + ** @link resetGroup Some description @endlink + ** + ** - 2017-05-04 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "reset.h" + +/** + ******************************************************************************* + ** \addtogroup ResetGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ******************************************************************************* + ** \brief 鑾峰彇澶嶄綅婧愮被鍨. + ** + ** \param [out] enRstFlg @ref en_reset_flag_t + ** + ** \retval TRUE or FALSE + ******************************************************************************/ +boolean_t Reset_GetFlag(en_reset_flag_t enRstFlg) +{ + if(M0P_RESET->RESET_FLAG&enRstFlg) + { + return TRUE; + } + else + { + return FALSE; + } +} + +/** + ******************************************************************************* + ** \brief 娓呴櫎澶嶄綅婧愮被鍨. + ** + ** \param [in] pstcFlag @ref en_reset_flag_t + ** + ** \retval Null + ******************************************************************************/ +void Reset_ClearFlag(en_reset_flag_t enRstFlg) +{ + M0P_RESET->RESET_FLAG &= ~(uint32_t)enRstFlg; +} + +/** + ******************************************************************************* + ** \brief 娓呴櫎鎵鏈夊浣嶆簮绫诲瀷. + ** + ** \param Null + ** + ** \retval Null + ******************************************************************************/ +void Reset_ClearFlagAll(void) +{ + M0P_RESET->RESET_FLAG = 0; +} + +/** + ******************************************************************************* + ** \brief 鎵鏈夋ā鍧楄繘琛屼竴娆″浣. + ** + ** + ** \retval Null + ******************************************************************************/ +void Reset_RstPeripheralAll(void) +{ + M0P_RESET->PERI_RESET0 = 0u; + M0P_RESET->PERI_RESET0 = 0xFFFFFFFFu; + M0P_RESET->PERI_RESET1 = 0u; + M0P_RESET->PERI_RESET1 = 0xFFFFFFFFu; +} + +/** + ******************************************************************************* + ** \brief 瀵瑰璁炬簮0妯″潡杩涜涓娆″浣. + ** + ** \param [in] enPeri @ref en_reset_peripheral0_t + ** + ** \retval Null + ******************************************************************************/ +void Reset_RstPeripheral0(en_reset_peripheral0_t enPeri) +{ + M0P_RESET->PERI_RESET0 &= ~(uint32_t)enPeri; + M0P_RESET->PERI_RESET0 |= (uint32_t)enPeri; +} + +/** + ******************************************************************************* + ** \brief 瀵瑰璁炬簮1妯″潡杩涜涓娆″浣. + ** + ** \param [in] enPeri @ref en_reset_peripheral1_t + ** + ** \retval Null + ******************************************************************************/ +void Reset_RstPeripheral1(en_reset_peripheral1_t enPeri) +{ + M0P_RESET->PERI_RESET1 &= ~(uint32_t)enPeri; + M0P_RESET->PERI_RESET1 |= (uint32_t)enPeri; +} + +//@} // ResetGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/driver/src/rtc.c b/driver/src/rtc.c new file mode 100644 index 0000000..6d25249 --- /dev/null +++ b/driver/src/rtc.c @@ -0,0 +1,520 @@ +/************************************************************************************* +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file rtc.c + ** + ** RTC function driver API. + ** @link SampleGroup Some description @endlink + ** + ** - 2019-04-10 First version + ** + ******************************************************************************/ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "rtc.h" +/** + ****************************************************************************** + ** \addtogroup RtcGroup + ******************************************************************************/ +//@{ + +/******************************************************************************/ +/* Local pre-processor symbols/macros ('#define') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local function prototypes ('const') */ +/******************************************************************************/ +const uint8_t Leap_Month_Base[] = {3,6,0,3,5,1,3,6,2,4,0,2}; +const uint8_t NonLeap_Month_Base[] = {4,0,0,3,5,1,3,6,2,4,0,2}; +const uint8_t Cnst_Month_Tbl[12]={0x31,0x28,0x31,0x30,0x31,0x30,0x31,0x31,0x30,0x31,0x30,0x31}; +/******************************************************************************/ +/* Local function prototypes ('static') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local variable prototypes ('static') */ +/******************************************************************************/ + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + *****************************************************************************/ + +/** +****************************************************************************** + ** \brief RTC璁℃暟鍣ㄧ殑浣胯兘鎴栧仠姝 + ** + ** @param NewState : TRUE 鎴 FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Rtc_Cmd(boolean_t NewState) +{ + SetBit((uint32_t)(&(M0P_RTC->CR0)), 7, NewState); +} + +/** +****************************************************************************** + ** \brief RTC璁℃暟鍣ㄥ惎鍔ㄧ瓑寰呭嚱鏁帮紝濡傚惎鍔≧TC璁℃暟鍣ㄥ悗绔嬪嵆杩涘叆浣庡姛鑰楁ā寮忥紝 + ** 杩涘叆浣庡姛鑰楁ā寮忎箣鍓嶉渶鎵ц姝ゅ嚱鏁帮紝浠ョ‘淇漅TC宸插惎鍔ㄥ畬鎴 + ** + ** @param NewState : TRUE 鎴 FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Rtc_StartWait(void) +{ + M0P_RTC->CR1_f.WAIT = 1; + while (M0P_RTC->CR1_f.WAITF != 1) //绛夊緟鐩村埌WAITF=1 + { + ; + } + M0P_RTC->CR1_f.WAIT = 0; + while (M0P_RTC->CR1_f.WAITF != 0) //绛夊緟鐩村埌WAITF=0 + { + ; + } +} + +/** +****************************************************************************** + ** \brief RTC鐨1Hz杈撳嚭鐨勪娇鑳芥垨鍋滄 + ** @param pricision : RtcHz1selGeneralPricision 鎴 RtcHz1selHighPricision + ** @param NewState : Hz1o_Disable 鎴 HZ1o_Enable + ** \retval 鏃 + ** +******************************************************************************/ +void Rtc_Hz1Cmd(en_rtc_hz1sel_t pricision, boolean_t NewState) +{ + SetBit((uint32_t)(&(M0P_RTC->CR0)), 6, pricision); //璁剧疆鏅氱簿搴︽垨鑰呴珮绮惧害1Hz杈撳嚭 + SetBit((uint32_t)(&(M0P_RTC->CR0)), 5, NewState); //璁剧疆1Hz杈撳嚭浣胯兘鎴栫姝 +} + +/** +****************************************************************************** + ** \brief 璁剧疆鍛ㄦ湡涓柇鐨勭被鍨(PRDSEL)鍙婂叾鎵閫夌被鍨嬬殑鏃堕棿(PRDS鎴朠RDX) + ** + ** @param pstCyc: 鏍规嵁缁撴瀯浣撶殑瀹氫箟璁剧疆PRDSEL銆丳RDS涓嶱RDX + ** \retval Ok銆丒rror 鎴 ErrorInvalidParameter + ** +******************************************************************************/ +en_result_t Rtc_SetCyc(stc_rtc_cyccfg_t* pstCyc) +{ + en_result_t enRet = Error; + M0P_RTC->CR0_f.PRDSEL = pstCyc->rtcPrdsel; + if(pstCyc->rtcPrdsel == RtcPrds) + { + M0P_RTC->CR0_f.PRDS = pstCyc->rtcPrds; + } + else if(pstCyc->rtcPrdsel == RtcPrdx) + { + if(pstCyc->rtcPrdx>=64) + { + enRet = ErrorInvalidParameter; + return enRet; + } + M0P_RTC->CR0_f.PRDX = pstCyc->rtcPrdx; + } + else + { + ; + } + enRet = Ok; + return enRet; +} + +/** +****************************************************************************** + ** \brief RTC闂归挓涓柇鐨勪娇鑳芥垨鍋滄 + ** + ** @param NewState : TRUE 鎴 FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Rtc_AlmIeCmd(boolean_t NewState) +{ + SetBit((uint32_t)(&(M0P_RTC->CR1)), 3, 0); //娓呴櫎鍛ㄦ湡涓柇鏍囧織浣 + SetBit((uint32_t)(&(M0P_RTC->CR1)), 4, 0); //娓呴櫎鍛ㄦ湡涓柇鏍囧織浣 + SetBit((uint32_t)(&(M0P_RTC->CR1)), 6, NewState); +} + +/** +****************************************************************************** + ** \brief RTC闂归挓鐨勪娇鑳芥垨鍋滄 + ** + ** @param NewState : Almen_Disable 鎴 Almen_Enable + ** \retval 鏃 + ** +******************************************************************************/ +void Rtc_AlmEnCmd(boolean_t NewState) +{ + SetBit((uint32_t)(&(M0P_RTC->CR1)), 7, NewState); +} + +/** +****************************************************************************** + ** \brief 鑾峰彇RTC闂归挓涓柇鐘舵佷綅 + ** + ** @param 鏃 + ** \retval TRUE 鎴 FALSE + ** +******************************************************************************/ +boolean_t Rtc_GetAlmfItStatus(void) +{ + return GetBit((uint32_t)(&(M0P_RTC->CR1)), 4); +} + +/** +****************************************************************************** + ** \brief 娓呴櫎RTC闂归挓涓柇鐘舵佷綅 + ** + ** @param 鏃 + ** \retval 鏃 + ** +******************************************************************************/ +void Rtc_ClearAlmfItStatus(void) +{ + SetBit((uint32_t)(&(M0P_RTC->CR1)), 4, 0); +} + +/** +****************************************************************************** + ** \brief 娓呴櫎RTC鍛ㄦ湡涓柇鐘舵佷綅 + ** + ** @param 鏃 + ** \retval 鏃 + ** +******************************************************************************/ +void Rtc_ClearPrdfItStatus(void) +{ + SetBit((uint32_t)(&(M0P_RTC->CR1)), 3, 0); +} + +/** +****************************************************************************** + ** \brief 鑾峰彇RTC鍛ㄦ湡涓柇鐘舵佷綅 + ** + ** @param 鏃 + ** \retval TRUE 鎴 FALSE + ** +******************************************************************************/ +boolean_t Rtc_GetPridItStatus(void) +{ + return GetBit((uint32_t)(&(M0P_RTC->CR1)), 3); +} + +/** +****************************************************************************** + ** \brief 閰嶇疆RTC鐨勮宸ˉ鍋垮瘎瀛樺櫒 + ** + ** @param CompValue:鏁板肩殑鑼冨洿涓猴細32-256 + ** @param NewStatus: RtcCompenDisable 鎴 RtcAmCompenEnable + ** \retval Ok ErrorInvalidParameter + ** +******************************************************************************/ +en_result_t Rtc_CompCfg(uint16_t CompVlue, en_rtc_compen_t NewStatus) +{ + en_result_t enRet = Error; + if(CompVlue<=256) + { + M0P_RTC->COMPEN_f.EN = NewStatus; + M0P_RTC->COMPEN_f.CR = CompVlue; + } + else + { + enRet = ErrorInvalidParameter; + } + return enRet; +} + +/** + ****************************************************************************** + ** \brief RTC鏍规嵁鏃ユ湡璁$畻鍛ㄦ暟 + ** + ** \param pu8buf鏃堕棿鏁版嵁 + ** \param u8limit_min鏈灏忓 + ** \param u8limit_max鏈澶у + ** + ** \retval Error 閿欒锛孫k鏍¢獙姝g‘ + ** + ******************************************************************************/ +en_result_t Check_BCD_Format(uint8_t u8data,uint8_t u8limit_min, uint8_t u8limit_max) +{ + + if (((u8data & 0x0F) > 0x09) || ((u8data & 0xF0) > 0x90) + ||(u8data > u8limit_max) || (u8data < u8limit_min)) + { + return Error; + } + return Ok; +} + +/** + ****************************************************************************** + ** \brief RTC 骞炽侀棸骞存娴 + ** +** \param u8year:骞村崄杩涘埗浣庝袱浣:0-99 + ** + ** \retval 1:闂板勾 0锛氬钩骞 + ** + ******************************************************************************/ +uint8_t Rtc_CheckLeapYear(uint8_t u8year) +{ + uint16_t tmp; + tmp=2000+u8year; + if((((tmp % 4)==0) && ((tmp % 100) !=0))|| ((tmp % 400) ==0)) + { + return 1; + } + else + { + return 0; + } +} + +/** + ****************************************************************************** + ** \brief RTC鏍规嵁骞磋幏鍙栦簩鏈堢殑澶╂暟 + ** + ** \param [in] u8month鏈堜唤锛寀8year骞翠唤 + ** +** \retval u8day澶╂暟:28鎴29 + ** + ******************************************************************************/ +uint8_t Get_Month2_Day( uint8_t u8year) +{ + uint8_t u8day = 0; + + u8day = 28; + if(Rtc_CheckLeapYear(u8year) == 1) + { + u8day++; + } + return u8day; +} + +/** + ****************************************************************************** + ** \brief RTC鑾峰彇鏃堕棿鍑芥暟 + ** + ** \param time: 鐢ㄤ簬瀛樻斁璇诲彇鑷椂闂村瘎瀛樺櫒鐨勬椂闂存暟鎹紝鏍煎紡涓築CD鐮佹牸寮 + ** + ** \retval Ok 鑾峰彇姝e父 + ** \retval ErrorTimeout 鏃堕棿婧㈠嚭閿欒 + ******************************************************************************/ +en_result_t Rtc_ReadDateTime(stc_rtc_time_t* time) +{ + uint32_t u32TimeOut; + ASSERT(NULL != pstcTimeDate); + u32TimeOut = 1000; + if(1 == M0P_RTC->CR0_f.START) + { + M0P_RTC->CR1_f.WAIT = 1; + while(u32TimeOut--) + { + if(M0P_RTC->CR1_f.WAITF) + { + break; + } + } + if(u32TimeOut==0) + { + return ErrorTimeout; + } + } + time->u8Second = M0P_RTC->SEC; + time->u8Minute = M0P_RTC->MIN; + if(1 == M0P_RTC->CR0_f.AMPM) + { + time->u8Hour = M0P_RTC->HOUR; + } + else + { + time->u8Hour = M0P_RTC->HOUR&0x1f; + } + time->u8Day = M0P_RTC->DAY; + time->u8DayOfWeek = M0P_RTC->WEEK; + time->u8Month = M0P_RTC->MON; + time->u8Year = M0P_RTC->YEAR; + + M0P_RTC->CR1_f.WAIT = 0; + if(1 == M0P_RTC->CR0_f.START) + { + while(M0P_RTC->CR1_f.WAITF) + {} + } + + return Ok; +} + +/** + ****************************************************************************** + ** \brief 鍚慠TC鏃堕棿瀵勫瓨鍣ㄥ啓鍏ユ椂闂 + ** + ** \param time锛 瀛樻斁鏃堕棿鐨勭粨鏋勪綋锛屽悇涓椂闂村潎涓築CD鐮佹牸寮 + ** + ** \retval ErrorTimeout 鎴 Ok + ** + ******************************************************************************/ +en_result_t Rtc_SetTime(stc_rtc_time_t* time) +{ + en_result_t enRet = Ok; + uint16_t u16TimeOut; + u16TimeOut = 1000; + if(M0P_RTC->CR0_f.START == 1) + { + M0P_RTC->CR1_f.WAIT = 1; + while(--u16TimeOut) + { + if(M0P_RTC->CR1_f.WAITF) + { + break; + } + } + if(u16TimeOut==0) + { + return ErrorTimeout; + } + } + M0P_RTC->SEC = time->u8Second; + M0P_RTC->MIN = time->u8Minute; + M0P_RTC->HOUR = time->u8Hour; + M0P_RTC->DAY = time->u8Day; + M0P_RTC->MON = time->u8Month; + M0P_RTC->YEAR = time->u8Year; + M0P_RTC->WEEK = time->u8DayOfWeek; + + M0P_RTC->CR1_f.WAIT = 0; + if(M0P_RTC->CR0_f.START == 1) + { + while(M0P_RTC->CR1_f.WAITF) + {} + } + enRet = Ok; + return enRet; +} + +/** + ****************************************************************************** + ** \brief RTC闂归挓涓柇鏃堕棿鑾峰彇 + ** + ** \param pstcAlarmTime锛氬瓨鏀鹃椆閽熸椂闂村瘎瀛樺櫒鏁版嵁锛氱 鍒 鏃 鍛 + ** + ** \retval 鏃 + ** + ******************************************************************************/ +void Rtc_GetAlarmTime(stc_rtc_alarmtime_t* pstcAlarmTime) +{ + pstcAlarmTime->RtcAlarmSec = M0P_RTC->ALMSEC; + pstcAlarmTime->RtcAlarmMinute = M0P_RTC->ALMMIN; + pstcAlarmTime->RtcAlarmHour = M0P_RTC->ALMHOUR; + pstcAlarmTime->RtcAlarmWeek = M0P_RTC->ALMWEEK; +} + +/** + ****************************************************************************** + ** \brief RTC闂归挓璁剧疆 + ** + ** \param [in] pstcAlarmTime闂归挓鏃堕棿锛氱 鍒 鏃 鍛 + ** + ** \retval Ok 璁剧疆姝e父 + ** + ******************************************************************************/ +en_result_t Rtc_SetAlarmTime(stc_rtc_alarmtime_t* pstcAlarmTime) +{ + en_result_t enRet = Ok; +// ASSERT(NULL != pstcAlarmTime); + Rtc_AlmEnCmd(FALSE); //闂归挓绂佹浠ュ悗鍐嶈缃椆閽熸椂闂 + enRet = Check_BCD_Format(pstcAlarmTime->RtcAlarmSec,0x00,0x59); + if(M0P_RTC->CR0_f.AMPM == RtcAm) + { + enRet = Check_BCD_Format(pstcAlarmTime->RtcAlarmHour,0x00,0x12); + } + else + { + enRet = Check_BCD_Format(pstcAlarmTime->RtcAlarmHour,0x00,0x24); + } + if(enRet != Ok) + { + return enRet; + } + enRet = Check_BCD_Format(pstcAlarmTime->RtcAlarmMinute,0x00,0x59); + if(enRet != Ok) + { + return enRet; + } + + if(enRet != Ok) + { + return enRet; + } + M0P_RTC->ALMSEC = pstcAlarmTime->RtcAlarmSec & 0x7f; + M0P_RTC->ALMMIN = pstcAlarmTime->RtcAlarmMinute & 0x7f; + M0P_RTC->ALMHOUR = pstcAlarmTime->RtcAlarmHour & 0x3f; + M0P_RTC->ALMWEEK = pstcAlarmTime->RtcAlarmWeek; + Rtc_AlmEnCmd(TRUE); //闂归挓璁稿彲 + enRet = Ok; + return enRet; +} + +/** +****************************************************************************** + ** \brief 鍒濆鍖朢TC + ** + ** @param Rtc_InitStruct 瀛樻斁stc_rtc_initstruct_t绫诲瀷鐨勭粨鏋勪綋 + ** \retval 鏃 + ** +******************************************************************************/ +void Rtc_Init(stc_rtc_initstruct_t* Rtc_InitStruct) +{ + Rtc_Cmd(FALSE); + M0P_RTC->CR0_f.AMPM = Rtc_InitStruct->rtcAmpm; //瀹炴椂鏃堕挓灏忔椂鐨勬椂鍒 + Rtc_SetCyc(&Rtc_InitStruct->rtcPrdsel); //璁剧疆鍛ㄦ湡涓柇鐨勭被鍨(PRDSEL)鍙婂叾鎵閫夌被鍨嬬殑鏃堕棿(PRDS鎴朠RDX) + M0P_RTC->CR1_f.CKSEL = Rtc_InitStruct->rtcClksrc; //瀹炴椂鏃堕挓RTC鐨勬椂閽熸簮 + Rtc_CompCfg(Rtc_InitStruct->rtcCompValue, Rtc_InitStruct->rtcCompen); //閰嶇疆鏃堕挓璇樊琛ュ伩瀵勫瓨鍣 + Rtc_SetTime(&Rtc_InitStruct->rtcTime); //璁剧疆鍒濆鏃堕挓 +} + + + diff --git a/driver/src/spi.c b/driver/src/spi.c new file mode 100644 index 0000000..a833ccd --- /dev/null +++ b/driver/src/spi.c @@ -0,0 +1,363 @@ +/****************************************************************************** +* Copyright (C) 2016, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with eaenCh copy of this software, whether used in part or whole, +* at all times. +*/ +/*****************************************************************************/ +/** \file spi.c + ** + ** SPI driver API. + ** @link Driver Group Some description @endlink + ** + ** - 2018-05-17 1.0 Devi First version for Device Driver Library of + ** Module. + ** + *****************************************************************************/ + +/****************************************************************************** + * Include files + *****************************************************************************/ +#include "spi.h" + +/** + ****************************************************************************** + ** \addtogroup SpiGroup + *****************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + *****************************************************************************/ + +#define IS_VALID_STAT(x) ( SpiIf == (x)||\ + SpiSserr == (x)||\ + SpiBusy == (x)||\ + SpiMdf == (x)||\ + SpiTxe == (x)||\ + SpiRxne == (x)) + + +/******************************************************************************/ +/* Local function prototypes ('static') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local variable prototypes ('static') */ +/******************************************************************************/ + +/** + ****************************************************************************** + ** \brief SPI 璇锋眰鐘舵佽幏鍙 + ** + ** \param [in]SPIx 閫氶亾锛 enStatus 鑾峰彇璇锋眰 + ** + ** \retval 璇锋眰鐘舵 + ** + ******************************************************************************/ +boolean_t Spi_GetStatus(M0P_SPI_TypeDef* SPIx, en_spi_status_t enStatus) +{ + ASSERT(IS_VALID_STAT(enStatus)); + + if(SPIx->STAT&enStatus) + { + return TRUE; + } + else + { + return FALSE; + } + +} +/** + ****************************************************************************** + ** \brief SPI涓柇娓呴櫎 + ** + ** \param [in]SPIx 閫氶亾閫夋嫨 + ** + ** \retval 璇锋眰鐘舵 + ** + ******************************************************************************/ +en_result_t Spi_ClearStatus(M0P_SPI_TypeDef* SPIx) +{ + SPIx->ICLR = 0; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief SPI 涓柇浣胯兘鍑芥暟 + ** + ** \param [in] SPIx 閫氶亾 + ** + ** \retval Ok鎴愬姛 + ** + ******************************************************************************/ +en_result_t Spi_IrqEnable(M0P_SPI_TypeDef* SPIx) +{ + SPIx->CR2 |= 0x4u; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief SPI 涓柇绂佹鍑芥暟 + ** + ** \param [in] enCh閫氶亾 + ** + ** \retval Ok鎴愬姛 + ** + ******************************************************************************/ +en_result_t Spi_IrqDisable(M0P_SPI_TypeDef* SPIx) +{ + SPIx->CR2 &= ~0x4u; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief SPI 鍔熻兘浣胯兘鍑芥暟 + ** + ** \param [in] SPIx 閫氶亾锛宔nFunc鍔熻兘 + ** + ** \retval Ok鍒濆鍖栨垚鍔 + ** + ******************************************************************************/ +en_result_t Spi_FuncEnable(M0P_SPI_TypeDef* SPIx, en_spi_func_t enFunc) +{ + SPIx->CR2 |= enFunc; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief SPI 鍔熻兘绂佹鍑芥暟 + ** + ** \param [in] SPIx 閫氶亾锛宔nFunc鍔熻兘 + ** + ** \retval Ok鍒濆鍖栨垚鍔 + ** + ******************************************************************************/ +en_result_t Spi_FuncDisable(M0P_SPI_TypeDef* SPIx, en_spi_func_t enFunc) +{ + SPIx->CR2 &= ~(uint32_t)enFunc; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief SPI 鎬讳綋鍒濆鍖栧嚱鏁 + ** + ** \param [in] SPIx 閫氶亾 + ** \param [in] pstcSpiCfg 鍒濆鍖栫粨鏋勪綋 + ** + ** \retval Ok鍒濆鍖栨垚鍔 + ** \retval ErrorInvalidParameter 鍒濆鍖栭敊璇 + ******************************************************************************/ +en_result_t Spi_Init(M0P_SPI_TypeDef* SPIx, stc_spi_cfg_t *pstcSpiCfg) +{ + ASSERT(NULL != pstcSpiCfg); + + SPIx->CR = 0; + + SPIx->SSN = TRUE; + + SPIx->CR = (uint32_t)pstcSpiCfg->enSpiMode | + (uint32_t)pstcSpiCfg->enPclkDiv | + (uint32_t)pstcSpiCfg->enCPOL | + (uint32_t)pstcSpiCfg->enCPHA | + (uint32_t)0x40; + + SPIx->STAT = 0x00; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief SPI 閰嶇疆涓诲彂閫佺殑鐢靛钩 + ** + ** \param [in] SPIx 閫氶亾閫夋嫨锛宐Flag楂樹綆鐢靛钩 + ** + ** \retval 鏃 + ** + ******************************************************************************/ +void Spi_SetCS(M0P_SPI_TypeDef* SPIx, boolean_t bFlag) +{ + SPIx->SSN = bFlag; +} +/** + ****************************************************************************** + ** \brief SPI 鍙戦佷竴瀛楄妭鍑芥暟 + ** + ** \param [in] SPIx 閫氶亾閫夋嫨锛寀8Data鍙戦佸瓧鑺 + ** + ** \retval Ok鍙戦佹垚鍔 + ** + ******************************************************************************/ +en_result_t Spi_SendData(M0P_SPI_TypeDef* SPIx, uint8_t u8Data) +{ + SPIx->DATA = u8Data; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief SPI 璇/鍐欎竴瀛楄妭鍑芥暟 + ** + ** \param [in] SPIx 閫氶亾閫夋嫨 + ** \param [in] u8Data 鍙戦佷竴瀛楄妭鏁版嵁 + ** + ** \retval 鎺ユ敹涓瀛楄妭鏁版嵁 + ** + ******************************************************************************/ +uint8_t Spi_RWByte(M0P_SPI_TypeDef* SPIx, uint8_t u8Data) +{ + uint16_t Dly = 0xffff; + + while(FALSE == SPIx->STAT_f.TXE) { + Dly--; + if(Dly == 0) + break; + } + Dly = 0xffff; + SPIx->DATA = u8Data; + while(FALSE == SPIx->STAT_f.RXNE) { + Dly--; + if(Dly == 0) + break; + } + return SPIx->DATA; +} + +/** + ****************************************************************************** +** \brief SPI 浠庢満棰勫噯澶囩涓瀛楄妭鏁版嵁 + ** + ** \param [in] SPIx 閫氶亾閫夋嫨 + ** \param [in] u8Data 棰勫噯澶囩涓瀛楄妭鏁版嵁 + ** + ** \retval None + ** + ******************************************************************************/ +void Spi_Slave_DummyWriteData(M0P_SPI_TypeDef* SPIx, uint8_t u8Data) +{ + while(FALSE == SPIx->STAT_f.TXE){;} + SPIx->DATA = u8Data; +} + +/** + ****************************************************************************** + ** \brief SPI 杩炵画鍙戦佸瀛楄妭鍑芥暟 + ** + ** \param [in] SPIx 閫氶亾閫夋嫨 + ** \param [in] pu8Buf 鍙戦佹暟鎹寚閽 + ** + ** \retval Ok鍙戦佹垚鍔 + ** + ******************************************************************************/ +en_result_t Spi_SendBuf(M0P_SPI_TypeDef* SPIx, uint8_t* pu8Buf, uint32_t u32Len) +{ + uint32_t u32Index=0; + + for(u32Index=0; u32IndexSTAT_f.TXE){;} + SPIx->DATA = pu8Buf[u32Index]; + while(FALSE == SPIx->STAT_f.RXNE){;} + pu8Buf[u32Index] = SPIx->DATA; + } + + while(FALSE == SPIx->STAT_f.TXE){;} + while(TRUE == SPIx->STAT_f.BUSY){;} + + return Ok; +} + +/** + ****************************************************************************** + ** \brief SPI 鎺ユ敹涓瀛楄妭鍑芥暟 + ** + ** \param [in] SPIx鎺ユ敹閫氶亾 + ** + ** \retval 鎺ユ敹涓瀛楄妭鏁版嵁 + ** + ******************************************************************************/ +uint8_t Spi_ReceiveData(M0P_SPI_TypeDef* SPIx) +{ + return SPIx->DATA; +} + +/** + ****************************************************************************** + ** \brief SPI 杩炵画鎺ユ敹澶氬瓧鑺傚嚱鏁 + ** + ** \param [in] SPIx 閫氶亾閫夋嫨 + ** \param [in] pu8Buf 鍙戦佹暟鎹寚閽 + ** + ** \retval Ok鍙戦佹垚鍔 + ** + ******************************************************************************/ +en_result_t Spi_ReceiveBuf(M0P_SPI_TypeDef* SPIx, uint8_t* pu8Buf, uint32_t u32Len) +{ + uint32_t u32Index=0; + + for(u32Index=0; u32IndexSTAT_f.TXE){;} + SPIx->DATA = 0x00; + while(FALSE == SPIx->STAT_f.RXNE){;} + pu8Buf[u32Index] = SPIx->DATA; + } + + while(TRUE == SPIx->STAT_f.BUSY){;} + + return Ok; +} + +//@} // SpiGroup +/****************************************************************************** + * EOF (not truncated) + *****************************************************************************/ + diff --git a/driver/src/sysctrl.c b/driver/src/sysctrl.c new file mode 100644 index 0000000..83f00be --- /dev/null +++ b/driver/src/sysctrl.c @@ -0,0 +1,746 @@ +/****************************************************************************** +*Copyright(C)2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file sysctrl.c + ** + ** Common API of sysctrl. + ** @link SysctrlGroup Some description @endlink + ** + ** - 2018-04-22 Lux + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "sysctrl.h" + +/** + ******************************************************************************* + ** \addtogroup SysctrlGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define CLK_TIMEOUT (1000000u) + +#define IS_VALID_SRC(x) ( ClkRCH == (x)||\ + ClkXTH == (x)||\ + ClkRCL == (x)||\ + ClkXTL == (x) ) + + +#define IS_VALID_FUNC(x) ( ClkFuncWkupRCH == (x)||\ + ClkFuncXTHEn == (x)||\ + ClkFuncXTLEn == (x)||\ + ClkFuncXTLAWSON == (x)||\ + ClkFuncFaultEn == (x)||\ + ClkFuncRtcLPWEn == (x)||\ + ClkFuncLockUpEn == (x)||\ + ClkFuncRstPinIOEn == (x)||\ + ClkFuncSwdPinIOEn == (x) ) + +#define RC_TRIM_BASE_ADDR ((volatile uint16_t*) (0x00100C00ul)) +#define RCH_CR_TRIM_24M_VAL (*((volatile uint16_t*) (0x00100C00ul))) +#define RCH_CR_TRIM_22_12M_VAL (*((volatile uint16_t*) (0x00100C02ul))) +#define RCH_CR_TRIM_16M_VAL (*((volatile uint16_t*) (0x00100C04ul))) +#define RCH_CR_TRIM_8M_VAL (*((volatile uint16_t*) (0x00100C06ul))) +#define RCH_CR_TRIM_4M_VAL (*((volatile uint16_t*) (0x00100C08ul))) + +#define RCL_CR_TRIM_38400_VAL (*((volatile uint16_t*) (0x00100C20ul))) +#define RCL_CR_TRIM_32768_VAL (*((volatile uint16_t*) (0x00100C22ul))) + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ +extern uint32_t SystemCoreClock; +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ******************************************************************************* + ** \brief SYSCTRL0\SYSCTRL1瀵勫瓨鍣ㄦ搷浣滆В閿 + ** + ** \retval None + ******************************************************************************/ +static void _SysctrlUnlock(void) +{ + M0P_SYSCTRL->SYSCTRL2 = 0x5A5A; + M0P_SYSCTRL->SYSCTRL2 = 0xA5A5; +} + +/** + ******************************************************************************* + ** \brief 绯荤粺鏃堕挓婧愪娇鑳 + ** \param [in] enSource 鐩爣鏃堕挓婧 + ** \param [in] bFlag 浣胯兘1-寮/0-鍏 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_ClkSourceEnable(en_sysctrl_clk_source_t enSource, boolean_t bFlag) +{ + en_result_t enRet = Ok; + uint32_t u32Temp; + + _SysctrlUnlock(); + bFlag = !!bFlag; + + u32Temp = M0P_SYSCTRL->PERI_CLKEN0; + switch (enSource) + { + case SysctrlClkRCH: + M0P_SYSCTRL->SYSCTRL0_f.RCH_EN = bFlag; + while(bFlag && (1 != M0P_SYSCTRL->RCH_CR_f.STABLE)) + { + ; + } + break; + + case SysctrlClkXTH: + M0P_SYSCTRL->PERI_CLKEN0_f.GPIO = TRUE; + M0P_GPIO->PFADS |= 3u; + M0P_SYSCTRL->SYSCTRL0_f.XTH_EN = bFlag; + while(bFlag && (1 != M0P_SYSCTRL->XTH_CR_f.STABLE)) + { + ; + } + break; + + case SysctrlClkRCL: + + M0P_SYSCTRL->SYSCTRL0_f.RCL_EN = bFlag; + while(bFlag && (1 != M0P_SYSCTRL->RCL_CR_f.STABLE)) + { + ; + } + break; + + case SysctrlClkXTL: + M0P_SYSCTRL->PERI_CLKEN0_f.GPIO = TRUE; + M0P_GPIO->PCADS |= 0xC000; + M0P_SYSCTRL->SYSCTRL0_f.XTL_EN = bFlag; + while(bFlag && (1 != M0P_SYSCTRL->XTL_CR_f.STABLE)) + { + ; + } + break; + + case SysctrlClkPLL: + M0P_SYSCTRL->PERI_CLKEN0_f.ADC = TRUE; + M0P_BGR->CR_f.BGR_EN = TRUE; + delay10us(20); + M0P_SYSCTRL->SYSCTRL0_f.PLL_EN = bFlag; + while(bFlag && (1 != M0P_SYSCTRL->PLL_CR_f.STABLE)) + { + ; + } + break; + + default: + enRet = ErrorInvalidParameter; + break; + } + M0P_SYSCTRL->PERI_CLKEN0 = u32Temp; + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 澶栭儴楂橀熸櫠鎸┍鍔ㄩ厤缃 + ** \param [in] enFreq 澶栭儴楂橀熸櫠鎸鐜囪寖鍥撮夋嫨 + ** \param [in] enDriver 澶栭儴楂橀熸櫠鎸┍鍔ㄨ兘鍔涢夋嫨 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_XTHDriverCfg(en_sysctrl_xtal_driver_t enDriver) +{ + en_result_t enRet = Ok; + + M0P_SYSCTRL->XTH_CR_f.DRIVER = enDriver; + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 澶栭儴浣庨熸櫠鎸┍鍔ㄩ厤缃 + ** \param [in] enFreq 澶栭儴浣庨熸櫠鎸鐜囪寖鍥撮夋嫨 + ** \param [in] enDriver 澶栭儴浣庨熸櫠鎸┍鍔ㄨ兘鍔涢夋嫨 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_XTLDriverCfg(en_sysctrl_xtl_amp_t enAmp, en_sysctrl_xtal_driver_t enDriver) +{ + en_result_t enRet = Ok; + + M0P_SYSCTRL->XTL_CR_f.AMP_SEL = enAmp; + M0P_SYSCTRL->XTL_CR_f.DRIVER = enDriver; + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 澶栭儴楂橀熸椂閽熺ǔ瀹氬懆鏈熼厤缃 + ** \param [in] enCycle 澶栭儴楂橀熸椂閽熺ǔ瀹氬懆鏈熻缃 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_SetXTHStableTime(en_sysctrl_xth_cycle_t enCycle) +{ + en_result_t enRet = Ok; + M0P_SYSCTRL->XTH_CR_f.STARTUP = enCycle; + return enRet; +} + +/** + ******************************************************************************* + ** \brief 鍐呴儴浣庨熸椂閽熺ǔ瀹氬懆鏈熼厤缃 + ** \param [in] enCycle 鍐呴儴浣庨熸椂閽熺ǔ瀹氬懆鏈熻缃 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_SetRCLStableTime(en_sysctrl_rcl_cycle_t enCycle) +{ + en_result_t enRet = Ok; + M0P_SYSCTRL->RCL_CR_f.STARTUP = enCycle; + return enRet; +} + +/** + ******************************************************************************* + ** \brief 澶栭儴浣庨熸椂閽熺ǔ瀹氬懆鏈熼厤缃 + ** \param [in] enCycle 澶栭儴浣庨熸椂閽熺ǔ瀹氬懆鏈熻缃 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_SetXTLStableTime(en_sysctrl_xtl_cycle_t enCycle) +{ + en_result_t enRet = Ok; + M0P_SYSCTRL->XTL_CR_f.STARTUP = enCycle; + return enRet; +} + +/** + ******************************************************************************* + ** \brief PLL绋冲畾鍛ㄦ湡閰嶇疆 + ** \param [in] enCycle PLL绋冲畾鍛ㄦ湡璁剧疆 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_SetPLLStableTime(en_sysctrl_pll_cycle_t enCycle) +{ + en_result_t enRet = Ok; + M0P_SYSCTRL->PLL_CR_f.STARTUP = enCycle; + return enRet; +} + +/** + ******************************************************************************* + ** \brief 鏃堕挓婧愬垏鎹紝璇ュ嚱鏁版墽琛屽悗浼氬紑鍚柊鏃堕挓婧 + ** \note 閫夋嫨鏃堕挓婧愪箣鍓嶏紝闇鏍规嵁闇瑕侀厤缃洰鏍囨椂閽熸簮鐨勯鐜/椹卞姩鍙傛暟/浣胯兘鏃堕挓婧愮瓑 + ** \param [in] enSource 鏂版椂閽熸簮 + ** + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_SysClkSwitch(en_sysctrl_clk_source_t enSource) +{ + en_result_t enRet = Ok; + + en_sysctrl_clk_source_t ClkNew = enSource; + + _SysctrlUnlock(); + M0P_SYSCTRL->SYSCTRL0_f.CLKSW = ClkNew; + + //鏇存柊Core鏃堕挓锛圚CLK锛 + SystemCoreClockUpdate(); + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 鑾峰緱绯荤粺鏃堕挓锛圚CLK锛夐鐜囧 + ** \retval uint32_t HCLK棰戠巼鍊 + ** + ******************************************************************************/ +uint32_t Sysctrl_GetHClkFreq(void) +{ + uint32_t u32Val = 0; + const uint32_t u32hcr_tbl[] = { 4000000, 8000000, 16000000, 22120000, 24000000}; + const uint16_t u32lcr_tbl[] = { 32768, 38400}; + en_sysctrl_clk_source_t enSrc; + uint16_t u16Trim[5] = {0}; + u16Trim[4] = RCH_CR_TRIM_24M_VAL; + u16Trim[3] = RCH_CR_TRIM_22_12M_VAL; + u16Trim[2] = RCH_CR_TRIM_16M_VAL; + u16Trim[1] = RCH_CR_TRIM_8M_VAL; + u16Trim[0] = RCL_CR_TRIM_38400_VAL; + + //鑾峰彇褰撳墠绯荤粺鏃堕挓 + enSrc = (en_sysctrl_clk_source_t)(M0P_SYSCTRL->SYSCTRL0_f.CLKSW); + + switch (enSrc) + { + case SysctrlClkRCH: + { + + if((M0P_SYSCTRL->RCH_CR_f.TRIM) == (u16Trim[4])) + { + u32Val = u32hcr_tbl[4]; + } + else if((M0P_SYSCTRL->RCH_CR_f.TRIM) == (u16Trim[3])) + { + u32Val = u32hcr_tbl[3]; + } + else if((M0P_SYSCTRL->RCH_CR_f.TRIM) == (u16Trim[2])) + { + u32Val = u32hcr_tbl[2]; + } + else if((M0P_SYSCTRL->RCH_CR_f.TRIM) == (u16Trim[1])) + { + u32Val = u32hcr_tbl[1]; + } + else + { + u32Val = u32hcr_tbl[0]; + } + } + break; + case SysctrlClkXTH: + u32Val = SYSTEM_XTH; + break; + case SysctrlClkRCL: + { + if(u16Trim[0] == (M0P_SYSCTRL->RCL_CR_f.TRIM)) + { + u32Val = u32lcr_tbl[1]; + } + else + { + u32Val = u32lcr_tbl[0]; + } + } + break; + case SysctrlClkXTL: + u32Val = SYSTEM_XTL; + break; + case SysctrlClkPLL: + { + if (SysctrlPllRch == M0P_SYSCTRL->PLL_CR_f.REFSEL) + { + if(u16Trim[4] == M0P_SYSCTRL->RCH_CR_f.TRIM) + { + u32Val = u32hcr_tbl[4]; + } + else if(u16Trim[3] == M0P_SYSCTRL->RCH_CR_f.TRIM) + { + u32Val = u32hcr_tbl[3]; + } + else if(u16Trim[2] == M0P_SYSCTRL->RCH_CR_f.TRIM) + { + u32Val = u32hcr_tbl[2]; + } + else if(u16Trim[1] == M0P_SYSCTRL->RCH_CR_f.TRIM) + { + u32Val = u32hcr_tbl[1]; + } + else + { + u32Val = u32hcr_tbl[0]; + } + } + else + { + u32Val = SYSTEM_XTH; + } + + u32Val = (u32Val * M0P_SYSCTRL->PLL_CR_f.DIVN); + } + break; + default: + u32Val = 0u; + break; + } + + u32Val = (u32Val >> M0P_SYSCTRL->SYSCTRL0_f.HCLK_PRS); + + return u32Val; +} + +/** + ******************************************************************************* + ** \brief 鑾峰緱澶栬鏃堕挓锛圥CLK锛夐鐜囧 + ** \retval uint32_t PCLK棰戠巼鍊(Hz) + ** + ******************************************************************************/ +uint32_t Sysctrl_GetPClkFreq(void) +{ + uint32_t u32Val = 0; + + u32Val = Sysctrl_GetHClkFreq(); + u32Val = (u32Val >> (M0P_SYSCTRL->SYSCTRL0_f.PCLK_PRS)); + + return u32Val; +} + + +/** + ******************************************************************************* + ** \brief 鏃堕挓鍒濆鍖栧嚱鏁 + ** \param [in] pstcCfg 鍒濆鍖栭厤缃弬鏁 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_ClkInit(stc_sysctrl_clk_cfg_t *pstcCfg) +{ + en_result_t enRet = Ok; + + //绯荤粺鏃堕挓鍙傛暟閰嶇疆 + switch(pstcCfg->enClkSrc) + { + case SysctrlClkRCH: + + break; + case SysctrlClkXTH: + Sysctrl_XTHDriverCfg(SysctrlXtalDriver3); + Sysctrl_SetXTHStableTime(SysctrlXthStableCycle16384); + break; + case SysctrlClkRCL: + Sysctrl_SetRCLStableTime(SysctrlRclStableCycle256); + break; + case SysctrlClkXTL: + Sysctrl_XTLDriverCfg(SysctrlXtlAmp3, SysctrlXtalDriver3); + Sysctrl_SetXTLStableTime(SysctrlXtlStableCycle16384); + break; + case SysctrlClkPLL: + Sysctrl_SetPLLStableTime(SysctrlPllStableCycle16384); + break; + default: + enRet = ErrorInvalidParameter; + break; + } + + //鏃堕挓婧愪娇鑳 + Sysctrl_ClkSourceEnable(pstcCfg->enClkSrc, TRUE); + + //鏃堕挓婧愬垏鎹 + Sysctrl_SysClkSwitch(pstcCfg->enClkSrc); + + //鏃堕挓鍒嗛璁剧疆 + Sysctrl_SetHCLKDiv(pstcCfg->enHClkDiv); + Sysctrl_SetPCLKDiv(pstcCfg->enPClkDiv); + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 鏃堕挓鍘诲垵濮嬪寲鍑芥暟 + ** \param [in] + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_ClkDeInit(void) +{ + en_result_t enRet = Ok; + + //閰嶇疆RCH涓哄唴閮4Hz + Sysctrl_SetRCHTrim(SysctrlRchFreq4MHz); + + //鏃堕挓婧愪娇鑳 + Sysctrl_ClkSourceEnable(SysctrlClkRCH, TRUE); + + //鏃堕挓婧愬垏鎹 + Sysctrl_SysClkSwitch(SysctrlClkRCH); + + //鍏跺畠鏃堕挓婧愪娇鑳藉叧闂 + Sysctrl_ClkSourceEnable(SysctrlClkXTH, FALSE); + Sysctrl_ClkSourceEnable(SysctrlClkRCL, FALSE); + Sysctrl_ClkSourceEnable(SysctrlClkXTL, FALSE); + Sysctrl_ClkSourceEnable(SysctrlClkPLL, FALSE); + + //鏃堕挓鍒嗛璁剧疆 + Sysctrl_SetHCLKDiv(SysctrlHclkDiv1); + Sysctrl_SetPCLKDiv(SysctrlPclkDiv1); + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 鍐呴儴楂橀熸椂閽熼鐜嘥RIM鍊煎姞杞 + ** \param [in] enRCHFreq 璁惧畾鐨凴CH鐩爣棰戠巼鍊 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触鎴栨椂閽熸湭绋冲畾 + ******************************************************************************/ +en_result_t Sysctrl_SetRCHTrim(en_sysctrl_rch_freq_t enRCHFreq) +{ + //鍔犺浇RCH Trim鍊 + M0P_SYSCTRL->RCH_CR_f.TRIM = *(RC_TRIM_BASE_ADDR + enRCHFreq); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief 澶栭儴楂橀熸椂閽熼鐜囪寖鍥磋瀹 + ** \param [in] enXTHFreq 璁惧畾鐨勯鐜囧 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触鎴栨椂閽熸湭绋冲畾 + ******************************************************************************/ +en_result_t Sysctrl_SetXTHFreq(en_sysctrl_xth_freq_t enXTHFreq) +{ + en_result_t enRet = Ok; + + M0P_SYSCTRL->XTH_CR_f.XTH_FSEL = enXTHFreq; + + return enRet; +} + +/** + ******************************************************************************* + ** \brief PLL鏃堕挓閰嶇疆 + ** \param [in] pstcPLLCfg PLL閰嶇疆缁撴瀯浣撴寚閽 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触鎴栧弬鏁板间笉鍖归厤 + ******************************************************************************/ +en_result_t Sysctrl_SetPLLFreq(stc_sysctrl_pll_cfg_t *pstcPLLCfg) +{ + en_result_t enRet = Ok; + + uint16_t u16Trim[5] = {0}; + u16Trim[4] = RCH_CR_TRIM_24M_VAL; + u16Trim[3] = RCH_CR_TRIM_22_12M_VAL; + u16Trim[2] = RCH_CR_TRIM_16M_VAL; + u16Trim[1] = RCH_CR_TRIM_8M_VAL; + + ////PLL鏈楂樻椂閽熶笉鑳借秴杩48MHz + //RCH浣滀负PLL杈撳叆 + if (SysctrlPllRch == pstcPLLCfg->enPllClkSrc) + { + if( ((u16Trim[4] == M0P_SYSCTRL->RCH_CR_f.TRIM) && (pstcPLLCfg->enPllMul > 2)) || + ((u16Trim[3] == M0P_SYSCTRL->RCH_CR_f.TRIM) && (pstcPLLCfg->enPllMul > 2)) || + ((u16Trim[2] == M0P_SYSCTRL->RCH_CR_f.TRIM) && (pstcPLLCfg->enPllMul > 3)) || + ((u16Trim[1] == M0P_SYSCTRL->RCH_CR_f.TRIM) && (pstcPLLCfg->enPllMul > 6))) + { + return ErrorInvalidMode; + } + } + else //XTH浣滀负PLL杈撳叆 + { + if ((SYSTEM_XTH * pstcPLLCfg->enPllMul) > 48*1000*1000) + { + return ErrorInvalidMode; + } + } + + M0P_SYSCTRL->PLL_CR_f.FRSEL = pstcPLLCfg->enInFreq; + M0P_SYSCTRL->PLL_CR_f.FOSC = pstcPLLCfg->enOutFreq; + M0P_SYSCTRL->PLL_CR_f.DIVN = pstcPLLCfg->enPllMul; + M0P_SYSCTRL->PLL_CR_f.REFSEL = pstcPLLCfg->enPllClkSrc; + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 鍐呴儴浣庨熸椂閽熼鐜嘥RIM鍊煎姞杞 + ** \param [in] enRCLFreq 璁惧畾鐨凴CL鐩爣棰戠巼鍊 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_SetRCLTrim(en_sysctrl_rcl_freq_t enRCLFreq) +{ + M0P_SYSCTRL->RCL_CR_f.TRIM = *(RC_TRIM_BASE_ADDR + enRCLFreq); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief 绯荤粺鏃堕挓锛圚CLK锛夊垎棰戣瀹 + ** \param [in] enHCLKDiv 鍒嗛璁惧畾鍊 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_SetHCLKDiv(en_sysctrl_hclk_div_t enHCLKDiv) +{ + _SysctrlUnlock(); + M0P_SYSCTRL->SYSCTRL0_f.HCLK_PRS = enHCLKDiv; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief 澶栬鏃堕挓锛圥CLK锛夊垎棰戣瀹 + ** \param [in] enPCLKDiv 鍒嗛璁惧畾鍊 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_SetPCLKDiv(en_sysctrl_pclk_div_t enPCLKDiv) +{ + _SysctrlUnlock(); + M0P_SYSCTRL->SYSCTRL0_f.PCLK_PRS = enPCLKDiv; + + return Ok; +} + +///<< for Sysctrl_SetPeripheralGate() & Sysctrl_GetPeripheralGate() +static volatile boolean_t bDacPeriBac = FALSE; + +/** + ******************************************************************************* + ** \brief 璁剧疆澶栬鏃堕挓闂ㄦ帶寮鍏 + ** \param [in] enPeripheral 鐩爣澶栬 + ** \param [in] bFlag 浣胯兘寮鍏 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_SetPeripheralGate(en_sysctrl_peripheral_gate_t enPeripheral, boolean_t bFlag) +{ + if(enPeripheral&0x20u) + { + enPeripheral &= ~0x20u; + SetBit((uint32_t)(&(M0P_SYSCTRL->PERI_CLKEN1)), enPeripheral, bFlag); + + if((SysctrlPeripheralDac & ~0x20u) == enPeripheral) + { + bDacPeriBac = bFlag; + } + else + { + SetBit((uint32_t)(&(M0P_SYSCTRL->PERI_CLKEN1)), (SysctrlPeripheralDac & ~0x20u), bDacPeriBac); + } + } + else + { + SetBit((uint32_t)(&(M0P_SYSCTRL->PERI_CLKEN0)), enPeripheral, bFlag); + } + + return Ok; +} + +/** + ******************************************************************************* + ** \brief 鑾峰緱澶栬鏃堕挓闂ㄦ帶寮鍏崇姸鎬 + ** \param [in] enPeripheral 鐩爣澶栬 + ** \retval TRUE 寮 + ** FALSE 鍏 + ******************************************************************************/ +boolean_t Sysctrl_GetPeripheralGate(en_sysctrl_peripheral_gate_t enPeripheral) +{ + if(enPeripheral&0x20u) + { + if(SysctrlPeripheralDac == enPeripheral) + { + return bDacPeriBac; + } + else + { + enPeripheral &= ~0x20u; + return GetBit((uint32_t)(&(M0P_SYSCTRL->PERI_CLKEN1)), enPeripheral); + } + + } + else + { + return GetBit((uint32_t)(&(M0P_SYSCTRL->PERI_CLKEN0)), enPeripheral); + } + +} + +/** + ******************************************************************************* + ** \brief 绯荤粺鍔熻兘璁惧畾 + ** \param [in] enFunc 绯荤粺鍔熻兘鏋氫妇绫诲瀷 + ** \param [in] bFlag 1-寮/0-鍏 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_SetFunc(en_sysctrl_func_t enFunc, boolean_t bFlag) +{ + _SysctrlUnlock(); + SetBit((uint32_t)(&(M0P_SYSCTRL->SYSCTRL1)), enFunc, bFlag); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief 璁惧畾RTC鏍″噯鏃堕挓棰戠巼 + ** \param [in] enRtcAdj 鏍″噯棰戠巼鍊 + ** \retval Ok 璁惧畾鎴愬姛 + ** 鍏朵粬 璁惧畾澶辫触 + ******************************************************************************/ +en_result_t Sysctrl_SetRTCAdjustClkFreq(en_sysctrl_rtc_adjust_t enRtcAdj) +{ + _SysctrlUnlock(); + M0P_SYSCTRL->SYSCTRL1_f.RTC_FREQ_ADJUST = enRtcAdj; + + return Ok; +} + +//@} // SysctrlGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/driver/src/timer3.c b/driver/src/timer3.c new file mode 100644 index 0000000..c45059a --- /dev/null +++ b/driver/src/timer3.c @@ -0,0 +1,1368 @@ +/****************************************************************************** +*Copyright(C)2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file timer3.c + ** + ** Common API of base timer. + ** @link Tiemr3 Group Some description @endlink + ** + ** - 2019-04-18 Husj First Version + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "timer3.h" +/** + ******************************************************************************* + ** \addtogroup Tim3Group + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ***************************************************************************** + ** \brief Timer3 涓柇鏍囧織鑾峰彇(妯″紡0/1/23) + ** + ** + ** \param [in] enTim3Irq 涓柇绫诲瀷 + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +boolean_t Tim3_GetIntFlag(en_tim3_irq_type_t enTim3Irq) +{ + boolean_t bRetVal = FALSE; + uint32_t u32Val; + + u32Val = M0P_TIM3_MODE23->IFR; + bRetVal = (u32Val>>enTim3Irq) & 0x1; + + return bRetVal; +} + +/** + ***************************************************************************** + ** \brief Timer3 涓柇鏍囧織娓呴櫎(妯″紡0/1/23) + ** + ** + ** \param [in] enTim3Irq 涓柇绫诲瀷 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_ClearIntFlag(en_tim3_irq_type_t enTim3Irq) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->ICLR = ~(1u<ICLR = 0; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 涓柇浣胯兘(妯″紡0) + ** + ** + ** \param [in] none + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_Mode0_EnableIrq(void) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE0->M0CR_f.UIE = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 涓柇绂佹(妯″紡0) + ** + ** + ** \param [in] none + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_Mode0_DisableIrq(void) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE0->M0CR_f.UIE = FALSE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 涓柇浣胯兘(妯″紡1) + ** + ** + ** \param [in] enTim3Irq 涓柇绫诲瀷 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_Mode1_EnableIrq (en_tim3_irq_type_t enTim3Irq) +{ + en_result_t enResult = Ok; + + + switch (enTim3Irq) + { + case Tim3UevIrq: + M0P_TIM3_MODE1->M1CR_f.UIE = TRUE; + break; + case Tim3CA0Irq: + M0P_TIM3_MODE1->CR0_f.CIEA = TRUE; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 涓柇绂佹(妯″紡1) + ** + ** + ** \param [in] enTim3Irq 涓柇绫诲瀷 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_Mode1_DisableIrq (en_tim3_irq_type_t enTim3Irq) +{ + en_result_t enResult = Ok; + + + switch (enTim3Irq) + { + case Tim3UevIrq: + M0P_TIM3_MODE1->M1CR_f.UIE = FALSE; + break; + case Tim3CA0Irq: + M0P_TIM3_MODE1->CR0_f.CIEA = FALSE; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 涓柇浣胯兘(妯″紡23) + ** + ** + ** \param [in] enTim3Irq 涓柇绫诲瀷 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_Mode23_EnableIrq (en_tim3_irq_type_t enTim3Irq) +{ + en_result_t enResult = Ok; + + + switch (enTim3Irq) + { + case Tim3UevIrq: + M0P_TIM3_MODE23->M23CR_f.UIE = TRUE; + break; + case Tim3CA0Irq: + M0P_TIM3_MODE23->CRCH0_f.CIEA = TRUE; + break; + case Tim3CB0Irq: + M0P_TIM3_MODE23->CRCH0_f.CIEB = TRUE; + break; + case Tim3CA1Irq: + M0P_TIM3_MODE23->CRCH1_f.CIEA = TRUE; + break; + case Tim3CB1Irq: + M0P_TIM3_MODE23->CRCH1_f.CIEB = TRUE; + break; + case Tim3CA2Irq: + M0P_TIM3_MODE23->CRCH2_f.CIEA = TRUE; + break; + case Tim3CB2Irq: + M0P_TIM3_MODE23->CRCH2_f.CIEB = TRUE; + break; + case Tim3BkIrq: + M0P_TIM3_MODE23->M23CR_f.BIE = TRUE; + break; + case Tim3TrigIrq: + M0P_TIM3_MODE23->M23CR_f.TIE = TRUE; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 涓柇绂佹(妯″紡23) + ** + ** + ** \param [in] enTim3Irq 涓柇绫诲瀷 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_Mode23_DisableIrq (en_tim3_irq_type_t enTim3Irq) +{ + en_result_t enResult = Ok; + + + switch (enTim3Irq) + { + case Tim3UevIrq: + M0P_TIM3_MODE23->M23CR_f.UIE = FALSE; + break; + case Tim3CA0Irq: + M0P_TIM3_MODE23->CRCH0_f.CIEA = FALSE; + break; + case Tim3CB0Irq: + M0P_TIM3_MODE23->CRCH0_f.CIEB = FALSE; + break; + case Tim3CA1Irq: + M0P_TIM3_MODE23->CRCH1_f.CIEA = FALSE; + break; + case Tim3CB1Irq: + M0P_TIM3_MODE23->CRCH1_f.CIEB = FALSE; + break; + case Tim3CA2Irq: + M0P_TIM3_MODE23->CRCH2_f.CIEA = FALSE; + break; + case Tim3CB2Irq: + M0P_TIM3_MODE23->CRCH2_f.CIEB = FALSE; + break; + case Tim3BkIrq: + M0P_TIM3_MODE23->M23CR_f.BIE = FALSE; + break; + case Tim3TrigIrq: + M0P_TIM3_MODE23->M23CR_f.TIE = FALSE; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 鍒濆鍖栭厤缃(妯″紡0) + ** + ** + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_Mode0_Init(stc_tim3_mode0_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE0->M0CR_f.MODE = pstcCfg->enWorkMode; + M0P_TIM3_MODE0->M0CR_f.GATEP = pstcCfg->enGateP; + M0P_TIM3_MODE0->M0CR_f.GATE = pstcCfg->bEnGate; + M0P_TIM3_MODE0->M0CR_f.PRS = pstcCfg->enPRS; + M0P_TIM3_MODE0->M0CR_f.TOGEN = pstcCfg->bEnTog; + M0P_TIM3_MODE0->M0CR_f.CT = pstcCfg->enCT; + M0P_TIM3_MODE0->M0CR_f.MD = pstcCfg->enCntMode; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 鍚姩杩愯(妯″紡0) + ** + ** + ** \param [in] none + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M0_Run(void) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE0->M0CR_f.CTEN = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 鍋滄杩愯(妯″紡0) + ** + ** + ** \param [in] none + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M0_Stop(void) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE0->M0CR_f.CTEN = FALSE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 绔彛杈撳嚭浣胯兘/绂佹璁惧畾(妯″紡0) + ** + ** + ** \param [in] bEnOutput 缈昏浆杈撳嚭璁惧畾 TRUE:浣胯兘, FALSE:绂佹 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M0_Enable_Output(boolean_t bEnOutput) +{ + en_result_t enResult = Ok; + + + M0P_TIM3_MODE0->DTR_f.MOE = bEnOutput; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 缈昏浆浣胯兘/绂佹锛堜綆鐢靛钩锛夎瀹(妯″紡0) + ** + ** + ** \param [in] bEnTOG 缈昏浆杈撳嚭璁惧畾 TRUE:浣胯兘, FALSE:绂佹 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M0_EnTOG(boolean_t bEnTOG) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE0->M0CR_f.TOGEN = bEnTOG; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 16浣嶈鏁板櫒鍒濆艰缃(妯″紡0) + ** + ** + ** \param [in] u16Data CNT 16浣嶅垵鍊 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M0_Cnt16Set(uint16_t u16Data) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE0->CNT_f.CNT = u16Data; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 16浣嶈鏁板艰幏鍙(妯″紡0) + ** + ** + ** \param [in] none + ** + ** \retval 16bits璁℃暟鍊 + *****************************************************************************/ +uint16_t Tim3_M0_Cnt16Get(void) +{ + uint16_t u16CntData = 0; + + u16CntData = M0P_TIM3_MODE0->CNT_f.CNT; + + return u16CntData; +} + +/** + ***************************************************************************** + ** \brief Timer3 閲嶈浇鍊艰缃(妯″紡0) + ** + ** + ** \param [in] u16Data 16bits閲嶈浇鍊 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M0_ARRSet(uint16_t u16Data) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE0->ARR_f.ARR = u16Data; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 32浣嶈鏁板櫒鍒濆艰缃(妯″紡0) + ** + ** + ** \param [in] u32Data 32浣嶅垵鍊 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M0_Cnt32Set(uint32_t u32Data) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE0->CNT32_f.CNT32 = u32Data; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 32浣嶈鏁板艰幏鍙(妯″紡0) + ** + ** + ** \param [in] none + ** + ** \retval 32bits璁℃暟鍊 + *****************************************************************************/ +uint32_t Tim3_M0_Cnt32Get(void) +{ + uint32_t u32CntData = 0; + + u32CntData = M0P_TIM3_MODE0->CNT32_f.CNT32; + + return u32CntData; +} + +/** + ***************************************************************************** + ** \brief Timer3 鍒濆鍖栭厤缃(妯″紡1) + ** + ** + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_Mode1_Init(stc_tim3_mode1_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE1->M1CR_f.MODE = pstcCfg->enWorkMode; + M0P_TIM3_MODE1->M1CR_f.PRS = pstcCfg->enPRS; + M0P_TIM3_MODE1->M1CR_f.CT = pstcCfg->enCT; + M0P_TIM3_MODE1->M1CR_f.ONESHOT = pstcCfg->enOneShot; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 PWC 杈撳叆閰嶇疆(妯″紡1) + ** + ** + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M1_Input_Cfg(stc_tim3_pwc_input_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE1->MSCR_f.TS = pstcCfg->enTsSel; + M0P_TIM3_MODE1->MSCR_f.IA0S = pstcCfg->enIA0Sel; + M0P_TIM3_MODE1->MSCR_f.IB0S = pstcCfg->enIB0Sel; + M0P_TIM3_MODE1->FLTR_f.ETP = pstcCfg->enETRPhase; + M0P_TIM3_MODE1->FLTR_f.FLTET = pstcCfg->enFltETR; + M0P_TIM3_MODE1->FLTR_f.FLTA0 = pstcCfg->enFltIA0; + M0P_TIM3_MODE1->FLTR_f.FLTB0 = pstcCfg->enFltIB0; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 PWC娴嬮噺杈规部璧峰缁撴潫閫夋嫨(妯″紡1) + ** + ** + ** \param [in] enEdgeSel pwc娴嬮噺璧峰缁堟鐢靛钩 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M1_PWC_Edge_Sel(en_tim3_m1cr_Edge_t enEdgeSel) +{ + en_result_t enResult = Ok; + + switch (enEdgeSel) + { + case 0: ///< 涓婂崌娌垮埌涓婂崌娌(鍛ㄦ湡) + M0P_TIM3_MODE1->M1CR_f.EDG1ST = 0; //涓婂崌娌 + M0P_TIM3_MODE1->M1CR_f.EDG2ND = 0; //涓婂崌娌 + break; + case 1: ///< 涓嬮檷娌垮埌涓婂崌娌(浣庣數骞) + M0P_TIM3_MODE1->M1CR_f.EDG1ST = 1; //涓嬮檷娌 + M0P_TIM3_MODE1->M1CR_f.EDG2ND = 0; //涓婂崌娌 + break; + case 2: ///< 涓婂崌娌垮埌涓嬮檷娌(楂樼數骞) + M0P_TIM3_MODE1->M1CR_f.EDG1ST = 0; //涓婂崌娌 + M0P_TIM3_MODE1->M1CR_f.EDG2ND = 1; //涓嬮檷娌 + break; + case 3: ///< 涓嬮檷娌垮埌涓嬮檷娌(鍛ㄦ湡) + M0P_TIM3_MODE1->M1CR_f.EDG1ST = 1; //涓嬮檷娌 + M0P_TIM3_MODE1->M1CR_f.EDG2ND = 1; //涓嬮檷娌 + break; + default: + ; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 鍚姩杩愯(妯″紡1) + ** + ** + ** \param [in] none + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M1_Run(void) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE1->M1CR_f.CTEN = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 鍋滄杩愯(妯″紡1) + ** + ** + ** \param [in] none + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M1_Stop(void) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE1->M1CR_f.CTEN = FALSE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 16浣嶈鏁板櫒鍒濆艰缃(妯″紡1) + ** + ** + ** \param [in] u16Data 16浣嶅垵鍊 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M1_Cnt16Set(uint16_t u16Data) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE1->CNT_f.CNT = u16Data; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 16浣嶈鏁板艰幏鍙(妯″紡1) + ** + ** + ** \param [in] none + ** + ** \retval 16bits璁℃暟鍊 + *****************************************************************************/ +uint16_t Tim3_M1_Cnt16Get(void) +{ + uint16_t u16CntData = 0; + + u16CntData = M0P_TIM3_MODE1->CNT_f.CNT; + + return u16CntData; +} + +/** + ***************************************************************************** + ** \brief Timer3 鑴夊啿瀹藉害娴嬮噺缁撴灉鏁板艰幏鍙(妯″紡1) + ** + ** + ** \param [in] none + ** + ** \retval 16bits鑴夊啿瀹藉害娴嬮噺缁撴灉 + *****************************************************************************/ +uint16_t Tim3_M1_PWC_CapValueGet(void) +{ + uint16_t u16CapData = 0; + + u16CapData = M0P_TIM3_MODE1->CCR0A_f.CCR0A; + + return u16CapData; +} + +/** + ***************************************************************************** + ** \brief Timer3 鍒濆鍖栭厤缃(妯″紡23) + ** + ** + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_Mode23_Init(stc_tim3_mode23_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->M23CR_f.MODE = pstcCfg->enWorkMode; + + M0P_TIM3_MODE23->M23CR_f.PRS = pstcCfg->enPRS; + M0P_TIM3_MODE23->M23CR_f.CT = pstcCfg->enCT; + M0P_TIM3_MODE23->M23CR_f.COMP = pstcCfg->enPWMTypeSel; + M0P_TIM3_MODE23->M23CR_f.PWM2S = pstcCfg->enPWM2sSel; + M0P_TIM3_MODE23->M23CR_f.ONESHOT = pstcCfg->bOneShot; + M0P_TIM3_MODE23->M23CR_f.URS = pstcCfg->bURSSel; + M0P_TIM3_MODE23->M23CR_f.DIR = pstcCfg->enCntDir; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 PWM杈撳嚭浣胯兘(妯″紡23) + ** + ** + ** \param [in] bEnOutput PWM杈撳嚭浣胯兘/绂佹璁惧畾 + ** \param [in] bEnAutoOutput PWM鑷姩杈撳嚭浣胯兘/绂佹璁惧畾 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_EnPWM_Output(boolean_t bEnOutput, boolean_t bEnAutoOutput) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->DTR_f.MOE = bEnOutput; + M0P_TIM3_MODE23->DTR_f.AOE = bEnAutoOutput; + + return enResult; +} + + +/** + ***************************************************************************** + ** \brief Timer3 鍚姩杩愯(妯″紡23) + ** + ** + ** \param [in] none + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_Run(void) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->M23CR_f.CTEN = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 鍋滄杩愯(妯″紡23) + ** + ** + ** \param [in] none + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_Stop(void) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->M23CR_f.CTEN = FALSE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 閲嶈浇鍊艰缃(妯″紡23) + ** + ** + ** \param [in] u16Data 16bits閲嶈浇鍊 + ** \param [in] bArrBufEn ARR閲嶈浇缂撳瓨浣胯兘TRUE/绂佹FALSE + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_ARRSet(uint16_t u16Data, boolean_t bArrBufEn) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->ARR_f.ARR = u16Data; + M0P_TIM3_MODE23->M23CR_f.BUFPEN = bArrBufEn; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 16浣嶈鏁板櫒鍒濆艰缃(妯″紡23) + ** + ** + ** \param [in] u16Data 16浣嶅垵鍊 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_Cnt16Set(uint16_t u16Data) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->CNT_f.CNT = u16Data; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 16浣嶈鏁板艰幏鍙(妯″紡23) + ** + ** + ** \param [in] none + ** + ** \retval 16bits璁℃暟鍊 + *****************************************************************************/ +uint16_t Tim3_M23_Cnt16Get(void) +{ + uint16_t u16CntData = 0; + + u16CntData = M0P_TIM3_MODE23->CNT_f.CNT; + + return u16CntData; +} + +/** + ***************************************************************************** + ** \brief Timer3 姣旇緝鎹曡幏瀵勫瓨鍣–CRxA/CCRxB璁剧疆(妯″紡23) + ** + ** + ** \param [in] enCCRSel CCRxA/CCRxB璁惧畾 + ** \param [in] u16Data CCRxA/CCRxB 16浣嶅垵濮嬪 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_CCR_Set(en_tim3_m23_ccrx_t enCCRSel, uint16_t u16Data) +{ + en_result_t enResult = Ok; + + if(Tim3CCR0A == enCCRSel) + { + M0P_TIM3_MODE23->CCR0A_f.CCR0A = u16Data; + } + else if(Tim3CCR0B == enCCRSel) + { + M0P_TIM3_MODE23->CCR0B_f.CCR0B = u16Data; + } + else if(Tim3CCR1A == enCCRSel) + { + M0P_TIM3_MODE23->CCR1A_f.CCR1A = u16Data; + } + else if(Tim3CCR1B == enCCRSel) + { + M0P_TIM3_MODE23->CCR1B_f.CCR1B = u16Data; + } + else if(Tim3CCR2A == enCCRSel) + { + M0P_TIM3_MODE23->CCR2A_f.CCR2A = u16Data; + } + else if(Tim3CCR2B == enCCRSel) + { + M0P_TIM3_MODE23->CCR2B_f.CCR2B = u16Data; + } + else + { + enResult = Error; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 姣旇緝鎹曡幏瀵勫瓨鍣–CRxA/CCRxB璇诲彇(妯″紡23) + ** + ** + ** \param [in] enCCRSel CCRxA/CCRxB璁惧畾 + ** + ** \retval 16bitsCCRxA/CCRxB鎹曡幏鍊 + *****************************************************************************/ +uint16_t Tim3_M23_CCR_Get(en_tim3_m23_ccrx_t enCCRSel) +{ + uint16_t u16Data = 0; + + if(Tim3CCR0A == enCCRSel) + { + u16Data = M0P_TIM3_MODE23->CCR0A_f.CCR0A; + } + else if(Tim3CCR0B == enCCRSel) + { + u16Data = M0P_TIM3_MODE23->CCR0B_f.CCR0B; + } + else if(Tim3CCR1A == enCCRSel) + { + u16Data = M0P_TIM3_MODE23->CCR1A_f.CCR1A; + } + else if(Tim3CCR1B == enCCRSel) + { + u16Data = M0P_TIM3_MODE23->CCR1B_f.CCR1B; + } + else if(Tim3CCR2A == enCCRSel) + { + u16Data = M0P_TIM3_MODE23->CCR2A_f.CCR2A; + } + else if(Tim3CCR2B == enCCRSel) + { + u16Data = M0P_TIM3_MODE23->CCR2B_f.CCR2B; + } + else + { + u16Data = 0; + } + + return u16Data; +} + +/** + ***************************************************************************** + ** \brief Timer3 PWM浜掕ˉ杈撳嚭妯″紡涓嬶紝GATE鍔熻兘閫夋嫨(妯″紡23) + ** + ** + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_GateFuncSel(stc_tim3_m23_gate_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->M23CR_f.CSG = pstcCfg->enGateFuncSel; + M0P_TIM3_MODE23->M23CR_f.CRG = pstcCfg->bGateRiseCap; + M0P_TIM3_MODE23->M23CR_f.CFG = pstcCfg->bGateFallCap; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 涓讳粠妯″紡閰嶇疆(妯″紡23) + ** + ** + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_MasterSlave_Set(stc_tim3_m23_master_slave_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->MSCR_f.MSM = pstcCfg->enMasterSlaveSel; + M0P_TIM3_MODE23->MSCR_f.MMS = pstcCfg->enMasterSrc; + M0P_TIM3_MODE23->MSCR_f.SMS = pstcCfg->enSlaveModeSel; + M0P_TIM3_MODE23->MSCR_f.TS = pstcCfg->enTsSel; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 CHxA/CHxB姣旇緝閫氶亾鎺у埗(妯″紡23) + ** + ** + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** \param [in] enTim3Chx Timer3閫氶亾(Tim3CH0, Tim3CH1, Tim3CH2) + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_PortOutput_Cfg(en_tim3_channel_t enTim3Chx, stc_tim3_m23_compare_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + switch (enTim3Chx) + { + case Tim3CH0: + M0P_TIM3_MODE23->CRCH0_f.CSA = 0; + M0P_TIM3_MODE23->FLTR_f.OCMA0_FLTA0 = pstcCfg->enCHxACmpCtrl; + M0P_TIM3_MODE23->FLTR_f.CCPA0 = pstcCfg->enCHxAPolarity; + M0P_TIM3_MODE23->CRCH0_f.BUFEA = pstcCfg->bCHxACmpBufEn; + M0P_TIM3_MODE23->M23CR_f.CIS = pstcCfg->enCHxACmpIntSel; + + M0P_TIM3_MODE23->CRCH0_f.CSB = 0; + M0P_TIM3_MODE23->FLTR_f.OCMB0_FLTB0 = pstcCfg->enCHxBCmpCtrl; + M0P_TIM3_MODE23->FLTR_f.CCPB0 = pstcCfg->enCHxBPolarity; + M0P_TIM3_MODE23->CRCH0_f.BUFEB = pstcCfg->bCHxBCmpBufEn; + M0P_TIM3_MODE23->CRCH0_f.CISB = pstcCfg->enCHxBCmpIntSel; + break; + case Tim3CH1: + M0P_TIM3_MODE23->CRCH1_f.CSA = 0; + M0P_TIM3_MODE23->FLTR_f.OCMA1_FLTA1 = pstcCfg->enCHxACmpCtrl; + M0P_TIM3_MODE23->FLTR_f.CCPA1 = pstcCfg->enCHxAPolarity; + M0P_TIM3_MODE23->CRCH1_f.BUFEA = pstcCfg->bCHxACmpBufEn; + M0P_TIM3_MODE23->M23CR_f.CIS = pstcCfg->enCHxACmpIntSel; + + M0P_TIM3_MODE23->CRCH1_f.CSB = 0; + M0P_TIM3_MODE23->FLTR_f.OCMB1_FLTB1 = pstcCfg->enCHxBCmpCtrl; + M0P_TIM3_MODE23->FLTR_f.CCPB1 = pstcCfg->enCHxBPolarity; + M0P_TIM3_MODE23->CRCH1_f.BUFEB = pstcCfg->bCHxBCmpBufEn; + M0P_TIM3_MODE23->CRCH1_f.CISB = pstcCfg->enCHxBCmpIntSel; + break; + case Tim3CH2: + M0P_TIM3_MODE23->CRCH2_f.CSA = 0; + M0P_TIM3_MODE23->FLTR_f.OCMA2_FLTA2 = pstcCfg->enCHxACmpCtrl; + M0P_TIM3_MODE23->FLTR_f.CCPA2 = pstcCfg->enCHxAPolarity; + M0P_TIM3_MODE23->CRCH2_f.BUFEA = pstcCfg->bCHxACmpBufEn; + M0P_TIM3_MODE23->M23CR_f.CIS = pstcCfg->enCHxACmpIntSel; + + M0P_TIM3_MODE23->CRCH2_f.CSB = 0; + M0P_TIM3_MODE23->FLTR_f.OCMB2_FLTB2 = pstcCfg->enCHxBCmpCtrl; + M0P_TIM3_MODE23->FLTR_f.CCPB2 = pstcCfg->enCHxBPolarity; + M0P_TIM3_MODE23->CRCH2_f.BUFEB = pstcCfg->bCHxBCmpBufEn; + M0P_TIM3_MODE23->CRCH2_f.CISB = pstcCfg->enCHxBCmpIntSel; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 CHxA/CHxB杈撳叆鎺у埗(妯″紡23) + ** + ** + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** \param [in] enTim3Chx Timer3閫氶亾(Tim3CH0, Tim3CH1, Tim3CH2) + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_PortInput_Cfg(en_tim3_channel_t enTim3Chx, stc_tim3_m23_input_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + switch (enTim3Chx) + { + case Tim3CH0: + M0P_TIM3_MODE23->CRCH0_f.CSA = 1; + M0P_TIM3_MODE23->CRCH0_f.CFA_CRA_BKSA = pstcCfg->enCHxACapSel; + M0P_TIM3_MODE23->FLTR_f.OCMA0_FLTA0 = pstcCfg->enCHxAInFlt; + M0P_TIM3_MODE23->FLTR_f.CCPA0 = pstcCfg->enCHxAPolarity; + + M0P_TIM3_MODE23->CRCH0_f.CSB = 1; + M0P_TIM3_MODE23->CRCH0_f.CFB_CRB_BKSB = pstcCfg->enCHxBCapSel; + M0P_TIM3_MODE23->FLTR_f.OCMB0_FLTB0 = pstcCfg->enCHxBInFlt; + M0P_TIM3_MODE23->FLTR_f.CCPB0 = pstcCfg->enCHxBPolarity; + break; + case Tim3CH1: + M0P_TIM3_MODE23->CRCH1_f.CSA = 1; + M0P_TIM3_MODE23->CRCH1_f.CFA_CRA_BKSA = pstcCfg->enCHxACapSel; + M0P_TIM3_MODE23->FLTR_f.OCMA1_FLTA1 = pstcCfg->enCHxAInFlt; + M0P_TIM3_MODE23->FLTR_f.CCPA1 = pstcCfg->enCHxAPolarity; + + M0P_TIM3_MODE23->CRCH1_f.CSB = 1; + M0P_TIM3_MODE23->CRCH1_f.CFB_CRB_BKSB = pstcCfg->enCHxBCapSel; + M0P_TIM3_MODE23->FLTR_f.OCMB1_FLTB1 = pstcCfg->enCHxBInFlt; + M0P_TIM3_MODE23->FLTR_f.CCPB1 = pstcCfg->enCHxBPolarity; + break; + case Tim3CH2: + M0P_TIM3_MODE23->CRCH2_f.CSA = 1; + M0P_TIM3_MODE23->CRCH2_f.CFA_CRA_BKSA = pstcCfg->enCHxACapSel; + M0P_TIM3_MODE23->FLTR_f.OCMA2_FLTA2 = pstcCfg->enCHxAInFlt; + M0P_TIM3_MODE23->FLTR_f.CCPA2 = pstcCfg->enCHxAPolarity; + + M0P_TIM3_MODE23->CRCH2_f.CSB = 1; + M0P_TIM3_MODE23->CRCH2_f.CFB_CRB_BKSB = pstcCfg->enCHxBCapSel; + M0P_TIM3_MODE23->FLTR_f.OCMB2_FLTB2 = pstcCfg->enCHxBInFlt; + M0P_TIM3_MODE23->FLTR_f.CCPB2 = pstcCfg->enCHxBPolarity; + break; + default: + enResult = Error; + break; + } + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 ERT杈撳叆鎺у埗(妯″紡23) + ** + ** + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_ETRInput_Cfg(stc_tim3_m23_etr_input_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->FLTR_f.ETP = pstcCfg->enETRPolarity; + M0P_TIM3_MODE23->FLTR_f.FLTET = pstcCfg->enETRFlt; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 鍒硅溅BK杈撳叆鎺у埗(妯″紡23) + ** + ** + ** \param [in] pstcBkCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_BrakeInput_Cfg(stc_tim3_m23_bk_input_cfg_t* pstcBkCfg) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->DTR_f.BKE = pstcBkCfg->bEnBrake; + M0P_TIM3_MODE23->DTR_f.VCE = pstcBkCfg->bEnVCBrake; + M0P_TIM3_MODE23->DTR_f.SAFEEN = pstcBkCfg->bEnSafetyBk; + M0P_TIM3_MODE23->DTR_f.BKSEL = pstcBkCfg->bEnBKSync; + M0P_TIM3_MODE23->CRCH0_f.CFA_CRA_BKSA = pstcBkCfg->enBkCH0AStat; + M0P_TIM3_MODE23->CRCH0_f.CFB_CRB_BKSB = pstcBkCfg->enBkCH0BStat; + M0P_TIM3_MODE23->CRCH1_f.CFA_CRA_BKSA = pstcBkCfg->enBkCH1AStat; + M0P_TIM3_MODE23->CRCH1_f.CFB_CRB_BKSB = pstcBkCfg->enBkCH1BStat; + M0P_TIM3_MODE23->CRCH2_f.CFA_CRA_BKSA = pstcBkCfg->enBkCH2AStat; + M0P_TIM3_MODE23->CRCH2_f.CFB_CRB_BKSB = pstcBkCfg->enBkCH2BStat; + M0P_TIM3_MODE23->FLTR_f.BKP = pstcBkCfg->enBrakePolarity; + M0P_TIM3_MODE23->FLTR_f.FLTBK = pstcBkCfg->enBrakeFlt; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer3 瑙﹀彂ADC鎺у埗(妯″紡23) + ** + ** + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_TrigADC_Cfg(stc_tim3_m23_adc_trig_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->ADTR_f.ADTE = pstcCfg->bEnTrigADC; + M0P_TIM3_MODE23->ADTR_f.UEVE = pstcCfg->bEnUevTrigADC; + M0P_TIM3_MODE23->ADTR_f.CMA0E = pstcCfg->bEnCH0ACmpTrigADC; + M0P_TIM3_MODE23->ADTR_f.CMB0E = pstcCfg->bEnCH0BCmpTrigADC; + M0P_TIM3_MODE23->ADTR_f.CMA1E = pstcCfg->bEnCH1ACmpTrigADC; + M0P_TIM3_MODE23->ADTR_f.CMB1E = pstcCfg->bEnCH1BCmpTrigADC; + M0P_TIM3_MODE23->ADTR_f.CMA2E = pstcCfg->bEnCH2ACmpTrigADC; + M0P_TIM3_MODE23->ADTR_f.CMB2E = pstcCfg->bEnCH2BCmpTrigADC; + return enResult; +} + +/** + ***************************************************************************** +** \brief Timer3 姝诲尯鍔熻兘(妯″紡23) + ** + ** + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_DT_Cfg(stc_tim3_m23_dt_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->DTR_f.DTEN = pstcCfg->bEnDeadTime; + M0P_TIM3_MODE23->DTR_f.DTR = pstcCfg->u8DeadTimeValue; + + return enResult; +} + +/** + ***************************************************************************** +** \brief Timer3 閲嶅鍛ㄦ湡璁剧疆(妯″紡23) + ** + ** + ** \param [in] u8ValidPeriod 閲嶅鍛ㄦ湡鍊 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_SetValidPeriod(uint8_t u8ValidPeriod) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->RCR_f.RCR = u8ValidPeriod; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 OCREF娓呴櫎鍔熻兘(妯″紡23) + ** + ** + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_OCRefClr(stc_tim3_m23_OCREF_Clr_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->M23CR_f.OCCS = pstcCfg->enOCRefClrSrcSel; + M0P_TIM3_MODE23->M23CR_f.OCCE = pstcCfg->bVCClrEn; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 浣胯兘DMA浼犺緭(妯″紡23) + ** + ** + ** \param [in] pstcCfg 鍒濆鍖栭厤缃粨鏋勪綋鎸囬拡 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_EnDMA(stc_tim3_m23_trig_dma_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->M23CR_f.UDE = pstcCfg->bUevTrigDMA; + M0P_TIM3_MODE23->M23CR_f.TDE = pstcCfg->bTITrigDMA; + M0P_TIM3_MODE23->CRCH0_f.CDEA = pstcCfg->bCmpA0TrigDMA; + M0P_TIM3_MODE23->CRCH0_f.CDEB = pstcCfg->bCmpB0TrigDMA; + M0P_TIM3_MODE23->CRCH1_f.CDEA = pstcCfg->bCmpA1TrigDMA; + M0P_TIM3_MODE23->CRCH1_f.CDEB = pstcCfg->bCmpB1TrigDMA; + M0P_TIM3_MODE23->CRCH2_f.CDEA = pstcCfg->bCmpA2TrigDMA; + M0P_TIM3_MODE23->CRCH2_f.CDEB = pstcCfg->bCmpB2TrigDMA; + M0P_TIM3_MODE23->MSCR_f.CCDS = pstcCfg->enCmpUevTrigDMA; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 鎹曡幏姣旇緝A杞欢瑙﹀彂(妯″紡23) + ** + ** + ** \param [in] enTim3Chx Timer3閫氶亾(Tim3CH0, Tim3CH1, Tim3CH2) + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_EnSwTrigCapCmpA(en_tim3_channel_t enTim3Chx) +{ + en_result_t enResult = Ok; + if(Tim3CH0 == enTim3Chx) + { + M0P_TIM3_MODE23->CRCH0_f.CCGA = TRUE; + } + else if(Tim3CH1 == enTim3Chx) + { + M0P_TIM3_MODE23->CRCH1_f.CCGA = TRUE; + } + else if(Tim3CH2 == enTim3Chx) + { + M0P_TIM3_MODE23->CRCH2_f.CCGA = TRUE; + } + else + { + enResult = Error; + } + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 鎹曡幏姣旇緝B杞欢瑙﹀彂(妯″紡23) + ** + ** + ** \param [in] enTim3Chx Timer3閫氶亾(Tim3CH0, Tim3CH1, Tim3CH2) + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_EnSwTrigCapCmpB(en_tim3_channel_t enTim3Chx) +{ + en_result_t enResult = Ok; + if(Tim3CH0 == enTim3Chx) + { + M0P_TIM3_MODE23->CRCH0_f.CCGB = TRUE; + } + else if(Tim3CH1 == enTim3Chx) + { + M0P_TIM3_MODE23->CRCH1_f.CCGB = TRUE; + } + else if(Tim3CH2 == enTim3Chx) + { + M0P_TIM3_MODE23->CRCH2_f.CCGB = TRUE; + } + else + { + enResult = Error; + } + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 杞欢鏇存柊浣胯兘(妯″紡23) + ** + ** + ** \param [in] none + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_EnSwUev(void) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->M23CR_f.UG = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 杞欢瑙﹀彂浣胯兘(妯″紡23) + ** + ** + ** \param [in] none + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_EnSwTrig(void) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->M23CR_f.TG = TRUE; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Timer3 杞欢鍒硅溅浣胯兘(妯″紡23) + ** + ** + ** \param [in] none + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Tim3_M23_EnSwBk(void) +{ + en_result_t enResult = Ok; + + M0P_TIM3_MODE23->M23CR_f.BG = TRUE; + + return enResult; +} + +//@} // Tim3Group + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/driver/src/trim.c b/driver/src/trim.c new file mode 100644 index 0000000..91d1b97 --- /dev/null +++ b/driver/src/trim.c @@ -0,0 +1,248 @@ +/****************************************************************************** +*Copyright(C)2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file trim.c + ** + ** Common API of trim. + ** @link trimGroup Some description @endlink + ** + ** - 2017-05-16 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "trim.h" +/** + ******************************************************************************* + ** \addtogroup TrimGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ +#define IS_VALID_TRIMINT(x) (TrimStop == (x) ||\ + TrimCalCntOf == (x) ||\ + TrimXTLFault == (x) ||\ + TrimXTHFault == (x) ||\ + TrimPLLFault == (x)) + + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +/** + ***************************************************************************** + ** \brief Trim涓柇鏍囧織鑾峰彇 + ** + ** + ** \param [in] enIntType 涓柇绫诲瀷锛圧efStop銆丆alCntOf銆乆TAL32KFault銆乆TAL32MFault锛 + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +boolean_t Trim_GetIntFlag(en_trim_inttype_t enIntType) +{ + ASSERT(IS_VALID_TRIMINT(enIntType)); + + if(M0P_CLK_TRIM->IFR&enIntType) + { + return TRUE; + } + else + { + return FALSE; + } + +} + +/** + ***************************************************************************** + ** \brief Trim涓柇鏍囧織娓呴櫎 + ** + ** + ** \param [in] enIntType 涓柇绫诲瀷锛圧efStop銆丆alCntOf銆乆TAL32KFault銆乆TAL32MFault锛 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Trim_ClearIntFlag(en_trim_inttype_t enIntType) +{ + en_result_t enResult = Error; + + ASSERT(IS_VALID_TRIMINT(enIntType)); + + M0P_CLK_TRIM->ICLR &= ~(uint32_t)enIntType; + + return enResult; +} + + + +/** + ***************************************************************************** + ** \brief Trim涓柇浣胯兘 + ** + ** + ** + ** \retval Null + *****************************************************************************/ +void Trim_EnableIrq (void) +{ + M0P_CLK_TRIM->CR_f.IE = TRUE; +} + +/** + ***************************************************************************** + ** \brief Trim涓柇绂佹 + ** + ** + ** + ** + ** \retval Ok or Error + *****************************************************************************/ +void Trim_DisableIrq(void) +{ + M0P_CLK_TRIM->CR_f.IE = FALSE; +} + +/** + ***************************************************************************** + ** \brief Trim鍒濆鍖栭厤缃 + ** + ** + ** \param [in] pstcCfg Trim閰嶇疆缁撴瀯浣撴寚閽 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Trim_Init(stc_trim_cfg_t* pstcCfg) +{ + en_result_t enResult = Error; + + M0P_CLK_TRIM->CR = 0; + + M0P_CLK_TRIM->CR = (uint32_t)pstcCfg->enCALCLK | + (uint32_t)pstcCfg->enREFCLK | + (uint32_t)pstcCfg->enMON; + + M0P_CLK_TRIM->REFCON = pstcCfg->u32RefCon; + M0P_CLK_TRIM->CALCON = pstcCfg->u32CalCon; + + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Trim鏍″噯/鐩戞祴鍚姩杩愯 + ** + ** + ** + ** \retval Null + *****************************************************************************/ +void Trim_Run(void) +{ + M0P_CLK_TRIM->CR_f.TRIM_START = TRUE; +} + +/** + ***************************************************************************** + ** \brief Trim鏍″噯/鐩戞祴鍋滄 + ** + ** + ** + ** + ** \retval Null + *****************************************************************************/ +void Trim_Stop(void) +{ + M0P_CLK_TRIM->CR_f.TRIM_START = FALSE; +} + +/** + ***************************************************************************** + ** \brief Trim鍙傝冭鏁板櫒璁℃暟鍊艰幏鍙 + ** + ** + ** \retval u32Data 鍙傝冭鏁板櫒璁℃暟鍊 + *****************************************************************************/ +uint32_t Trim_RefCntGet(void) +{ + return (uint32_t)M0P_CLK_TRIM->REFCNT; +} + +/** + ***************************************************************************** + ** \brief Trim鏍″噯璁℃暟鍣ㄨ鏁板艰幏鍙 + ** + ** + ** + ** + ** \retval u32Data 鏍″噯璁℃暟鍣ㄨ鏁板 + *****************************************************************************/ +uint32_t Trim_CalCntGet(void) +{ + return (uint32_t)M0P_CLK_TRIM->CALCNT; +} + +//@} // TrimGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/driver/src/trng.c b/driver/src/trng.c new file mode 100644 index 0000000..3cc7842 --- /dev/null +++ b/driver/src/trng.c @@ -0,0 +1,191 @@ +/****************************************************************************** +*Copyright(C)2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file rng.c + ** + ** Common API of rng. + ** @link flashGroup Some description @endlink + ** + ** - 2018-05-08 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "trng.h" +/** + ******************************************************************************* + ** \addtogroup FlashGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ***************************************************************************** + ** \brief 闅忔満鏁板垵濮嬪寲(涓婄數绗竴娆$敓鎴愰殢鏈烘暟锛 + ** + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +en_result_t Trng_Init(void) +{ + //==>>鐢熸垚64bits闅忔満鏁帮紙涓婄數绗竴娆★級 + M0P_TRNG->CR_f.RNGCIR_EN = 1; + //妯″紡閰嶇疆0 + M0P_TRNG->MODE_f.LOAD = 1; + M0P_TRNG->MODE_f.FDBK = 1; + M0P_TRNG->MODE_f.CNT = 6; + //鐢熸垚闅忔満鏁0 + M0P_TRNG->CR_f.RNG_RUN = 1; + while(M0P_TRNG->CR_f.RNG_RUN) + { + ; + } + + //妯″紡閰嶇疆1 + M0P_TRNG->MODE_f.LOAD = 0; + M0P_TRNG->MODE_f.FDBK = 0; + M0P_TRNG->MODE_f.CNT = 4; + //鐢熸垚闅忔満鏁1 + M0P_TRNG->CR_f.RNG_RUN = 1; + while(M0P_TRNG->CR_f.RNG_RUN) + { + ; + } + + //鍏抽棴闅忔満婧愮數璺紝鑺傜渷鍔熻 + M0P_TRNG->CR_f.RNGCIR_EN = 0; + + return Ok; +} + +/** + ***************************************************************************** + ** \brief 鐢熸垚闅忔満鏁帮紙闈炰笂鐢电涓娆$敓鎴愰殢鏈烘暟锛 + ** + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +en_result_t Trng_Generate(void) +{ + //==>>鐢熸垚64bits闅忔満鏁帮紙闈炰笂鐢电涓娆$敓鎴愶級 + M0P_TRNG->CR_f.RNGCIR_EN = 1; + + //妯″紡閰嶇疆0 + M0P_TRNG->MODE_f.LOAD = 0; + M0P_TRNG->MODE_f.FDBK = 1; + M0P_TRNG->MODE_f.CNT = 6; + //鐢熸垚闅忔満鏁0 + M0P_TRNG->CR_f.RNG_RUN = 1; + while(M0P_TRNG->CR_f.RNG_RUN) + { + ; + } + + //妯″紡閰嶇疆1 + M0P_TRNG->MODE_f.FDBK = 0; + M0P_TRNG->MODE_f.CNT = 4; + M0P_TRNG->MODE_f.CNT = 4; + //鐢熸垚闅忔満鏁1 + M0P_TRNG->CR_f.RNG_RUN = 1; + while(M0P_TRNG->CR_f.RNG_RUN) + { + ; + } + + //鍏抽棴闅忔満婧愮數璺紝鑺傜渷鍔熻 + M0P_TRNG->CR_f.RNGCIR_EN = 0; + + return Ok; +} + +/** + ***************************************************************************** + ** \brief 闅忔満鏁拌幏鍙 + ** + ** \retval data0 + *****************************************************************************/ +uint32_t Trng_GetData0(void) +{ + return M0P_TRNG->DATA0; +} + +/** + ***************************************************************************** + ** \brief 闅忔満鏁拌幏鍙 + ** + ** \retval data1 + *****************************************************************************/ +uint32_t Trng_GetData1(void) +{ + return M0P_TRNG->DATA1; +} + +//@} // TrngGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/driver/src/uart.c b/driver/src/uart.c new file mode 100644 index 0000000..2dee506 --- /dev/null +++ b/driver/src/uart.c @@ -0,0 +1,405 @@ +/************************************************************************************* +* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file uart.c + ** + ** UART function driver API. + ** @link SampleGroup Some description @endlink + ** + ** - 2017-05-17 1.0 CJ First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "uart.h" +/** + ****************************************************************************** + ** \addtogroup UartGroup + ******************************************************************************/ +//@{ +/******************************************************************************/ +/* Local pre-processor symbols/macros ('#define') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local function prototypes ('static') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local variable definitions ('static') */ +/******************************************************************************/ + +/** + ****************************************************************************** + ** \brief UART閫氫俊涓柇浣胯兘鍑芥暟璁剧疆 + ** + ** \param [in] UARTx閫氶亾鍙凤紝enIrqSel鍙戦乷r鎺ユ敹涓柇浣胯兘 + ** + ** \retval OK閰嶇疆鎴愬姛 + ** \retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t Uart_EnableIrq(M0P_UART_TypeDef* UARTx, en_uart_irq_sel_t enIrqSel) +{ + SetBit((uint32_t)(&(UARTx->SCON)), enIrqSel, TRUE); + + return Ok; +} +/** + ****************************************************************************** + ** \brief UART閫氫俊涓柇绂佹鍑芥暟璁剧疆 + ** + ** \param [in] UARTx閫氶亾鍙凤紝enIrqSel鍙戦乷r鎺ユ敹涓柇绂佹 + ** + ** \retval OK閰嶇疆鎴愬姛 + ** \retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t Uart_DisableIrq(M0P_UART_TypeDef* UARTx, en_uart_irq_sel_t enIrqSel) +{ + SetBit((uint32_t)(&(UARTx->SCON)), enIrqSel, FALSE); + + return Ok; +} + +/** + ****************************************************************************** + ** \brief UART閫氶亾澶氫富鏈烘ā寮忛厤缃 + ** + ** \param [in] UARTx閫氶亾鍙凤紝stcMultiCfg澶氫富鏈烘ā寮忕粨鏋 + ** + ** \retval OK閰嶇疆鎴愬姛 + ** \retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t Uart_SetMultiMode(M0P_UART_TypeDef* UARTx, stc_uart_multimode_t* pstcMultiCfg) +{ + if(NULL != pstcMultiCfg) + { + UARTx->SCON_f.ADRDET = TRUE; + UARTx->SADDR = pstcMultiCfg->u8SlaveAddr; + UARTx->SADEN = pstcMultiCfg->u8SaddEn; + + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + ****************************************************************************** + ** \brief UART鍗曠嚎鍗婂弻宸ユā寮忎娇鑳 + ** + ** \param [in] UARTx 閫氶亾鍙 + ** + ** \retval Null + ******************************************************************************/ +void Uart_HdModeEnable(M0P_UART_TypeDef* UARTx) +{ + UARTx->SCON_f.HDSEL = TRUE; +} + +/** + ****************************************************************************** + ** \brief UART鍗曠嚎鍗婂弻宸ユā寮忓叧闂 + ** + ** \param [in] UARTx 閫氶亾鍙 + ** + ** \retval Null + ******************************************************************************/ +void Uart_HdModeDisable(M0P_UART_TypeDef* UARTx) +{ + UARTx->SCON_f.HDSEL = FALSE; +} + +/** + ****************************************************************************** + ** \brief UART閫氶亾澶氭満妯″紡鍙戦佹暟鎹/鍦板潃甯ч厤缃甌B8 + ** + ** \param [in] UARTx 閫氶亾鍙 + ** \param [in] TRUE-TB8涓哄湴鍧甯ф爣蹇楋紱FALSE-TB8涓烘暟鎹抚鏍囧織锛 + ** + ** \retval Null + ******************************************************************************/ +void Uart_SetTb8(M0P_UART_TypeDef* UARTx, boolean_t bTB8Value) +{ + UARTx->SCON_f.B8CONT = bTB8Value; + +} + +/** + ****************************************************************************** + ** \brief 鑾峰彇RB8鏁板 + ** + ** \param [in] UARTx閫氶亾鍙 + ** + ** \retval RB8 + ******************************************************************************/ +boolean_t Uart_GetRb8(M0P_UART_TypeDef* UARTx) +{ + return (UARTx->SBUF_f.DATA8); +} + +/** + ****************************************************************************** + ** \brief UART閫氶亾澶氫富鏈烘ā寮忎粠鏈哄湴鍧閰嶇疆鍑芥暟 + ** + ** \param [in] UARTx閫氶亾鍙凤紝addr鍦板潃 + ** + ** \retval OK閰嶇疆鎴愬姛 + ** \retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t Uart_SetSaddr(M0P_UART_TypeDef* UARTx,uint8_t u8Addr) +{ + UARTx->SADDR = u8Addr; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief UART閫氶亾鍙戦佹垨鎺ユ敹绛夊姛鑳戒娇鑳借缃 + ** + ** \param [in] UARTx閫氶亾鍙凤紝enFunc鍔熻兘 + ** + ** \retval OK閰嶇疆鎴愬姛 + ** \retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t Uart_EnableFunc(M0P_UART_TypeDef* UARTx, en_uart_func_t enFunc) +{ + SetBit((uint32_t)(&(UARTx->SCON)), enFunc, TRUE); + + return Ok; +} +/** + ****************************************************************************** + ** \brief UART閫氶亾鍙戦佹垨鎺ユ敹绛夊姛鑳界姝㈣缃 + ** + ** \param [in] UARTx閫氶亾鍙凤紝enFunc鍔熻兘 + ** + ** \retval OK閰嶇疆鎴愬姛 + ** \retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t Uart_DisableFunc(M0P_UART_TypeDef* UARTx, en_uart_func_t enFunc) +{ + SetBit((uint32_t)(&(UARTx->SCON)), enFunc, FALSE); + + return Ok; +} +/** + ****************************************************************************** + ** \brief UART閫氶亾閫氫俊鐘舵佽幏鍙 + ** + ** \param [in] UARTx閫氶亾鍙 + ** + ** \retval 鐘舵佸 + ******************************************************************************/ +uint8_t Uart_GetIsr(M0P_UART_TypeDef* UARTx) +{ + return (UARTx->ISR); +} + +/** + ****************************************************************************** + ** \brief UART閫氶亾閫氫俊鐘舵佽幏鍙 + ** + ** \param [in] UARTx閫氶亾鍙凤紝enStatus鑾峰彇鍝釜鐘舵 + ** + ** \retval 鐘舵佸 + ******************************************************************************/ +boolean_t Uart_GetStatus(M0P_UART_TypeDef* UARTx, en_uart_status_t enStatus) +{ + boolean_t bStatus = FALSE; + + + ASSERT(IS_VALID_STATUS(enStatus)); + + bStatus = GetBit((uint32_t)(&(UARTx->ISR)), enStatus); + + return bStatus; +} +/** + ****************************************************************************** + ** \brief UART閫氶亾閫氫俊鐘舵佹竻闄 + ** + ** \param [in] UARTx閫氶亾鍙 + ** + ** \retval OK + ** \retval ErrorInvalidParameter娓呴櫎澶辫触 + ******************************************************************************/ +en_result_t Uart_ClrIsr(M0P_UART_TypeDef* UARTx) +{ + UARTx->ICR = 0u; + return Ok; +} +/** + ****************************************************************************** + ** \brief UART閫氶亾閫氫俊鐘舵佹竻闄 + ** + ** \param [in] UARTx閫氶亾鍙凤紝enStatus娓呴櫎鍝釜鐘舵 + ** + ** \retval OK + ** \retval ErrorInvalidParameter娓呴櫎澶辫触 + ******************************************************************************/ +en_result_t Uart_ClrStatus(M0P_UART_TypeDef* UARTx,en_uart_status_t enStatus) +{ + ASSERT(IS_VALID_STATUS(enStatus)); + + SetBit((uint32_t)(&(UARTx->ICR)), enStatus, FALSE); + + return Ok; +} +/** + ****************************************************************************** + ** \brief UART閫氶亾鍙戦佹暟鎹嚱鏁,鏌ヨ鏂瑰紡璋冪敤姝ゅ嚱鏁帮紝涓柇鏂瑰紡鍙戦佷笉閫傜敤 + ** + ** \param [in] UARTx閫氶亾鍙凤紝Data鍙戦佹暟鎹 + ** + ** \retval Ok鍙戦佹垚鍔 + ** \retval ErrorInvalidParameter鍙戦佸け璐 + ******************************************************************************/ +en_result_t Uart_SendDataPoll(M0P_UART_TypeDef* UARTx, uint8_t u8Data) +{ + while(FALSE == Uart_GetStatus(UARTx,UartTxe)) + {} + UARTx->SBUF_f.DATA = u8Data; + while(FALSE == Uart_GetStatus(UARTx,UartTC)) + {} + Uart_ClrStatus(UARTx,UartTC); + return Ok; +} + +/** + ****************************************************************************** + ** \brief UART閫氶亾鍙戦佹暟鎹嚱鏁,涓柇鏂瑰紡璋冪敤姝ゅ嚱鏁 + ** + ** \param [in] UARTx閫氶亾鍙凤紝Data鍙戦佹暟鎹 + ** + ** \retval Ok鍙戦佹垚鍔 + ** \retval ErrorInvalidParameter鍙戦佸け璐 + ******************************************************************************/ +en_result_t Uart_SendDataIt(M0P_UART_TypeDef* UARTx, uint8_t u8Data) +{ + UARTx->SBUF_f.DATA = u8Data; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief UART閫氶亾鎺ユ敹鏁版嵁鍑芥暟 + ** + ** \param [in] UARTx閫氶亾鍙 + ** + ** \retval 鎺ユ敹鏁版嵁 + ******************************************************************************/ +uint8_t Uart_ReceiveData(M0P_UART_TypeDef* UARTx) +{ + return (UARTx->SBUF_f.DATA); +} + +/** + ****************************************************************************** + ** \brief UART閫氶亾鍒濆鍖栧嚱鏁 + ** + ** \param [in] UARTx閫氶亾鍙凤紝pstcCfg鍒濆鍖栫粨鏋勪綋 @ref stc_uart_cfg_t + ** + ** \retval OK閰嶇疆鎴愬姛 + ** \retval ErrorInvalidParameter閰嶇疆澶辫触 + ******************************************************************************/ +en_result_t Uart_Init(M0P_UART_TypeDef* UARTx, stc_uart_cfg_t* pstcCfg) +{ + en_result_t enRet = Error; + uint32_t u32Over[2] = {0x4, 0x3}; + uint16_t u16OverShift; + float32_t f32Scnt=0; + + if(NULL == pstcCfg) + { + return ErrorInvalidParameter; + } + + UARTx->SCON = 0; + + UARTx->SCON = (uint32_t)pstcCfg->enStopBit | + (uint32_t)pstcCfg->enMmdorCk | + (uint32_t)pstcCfg->stcBaud.enClkDiv | + (uint32_t)pstcCfg->enRunMode; + + if((UartMskMode1 == pstcCfg->enRunMode) || (UartMskMode3 == pstcCfg->enRunMode)) + { + u16OverShift = u32Over[pstcCfg->stcBaud.enClkDiv/UartMsk8Or16Div]; + f32Scnt = (float32_t)(pstcCfg->stcBaud.u32Pclk)/(float32_t)(pstcCfg->stcBaud.u32Baud<SCNT = (uint16_t)(float32_t)(f32Scnt + 0.5f); + Uart_EnableFunc(UARTx,UartRenFunc); ///<浣胯兘鏀跺彂 + } + + + + enRet = Ok; + return enRet; +} + +/** + ****************************************************************************** + ** \brief UART鍙戦佸瓧绗︿覆 + ** + ** \param [in] UARTx閫氶亾鍙凤紝SendDataString瑕佸彂閫佺殑瀛楃涓 + ** + ** \retval + ** \retval + ******************************************************************************/ +void USART_SendString(M0P_UART_TypeDef* USARTx,uint16_t Len, uint8_t *SendDataString) +{ + int i = 0; + while(i < Len) //瀛楃涓茬粨鏉熺 + { + Uart_SendDataPoll(USARTx,SendDataString[i]); //姣忔鍙戦佸瓧绗︿覆鐨勪竴涓瓧绗 + //Uart_ClrStatus(USARTx, UartTC); //鍙戦佸瓧绗﹀悗娓呯┖鏍囧織浣 + i++; + } +} + + +//@} // UartGroup diff --git a/driver/src/vc.c b/driver/src/vc.c new file mode 100644 index 0000000..8e09495 --- /dev/null +++ b/driver/src/vc.c @@ -0,0 +1,298 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file vc.c + ** + ** voltage comparator driver API. + ** @link VC Group Some description @endlink + ** + ** - 2019-04-10 First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "vc.h" + +/** + ****************************************************************************** + ** \addtogroup VcGroup + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/****************************************************************************** + * Local variable definitions ('static') + ******************************************************************************/ + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + *****************************************************************************/ + +/** +****************************************************************************** + ** \brief 閰嶇疆VC涓柇瑙﹀彂鏂瑰紡 + ** + ** @param Channelx : VcChannelx x=0銆1銆2 + ** @param enSel : VcIrqRise銆乂cIrqFall銆乂cIrqHigh + ** \retval 鏃 + ** +******************************************************************************/ +void Vc_CfgItType(en_vc_channel_t Channelx, en_vc_irq_sel_t ItType) +{ + stc_vc_vc0_cr_field_t *stcVcnCr; + switch(Channelx) + { + case VcChannel0: + stcVcnCr = (stc_vc_vc0_cr_field_t*)&M0P_VC->VC0_CR_f; + break; + case VcChannel1: + stcVcnCr = (stc_vc_vc0_cr_field_t*)&M0P_VC->VC1_CR_f; + break; + case VcChannel2: + stcVcnCr = (stc_vc_vc0_cr_field_t*)&M0P_VC->VC2_CR_f; + break; + default: + break; + } + switch (ItType) + { + case VcIrqNone: + stcVcnCr->RISING = 0u; + stcVcnCr->FALLING = 0u; + stcVcnCr->LEVEL = 0u; + break; + case VcIrqRise: + stcVcnCr->RISING = 1u; + break; + case VcIrqFall: + stcVcnCr->FALLING = 1u; + break; + case VcIrqHigh: + stcVcnCr->LEVEL = 1u; + break; + default: + break; + } +} + +/** +****************************************************************************** + ** \brief VC 涓柇浣胯兘涓庣姝 + ** + ** @param Channelx : VcChannelx x=0銆1銆2 + ** @param NewStatus : TRUE 鎴 FALSE + ** \retval 鏃 + ** +******************************************************************************/ +void Vc_ItCfg(en_vc_channel_t Channelx, boolean_t NewStatus) +{ + switch(Channelx) + { + case VcChannel0: + SetBit((uint32_t)(&(M0P_VC->VC0_CR)), 15, NewStatus); + break; + case VcChannel1: + SetBit((uint32_t)(&(M0P_VC->VC1_CR)), 15, NewStatus); + break; + case VcChannel2: + SetBit((uint32_t)(&(M0P_VC->VC2_CR)), 15, NewStatus); + break; + default: + break; + } +} + +/** +****************************************************************************** + ** \brief VC 姣旇緝缁撴灉鑾峰彇锛屽寘鍚腑鏂爣蹇椾綅鍜屾护娉㈢粨鏋 + ** + ** @param Result : 鎵瑕佽鍙栫殑缁撴灉 + ** \retval TRUE 鎴 FALSE + ** +******************************************************************************/ +boolean_t Vc_GetItStatus(en_vc_ifr_t Result) +{ + boolean_t bFlag; + bFlag = GetBit((uint32_t)(&(M0P_VC->IFR)), Result); + return bFlag; +} + +/** +****************************************************************************** + ** \brief VC 娓呴櫎涓柇鏍囧織浣 + ** + ** @param NewStatus : Vc0_Intf銆乂c1_Intf銆乂c2_Intf + ** \retval 鏃 + ** +******************************************************************************/ +void Vc_ClearItStatus(en_vc_ifr_t NewStatus) +{ + SetBit((uint32_t)(&(M0P_VC->IFR)), NewStatus, 0); +} + +/** +****************************************************************************** + ** \brief VC 閰嶇疆DAC鐩稿叧鐨勫唴瀹 VC_CR涓 VC_REF2P5_SEL VC_DIV_EN VC_DIV + ** + ** @param pstcDacCfg : + ** \retval Ok 鎴 ErrorInvalidParameter + ** +******************************************************************************/ +en_result_t Vc_DacInit(stc_vc_dac_cfg_t *pstcDacCfg) +{ + if (NULL == pstcDacCfg) + { + return ErrorInvalidParameter; + } + + M0P_VC->CR_f.DIV_EN = pstcDacCfg->bDivEn; + M0P_VC->CR_f.REF2P5_SEL = pstcDacCfg->enDivVref; + + if (pstcDacCfg->u8DivVal < 0x40) + { + M0P_VC->CR_f.DIV = pstcDacCfg->u8DivVal; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** +****************************************************************************** + ** \brief VC閫氶亾鍒濆鍖 + ** + ** @param pstcDacCfg : + ** \retval 鏃 + ** +******************************************************************************/ +void Vc_Init(stc_vc_channel_cfg_t *pstcChannelCfg) +{ + if (VcChannel0 == pstcChannelCfg->enVcChannel) + { + M0P_VC->CR_f.VC0_HYS_SEL = pstcChannelCfg->enVcCmpDly; + M0P_VC->CR_f.VC0_BIAS_SEL = pstcChannelCfg->enVcBiasCurrent; + M0P_VC->VC0_CR_f.DEBOUNCE_TIME = pstcChannelCfg->enVcFilterTime; + M0P_VC->VC0_CR_f.P_SEL = pstcChannelCfg->enVcInPin_P; + M0P_VC->VC0_CR_f.N_SEL = pstcChannelCfg->enVcInPin_N; + M0P_VC->VC0_CR_f.FLTEN = pstcChannelCfg->bFlten; + M0P_VC->VC0_OUT_CFG = 1<enVcOutCfg; + } + else if (VcChannel1 == pstcChannelCfg->enVcChannel) + { + M0P_VC->CR_f.VC1_HYS_SEL = pstcChannelCfg->enVcCmpDly; + M0P_VC->CR_f.VC1_BIAS_SEL = pstcChannelCfg->enVcBiasCurrent; + M0P_VC->VC1_CR_f.DEBOUNCE_TIME = pstcChannelCfg->enVcFilterTime; + M0P_VC->VC1_CR_f.P_SEL = pstcChannelCfg->enVcInPin_P; + M0P_VC->VC1_CR_f.N_SEL = pstcChannelCfg->enVcInPin_N; + M0P_VC->VC1_CR_f.FLTEN = pstcChannelCfg->bFlten; + M0P_VC->VC1_OUT_CFG = 1<enVcOutCfg; + } + else if(VcChannel2 == pstcChannelCfg->enVcChannel) + { + M0P_VC->CR_f.VC2_HYS_SEL = pstcChannelCfg->enVcCmpDly; + M0P_VC->CR_f.VC2_BIAS_SEL = pstcChannelCfg->enVcBiasCurrent; + M0P_VC->VC2_CR_f.DEBOUNCE_TIME = pstcChannelCfg->enVcFilterTime; + M0P_VC->VC2_CR_f.P_SEL = pstcChannelCfg->enVcInPin_P; + M0P_VC->VC2_CR_f.N_SEL = pstcChannelCfg->enVcInPin_N; + M0P_VC->VC2_CR_f.FLTEN = pstcChannelCfg->bFlten; + M0P_VC->VC2_OUT_CFG = 1<enVcOutCfg; + } + else + { + ; + } +} + +/** +****************************************************************************** + ** \brief VC 閫氶亾浣胯兘 + ** + ** \param enChannel : 閫氶亾鍙稸cChannel0 VcChannel1 VcChannel2 + ** \param NewStatus : TRUE FALSE + ** \retval NewStatus : TRUE FALSE + ** +******************************************************************************/ +void Vc_Cmd(en_vc_channel_t enChannel, boolean_t NewStatus) +{ + switch(enChannel) + { + case VcChannel0: + SetBit((uint32_t)(&(M0P_VC->VC0_CR)), 16, NewStatus); + break; + case VcChannel1: + SetBit((uint32_t)(&(M0P_VC->VC1_CR)), 16, NewStatus); + break; + case VcChannel2: + SetBit((uint32_t)(&(M0P_VC->VC2_CR)), 16, NewStatus); + break; + default: + break; + } +} + +//@} // VcGroup + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/driver/src/wdt.c b/driver/src/wdt.c new file mode 100644 index 0000000..4d07496 --- /dev/null +++ b/driver/src/wdt.c @@ -0,0 +1,203 @@ +/************************************************************************************* +* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file wdt.c + ** + ** WDT function driver API. + ** @link WdtGroup Some description @endlink + ** + ** - 2017-05-17 1.0 CJ First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "wdt.h" + +/** + ****************************************************************************** + ** \defgroup WdtGroup + ** + ******************************************************************************/ +//@{ + +/******************************************************************************/ +/* Local function prototypes ('static') */ +/******************************************************************************/ + +/** + ****************************************************************************** + ** \brief WDT婧㈠嚭鏃堕棿璁剧疆鍑芥暟 + ** + ** \param [in] u8LoadValue 婧㈠嚭鏃堕棿 + ** + ** \retval 鏃 + ** + ******************************************************************************/ +void Wdt_WriteWdtLoad(uint8_t u8LoadValue) +{ + M0P_WDT->CON_f.WOV = u8LoadValue; +} +/** + ****************************************************************************** + ** \brief WDT鍒濆鍖栧嚱鏁 + ** + ** \param [in] enFunc @ref en_wdt_func_t + ** \param [in] enTime @ref en_wdt_time_t + ** + ** \retval Ok + ** + ******************************************************************************/ +en_result_t Wdt_Init(en_wdt_func_t enFunc, en_wdt_time_t enTime) +{ + en_result_t enRet = Error; + + Wdt_WriteWdtLoad(enTime); + M0P_WDT->CON_f.WINT_EN = enFunc; + enRet = Ok; + return enRet; +} +/** + ****************************************************************************** + ** \brief WDT澶嶄綅鍙婂惎鍔ㄥ嚱鏁 + ** + ** \param [in] 鏃 + ** + ** \retval 鏃 + ** + ******************************************************************************/ +void Wdt_Start(void) +{ + M0P_WDT->RST = 0x1E; + M0P_WDT->RST = 0xE1; +} + +/** + ****************************************************************************** + ** \brief WDT鍠傜嫍 + ** + ** \param [in] 鏃 + ** + ** \retval Ok + ** + ******************************************************************************/ +void Wdt_Feed(void) +{ + M0P_WDT->RST = 0x1E; + M0P_WDT->RST = 0xE1; +} + +/** + ****************************************************************************** + ** \brief WDT涓柇鏍囧織娓呴櫎 + ** + ** \param [in] 鏃 + ** + ** \retval Ok + ** + ******************************************************************************/ +void Wdt_IrqClr(void) +{ + M0P_WDT->RST = 0x1E; + M0P_WDT->RST = 0xE1; +} + +/** + ****************************************************************************** + ** \brief WDT璇诲彇褰撳墠璁℃暟鍊煎嚱鏁 + ** + ** \param [in] 鏃 + ** + ** \retval 璁℃暟鍊 + ** + ******************************************************************************/ +uint8_t Wdt_ReadWdtValue(void) +{ + uint8_t u8Count; + + u8Count = M0P_WDT->CON_f.WCNTL; + + return u8Count; +} +/** + ****************************************************************************** + ** \brief WDT璇诲彇褰撳墠杩愯鐘舵 + ** + ** \param [in] 鏃 + ** + ** \retval 鐘舵佸 + ** + ******************************************************************************/ +boolean_t Wdt_ReadwdtStatus(void) +{ + if(M0P_WDT->CON&0x10u) + { + return TRUE; + } + else + { + return FALSE; + } +} + +/** + ******************************************************************************* + ** \brief WDT 涓柇鐘舵佹爣璁拌幏鍙 + ** + ** + ** \retval 涓柇鐘舵 + ******************************************************************************/ +boolean_t Wdt_GetIrqStatus(void) +{ + if(M0P_WDT->CON&0x80u) + { + return TRUE; + } + else + { + return FALSE; + } +} + + +//@} // WdtGroup diff --git a/keilkill.bat b/keilkill.bat new file mode 100644 index 0000000..f7819f4 --- /dev/null +++ b/keilkill.bat @@ -0,0 +1,30 @@ +del *.bak /s +del *.ddk /s +del *.edk /s +del *.lst /s +del *.lnp /s +del *.mpf /s +del *.mpj /s +del *.obj /s +del *.omf /s +::del *.opt /s ::不允许删除JLINK的设置 +del *.plg /s +del *.rpt /s +del *.tmp /s +del *.__i /s +del *.crf /s +del *.o /s +del *.d /s +del *.axf /s +del *.tra /s +del *.dep /s +del JLinkLog.txt /s + +del *.iex /s +del *.htm /s +del *.sct /s +del *.map /s + +del *.dbgconf /s +del *.Administrator /s +exit diff --git a/mcu/EWARM/HC32L17X.svd b/mcu/EWARM/HC32L17X.svd new file mode 100644 index 0000000..85deab5 --- /dev/null +++ b/mcu/EWARM/HC32L17X.svd @@ -0,0 +1,37132 @@ + + + HDSC Co.Ltd + HDSC + HDSC_HC32L17X + ARMCM0P + 1.2 + + CM0 + r0p0 + little + false + false + 3 + false + + 8 + 32 + 32 + read-write + 0x0 + 0x0 + + + ADC + desc ADC + 0x40002400 + + 0x0 + 0xD0 + + + + CR0 + desc CR0 + 0x4 + 32 + read-write + 0x67F0 + 0xBFFF + + + EN + desc EN + 0 + 0 + read-write + + + CLKDIV + desc CLKDIV + 3 + 2 + read-write + + + SGLMUX + desc SGLMUX + 8 + 4 + read-write + + + REF + desc REF + 10 + 9 + read-write + + + BUF + desc BUF + 11 + 11 + read-write + + + SAM + desc SAM + 13 + 12 + read-write + + + INREFEN + desc INREFEN + 14 + 14 + read-write + + + IE + desc IE + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CR1 + desc CR1 + 0x8 + 32 + read-write + 0x8000 + 0xFFFC + + + ALIGN + desc ALIGN + 2 + 2 + read-write + + + THCH + desc THCH + 7 + 3 + read-write + + + DMASQR + desc DMASQR + 8 + 8 + read-write + + + DMAJQR + desc DMAJQR + 9 + 9 + read-write + + + MODE + desc MODE + 10 + 10 + read-write + + + RACCEN + desc RACCEN + 11 + 11 + read-write + + + LTCMP + desc LTCMP + 12 + 12 + read-write + + + HTCMP + desc HTCMP + 13 + 13 + read-write + + + REGCMP + desc REGCMP + 14 + 14 + read-write + + + RACCCLR + desc RACCCLR + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQR0 + desc SQR0 + 0x40 + 32 + read-write + 0x0 + 0x3FFFFFFF + + + CH0MUX + desc CH0MUX + 4 + 0 + read-write + + + CH1MUX + desc CH1MUX + 9 + 5 + read-write + + + CH2MUX + desc CH2MUX + 14 + 10 + read-write + + + CH3MUX + desc CH3MUX + 19 + 15 + read-write + + + CH4MUX + desc CH4MUX + 24 + 20 + read-write + + + CH5MUX + desc CH5MUX + 29 + 25 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQR1 + desc SQR1 + 0x44 + 32 + read-write + 0x0 + 0x3FFFFFFF + + + CH6MUX + desc CH6MUX + 4 + 0 + read-write + + + CH7MUX + desc CH7MUX + 9 + 5 + read-write + + + CH8MUX + desc CH8MUX + 14 + 10 + read-write + + + CH9MUX + desc CH9MUX + 19 + 15 + read-write + + + CH10MUX + desc CH10MUX + 24 + 20 + read-write + + + CH11MUX + desc CH11MUX + 29 + 25 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQR2 + desc SQR2 + 0x48 + 32 + read-write + 0x0 + 0xFFFFFFF + + + CH12MUX + desc CH12MUX + 4 + 0 + read-write + + + CH13MUX + desc CH13MUX + 9 + 5 + read-write + + + CH14MUX + desc CH14MUX + 14 + 10 + read-write + + + CH15MUX + desc CH15MUX + 19 + 15 + read-write + + + CNT + desc CNT + 23 + 20 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + JQR + desc JQR + 0x4C + 32 + read-write + 0x0 + 0x3FFFFFF + + + CH0MUX + desc CH0MUX + 4 + 0 + read-write + + + CH1MUX + desc CH1MUX + 9 + 5 + read-write + + + CH2MUX + desc CH2MUX + 14 + 10 + read-write + + + CH3MUX + desc CH3MUX + 19 + 15 + read-write + + + CNT + desc CNT + 21 + 20 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT0 + desc SQRRESULT0 + 0x50 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT1 + desc SQRRESULT1 + 0x54 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT2 + desc SQRRESULT2 + 0x58 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT3 + desc SQRRESULT3 + 0x5C + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT4 + desc SQRRESULT4 + 0x60 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT5 + desc SQRRESULT5 + 0x64 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT6 + desc SQRRESULT6 + 0x68 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT7 + desc SQRRESULT7 + 0x6C + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT8 + desc SQRRESULT8 + 0x70 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT9 + desc SQRRESULT9 + 0x74 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT10 + desc SQRRESULT10 + 0x78 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT11 + desc SQRRESULT11 + 0x7C + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT12 + desc SQRRESULT12 + 0x80 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQR_RESULT13 + desc SQR_RESULT13 + 0x84 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT14 + desc SQRRESULT14 + 0x88 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRRESULT15 + desc SQRRESULT15 + 0x8C + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + JQRRESULT0 + desc JQRRESULT0 + 0x90 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + JQRRESULT1 + desc JQRRESULT1 + 0x94 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + JQRRESULT2 + desc JQRRESULT2 + 0x98 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + JQRRESULT3 + desc JQRRESULT3 + 0x9C + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + RESULT + desc RESULT + 0xA0 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + RESULTACC + desc RESULTACC + 0xA4 + 32 + read-only + 0x0 + 0xFFFFF + + + RESULTACC + desc RESULTACC + 19 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + HT + desc HT + 0xA8 + 32 + read-write + 0xFFF + 0xFFF + + + HT + desc HT + 11 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + LT + desc LT + 0xAC + 32 + read-write + 0x0 + 0xFFF + + + LT + desc LT + 11 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0xB0 + 32 + read-only + 0x0 + 0x3F + + + SGLIF + desc SGLIF + 0 + 0 + read-only + + + LTIF + desc LTIF + 1 + 1 + read-only + + + HTIF + desc HTIF + 2 + 2 + read-only + + + REGIF + desc REGIF + 3 + 3 + read-only + + + SQRIF + desc SQRIF + 4 + 4 + read-only + + + JQRIF + desc JQRIF + 5 + 5 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICR + desc ICR + 0xB4 + 32 + write-only + 0x3F + 0x3F + + + SGLIC + desc SGLIC + 0 + 0 + write-only + + + LTIC + desc LTIC + 1 + 1 + write-only + + + HTIC + desc HTIC + 2 + 2 + write-only + + + REGIC + desc REGIC + 3 + 3 + write-only + + + SQRIC + desc SQRIC + 4 + 4 + write-only + + + JQRIC + desc JQRIC + 5 + 5 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + EXTTRIGGER0 + desc EXTTRIGGER0 + 0xB8 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + TIM0 + desc TIM0 + 0 + 0 + read-write + + + TIM1 + desc TIM1 + 1 + 1 + read-write + + + TIM2 + desc TIM2 + 2 + 2 + read-write + + + TIM3 + desc TIM3 + 3 + 3 + read-write + + + TIM4 + desc TIM4 + 4 + 4 + read-write + + + TIM5 + desc TIM5 + 5 + 5 + read-write + + + TIM6 + desc TIM6 + 6 + 6 + read-write + + + UART0 + desc UART0 + 7 + 7 + read-write + + + UART1 + desc UART1 + 8 + 8 + read-write + + + LPUART0 + desc LPUART0 + 9 + 9 + read-write + + + LPUART1 + desc LPUART1 + 10 + 10 + read-write + + + VC0 + desc VC0 + 11 + 11 + read-write + + + VC1 + desc VC1 + 12 + 12 + read-write + + + RTC + desc RTC + 13 + 13 + read-write + + + PCA + desc PCA + 14 + 14 + read-write + + + SPI0 + desc SPI0 + 15 + 15 + read-write + + + SPI1 + desc SPI1 + 16 + 16 + read-write + + + DMA + desc DMA + 17 + 17 + read-write + + + PA03 + desc PA03 + 18 + 18 + read-write + + + PB03 + desc PB03 + 19 + 19 + read-write + + + PC03 + desc PC03 + 20 + 20 + read-write + + + PD03 + desc PD03 + 21 + 21 + read-write + + + PA07 + desc PA07 + 22 + 22 + read-write + + + PB07 + desc PB07 + 23 + 23 + read-write + + + PC07 + desc PC07 + 24 + 24 + read-write + + + PD07 + desc PD07 + 25 + 25 + read-write + + + PA11 + desc PA11 + 26 + 26 + read-write + + + PB11 + desc PB11 + 27 + 27 + read-write + + + PC11 + desc PC11 + 28 + 28 + read-write + + + PA15 + desc PA15 + 29 + 29 + read-write + + + PB15 + desc PB15 + 30 + 30 + read-write + + + PC15 + desc PC15 + 31 + 31 + read-write + + + + + EXTTRIGGER1 + desc EXTTRIGGER1 + 0xBC + 32 + read-write + 0x0 + 0xFFFFFFFF + + + TIM0 + desc TIM0 + 0 + 0 + read-write + + + TIM1 + desc TIM1 + 1 + 1 + read-write + + + TIM2 + desc TIM2 + 2 + 2 + read-write + + + TIM3 + desc TIM3 + 3 + 3 + read-write + + + TIM4 + desc TIM4 + 4 + 4 + read-write + + + TIM5 + desc TIM5 + 5 + 5 + read-write + + + TIM6 + desc TIM6 + 6 + 6 + read-write + + + UART0 + desc UART0 + 7 + 7 + read-write + + + UART1 + desc UART1 + 8 + 8 + read-write + + + LPUART0 + desc LPUART0 + 9 + 9 + read-write + + + LPUART1 + desc LPUART1 + 10 + 10 + read-write + + + VC0 + desc VC0 + 11 + 11 + read-write + + + VC1 + desc VC1 + 12 + 12 + read-write + + + RTC + desc RTC + 13 + 13 + read-write + + + PCA + desc PCA + 14 + 14 + read-write + + + SPI0 + desc SPI0 + 15 + 15 + read-write + + + SPI1 + desc SPI1 + 16 + 16 + read-write + + + DMA + desc DMA + 17 + 17 + read-write + + + PA03 + desc PA03 + 18 + 18 + read-write + + + PB03 + desc PB03 + 19 + 19 + read-write + + + PC03 + desc PC03 + 20 + 20 + read-write + + + PD03 + desc PD03 + 21 + 21 + read-write + + + PA07 + desc PA07 + 22 + 22 + read-write + + + PB07 + desc PB07 + 23 + 23 + read-write + + + PC07 + desc PC07 + 24 + 24 + read-write + + + PD07 + desc PD07 + 25 + 25 + read-write + + + PA11 + desc PA11 + 26 + 26 + read-write + + + PB11 + desc PB11 + 27 + 27 + read-write + + + PC11 + desc PC11 + 28 + 28 + read-write + + + PA15 + desc PA15 + 29 + 29 + read-write + + + PB15 + desc PB15 + 30 + 30 + read-write + + + PC15 + desc PC15 + 31 + 31 + read-write + + + + + SGLSTART + desc SGLSTART + 0xC0 + 32 + read-write + 0x0 + 0x1 + + + START + desc START + 0 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SQRSTART + desc SQRSTART + 0xC4 + 32 + read-write + 0x0 + 0x1 + + + START + desc START + 0 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + JQRSTART + desc JQRSTART + 0xC8 + 32 + read-write + 0x0 + 0x1 + + + START + desc START + 0 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ALLSTART + desc ALLSTART + 0xCC + 32 + read-write + 0x0 + 0x1 + + + START + desc START + 0 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + ADTIM4 + desc ADTIM + 0x40003000 + + 0x0 + 0x400 + + + + CNTER + desc CNTER + 0x0 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PERAR + desc PERAR + 0x4 + 32 + read-write + 0xFFFF + 0xFFFF + + + PERA + desc PERA + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PERBR + desc PERBR + 0x8 + 32 + read-write + 0xFFFF + 0xFFFF + + + PERB + desc PERB + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + GCMAR + desc GCMAR + 0x10 + 32 + read-write + 0xFFFF + 0xFFFF + + + GCMA + desc GCMA + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + GCMBR + desc GCMBR + 0x14 + 32 + read-write + 0xFFFF + 0xFFFF + + + GCMB + desc GCMB + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + GCMCR + desc GCMCR + 0x18 + 32 + read-write + 0xFFFF + 0xFFFF + + + GCMC + desc GCMC + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + GCMDR + desc GCMDR + 0x1C + 32 + read-write + 0xFFFF + 0xFFFF + + + GCMD + desc GCMD + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SCMAR + desc SCMAR + 0x28 + 32 + read-write + 0xFFFF + 0xFFFF + + + SCMA + desc SCMA + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SCMBR + desc SCMBR + 0x2C + 32 + read-write + 0xFFFF + 0xFFFF + + + SCMB + desc SCMB + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DTUAR + desc DTUAR + 0x40 + 32 + read-write + 0xFFFF + 0xFFFF + + + DTUA + desc DTUA + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DTDAR + desc DTDAR + 0x44 + 32 + read-write + 0xFFFF + 0xFFFF + + + DTDA + desc DTDA + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + GCONR + desc GCONR + 0x50 + 32 + read-write + 0x100 + 0xF017F + + + START + desc START + 0 + 0 + read-write + + + MODE + desc MODE + 3 + 1 + read-write + + + CKDIV + desc CKDIV + 6 + 4 + read-write + + + DIR + desc DIR + 8 + 8 + read-write + + + ZMSKREV + desc ZMSKREV + 16 + 16 + read-write + + + ZMSKPOS + desc ZMSKPOS + 17 + 17 + read-write + + + ZMSK + desc ZMSK + 19 + 18 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICONR + desc ICONR + 0x54 + 32 + read-write + 0x0 + 0xFC1CF + + + INTENA + desc INTENA + 0 + 0 + read-write + + + INTENB + desc INTENB + 1 + 1 + read-write + + + INTENC + desc INTENC + 2 + 2 + read-write + + + INTEND + desc INTEND + 3 + 3 + read-write + + + INTENOVF + desc INTENOVF + 6 + 6 + read-write + + + INTENUDF + desc INTENUDF + 7 + 7 + read-write + + + INTENDE + desc INTENDE + 8 + 8 + read-write + + + INTENSAML + desc INTENSAML + 14 + 14 + read-write + + + INTENSAMH + desc INTENSAMH + 15 + 15 + read-write + + + INTENSAU + desc INTENSAU + 16 + 16 + read-write + + + INTENSAD + desc INTENSAD + 17 + 17 + read-write + + + INTENSBU + desc INTENSBU + 18 + 18 + read-write + + + INTENSBD + desc INTENSBD + 19 + 19 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCONR + desc PCONR + 0x58 + 32 + read-write + 0x0 + 0x1FFF1FFF + + + CAPCA + desc CAPCA + 0 + 0 + read-write + + + STACA + desc STACA + 1 + 1 + read-write + + + STPCA + desc STPCA + 2 + 2 + read-write + + + STASTPSA + desc STASTPSA + 3 + 3 + read-write + + + CMPCA + desc CMPCA + 5 + 4 + read-write + + + PERCA + desc PERCA + 7 + 6 + read-write + + + OUTENA + desc OUTENA + 8 + 8 + read-write + + + DISSELA + desc DISSELA + 10 + 9 + read-write + + + DISVALA + desc DISVALA + 12 + 11 + read-write + + + CAPCB + desc CAPCB + 16 + 16 + read-write + + + STACB + desc STACB + 17 + 17 + read-write + + + STPCB + desc STPCB + 18 + 18 + read-write + + + STASTPSB + desc STASTPSB + 19 + 19 + read-write + + + CMPCB + desc CMPCB + 21 + 20 + read-write + + + PERCB + desc PERCB + 23 + 22 + read-write + + + OUTENB + desc OUTENB + 24 + 24 + read-write + + + DISSELB + desc DISSELB + 26 + 25 + read-write + + + DISVALB + desc DISVALB + 28 + 27 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + BCONR + desc BCONR + 0x5C + 32 + read-write + 0x0 + 0x105 + + + BENA + desc BENA + 0 + 0 + read-write + + + BENB + desc BENB + 2 + 2 + read-write + + + BENP + desc BENP + 8 + 8 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DCONR + desc DCONR + 0x60 + 32 + read-write + 0x0 + 0x101 + + + DTCEN + desc DTCEN + 0 + 0 + read-write + + + SEPA + desc SEPA + 8 + 8 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + FCONR + desc FCONR + 0x68 + 32 + read-write + 0x0 + 0x77770077 + + + NOFIENGA + desc NOFIENGA + 0 + 0 + read-write + + + NOFICKGA + desc NOFICKGA + 2 + 1 + read-write + + + NOFIENGB + desc NOFIENGB + 4 + 4 + read-write + + + NOFICKGB + desc NOFICKGB + 6 + 5 + read-write + + + NOFIENTA + desc NOFIENTA + 16 + 16 + read-write + + + NOFICKTA + desc NOFICKTA + 18 + 17 + read-write + + + NOFIENTB + desc NOFIENTB + 20 + 20 + read-write + + + NOFICKTB + desc NOFICKTB + 22 + 21 + read-write + + + NOFIENTC + desc NOFIENTC + 24 + 24 + read-write + + + NOFICKTC + desc NOFICKTC + 26 + 25 + read-write + + + NOFIENTD + desc NOFIENTD + 28 + 28 + read-write + + + NOFICKTD + desc NOFICKTD + 30 + 29 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + VPERR + desc VPERR + 0x6C + 32 + read-write + 0x0 + 0x1F000F + + + GEPERIA + desc GEPERIA + 0 + 0 + read-write + + + GEPERIB + desc GEPERIB + 1 + 1 + read-write + + + GEPERIC + desc GEPERIC + 2 + 2 + read-write + + + GEPERID + desc GEPERID + 3 + 3 + read-write + + + PCNTE + desc PCNTE + 17 + 16 + read-write + + + PCNTS + desc PCNTS + 20 + 18 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + STFLR + desc STFLR + 0x70 + 32 + read-write + 0x0 + 0x80E01FCF + + + CMAF + desc CMAF + 0 + 0 + read-write + + + CMBF + desc CMBF + 1 + 1 + read-write + + + CMCF + desc CMCF + 2 + 2 + read-write + + + CMDF + desc CMDF + 3 + 3 + read-write + + + OVFF + desc OVFF + 6 + 6 + read-write + + + UDFF + desc UDFF + 7 + 7 + read-write + + + DTEF + desc DTEF + 8 + 8 + read-write + + + CMSAUF + desc CMSAUF + 9 + 9 + read-write + + + CMSADF + desc CMSADF + 10 + 10 + read-write + + + CMSBUF + desc CMSBUF + 11 + 11 + read-write + + + CMSBDF + desc CMSBDF + 12 + 12 + read-write + + + VPERNUM + desc VPERNUM + 23 + 21 + read-only + + + DIRF + desc DIRF + 31 + 31 + read-only + + + + + HSTAR + desc HSTAR + 0x74 + 32 + read-write + 0x0 + 0x8000FFFF + + + HSTA0 + desc HSTA0 + 0 + 0 + read-write + + + HSTA1 + desc HSTA1 + 1 + 1 + read-write + + + HSTA2 + desc HSTA2 + 2 + 2 + read-write + + + HSTA3 + desc HSTA3 + 3 + 3 + read-write + + + HSTA4 + desc HSTA4 + 4 + 4 + read-write + + + HSTA5 + desc HSTA5 + 5 + 5 + read-write + + + HSTA6 + desc HSTA6 + 6 + 6 + read-write + + + HSTA7 + desc HSTA7 + 7 + 7 + read-write + + + HSTA8 + desc HSTA8 + 8 + 8 + read-write + + + HSTA9 + desc HSTA9 + 9 + 9 + read-write + + + HSTA10 + desc HSTA10 + 10 + 10 + read-write + + + HSTA11 + desc HSTA11 + 11 + 11 + read-write + + + HSTA12 + desc HSTA12 + 12 + 12 + read-write + + + HSTA13 + desc HSTA13 + 13 + 13 + read-write + + + HSTA14 + desc HSTA14 + 14 + 14 + read-write + + + HSTA15 + desc HSTA15 + 15 + 15 + read-write + + + STARTS + desc STARTS + 31 + 31 + read-write + + + + + HSTPR + desc HSTPR + 0x78 + 32 + read-write + 0x0 + 0x8000FFFF + + + HSTP0 + desc HSTP0 + 0 + 0 + read-write + + + HSTP1 + desc HSTP1 + 1 + 1 + read-write + + + HSTP2 + desc HSTP2 + 2 + 2 + read-write + + + HSTP3 + desc HSTP3 + 3 + 3 + read-write + + + HSTP4 + desc HSTP4 + 4 + 4 + read-write + + + HSTP5 + desc HSTP5 + 5 + 5 + read-write + + + HSTP6 + desc HSTP6 + 6 + 6 + read-write + + + HSTP7 + desc HSTP7 + 7 + 7 + read-write + + + HSTP8 + desc HSTP8 + 8 + 8 + read-write + + + HSTP9 + desc HSTP9 + 9 + 9 + read-write + + + HSTP10 + desc HSTP10 + 10 + 10 + read-write + + + HSTP11 + desc HSTP11 + 11 + 11 + read-write + + + HSTP12 + desc HSTP12 + 12 + 12 + read-write + + + HSTP13 + desc HSTP13 + 13 + 13 + read-write + + + HSTP14 + desc HSTP14 + 14 + 14 + read-write + + + HSTP15 + desc HSTP15 + 15 + 15 + read-write + + + STOPS + desc STOPS + 31 + 31 + read-write + + + + + HCELR + desc HCELR + 0x7C + 32 + read-write + 0x0 + 0x8000FFFF + + + HCEL0 + desc HCEL0 + 0 + 0 + read-write + + + HCEL1 + desc HCEL1 + 1 + 1 + read-write + + + HCEL2 + desc HCEL2 + 2 + 2 + read-write + + + HCEL3 + desc HCEL3 + 3 + 3 + read-write + + + HCEL4 + desc HCEL4 + 4 + 4 + read-write + + + HCEL5 + desc HCEL5 + 5 + 5 + read-write + + + HCEL6 + desc HCEL6 + 6 + 6 + read-write + + + HCEL7 + desc HCEL7 + 7 + 7 + read-write + + + HCEL8 + desc HCEL8 + 8 + 8 + read-write + + + HCEL9 + desc HCEL9 + 9 + 9 + read-write + + + HCEL10 + desc HCEL10 + 10 + 10 + read-write + + + HCEL11 + desc HCEL11 + 11 + 11 + read-write + + + HCEL12 + desc HCEL12 + 12 + 12 + read-write + + + HCEL13 + desc HCEL13 + 13 + 13 + read-write + + + HCEL14 + desc HCEL14 + 14 + 14 + read-write + + + HCEL15 + desc HCEL15 + 15 + 15 + read-write + + + CLEARS + desc CLEARS + 31 + 31 + read-write + + + + + HCPAR + desc HCPAR + 0x80 + 32 + read-write + 0x0 + 0xFFFF + + + HCPA0 + desc HCPA0 + 0 + 0 + read-write + + + HCPA1 + desc HCPA1 + 1 + 1 + read-write + + + HCPA2 + desc HCPA2 + 2 + 2 + read-write + + + HCPA3 + desc HCPA3 + 3 + 3 + read-write + + + HCPA4 + desc HCPA4 + 4 + 4 + read-write + + + HCPA5 + desc HCPA5 + 5 + 5 + read-write + + + HCPA6 + desc HCPA6 + 6 + 6 + read-write + + + HCPA7 + desc HCPA7 + 7 + 7 + read-write + + + HCPA8 + desc HCPA8 + 8 + 8 + read-write + + + HCPA9 + desc HCPA9 + 9 + 9 + read-write + + + HCPA10 + desc HCPA10 + 10 + 10 + read-write + + + HCPA11 + desc HCPA11 + 11 + 11 + read-write + + + HCPA12 + desc HCPA12 + 12 + 12 + read-write + + + HCPA13 + desc HCPA13 + 13 + 13 + read-write + + + HCPA14 + desc HCPA14 + 14 + 14 + read-write + + + HCPA15 + desc HCPA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + HCPBR + desc HCPBR + 0x84 + 32 + read-write + 0x0 + 0xFFFF + + + HCPB0 + desc HCPB0 + 0 + 0 + read-write + + + HCPB1 + desc HCPB1 + 1 + 1 + read-write + + + HCPB2 + desc HCPB2 + 2 + 2 + read-write + + + HCPB3 + desc HCPB3 + 3 + 3 + read-write + + + HCPB4 + desc HCPB4 + 4 + 4 + read-write + + + HCPB5 + desc HCPB5 + 5 + 5 + read-write + + + HCPB6 + desc HCPB6 + 6 + 6 + read-write + + + HCPB7 + desc HCPB7 + 7 + 7 + read-write + + + HCPB8 + desc HCPB8 + 8 + 8 + read-write + + + HCPB9 + desc HCPB9 + 9 + 9 + read-write + + + HCPB10 + desc HCPB10 + 10 + 10 + read-write + + + HCPB11 + desc HCPB11 + 11 + 11 + read-write + + + HCPB12 + desc HCPB12 + 12 + 12 + read-write + + + HCPB13 + desc HCPB13 + 13 + 13 + read-write + + + HCPB14 + desc HCPB14 + 14 + 14 + read-write + + + HCPB15 + desc HCPB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + HCUPR + desc HCUPR + 0x88 + 32 + read-write + 0x0 + 0xFFFFF + + + HCUP0 + desc HCUP0 + 0 + 0 + read-write + + + HCUP1 + desc HCUP1 + 1 + 1 + read-write + + + HCUP2 + desc HCUP2 + 2 + 2 + read-write + + + HCUP3 + desc HCUP3 + 3 + 3 + read-write + + + HCUP4 + desc HCUP4 + 4 + 4 + read-write + + + HCUP5 + desc HCUP5 + 5 + 5 + read-write + + + HCUP6 + desc HCUP6 + 6 + 6 + read-write + + + HCUP7 + desc HCUP7 + 7 + 7 + read-write + + + HCUP8 + desc HCUP8 + 8 + 8 + read-write + + + HCUP9 + desc HCUP9 + 9 + 9 + read-write + + + HCUP10 + desc HCUP10 + 10 + 10 + read-write + + + HCUP11 + desc HCUP11 + 11 + 11 + read-write + + + HCUP12 + desc HCUP12 + 12 + 12 + read-write + + + HCUP13 + desc HCUP13 + 13 + 13 + read-write + + + HCUP14 + desc HCUP14 + 14 + 14 + read-write + + + HCUP15 + desc HCUP15 + 15 + 15 + read-write + + + HCUP16 + desc HCUP16 + 16 + 16 + read-write + + + HCUP17 + desc HCUP17 + 17 + 17 + read-write + + + HCUP18 + desc HCUP18 + 18 + 18 + read-write + + + HCUP19 + desc HCUP19 + 19 + 19 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + HCDOR + desc HCDOR + 0x8C + 32 + read-write + 0x0 + 0xFFFFF + + + HCDO0 + desc HCDO0 + 0 + 0 + read-write + + + HCDO1 + desc HCDO1 + 1 + 1 + read-write + + + HCDO2 + desc HCDO2 + 2 + 2 + read-write + + + HCDO3 + desc HCDO3 + 3 + 3 + read-write + + + HCDO4 + desc HCDO4 + 4 + 4 + read-write + + + HCDO5 + desc HCDO5 + 5 + 5 + read-write + + + HCDO6 + desc HCDO6 + 6 + 6 + read-write + + + HCDO7 + desc HCDO7 + 7 + 7 + read-write + + + HCDO8 + desc HCDO8 + 8 + 8 + read-write + + + HCDO9 + desc HCDO9 + 9 + 9 + read-write + + + HCDO10 + desc HCDO10 + 10 + 10 + read-write + + + HCDO11 + desc HCDO11 + 11 + 11 + read-write + + + HCDO12 + desc HCDO12 + 12 + 12 + read-write + + + HCDO13 + desc HCDO13 + 13 + 13 + read-write + + + HCDO14 + desc HCDO14 + 14 + 14 + read-write + + + HCDO15 + desc HCDO15 + 15 + 15 + read-write + + + HCDO16 + desc HCDO16 + 16 + 16 + read-write + + + HCDO17 + desc HCDO17 + 17 + 17 + read-write + + + HCDO18 + desc HCDO18 + 18 + 18 + read-write + + + HCDO19 + desc HCDO19 + 19 + 19 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x100 + 32 + read-only + 0x0 + 0xC1CF + + + CMAF + desc CMAF + 0 + 0 + read-only + + + CMBF + desc CMBF + 1 + 1 + read-only + + + CMCF + desc CMCF + 2 + 2 + read-only + + + CMDF + desc CMDF + 3 + 3 + read-only + + + OVFF + desc OVFF + 6 + 6 + read-only + + + UDFF + desc UDFF + 7 + 7 + read-only + + + DTEF + desc DTEF + 8 + 8 + read-only + + + SAMLF + desc SAMLF + 14 + 14 + read-only + + + SAMHF + desc SAMHF + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x104 + 32 + write-only + 0x0 + 0xC1CF + + + CMAC + desc CMAC + 0 + 0 + write-only + + + CMBC + desc CMBC + 1 + 1 + write-only + + + CMCC + desc CMCC + 2 + 2 + write-only + + + CMDC + desc CMDC + 3 + 3 + write-only + + + OVFC + desc OVFC + 6 + 6 + write-only + + + UDFC + desc UDFC + 7 + 7 + write-only + + + DTEC + desc DTEC + 8 + 8 + write-only + + + SAMLC + desc SAMLC + 14 + 14 + write-only + + + SAMHC + desc SAMHC + 15 + 15 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CR + desc CR + 0x108 + 32 + read-write + 0x300 + 0x79FFCF + + + CMAE + desc CMAE + 0 + 0 + read-write + + + CMBE + desc CMBE + 1 + 1 + read-write + + + CMCE + desc CMCE + 2 + 2 + read-write + + + CMDE + desc CMDE + 3 + 3 + read-write + + + OVFE + desc OVFE + 6 + 6 + read-write + + + UDFE + desc UDFE + 7 + 7 + read-write + + + DITENA + desc DITENA + 8 + 8 + read-write + + + DITENB + desc DITENB + 9 + 9 + read-write + + + DITENS + desc DITENS + 10 + 10 + read-write + + + CMSAE + desc CMSAE + 11 + 11 + read-write + + + CMSBE + desc CMSBE + 12 + 12 + read-write + + + DMA_G_CMA + desc DMA_G_CMA + 13 + 13 + read-write + + + DMA_G_CMB + desc DMA_G_CMB + 14 + 14 + read-write + + + DMA_G_CMC + desc DMA_G_CMC + 15 + 15 + read-write + + + DMA_G_CMD + desc DMA_G_CMD + 16 + 16 + read-write + + + DMA_G_OVF + desc DMA_G_OVF + 19 + 19 + read-write + + + DMA_G_UDF + desc DMA_G_UDF + 20 + 20 + read-write + + + DMA_S_CMA + desc DMA_S_CMA + 21 + 21 + read-write + + + DMA_S_CMB + desc DMA_S_CMB + 22 + 22 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + AOSSR + desc AOSSR + 0x110 + 32 + read-write + 0x0 + 0x3F9F + + + FBRAKE + desc FBRAKE + 0 + 0 + read-only + + + FSAME + desc FSAME + 1 + 1 + read-only + + + BFILTS + desc BFILTS + 3 + 2 + read-write + + + BFILTEN + desc BFILTEN + 4 + 4 + read-write + + + SOFTBK + desc SOFTBK + 7 + 7 + read-write + + + SML0 + desc SML0 + 8 + 8 + read-write + + + SML1 + desc SML1 + 9 + 9 + read-write + + + SML2 + desc SML2 + 10 + 10 + read-write + + + SMH0 + desc SMH0 + 11 + 11 + read-write + + + SMH1 + desc SMH1 + 12 + 12 + read-write + + + SMH2 + desc SMH2 + 13 + 13 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + AOSCL + desc AOSCL + 0x114 + 32 + write-only + 0x0 + 0x3 + + + FBRAKE + desc FBRAKE + 0 + 0 + write-only + + + FSAME + desc FSAME + 1 + 1 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PTBKS + desc PTBKS + 0x118 + 32 + read-write + 0x0 + 0xFFFF + + + EN0 + desc EN0 + 0 + 0 + read-write + + + EN1 + desc EN1 + 1 + 1 + read-write + + + EN2 + desc EN2 + 2 + 2 + read-write + + + EN3 + desc EN3 + 3 + 3 + read-write + + + EN4 + desc EN4 + 4 + 4 + read-write + + + EN5 + desc EN5 + 5 + 5 + read-write + + + EN6 + desc EN6 + 6 + 6 + read-write + + + EN7 + desc EN7 + 7 + 7 + read-write + + + EN8 + desc EN8 + 8 + 8 + read-write + + + EN9 + desc EN9 + 9 + 9 + read-write + + + EN10 + desc EN10 + 10 + 10 + read-write + + + EN11 + desc EN11 + 11 + 11 + read-write + + + EN12 + desc EN12 + 12 + 12 + read-write + + + EN13 + desc EN13 + 13 + 13 + read-write + + + EN14 + desc EN14 + 14 + 14 + read-write + + + EN15 + desc EN15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + TTRIG + desc TTRIG + 0x11C + 32 + read-write + 0x0 + 0xFFFF + + + TRIGAS + desc TRIGAS + 3 + 0 + read-write + + + TRIGBS + desc TRIGBS + 7 + 4 + read-write + + + TRIGCS + desc TRIGCS + 11 + 8 + read-write + + + TRIGDS + desc TRIGDS + 15 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ITRIG + desc ITRIG + 0x120 + 32 + read-write + 0x0 + 0xFFFF + + + IAOS0S + desc IAOS0S + 3 + 0 + read-write + + + IAOS1S + desc IAOS1S + 7 + 4 + read-write + + + IAOS2S + desc IAOS2S + 11 + 8 + read-write + + + IAOS3S + desc IAOS3S + 15 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PTBKP + desc PTBKP + 0x124 + 32 + read-write + 0x0 + 0xFFFF + + + POL0 + desc POL0 + 0 + 0 + read-write + + + POL1 + desc POL1 + 1 + 1 + read-write + + + POL2 + desc POL2 + 2 + 2 + read-write + + + POL3 + desc POL3 + 3 + 3 + read-write + + + POL4 + desc POL4 + 4 + 4 + read-write + + + POL5 + desc POL5 + 5 + 5 + read-write + + + POL6 + desc POL6 + 6 + 6 + read-write + + + POL7 + desc POL7 + 7 + 7 + read-write + + + POL8 + desc POL8 + 8 + 8 + read-write + + + POL9 + desc POL9 + 9 + 9 + read-write + + + POL10 + desc POL10 + 10 + 10 + read-write + + + POL11 + desc POL11 + 11 + 11 + read-write + + + POL12 + desc POL12 + 12 + 12 + read-write + + + POL13 + desc POL13 + 13 + 13 + read-write + + + POL14 + desc POL14 + 14 + 14 + read-write + + + POL15 + desc POL15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SSTAR + desc SSTAR + 0x3F4 + 32 + read-write + 0x0 + 0x7 + + + SSTA0 + desc SSTA0 + 0 + 0 + read-write + + + SSTA1 + desc SSTA1 + 1 + 1 + read-write + + + SSTA2 + desc SSTA2 + 2 + 2 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SSTPR + desc SSTPR + 0x3F8 + 32 + read-write + 0x0 + 0x7 + + + SSTP0 + desc SSTP0 + 0 + 0 + read-write + + + SSTP1 + desc SSTP1 + 1 + 1 + read-write + + + SSTP2 + desc SSTP2 + 2 + 2 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SCLRR + desc SCLRR + 0x3FC + 32 + read-write + 0x0 + 0x7 + + + SCLR0 + desc SCLR0 + 0 + 0 + read-write + + + SCLR1 + desc SCLR1 + 1 + 1 + read-write + + + SCLR2 + desc SCLR2 + 2 + 2 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + ADTIM5 + desc ADTIM + 0x40003400 + + 0x0 + 0x400 + + + + ADTIM6 + desc ADTIM + 0x40003800 + + 0x0 + 0x400 + + + + AES + desc AES + 0x40021400 + + 0x0 + 0x40 + + + + CR + desc CR + 0x0 + 32 + read-write + 0x0 + 0x3 + + + START + desc START + 0 + 0 + read-write + + + MODE + desc MODE + 1 + 1 + read-write + + + KEYSIZE + desc KEYSIZE + 4 + 3 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DATA0 + desc DATA0 + 0x10 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + DATA0 + desc DATA0 + 31 + 0 + read-write + + + + + DATA1 + desc DATA1 + 0x14 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + DATA0 + desc DATA0 + 31 + 0 + read-write + + + + + DATA2 + desc DATA2 + 0x18 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + DATA0 + desc DATA0 + 31 + 0 + read-write + + + + + DATA3 + desc DATA3 + 0x1C + 32 + read-write + 0x0 + 0xFFFFFFFF + + + DATA0 + desc DATA0 + 31 + 0 + read-write + + + + + KEY0 + desc KEY0 + 0x20 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + KEY0 + desc KEY0 + 31 + 0 + read-write + + + + + KEY1 + desc KEY1 + 0x24 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + KEY0 + desc KEY0 + 31 + 0 + read-write + + + + + KEY2 + desc KEY2 + 0x28 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + KEY0 + desc KEY0 + 31 + 0 + read-write + + + + + KEY3 + desc KEY3 + 0x2C + 32 + read-write + 0x0 + 0xFFFFFFFF + + + KEY0 + desc KEY0 + 31 + 0 + read-write + + + + + KEY4 + desc KEY4 + 0x30 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + KEY0 + desc KEY0 + 31 + 0 + read-write + + + + + KEY5 + desc KEY5 + 0x34 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + KEY0 + desc KEY0 + 31 + 0 + read-write + + + + + KEY6 + desc KEY6 + 0x38 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + KEY0 + desc KEY0 + 31 + 0 + read-write + + + + + KEY7 + desc KEY7 + 0x3C + 32 + read-write + 0x0 + 0xFFFFFFFF + + + KEY0 + desc KEY0 + 31 + 0 + read-write + + + + + + + BGR + desc BGR + 0x40002400 + ADC + + 0x0 + 0x4 + + + + CR + desc CR + 0x0 + 32 + read-write + 0x0 + 0x3 + + + BGR_EN + desc BGR_EN + 0 + 0 + read-write + + + TS_EN + desc TS_EN + 1 + 1 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + CLK_TRIM + desc CLK_TRIM + 0x40001800 + + 0x0 + 0x1C + + + + CR + desc CR + 0x0 + 32 + read-write + 0x0 + 0xFF + + + TRIM_START + desc TRIM_START + 0 + 0 + read-write + + + REFCLK_SEL + desc REFCLK_SEL + 3 + 1 + read-write + + + CALCLK_SEL + desc CALCLK_SEL + 5 + 4 + read-write + + + MON_EN + desc MON_EN + 6 + 6 + read-write + + + IE + desc IE + 7 + 7 + read-write + + + CALCLK_SEL2 + desc CALCLK_SEL2 + 8 + 8 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + REFCON + desc REFCON + 0x4 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + RCNTVAL + desc RCNTVAL + 31 + 0 + read-write + + + + + REFCNT + desc REFCNT + 0x8 + 32 + read-only + 0x0 + 0xFFFFFFFF + + + REFCNT + desc REFCNT + 31 + 0 + read-only + + + + + CALCNT + desc CALCNT + 0xC + 32 + read-only + 0x0 + 0xFFFFFFFF + + + CALCNT + desc CALCNT + 31 + 0 + read-only + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0xF + + + STOP + desc STOP + 0 + 0 + read-only + + + CALCNT_OF + desc CALCNT_OF + 1 + 1 + read-only + + + XTL_FAULT + desc XTL_FAULT + 2 + 2 + read-only + + + XTH_FAULT + desc XTH_FAULT + 3 + 3 + read-only + + + PLL_FAULT + desc PLL_FAULT + 4 + 4 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + ICLR + desc ICLR + 0x14 + 32 + read-write + 0xC + 0xC + + + XTL_FAULT_CLR + desc XTL_FAULT_CLR + 2 + 2 + read-write + + + XTH_FAULT_CLR + desc XTH_FAULT_CLR + 3 + 3 + read-write + + + PLL_FAULT_CLR + desc PLL_FAULT_CLR + 4 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CALCON + desc CALCON + 0x18 + 32 + read-write + 0xFFFFFFFF + 0xFFFFFFFF + + + CCNTVAL + desc CCNTVAL + 31 + 0 + read-write + + + + + + + CRC + desc CRC + 0x40020900 + + 0x0 + 0x100 + + + + CR + desc CR + 0x0 + 32 + read-write + 0x1 + 0x3 + + + CR + desc CR + 0 + 0 + read-write + + + FLAG + desc FLAG + 1 + 1 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + RESULT + desc RESULT + 0x4 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + RESULT + desc RESULT + 31 + 0 + read-write + + + + + DATA + desc DATA + 0x80 + 32 + write-only + 0x0 + 0xFFFFFFFF + + + DATA + desc DATA + 31 + 0 + write-only + + + + + + + DAC + desc DAC + 0x40002500 + + 0x0 + 0x3C + + + + CR0 + desc CR0 + 0x0 + 32 + read-write + 0xC000C000 + 0xFFFFFFFF + + + EN0 + desc EN0 + 0 + 0 + read-write + + + BOFF0 + desc BOFF0 + 1 + 1 + read-write + + + TEN0 + desc TEN0 + 2 + 2 + read-write + + + TSEL0 + desc TSEL0 + 5 + 3 + read-write + + + WAVE0 + desc WAVE0 + 7 + 6 + read-write + + + MAMP0 + desc MAMP0 + 11 + 8 + read-write + + + DMAEN0 + desc DMAEN0 + 12 + 12 + read-write + + + DMAUDRIE0 + desc DMAUDRIE0 + 13 + 13 + read-write + + + SREF0 + desc SREF0 + 15 + 14 + read-write + + + + + SWTRIGR + desc SWTRIGR + 0x4 + 32 + write-only + 0x0 + 0x3 + + + SWTRIG0 + desc SWTRIG0 + 0 + 0 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DHR12R0 + desc DHR12R0 + 0x8 + 32 + read-write + 0x0 + 0xFFF + + + DHR0 + desc DHR0 + 11 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DHR12L0 + desc DHR12L0 + 0xC + 32 + read-write + 0x0 + 0xFFF0 + + + DHR0 + desc DHR0 + 15 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DHR8R0 + desc DHR8R0 + 0x10 + 32 + read-write + 0x0 + 0xFF + + + DHR0 + desc DHR0 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DOR0 + desc DOR0 + 0x2C + 32 + read-only + 0x0 + 0xFFF + + + DOR0 + desc DOR0 + 11 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SR + desc SR + 0x34 + 32 + read-write + 0x4000 + 0x20002000 + + + DMAUDR0 + desc DMAUDR0 + 13 + 13 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ETRS + desc ETRS + 0x38 + 32 + read-write + 0x0 + 0x70 + + + PTRIGSEL + desc PTRIGSEL + 6 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + DEBUG_ACTIVE + desc DEBUG_ACTIVE + 0x40002038 + + 0x0 + 0x4 + + + + DEBUG_ACTIVE + desc DEBUG_ACTIVE + 0x0 + 32 + read-write + 0xFFF + 0xFFF + + + TIM0 + desc TIM0 + 0 + 0 + read-write + + + TIM1 + desc TIM1 + 1 + 1 + read-write + + + TIM2 + desc TIM2 + 2 + 2 + read-write + + + LPTIM0 + desc LPTIM0 + 3 + 3 + read-write + + + TIM4 + desc TIM4 + 4 + 4 + read-write + + + TIM5 + desc TIM5 + 5 + 5 + read-write + + + TIM6 + desc TIM6 + 6 + 6 + read-write + + + PCA + desc PCA + 7 + 7 + read-write + + + WDT + desc WDT + 8 + 8 + read-write + + + RTC + desc RTC + 9 + 9 + read-write + + + TIM3 + desc TIM3 + 11 + 11 + read-write + + + LPTIM1 + desc LPTIM1 + 12 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + DMAC + desc DMAC + 0x40021000 + + 0x0 + 0x30 + + + + CONF + desc CONF + 0x0 + 32 + read-write + 0x0 + 0xDF000000 + + + HALT + desc HALT + 27 + 24 + read-write + + + PRIO + desc PRIO + 28 + 28 + read-write + + + ST + desc ST + 30 + 30 + read-write + + + EN + desc EN + 31 + 31 + read-write + + + + + CONFA0 + desc CONFA0 + 0x10 + 32 + read-write + 0x0 + 0xFF8FFFFF + + + TC + desc TC + 15 + 0 + read-write + + + BC + desc BC + 19 + 16 + read-write + + + TRI_SEL + desc TRI_SEL + 28 + 22 + read-write + + + ST + desc ST + 29 + 29 + read-write + + + PAS + desc PAS + 30 + 30 + read-write + + + ENS + desc ENS + 31 + 31 + read-write + + + + + CONFB0 + desc CONFB0 + 0x14 + 32 + read-write + 0x0 + 0x3FFFFFF1 + + + MSK + desc MSK + 0 + 0 + read-write + + + STAT + desc STAT + 18 + 16 + read-write + + + FIS_IE + desc FIS_IE + 19 + 19 + read-write + + + ERR_IE + desc ERR_IE + 20 + 20 + read-write + + + RD + desc RD + 21 + 21 + read-write + + + RS + desc RS + 22 + 22 + read-write + + + RC + desc RC + 23 + 23 + read-write + + + FD + desc FD + 24 + 24 + read-write + + + FS + desc FS + 25 + 25 + read-write + + + WIDTH + desc WIDTH + 27 + 26 + read-write + + + MODE + desc MODE + 29 + 28 + read-write + + + + + SRCADR0 + desc SRCADR0 + 0x18 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + SRCADR + desc SRCADR + 31 + 0 + read-write + + + + + DSTADR0 + desc DSTADR0 + 0x1C + 32 + read-write + 0x0 + 0xFFFFFFFF + + + DSTADR + desc DSTADR + 31 + 0 + read-write + + + + + CONFA1 + desc CONFA1 + 0x20 + 32 + read-write + 0x0 + 0xFF8FFFFF + + + TC + desc TC + 15 + 0 + read-write + + + BC + desc BC + 19 + 16 + read-write + + + TRI_SEL + desc TRI_SEL + 28 + 22 + read-write + + + ST + desc ST + 29 + 29 + read-write + + + PAS + desc PAS + 30 + 30 + read-write + + + ENS + desc ENS + 31 + 31 + read-write + + + + + CONFB1 + desc CONFB1 + 0x24 + 32 + read-write + 0x0 + 0x3FFFFFF1 + + + MSK + desc MSK + 0 + 0 + read-write + + + STAT + desc STAT + 18 + 16 + read-write + + + FIS_IE + desc FIS_IE + 19 + 19 + read-write + + + ERR_IE + desc ERR_IE + 20 + 20 + read-write + + + RD + desc RD + 21 + 21 + read-write + + + RS + desc RS + 22 + 22 + read-write + + + RC + desc RC + 23 + 23 + read-write + + + FD + desc FD + 24 + 24 + read-write + + + FS + desc FS + 25 + 25 + read-write + + + WIDTH + desc WIDTH + 27 + 26 + read-write + + + MODE + desc MODE + 29 + 28 + read-write + + + + + SRCADR1 + desc SRCADR1 + 0x28 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + SRCADR + desc SRCADR + 31 + 0 + read-write + + + + + DSTADR1 + desc DSTADR1 + 0x2C + 32 + read-write + 0x0 + 0xFFFFFFFF + + + DSTADR + desc DSTADR + 31 + 0 + read-write + + + + + + + FLASH + desc FLASH + 0x40020000 + + 0x0 + 0x38 + + + + TNVS + desc TNVS + 0x0 + 32 + read-write + 0x20 + 0x1FF + + + TNVS + desc TNVS + 8 + 0 + read-write + + + RSV + desc RSV + 31 + 9 + read-write + + + + + TPGS + desc TPGS + 0x4 + 32 + read-write + 0x17 + 0xFF + + + TPGS + desc TPGS + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 8 + read-write + + + + + TPROG + desc TPROG + 0x8 + 32 + read-write + 0x1B + 0xFF + + + TPROG + desc TPROG + 8 + 0 + read-write + + + RSV + desc RSV + 31 + 9 + read-write + + + + + TSERASE + desc TSERASE + 0xC + 32 + read-write + 0x4650 + 0x3FFFF + + + TSERASE + desc TSERASE + 17 + 0 + read-write + + + RSV + desc RSV + 31 + 18 + read-write + + + + + TMERASE + desc TMERASE + 0x10 + 32 + read-write + 0x222E0 + 0x1FFFFF + + + TMERASE + desc TMERASE + 20 + 0 + read-write + + + RSV + desc RSV + 31 + 21 + read-write + + + + + TPRCV + desc TPRCV + 0x14 + 32 + read-write + 0x18 + 0xFFF + + + TPRCV + desc TPRCV + 11 + 0 + read-write + + + RSV + desc RSV + 31 + 12 + read-write + + + + + TSRCV + desc TSRCV + 0x18 + 32 + read-write + 0xF0 + 0xFFF + + + TSRCV + desc TSRCV + 11 + 0 + read-write + + + RSV + desc RSV + 31 + 12 + read-write + + + + + TMRCV + desc TMRCV + 0x1C + 32 + read-write + 0x3E8 + 0x1FFF + + + TMRCV + desc TMRCV + 13 + 0 + read-write + + + RSV + desc RSV + 31 + 14 + read-write + + + + + CR + desc CR + 0x20 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + OP + desc OP + 1 + 0 + read-write + + + WAIT + desc WAIT + 3 + 2 + read-write + + + BUSY + desc BUSY + 4 + 4 + read-only + + + IE + desc IE + 6 + 5 + read-write + + + DPSTB_EN + desc DPSTB_EN + 9 + 9 + read-write + + + RSV + desc RSV + 31 + 10 + read-write + + + + + IFR + desc IFR + 0x24 + 32 + read-only + 0x0 + 0x3 + + + IF0 + desc IF0 + 0 + 0 + read-only + + + IF1 + desc IF1 + 1 + 1 + read-only + + + RSV + desc RSV + 31 + 2 + read-write + + + + + ICLR + desc ICLR + 0x28 + 32 + write-only + 0x3 + 0xFFFFFFFF + + + ICLR0 + desc ICLR0 + 0 + 0 + write-only + + + ICLR1 + desc ICLR1 + 1 + 1 + write-only + + + RSV + desc RSV + 31 + 2 + read-write + + + + + BYPASS + desc BYPASS + 0x2C + 32 + write-only + 0x0 + 0xFFFF + + + BYSEQ + desc BYSEQ + 15 + 0 + write-only + + + RSV + desc RSV + 31 + 16 + read-write + + + + + SLOCK0 + desc SLOCK0 + 0x30 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + SLOCK + desc SLOCK + 31 + 0 + read-write + + + + + SLOCK1 + desc SLOCK1 + 0x34 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + SLOCK + desc SLOCK + 31 + 0 + read-write + + + + + + + GPIO + desc GPIO + 0x40020C00 + + 0x0 + 0x1250 + + + + PA00_SEL + desc PA00_SEL + 0x0 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA01_SEL + desc PA01_SEL + 0x4 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA02_SEL + desc PA02_SEL + 0x8 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA03_SEL + desc PA03_SEL + 0xC + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA04_SEL + desc PA04_SEL + 0x10 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA05_SEL + desc PA05_SEL + 0x14 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA06_SEL + desc PA06_SEL + 0x18 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA07_SEL + desc PA07_SEL + 0x1C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA08_SEL + desc PA08_SEL + 0x20 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA09_SEL + desc PA09_SEL + 0x24 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA10_SEL + desc PA10_SEL + 0x28 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA11_SEL + desc PA11_SEL + 0x2C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA12_SEL + desc PA12_SEL + 0x30 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA13_SEL + desc PA13_SEL + 0x34 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA14_SEL + desc PA14_SEL + 0x38 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA15_SEL + desc PA15_SEL + 0x3C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB00_SEL + desc PB00_SEL + 0x40 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB01_SEL + desc PB01_SEL + 0x44 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB02_SEL + desc PB02_SEL + 0x48 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB03_SEL + desc PB03_SEL + 0x4C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB04_SEL + desc PB04_SEL + 0x50 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB05_SEL + desc PB05_SEL + 0x54 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB06_SEL + desc PB06_SEL + 0x58 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB07_SEL + desc PB07_SEL + 0x5C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB08_SEL + desc PB08_SEL + 0x60 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB09_SEL + desc PB09_SEL + 0x64 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB10_SEL + desc PB10_SEL + 0x68 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB11_SEL + desc PB11_SEL + 0x6C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB12_SEL + desc PB12_SEL + 0x70 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB13_SEL + desc PB13_SEL + 0x74 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB14_SEL + desc PB14_SEL + 0x78 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB15_SEL + desc PB15_SEL + 0x7C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC00_SEL + desc PC00_SEL + 0x80 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC01_SEL + desc PC01_SEL + 0x84 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC02_SEL + desc PC02_SEL + 0x88 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC03_SEL + desc PC03_SEL + 0x8C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC04_SEL + desc PC04_SEL + 0x90 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC05_SEL + desc PC05_SEL + 0x94 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC06_SEL + desc PC06_SEL + 0x98 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC07_SEL + desc PC07_SEL + 0x9C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC08_SEL + desc PC08_SEL + 0xA0 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC09_SEL + desc PC09_SEL + 0xA4 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC10_SEL + desc PC10_SEL + 0xA8 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC11_SEL + desc PC11_SEL + 0xAC + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC12_SEL + desc PC12_SEL + 0xB0 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC13_SEL + desc PC13_SEL + 0xB4 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC14_SEL + desc PC14_SEL + 0xB8 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC15_SEL + desc PC15_SEL + 0xBC + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD00_SEL + desc PD00_SEL + 0xC0 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD01_SEL + desc PD01_SEL + 0xC4 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD02_SEL + desc PD02_SEL + 0xC8 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD03_SEL + desc PD03_SEL + 0xCC + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD04_SEL + desc PD04_SEL + 0xD0 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD05_SEL + desc PD05_SEL + 0xD4 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD06_SEL + desc PD06_SEL + 0xD8 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD07_SEL + desc PD07_SEL + 0xDC + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD08_SEL + desc PD08_SEL + 0xE0 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD09_SEL + desc PD09_SEL + 0xE4 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD10_SEL + desc PD10_SEL + 0xE8 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD11_SEL + desc PD11_SEL + 0xEC + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD12_SEL + desc PD12_SEL + 0xF0 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD13_SEL + desc PD13_SEL + 0xF4 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD14_SEL + desc PD14_SEL + 0xF8 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD15_SEL + desc PD15_SEL + 0xFC + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PADIR + desc PADIR + 0x100 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PAIN + desc PAIN + 0x104 + 32 + read-only + 0x0 + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-only + + + PA01 + desc PA01 + 1 + 1 + read-only + + + PA02 + desc PA02 + 2 + 2 + read-only + + + PA03 + desc PA03 + 3 + 3 + read-only + + + PA04 + desc PA04 + 4 + 4 + read-only + + + PA05 + desc PA05 + 5 + 5 + read-only + + + PA06 + desc PA06 + 6 + 6 + read-only + + + PA07 + desc PA07 + 7 + 7 + read-only + + + PA08 + desc PA08 + 8 + 8 + read-only + + + PA09 + desc PA09 + 9 + 9 + read-only + + + PA10 + desc PA10 + 10 + 10 + read-only + + + PA11 + desc PA11 + 11 + 11 + read-only + + + PA12 + desc PA12 + 12 + 12 + read-only + + + PA13 + desc PA13 + 13 + 13 + read-only + + + PA14 + desc PA14 + 14 + 14 + read-only + + + PA15 + desc PA15 + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + PAOUT + desc PAOUT + 0x108 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PAADS + desc PAADS + 0x10C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PABSET + desc PABSET + 0x110 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PABCLR + desc PABCLR + 0x114 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PABSETCLR + desc PABSETCLR + 0x118 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + PABCLR + desc PABCLR + 15 + 0 + read-write + + + PABSET + desc PABSET + 31 + 16 + read-write + + + + + PADR + desc PADR + 0x11C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PAPU + desc PAPU + 0x120 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PAPD + desc PAPD + 0x124 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PAOD + desc PAOD + 0x12C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PAHIE + desc PAHIE + 0x130 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PALIE + desc PALIE + 0x134 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PARIE + desc PARIE + 0x138 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PAFIE + desc PAFIE + 0x13C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PBDIR + desc PBDIR + 0x140 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PBIN + desc PBIN + 0x144 + 32 + read-only + 0x0 + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-only + + + PB01 + desc PB01 + 1 + 1 + read-only + + + PB02 + desc PB02 + 2 + 2 + read-only + + + PB03 + desc PB03 + 3 + 3 + read-only + + + PB04 + desc PB04 + 4 + 4 + read-only + + + PB05 + desc PB05 + 5 + 5 + read-only + + + PB06 + desc PB06 + 6 + 6 + read-only + + + PB07 + desc PB07 + 7 + 7 + read-only + + + PB08 + desc PB08 + 8 + 8 + read-only + + + PB09 + desc PB09 + 9 + 9 + read-only + + + PB10 + desc PB10 + 10 + 10 + read-only + + + PB11 + desc PB11 + 11 + 11 + read-only + + + PB12 + desc PB12 + 12 + 12 + read-only + + + PB13 + desc PB13 + 13 + 13 + read-only + + + PB14 + desc PB14 + 14 + 14 + read-only + + + PB15 + desc PB15 + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + PBOUT + desc PBOUT + 0x148 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PBADS + desc PBADS + 0x14C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PBBSET + desc PBBSET + 0x150 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PBBCLR + desc PBBCLR + 0x154 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PBBSETCLR + desc PBBSETCLR + 0x158 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + PBBCLR + desc PBBCLR + 15 + 0 + read-write + + + PBBSET + desc PBBSET + 31 + 16 + read-write + + + + + PBDR + desc PBDR + 0x15C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PBPU + desc PBPU + 0x160 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PBPD + desc PBPD + 0x164 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PBOD + desc PBOD + 0x16C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PBHIE + desc PBHIE + 0x170 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PBLIE + desc PBLIE + 0x174 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PBRIE + desc PBRIE + 0x178 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PBFIE + desc PBFIE + 0x17C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCDIR + desc PCDIR + 0x180 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCIN + desc PCIN + 0x184 + 32 + read-only + 0x0 + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-only + + + PC01 + desc PC01 + 1 + 1 + read-only + + + PC02 + desc PC02 + 2 + 2 + read-only + + + PC03 + desc PC03 + 3 + 3 + read-only + + + PC04 + desc PC04 + 4 + 4 + read-only + + + PC05 + desc PC05 + 5 + 5 + read-only + + + PC06 + desc PC06 + 6 + 6 + read-only + + + PC07 + desc PC07 + 7 + 7 + read-only + + + PC08 + desc PC08 + 8 + 8 + read-only + + + PC09 + desc PC09 + 9 + 9 + read-only + + + PC10 + desc PC10 + 10 + 10 + read-only + + + PC11 + desc PC11 + 11 + 11 + read-only + + + PC12 + desc PC12 + 12 + 12 + read-only + + + PC13 + desc PC13 + 13 + 13 + read-only + + + PC14 + desc PC14 + 14 + 14 + read-only + + + PC15 + desc PC15 + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + PCOUT + desc PCOUT + 0x188 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCADS + desc PCADS + 0x18C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCBSET + desc PCBSET + 0x190 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCBCLR + desc PCBCLR + 0x194 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCBSETCLR + desc PCBSETCLR + 0x198 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + PCBCLR + desc PCBCLR + 15 + 0 + read-write + + + PCBSET + desc PCBSET + 31 + 16 + read-write + + + + + PCDR + desc PCDR + 0x19C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCPU + desc PCPU + 0x1A0 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCPD + desc PCPD + 0x1A4 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCOD + desc PCOD + 0x1AC + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCHIE + desc PCHIE + 0x1B0 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCLIE + desc PCLIE + 0x1B4 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCRIE + desc PCRIE + 0x1B8 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCFIE + desc PCFIE + 0x1BC + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PDDIR + desc PDDIR + 0x1C0 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PDIN + desc PDIN + 0x1C4 + 32 + read-only + 0x0 + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-only + + + PD01 + desc PD01 + 1 + 1 + read-only + + + PD02 + desc PD02 + 2 + 2 + read-only + + + PD03 + desc PD03 + 3 + 3 + read-only + + + PD04 + desc PD04 + 4 + 4 + read-only + + + PD05 + desc PD05 + 5 + 5 + read-only + + + PD06 + desc PD06 + 6 + 6 + read-only + + + PD07 + desc PD07 + 7 + 7 + read-only + + + PD08 + desc PD08 + 8 + 8 + read-only + + + PD09 + desc PD09 + 9 + 9 + read-only + + + PD10 + desc PD10 + 10 + 10 + read-only + + + PD11 + desc PD11 + 11 + 11 + read-only + + + PD12 + desc PD12 + 12 + 12 + read-only + + + PD13 + desc PD13 + 13 + 13 + read-only + + + PD14 + desc PD14 + 14 + 14 + read-only + + + PD15 + desc PD15 + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + PDOUT + desc PDOUT + 0x1C8 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PDADS + desc PDADS + 0x1CC + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PDBSET + desc PDBSET + 0x1D0 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PDBCLR + desc PDBCLR + 0x1D4 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PDBSETCLR + desc PDBSETCLR + 0x1D8 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + PDBCLR + desc PDBCLR + 15 + 0 + read-write + + + PDBSET + desc PDBSET + 31 + 16 + read-write + + + + + PDDR + desc PDDR + 0x1DC + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PDPU + desc PDPU + 0x1E0 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PDPD + desc PDPD + 0x1E4 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PDOD + desc PDOD + 0x1EC + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PDHIE + desc PDHIE + 0x1F0 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PDLIE + desc PDLIE + 0x1F4 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PDRIE + desc PDRIE + 0x1F8 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PDFIE + desc PDFIE + 0x1FC + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PA_STAT + desc PA_STAT + 0x200 + 32 + read-only + 0x0 + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-only + + + PA01 + desc PA01 + 1 + 1 + read-only + + + PA02 + desc PA02 + 2 + 2 + read-only + + + PA03 + desc PA03 + 3 + 3 + read-only + + + PA04 + desc PA04 + 4 + 4 + read-only + + + PA05 + desc PA05 + 5 + 5 + read-only + + + PA06 + desc PA06 + 6 + 6 + read-only + + + PA07 + desc PA07 + 7 + 7 + read-only + + + PA08 + desc PA08 + 8 + 8 + read-only + + + PA09 + desc PA09 + 9 + 9 + read-only + + + PA10 + desc PA10 + 10 + 10 + read-only + + + PA11 + desc PA11 + 11 + 11 + read-only + + + PA12 + desc PA12 + 12 + 12 + read-only + + + PA13 + desc PA13 + 13 + 13 + read-only + + + PA14 + desc PA14 + 14 + 14 + read-only + + + PA15 + desc PA15 + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + PA_ICLR + desc PA_ICLR + 0x210 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PA00 + desc PA00 + 0 + 0 + read-write + + + PA01 + desc PA01 + 1 + 1 + read-write + + + PA02 + desc PA02 + 2 + 2 + read-write + + + PA03 + desc PA03 + 3 + 3 + read-write + + + PA04 + desc PA04 + 4 + 4 + read-write + + + PA05 + desc PA05 + 5 + 5 + read-write + + + PA06 + desc PA06 + 6 + 6 + read-write + + + PA07 + desc PA07 + 7 + 7 + read-write + + + PA08 + desc PA08 + 8 + 8 + read-write + + + PA09 + desc PA09 + 9 + 9 + read-write + + + PA10 + desc PA10 + 10 + 10 + read-write + + + PA11 + desc PA11 + 11 + 11 + read-write + + + PA12 + desc PA12 + 12 + 12 + read-write + + + PA13 + desc PA13 + 13 + 13 + read-write + + + PA14 + desc PA14 + 14 + 14 + read-write + + + PA15 + desc PA15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PB_STAT + desc PB_STAT + 0x240 + 32 + read-only + 0x0 + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-only + + + PB01 + desc PB01 + 1 + 1 + read-only + + + PB02 + desc PB02 + 2 + 2 + read-only + + + PB03 + desc PB03 + 3 + 3 + read-only + + + PB04 + desc PB04 + 4 + 4 + read-only + + + PB05 + desc PB05 + 5 + 5 + read-only + + + PB06 + desc PB06 + 6 + 6 + read-only + + + PB07 + desc PB07 + 7 + 7 + read-only + + + PB08 + desc PB08 + 8 + 8 + read-only + + + PB09 + desc PB09 + 9 + 9 + read-only + + + PB10 + desc PB10 + 10 + 10 + read-only + + + PB11 + desc PB11 + 11 + 11 + read-only + + + PB12 + desc PB12 + 12 + 12 + read-only + + + PB13 + desc PB13 + 13 + 13 + read-only + + + PB14 + desc PB14 + 14 + 14 + read-only + + + PB15 + desc PB15 + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + PB_ICLR + desc PB_ICLR + 0x250 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PB00 + desc PB00 + 0 + 0 + read-write + + + PB01 + desc PB01 + 1 + 1 + read-write + + + PB02 + desc PB02 + 2 + 2 + read-write + + + PB03 + desc PB03 + 3 + 3 + read-write + + + PB04 + desc PB04 + 4 + 4 + read-write + + + PB05 + desc PB05 + 5 + 5 + read-write + + + PB06 + desc PB06 + 6 + 6 + read-write + + + PB07 + desc PB07 + 7 + 7 + read-write + + + PB08 + desc PB08 + 8 + 8 + read-write + + + PB09 + desc PB09 + 9 + 9 + read-write + + + PB10 + desc PB10 + 10 + 10 + read-write + + + PB11 + desc PB11 + 11 + 11 + read-write + + + PB12 + desc PB12 + 12 + 12 + read-write + + + PB13 + desc PB13 + 13 + 13 + read-write + + + PB14 + desc PB14 + 14 + 14 + read-write + + + PB15 + desc PB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PC_STAT + desc PC_STAT + 0x280 + 32 + read-only + 0x0 + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-only + + + PC01 + desc PC01 + 1 + 1 + read-only + + + PC02 + desc PC02 + 2 + 2 + read-only + + + PC03 + desc PC03 + 3 + 3 + read-only + + + PC04 + desc PC04 + 4 + 4 + read-only + + + PC05 + desc PC05 + 5 + 5 + read-only + + + PC06 + desc PC06 + 6 + 6 + read-only + + + PC07 + desc PC07 + 7 + 7 + read-only + + + PC08 + desc PC08 + 8 + 8 + read-only + + + PC09 + desc PC09 + 9 + 9 + read-only + + + PC10 + desc PC10 + 10 + 10 + read-only + + + PC11 + desc PC11 + 11 + 11 + read-only + + + PC12 + desc PC12 + 12 + 12 + read-only + + + PC13 + desc PC13 + 13 + 13 + read-only + + + PC14 + desc PC14 + 14 + 14 + read-only + + + PC15 + desc PC15 + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + PC_ICLR + desc PC_ICLR + 0x290 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PC00 + desc PC00 + 0 + 0 + read-write + + + PC01 + desc PC01 + 1 + 1 + read-write + + + PC02 + desc PC02 + 2 + 2 + read-write + + + PC03 + desc PC03 + 3 + 3 + read-write + + + PC04 + desc PC04 + 4 + 4 + read-write + + + PC05 + desc PC05 + 5 + 5 + read-write + + + PC06 + desc PC06 + 6 + 6 + read-write + + + PC07 + desc PC07 + 7 + 7 + read-write + + + PC08 + desc PC08 + 8 + 8 + read-write + + + PC09 + desc PC09 + 9 + 9 + read-write + + + PC10 + desc PC10 + 10 + 10 + read-write + + + PC11 + desc PC11 + 11 + 11 + read-write + + + PC12 + desc PC12 + 12 + 12 + read-write + + + PC13 + desc PC13 + 13 + 13 + read-write + + + PC14 + desc PC14 + 14 + 14 + read-write + + + PC15 + desc PC15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PD_STAT + desc PD_STAT + 0x2C0 + 32 + read-only + 0x0 + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-only + + + PD01 + desc PD01 + 1 + 1 + read-only + + + PD02 + desc PD02 + 2 + 2 + read-only + + + PD03 + desc PD03 + 3 + 3 + read-only + + + PD04 + desc PD04 + 4 + 4 + read-only + + + PD05 + desc PD05 + 5 + 5 + read-only + + + PD06 + desc PD06 + 6 + 6 + read-only + + + PD07 + desc PD07 + 7 + 7 + read-only + + + PD08 + desc PD08 + 8 + 8 + read-only + + + PD09 + desc PD09 + 9 + 9 + read-only + + + PD10 + desc PD10 + 10 + 10 + read-only + + + PD11 + desc PD11 + 11 + 11 + read-only + + + PD12 + desc PD12 + 12 + 12 + read-only + + + PD13 + desc PD13 + 13 + 13 + read-only + + + PD14 + desc PD14 + 14 + 14 + read-only + + + PD15 + desc PD15 + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + PD_ICLR + desc PD_ICLR + 0x2D0 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PD00 + desc PD00 + 0 + 0 + read-write + + + PD01 + desc PD01 + 1 + 1 + read-write + + + PD02 + desc PD02 + 2 + 2 + read-write + + + PD03 + desc PD03 + 3 + 3 + read-write + + + PD04 + desc PD04 + 4 + 4 + read-write + + + PD05 + desc PD05 + 5 + 5 + read-write + + + PD06 + desc PD06 + 6 + 6 + read-write + + + PD07 + desc PD07 + 7 + 7 + read-write + + + PD08 + desc PD08 + 8 + 8 + read-write + + + PD09 + desc PD09 + 9 + 9 + read-write + + + PD10 + desc PD10 + 10 + 10 + read-write + + + PD11 + desc PD11 + 11 + 11 + read-write + + + PD12 + desc PD12 + 12 + 12 + read-write + + + PD13 + desc PD13 + 13 + 13 + read-write + + + PD14 + desc PD14 + 14 + 14 + read-write + + + PD15 + desc PD15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CTRL0 + desc CTRL0 + 0x300 + 32 + read-write + 0x1 + 0x1 + + + IESEL + desc IESEL + 0 + 0 + read-write + + + + + CTRL1 + desc CTRL1 + 0x304 + 32 + read-write + 0x0 + 0xFFFF + + + EXT_CLK_SEL + desc EXT_CLK_SEL + 3 + 0 + read-write + + + SSN0_SEL + desc SSN0_SEL + 7 + 4 + read-write + + + PCLK_SEL + desc PCLK_SEL + 9 + 8 + read-write + + + HCLK_SEL + desc HCLK_SEL + 11 + 10 + read-write + + + PCLK_EN + desc PCLK_EN + 12 + 12 + read-write + + + HCLK_EN + desc HCLK_EN + 13 + 13 + read-write + + + IR_POL + desc IR_POL + 14 + 14 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CTRL2 + desc CTRL2 + 0x308 + 32 + read-write + 0x0 + 0xFFFF + + + SSN1_SEL + desc SSN1_SEL + 3 + 0 + read-write + + + TCLK_SEL + desc TCLK_SEL + 5 + 4 + read-write + + + TCLK_DIV + desc TCLK_DIV + 7 + 6 + read-write + + + AHB_SEL + desc AHB_SEL + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + TIMGS + desc TIMGS + 0x30C + 32 + read-write + 0x0 + 0xFFFF + + + TIM0_G + desc TIM0_G + 2 + 0 + read-write + + + TIM1_G + desc TIM1_G + 5 + 3 + read-write + + + TIM2_G + desc TIM2_G + 8 + 6 + read-write + + + TIM3_G + desc TIM3_G + 11 + 9 + read-write + + + LPTIM0_G + desc LPTIM0_G + 14 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + TIMES + desc TIMES + 0x310 + 32 + read-write + 0x0 + 0xFFFF + + + TIM0_E + desc TIM0_E + 2 + 0 + read-write + + + TIM1_E + desc TIM1_E + 5 + 3 + read-write + + + TIM2_E + desc TIM2_E + 8 + 6 + read-write + + + TIM3_E + desc TIM3_E + 11 + 9 + read-write + + + LPTIM0_E + desc LPTIM0_E + 14 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + TIMCPS + desc TIMCPS + 0x314 + 32 + read-write + 0x0 + 0xFFFF + + + TIM0_CA + desc TIM0_CA + 2 + 0 + read-write + + + TIM1_CA + desc TIM1_CA + 5 + 3 + read-write + + + TIM2_CA + desc TIM2_CA + 8 + 6 + read-write + + + TIM3_CA + desc TIM3_CA + 11 + 9 + read-write + + + TIM3_CB + desc TIM3_CB + 14 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCAS + desc PCAS + 0x318 + 32 + read-write + 0x0 + 0xFFF + + + PCA_CH0 + desc PCA_CH0 + 2 + 0 + read-write + + + PCA_ECI + desc PCA_ECI + 5 + 3 + read-write + + + LPTIM1_G + desc LPTIM1_G + 8 + 6 + read-write + + + LPTIM1_E + desc LPTIM1_E + 11 + 9 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCNT + desc PCNT + 0x31C + 32 + read-write + 0x0 + 0xF + + + PCNT_S0 + desc PCNT_S0 + 1 + 0 + read-write + + + PCNT_S1 + desc PCNT_S1 + 3 + 2 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE00_SEL + desc PE00_SEL + 0x1000 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE01_SEL + desc PE01_SEL + 0x1004 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE02_SEL + desc PE02_SEL + 0x1008 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE03_SEL + desc PE03_SEL + 0x100C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE04_SEL + desc PE04_SEL + 0x1010 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE05_SEL + desc PE05_SEL + 0x1014 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE06_SEL + desc PE06_SEL + 0x1018 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE07_SEL + desc PE07_SEL + 0x101C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE08_SEL + desc PE08_SEL + 0x1020 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE09_SEL + desc PE09_SEL + 0x1024 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE10_SEL + desc PE10_SEL + 0x1028 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE11_SEL + desc PE11_SEL + 0x102C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE12_SEL + desc PE12_SEL + 0x1030 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE13_SEL + desc PE13_SEL + 0x1034 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE14_SEL + desc PE14_SEL + 0x1038 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE15_SEL + desc PE15_SEL + 0x103C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PF00_SEL + desc PF00_SEL + 0x1040 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PF01_SEL + desc PF01_SEL + 0x1044 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PF02_SEL + desc PF02_SEL + 0x1048 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PF03_SEL + desc PF03_SEL + 0x104C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PF04_SEL + desc PF04_SEL + 0x1050 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PF05_SEL + desc PF05_SEL + 0x1054 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PF06_SEL + desc PF06_SEL + 0x1058 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PF07_SEL + desc PF07_SEL + 0x105C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PF08_SEL + desc PF08_SEL + 0x1060 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PF09_SEL + desc PF09_SEL + 0x1064 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PF10_SEL + desc PF10_SEL + 0x1068 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PF11_SEL + desc PF11_SEL + 0x106C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PEDIR + desc PEDIR + 0x1100 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PEIN + desc PEIN + 0x1104 + 32 + read-only + 0x0 + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-only + + + PE01 + desc PE01 + 1 + 1 + read-only + + + PE02 + desc PE02 + 2 + 2 + read-only + + + PE03 + desc PE03 + 3 + 3 + read-only + + + PE04 + desc PE04 + 4 + 4 + read-only + + + PE05 + desc PE05 + 5 + 5 + read-only + + + PE06 + desc PE06 + 6 + 6 + read-only + + + PE07 + desc PE07 + 7 + 7 + read-only + + + PE08 + desc PE08 + 8 + 8 + read-only + + + PE09 + desc PE09 + 9 + 9 + read-only + + + PE10 + desc PE10 + 10 + 10 + read-only + + + PE11 + desc PE11 + 11 + 11 + read-only + + + PE12 + desc PE12 + 12 + 12 + read-only + + + PE13 + desc PE13 + 13 + 13 + read-only + + + PE14 + desc PE14 + 14 + 14 + read-only + + + PE15 + desc PE15 + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + PEOUT + desc PEOUT + 0x1108 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PEADS + desc PEADS + 0x110C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PEBSET + desc PEBSET + 0x1110 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PEBCLR + desc PEBCLR + 0x1114 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PEBSETCLR + desc PEBSETCLR + 0x1118 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + PEBCLR + desc PEBCLR + 15 + 0 + read-write + + + PEBSET + desc PEBSET + 31 + 16 + read-write + + + + + PEDR + desc PEDR + 0x111C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PEPU + desc PEPU + 0x1120 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PEPD + desc PEPD + 0x1124 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PEOD + desc PEOD + 0x112C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PEHIE + desc PEHIE + 0x1130 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PELIE + desc PELIE + 0x1134 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PERIE + desc PERIE + 0x1138 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PEFIE + desc PEFIE + 0x113C + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PFDIR + desc PFDIR + 0x1140 + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PFIN + desc PFIN + 0x1144 + 32 + read-only + 0x0 + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-only + + + PF01 + desc PF01 + 1 + 1 + read-only + + + PF02 + desc PF02 + 2 + 2 + read-only + + + PF03 + desc PF03 + 3 + 3 + read-only + + + PF04 + desc PF04 + 4 + 4 + read-only + + + PF05 + desc PF05 + 5 + 5 + read-only + + + PF06 + desc PF06 + 6 + 6 + read-only + + + PF07 + desc PF07 + 7 + 7 + read-only + + + PF08 + desc PF08 + 8 + 8 + read-only + + + PF09 + desc PF09 + 9 + 9 + read-only + + + PF10 + desc PF10 + 10 + 10 + read-only + + + PF11 + desc PF11 + 11 + 11 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + PFOUT + desc PFOUT + 0x1148 + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PFADS + desc PFADS + 0x114C + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PFBSET + desc PFBSET + 0x1150 + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PFBCLR + desc PFBCLR + 0x1154 + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PFBSETCLR + desc PFBSETCLR + 0x1158 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + PFBCLR + desc PFBCLR + 11 + 0 + read-write + + + PFBSET + desc PFBSET + 27 + 16 + read-write + + + + + PFDR + desc PFDR + 0x115C + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PFPU + desc PFPU + 0x1160 + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PFPD + desc PFPD + 0x1164 + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PFOD + desc PFOD + 0x116C + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PFHIE + desc PFHIE + 0x1170 + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PFLIE + desc PFLIE + 0x1174 + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PFRIE + desc PFRIE + 0x1178 + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PFFIE + desc PFFIE + 0x117C + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PE_STAT + desc PE_STAT + 0x1200 + 32 + read-only + 0x0 + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-only + + + PE01 + desc PE01 + 1 + 1 + read-only + + + PE02 + desc PE02 + 2 + 2 + read-only + + + PE03 + desc PE03 + 3 + 3 + read-only + + + PE04 + desc PE04 + 4 + 4 + read-only + + + PE05 + desc PE05 + 5 + 5 + read-only + + + PE06 + desc PE06 + 6 + 6 + read-only + + + PE07 + desc PE07 + 7 + 7 + read-only + + + PE08 + desc PE08 + 8 + 8 + read-only + + + PE09 + desc PE09 + 9 + 9 + read-only + + + PE10 + desc PE10 + 10 + 10 + read-only + + + PE11 + desc PE11 + 11 + 11 + read-only + + + PE12 + desc PE12 + 12 + 12 + read-only + + + PE13 + desc PE13 + 13 + 13 + read-only + + + PE14 + desc PE14 + 14 + 14 + read-only + + + PE15 + desc PE15 + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + PE_ICLR + desc PE_ICLR + 0x1210 + 32 + read-write + 0xFFFFFFFF + 0xFFFF + + + PE00 + desc PE00 + 0 + 0 + read-write + + + PE01 + desc PE01 + 1 + 1 + read-write + + + PE02 + desc PE02 + 2 + 2 + read-write + + + PE03 + desc PE03 + 3 + 3 + read-write + + + PE04 + desc PE04 + 4 + 4 + read-write + + + PE05 + desc PE05 + 5 + 5 + read-write + + + PE06 + desc PE06 + 6 + 6 + read-write + + + PE07 + desc PE07 + 7 + 7 + read-write + + + PE08 + desc PE08 + 8 + 8 + read-write + + + PE09 + desc PE09 + 9 + 9 + read-write + + + PE10 + desc PE10 + 10 + 10 + read-write + + + PE11 + desc PE11 + 11 + 11 + read-write + + + PE12 + desc PE12 + 12 + 12 + read-write + + + PE13 + desc PE13 + 13 + 13 + read-write + + + PE14 + desc PE14 + 14 + 14 + read-write + + + PE15 + desc PE15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PF_STAT + desc PF_STAT + 0x1240 + 32 + read-only + 0x0 + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-only + + + PF01 + desc PF01 + 1 + 1 + read-only + + + PF02 + desc PF02 + 2 + 2 + read-only + + + PF03 + desc PF03 + 3 + 3 + read-only + + + PF04 + desc PF04 + 4 + 4 + read-only + + + PF05 + desc PF05 + 5 + 5 + read-only + + + PF06 + desc PF06 + 6 + 6 + read-only + + + PF07 + desc PF07 + 7 + 7 + read-only + + + PF08 + desc PF08 + 8 + 8 + read-only + + + PF09 + desc PF09 + 9 + 9 + read-only + + + PF10 + desc PF10 + 10 + 10 + read-only + + + PF11 + desc PF11 + 11 + 11 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + PF_ICLR + desc PF_ICLR + 0x1250 + 32 + read-write + 0xFFFFFFFF + 0xFFF + + + PF00 + desc PF00 + 0 + 0 + read-write + + + PF01 + desc PF01 + 1 + 1 + read-write + + + PF02 + desc PF02 + 2 + 2 + read-write + + + PF03 + desc PF03 + 3 + 3 + read-write + + + PF04 + desc PF04 + 4 + 4 + read-write + + + PF05 + desc PF05 + 5 + 5 + read-write + + + PF06 + desc PF06 + 6 + 6 + read-write + + + PF07 + desc PF07 + 7 + 7 + read-write + + + PF08 + desc PF08 + 8 + 8 + read-write + + + PF09 + desc PF09 + 9 + 9 + read-write + + + PF10 + desc PF10 + 10 + 10 + read-write + + + PF11 + desc PF11 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + I2C0 + desc I2C + 0x40000400 + + 0x0 + 0x18 + + + + TMRUN + desc TMRUN + 0x0 + 32 + read-write + 0x0 + 0x1 + + + TME + desc TME + 0 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + TM + desc TM + 0x4 + 32 + read-write + 0x0 + 0xFF + + + TM + desc TM + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CR + desc CR + 0x8 + 32 + read-write + 0x0 + 0x7D + + + H1M + desc H1M + 0 + 0 + read-write + + + AA + desc AA + 2 + 2 + read-write + + + SI + desc SI + 3 + 3 + read-write + + + STO + desc STO + 4 + 4 + read-write + + + STA + desc STA + 5 + 5 + read-write + + + ENS + desc ENS + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DATA + desc DATA + 0xC + 32 + read-write + 0x0 + 0xFF + + + DAT + desc DAT + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ADDR + desc ADDR + 0x10 + 32 + read-write + 0x0 + 0xFF + + + GC + desc GC + 0 + 0 + read-write + + + ADR + desc ADR + 7 + 1 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + STAT + desc STAT + 0x14 + 32 + read-only + 0x0 + 0xFF + + + STA + desc STA + 7 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + I2C1 + desc I2C + 0x40004400 + + 0x0 + 0x18 + + + + LCD + desc LCD + 0x40005C00 + + 0x0 + 0x80 + + + + CR0 + desc CR0 + 0x0 + 32 + read-write + 0xDA + 0xFF + + + EN + desc EN + 0 + 0 + read-write + + + LCDCLK + desc LCDCLK + 2 + 1 + read-write + + + CPCLK + desc CPCLK + 4 + 3 + read-write + + + BIAS + desc BIAS + 5 + 5 + read-write + + + DUTY + desc DUTY + 8 + 6 + read-write + + + BSEL + desc BSEL + 11 + 9 + read-write + + + CONTRAST + desc CONTRAST + 15 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CR1 + desc CR1 + 0x4 + 32 + read-write + 0x0 + 0xFFF + + + BLINKCNT + desc BLINKCNT + 5 + 0 + read-write + + + BLINKEN + desc BLINKEN + 6 + 6 + read-write + + + CLKSRC + desc CLKSRC + 7 + 7 + read-write + + + MODE + desc MODE + 8 + 8 + read-write + + + IE + desc IE + 9 + 9 + read-write + + + DMAEN + desc DMAEN + 10 + 10 + read-write + + + INTF + desc INTF + 11 + 11 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + INTCLR + desc INTCLR + 0x8 + 32 + write-only + 0x0 + 0x400 + + + INTF + desc INTF + 10 + 10 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + POEN0 + desc POEN0 + 0xC + 32 + read-write + 0xFFFFFFFF + 0xFFFFFFFF + + + S0 + desc S0 + 0 + 0 + read-write + + + S1 + desc S1 + 1 + 1 + read-write + + + S2 + desc S2 + 2 + 2 + read-write + + + S3 + desc S3 + 3 + 3 + read-write + + + S4 + desc S4 + 4 + 4 + read-write + + + S5 + desc S5 + 5 + 5 + read-write + + + S6 + desc S6 + 6 + 6 + read-write + + + S7 + desc S7 + 7 + 7 + read-write + + + S8 + desc S8 + 8 + 8 + read-write + + + S9 + desc S9 + 9 + 9 + read-write + + + S10 + desc S10 + 10 + 10 + read-write + + + S11 + desc S11 + 11 + 11 + read-write + + + S12 + desc S12 + 12 + 12 + read-write + + + S13 + desc S13 + 13 + 13 + read-write + + + S14 + desc S14 + 14 + 14 + read-write + + + S15 + desc S15 + 15 + 15 + read-write + + + S16 + desc S16 + 16 + 16 + read-write + + + S17 + desc S17 + 17 + 17 + read-write + + + S18 + desc S18 + 18 + 18 + read-write + + + S19 + desc S19 + 19 + 19 + read-write + + + S20 + desc S20 + 20 + 20 + read-write + + + S21 + desc S21 + 21 + 21 + read-write + + + S22 + desc S22 + 22 + 22 + read-write + + + S23 + desc S23 + 23 + 23 + read-write + + + S24 + desc S24 + 24 + 24 + read-write + + + S25 + desc S25 + 25 + 25 + read-write + + + S26 + desc S26 + 26 + 26 + read-write + + + S27 + desc S27 + 27 + 27 + read-write + + + S28 + desc S28 + 28 + 28 + read-write + + + S29 + desc S29 + 29 + 29 + read-write + + + S30 + desc S30 + 30 + 30 + read-write + + + S31 + desc S31 + 31 + 31 + read-write + + + + + POEN1 + desc POEN1 + 0x10 + 32 + read-write + 0x1FFF + 0x1FFF + + + S32 + desc S32 + 0 + 0 + read-write + + + S33 + desc S33 + 1 + 1 + read-write + + + S34 + desc S34 + 2 + 2 + read-write + + + S35 + desc S35 + 3 + 3 + read-write + + + S36C7 + desc S36C7 + 4 + 4 + read-write + + + S37C6 + desc S37C6 + 5 + 5 + read-write + + + S38C5 + desc S38C5 + 6 + 6 + read-write + + + S39C4 + desc S39C4 + 7 + 7 + read-write + + + S40 + desc S40 + 8 + 8 + read-write + + + S41 + desc S41 + 9 + 9 + read-write + + + S42 + desc S42 + 10 + 10 + read-write + + + S43 + desc S43 + 11 + 11 + read-write + + + MUX + desc MUX + 12 + 12 + read-write + + + S44 + desc S44 + 13 + 13 + read-write + + + S45 + desc S45 + 14 + 14 + read-write + + + S46 + desc S46 + 15 + 15 + read-write + + + S47 + desc S47 + 16 + 16 + read-write + + + S48 + desc S48 + 17 + 17 + read-write + + + S49 + desc S49 + 18 + 18 + read-write + + + S50 + desc S50 + 19 + 19 + read-write + + + S51 + desc S51 + 20 + 20 + read-write + + + C0 + desc C0 + 21 + 21 + read-write + + + C1 + desc C1 + 22 + 22 + read-write + + + C2 + desc C2 + 23 + 23 + read-write + + + C3 + desc C3 + 24 + 24 + read-write + + + + + RAM0 + desc RAM0 + 0x40 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + D24 + desc D24 + 24 + 24 + read-write + + + D25 + desc D25 + 25 + 25 + read-write + + + D26 + desc D26 + 26 + 26 + read-write + + + D27 + desc D27 + 27 + 27 + read-write + + + D28 + desc D28 + 28 + 28 + read-write + + + D29 + desc D29 + 29 + 29 + read-write + + + D30 + desc D30 + 30 + 30 + read-write + + + D31 + desc D31 + 31 + 31 + read-write + + + + + RAM1 + desc RAM1 + 0x44 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + D24 + desc D24 + 24 + 24 + read-write + + + D25 + desc D25 + 25 + 25 + read-write + + + D26 + desc D26 + 26 + 26 + read-write + + + D27 + desc D27 + 27 + 27 + read-write + + + D28 + desc D28 + 28 + 28 + read-write + + + D29 + desc D29 + 29 + 29 + read-write + + + D30 + desc D30 + 30 + 30 + read-write + + + D31 + desc D31 + 31 + 31 + read-write + + + + + RAM2 + desc RAM2 + 0x48 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + D24 + desc D24 + 24 + 24 + read-write + + + D25 + desc D25 + 25 + 25 + read-write + + + D26 + desc D26 + 26 + 26 + read-write + + + D27 + desc D27 + 27 + 27 + read-write + + + D28 + desc D28 + 28 + 28 + read-write + + + D29 + desc D29 + 29 + 29 + read-write + + + D30 + desc D30 + 30 + 30 + read-write + + + D31 + desc D31 + 31 + 31 + read-write + + + + + RAM3 + desc RAM3 + 0x4C + 32 + read-write + 0x0 + 0xFFFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + D24 + desc D24 + 24 + 24 + read-write + + + D25 + desc D25 + 25 + 25 + read-write + + + D26 + desc D26 + 26 + 26 + read-write + + + D27 + desc D27 + 27 + 27 + read-write + + + D28 + desc D28 + 28 + 28 + read-write + + + D29 + desc D29 + 29 + 29 + read-write + + + D30 + desc D30 + 30 + 30 + read-write + + + D31 + desc D31 + 31 + 31 + read-write + + + + + RAM4 + desc RAM4 + 0x50 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + D24 + desc D24 + 24 + 24 + read-write + + + D25 + desc D25 + 25 + 25 + read-write + + + D26 + desc D26 + 26 + 26 + read-write + + + D27 + desc D27 + 27 + 27 + read-write + + + D28 + desc D28 + 28 + 28 + read-write + + + D29 + desc D29 + 29 + 29 + read-write + + + D30 + desc D30 + 30 + 30 + read-write + + + D31 + desc D31 + 31 + 31 + read-write + + + + + RAM5 + desc RAM5 + 0x54 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + D24 + desc D24 + 24 + 24 + read-write + + + D25 + desc D25 + 25 + 25 + read-write + + + D26 + desc D26 + 26 + 26 + read-write + + + D27 + desc D27 + 27 + 27 + read-write + + + D28 + desc D28 + 28 + 28 + read-write + + + D29 + desc D29 + 29 + 29 + read-write + + + D30 + desc D30 + 30 + 30 + read-write + + + D31 + desc D31 + 31 + 31 + read-write + + + + + RAM6 + desc RAM6 + 0x58 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + D24 + desc D24 + 24 + 24 + read-write + + + D25 + desc D25 + 25 + 25 + read-write + + + D26 + desc D26 + 26 + 26 + read-write + + + D27 + desc D27 + 27 + 27 + read-write + + + D28 + desc D28 + 28 + 28 + read-write + + + D29 + desc D29 + 29 + 29 + read-write + + + D30 + desc D30 + 30 + 30 + read-write + + + D31 + desc D31 + 31 + 31 + read-write + + + + + RAM7 + desc RAM7 + 0x5C + 32 + read-write + 0x0 + 0xFFFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + D24 + desc D24 + 24 + 24 + read-write + + + D25 + desc D25 + 25 + 25 + read-write + + + D26 + desc D26 + 26 + 26 + read-write + + + D27 + desc D27 + 27 + 27 + read-write + + + D28 + desc D28 + 28 + 28 + read-write + + + D29 + desc D29 + 29 + 29 + read-write + + + D30 + desc D30 + 30 + 30 + read-write + + + D31 + desc D31 + 31 + 31 + read-write + + + + + RAM8 + desc RAM8 + 0x60 + 32 + read-write + 0x0 + 0xFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + RSV + desc RSV + 31 + 24 + read-write + + + + + RAM9 + desc RAM9 + 0x64 + 32 + read-write + 0x0 + 0xFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + RSV + desc RSV + 31 + 24 + read-write + + + + + RAMA + desc RAMA + 0x68 + 32 + read-write + 0x0 + 0xFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + RSV + desc RSV + 31 + 24 + read-write + + + + + RAMB + desc RAMB + 0x6C + 32 + read-write + 0x0 + 0xFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + RSV + desc RSV + 31 + 24 + read-write + + + + + RAMC + desc RAMC + 0x70 + 32 + read-write + 0x0 + 0xFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + RSV + desc RSV + 31 + 24 + read-write + + + + + RAMD + desc RAMD + 0x74 + 32 + read-write + 0x0 + 0xFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + RSV + desc RSV + 31 + 24 + read-write + + + + + RAME + desc RAME + 0x78 + 32 + read-write + 0x0 + 0xFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + RSV + desc RSV + 31 + 24 + read-write + + + + + RAMF + desc RAMF + 0x7C + 32 + read-write + 0x0 + 0xFFFFFF + + + D0 + desc D0 + 0 + 0 + read-write + + + D1 + desc D1 + 1 + 1 + read-write + + + D2 + desc D2 + 2 + 2 + read-write + + + D3 + desc D3 + 3 + 3 + read-write + + + D4 + desc D4 + 4 + 4 + read-write + + + D5 + desc D5 + 5 + 5 + read-write + + + D6 + desc D6 + 6 + 6 + read-write + + + D7 + desc D7 + 7 + 7 + read-write + + + D8 + desc D8 + 8 + 8 + read-write + + + D9 + desc D9 + 9 + 9 + read-write + + + D10 + desc D10 + 10 + 10 + read-write + + + D11 + desc D11 + 11 + 11 + read-write + + + D12 + desc D12 + 12 + 12 + read-write + + + D13 + desc D13 + 13 + 13 + read-write + + + D14 + desc D14 + 14 + 14 + read-write + + + D15 + desc D15 + 15 + 15 + read-write + + + D16 + desc D16 + 16 + 16 + read-write + + + D17 + desc D17 + 17 + 17 + read-write + + + D18 + desc D18 + 18 + 18 + read-write + + + D19 + desc D19 + 19 + 19 + read-write + + + D20 + desc D20 + 20 + 20 + read-write + + + D21 + desc D21 + 21 + 21 + read-write + + + D22 + desc D22 + 22 + 22 + read-write + + + D23 + desc D23 + 23 + 23 + read-write + + + RSV + desc RSV + 31 + 24 + read-write + + + + + + + LPTIMER0 + desc LPTIMER + 0x40000F00 + + 0x0 + 0x18 + + + + CNT + desc CNT + 0x0 + 32 + read-only + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ARR + desc ARR + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + ARR + desc ARR + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CR + desc CR + 0xC + 32 + read-write + 0x8 + 0x3FBF + + + TR + desc TR + 0 + 0 + read-write + + + MD + desc MD + 1 + 1 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + TOG_EN + desc TOG_EN + 3 + 3 + read-write + + + TCK_SEL + desc TCK_SEL + 5 + 4 + read-write + + + WT_FLAG + desc WT_FLAG + 7 + 7 + read-only + + + GATE + desc GATE + 8 + 8 + read-write + + + GATE_P + desc GATE_P + 9 + 9 + read-write + + + IE + desc IE + 10 + 10 + read-write + + + PRS + desc PRS + 13 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0x1 + + + TF + desc TF + 0 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0x1 + 0x1 + + + TFC + desc TFC + 0 + 0 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + LPTIMER1 + desc LPTIMER + 0x40000F40 + + 0x0 + 0x18 + + + + LPUART0 + desc LPUART + 0x40000200 + + 0x0 + 0x1C + + + + SBUF + desc SBUF + 0x0 + 32 + read-write + 0x0 + 0x1FF + + + DATA + desc DATA + 7 + 0 + read-write + + + DATA8 + desc DATA8 + 8 + 8 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SCON + desc SCON + 0x4 + 32 + read-write + 0x0 + 0x7FFFFF + + + RCIE + desc RCIE + 0 + 0 + read-write + + + TCIE + desc TCIE + 1 + 1 + read-write + + + B8CONT + desc B8CONT + 3 + 2 + read-write + + + REN + desc REN + 4 + 4 + read-write + + + ADRDET + desc ADRDET + 5 + 5 + read-write + + + SM + desc SM + 7 + 6 + read-write + + + TXEIE + desc TXEIE + 8 + 8 + read-write + + + OVER + desc OVER + 10 + 9 + read-write + + + SCLKSEL + desc SCLKSEL + 12 + 11 + read-write + + + PEIE + desc PEIE + 13 + 13 + read-write + + + STOPBIT + desc STOPBIT + 15 + 14 + read-write + + + DMARXEN + desc DMARXEN + 16 + 16 + read-write + + + DMATXEN + desc DMATXEN + 17 + 17 + read-write + + + RTSEN + desc RTSEN + 18 + 18 + read-write + + + CTSEN + desc CTSEN + 19 + 19 + read-write + + + CTSIE + desc CTSIE + 20 + 20 + read-write + + + FEIE + desc FEIE + 21 + 21 + read-write + + + HDSEL + desc HDSEL + 22 + 22 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SADDR + desc SADDR + 0x8 + 32 + read-write + 0x0 + 0xFF + + + SADDR + desc SADDR + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SADEN + desc SADEN + 0xC + 32 + read-write + 0x0 + 0xFF + + + SADEN + desc SADEN + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ISR + desc ISR + 0x10 + 32 + read-only + 0x8 + 0x7F + + + RC + desc RC + 0 + 0 + read-only + + + TC + desc TC + 1 + 1 + read-only + + + FE + desc FE + 2 + 2 + read-only + + + TXE + desc TXE + 3 + 3 + read-only + + + PE + desc PE + 4 + 4 + read-only + + + CTSIF + desc CTSIF + 5 + 5 + read-only + + + CTS + desc CTS + 6 + 6 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICR + desc ICR + 0x14 + 32 + write-only + 0x0 + 0x37 + + + RCCF + desc RCCF + 0 + 0 + write-only + + + TCCF + desc TCCF + 1 + 1 + write-only + + + FECF + desc FECF + 2 + 2 + write-only + + + PECF + desc PECF + 4 + 4 + write-only + + + CTSIFCF + desc CTSIFCF + 5 + 5 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SCNT + desc SCNT + 0x18 + 32 + read-write + 0x0 + 0xFFFF + + + SCNT + desc SCNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + LPUART1 + desc LPUART + 0x40004000 + + 0x0 + 0x1C + + + + LVD + desc LVD + 0x40002400 + ADC + + 0x0 + 0x30 + + + + CR + desc CR + 0x28 + 32 + read-write + 0x0 + 0xFFFF + + + LVDEN + desc LVDEN + 0 + 0 + read-write + + + ACT + desc ACT + 1 + 1 + read-write + + + SOURCE_SEL + desc SOURCE_SEL + 3 + 2 + read-write + + + VTDS + desc VTDS + 7 + 4 + read-write + + + FLTEN + desc FLTEN + 8 + 8 + read-write + + + DEBOUNCE_TIME + desc DEBOUNCE_TIME + 11 + 9 + read-write + + + FTEN + desc FTEN + 12 + 12 + read-write + + + RTEN + desc RTEN + 13 + 13 + read-write + + + HTEN + desc HTEN + 14 + 14 + read-write + + + IE + desc IE + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x2C + 32 + read-write + 0x0 + 0x3 + + + INTF + desc INTF + 0 + 0 + read-write + + + FILTER + desc FILTER + 1 + 1 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + OPA + desc OPA + 0x40002400 + ADC + + 0x0 + 0x40 + + + + CR0 + desc CR0 + 0x30 + 32 + read-write + 0x0 + 0xFFF + + + EN + desc EN + 0 + 0 + read-write + + + AZEN + desc AZEN + 1 + 1 + read-write + + + BUFEN + desc BUFEN + 2 + 2 + read-write + + + OEN1 + desc OEN1 + 3 + 3 + read-write + + + OEN2 + desc OEN2 + 4 + 4 + read-write + + + OEN3 + desc OEN3 + 5 + 5 + read-write + + + OEN4 + desc OEN4 + 6 + 6 + read-write + + + BIASSEL + desc BIASSEL + 9 + 7 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CR1 + desc CR1 + 0x3C + 32 + read-write + 0x0 + 0xFF + + + ADCTR_EN + desc ADCTR_EN + 0 + 0 + read-write + + + TRIGGER + desc TRIGGER + 1 + 1 + read-write + + + AZ_PULSE + desc AZ_PULSE + 2 + 2 + read-write + + + CLK_SW_SET + desc CLK_SW_SET + 3 + 3 + read-write + + + CLK_SEL + desc CLK_SEL + 7 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + PCA + desc PCA + 0x40001000 + + 0x0 + 0x6C + + + + CCON + desc CCON + 0x0 + 32 + read-write + 0x0 + 0xDF + + + CCF0 + desc CCF0 + 0 + 0 + read-write + + + CCF1 + desc CCF1 + 1 + 1 + read-write + + + CCF2 + desc CCF2 + 2 + 2 + read-write + + + CCF3 + desc CCF3 + 3 + 3 + read-write + + + CCF4 + desc CCF4 + 4 + 4 + read-write + + + CR + desc CR + 6 + 6 + read-write + + + CF + desc CF + 7 + 7 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CMOD + desc CMOD + 0x4 + 32 + read-write + 0x0 + 0xCF + + + CFIE + desc CFIE + 0 + 0 + read-write + + + CPS + desc CPS + 3 + 1 + read-write + + + WDTE + desc WDTE + 6 + 6 + read-write + + + CIDL + desc CIDL + 7 + 7 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT + desc CNT + 0x8 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0xC + 32 + write-only + 0x9F + 0x9F + + + CCF0 + desc CCF0 + 0 + 0 + write-only + + + CCF1 + desc CCF1 + 1 + 1 + write-only + + + CCF2 + desc CCF2 + 2 + 2 + write-only + + + CCF3 + desc CCF3 + 3 + 3 + write-only + + + CCF4 + desc CCF4 + 4 + 4 + write-only + + + CF + desc CF + 7 + 7 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAPM0 + desc CCAPM0 + 0x10 + 32 + read-write + 0x0 + 0x7F + + + CCIE + desc CCIE + 0 + 0 + read-write + + + PWM + desc PWM + 1 + 1 + read-write + + + TOG + desc TOG + 2 + 2 + read-write + + + MAT + desc MAT + 3 + 3 + read-write + + + CAPN + desc CAPN + 4 + 4 + read-write + + + CAPP + desc CAPP + 5 + 5 + read-write + + + ECOM + desc ECOM + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAPM1 + desc CCAPM1 + 0x14 + 32 + read-write + 0x0 + 0x7F + + + CCIE + desc CCIE + 0 + 0 + read-write + + + PWM + desc PWM + 1 + 1 + read-write + + + TOG + desc TOG + 2 + 2 + read-write + + + MAT + desc MAT + 3 + 3 + read-write + + + CAPN + desc CAPN + 4 + 4 + read-write + + + CAPP + desc CAPP + 5 + 5 + read-write + + + ECOM + desc ECOM + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAPM2 + desc CCAPM2 + 0x18 + 32 + read-write + 0x0 + 0x7F + + + CCIE + desc CCIE + 0 + 0 + read-write + + + PWM + desc PWM + 1 + 1 + read-write + + + TOG + desc TOG + 2 + 2 + read-write + + + MAT + desc MAT + 3 + 3 + read-write + + + CAPN + desc CAPN + 4 + 4 + read-write + + + CAPP + desc CAPP + 5 + 5 + read-write + + + ECOM + desc ECOM + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAPM3 + desc CCAPM3 + 0x1C + 32 + read-write + 0x0 + 0x7F + + + CCIE + desc CCIE + 0 + 0 + read-write + + + PWM + desc PWM + 1 + 1 + read-write + + + TOG + desc TOG + 2 + 2 + read-write + + + MAT + desc MAT + 3 + 3 + read-write + + + CAPN + desc CAPN + 4 + 4 + read-write + + + CAPP + desc CAPP + 5 + 5 + read-write + + + ECOM + desc ECOM + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAPM4 + desc CCAPM4 + 0x20 + 32 + read-write + 0x0 + 0x7F + + + CCIE + desc CCIE + 0 + 0 + read-write + + + PWM + desc PWM + 1 + 1 + read-write + + + TOG + desc TOG + 2 + 2 + read-write + + + MAT + desc MAT + 3 + 3 + read-write + + + CAPN + desc CAPN + 4 + 4 + read-write + + + CAPP + desc CAPP + 5 + 5 + read-write + + + ECOM + desc ECOM + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP0H + desc CCAP0H + 0x24 + 32 + read-write + 0x0 + 0xFF + + + CCAP0 + desc CCAP0 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP0L + desc CCAP0L + 0x28 + 32 + read-write + 0x0 + 0xFF + + + CCAP0 + desc CCAP0 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP1H + desc CCAP1H + 0x2C + 32 + read-write + 0x0 + 0xFF + + + CCAP1 + desc CCAP1 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP1L + desc CCAP1L + 0x30 + 32 + read-write + 0x0 + 0xFF + + + CCAP1 + desc CCAP1 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP2H + desc CCAP2H + 0x34 + 32 + read-write + 0x0 + 0xFF + + + CCAP2 + desc CCAP2 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP2L + desc CCAP2L + 0x38 + 32 + read-write + 0x0 + 0xFF + + + CCAP2 + desc CCAP2 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP3H + desc CCAP3H + 0x3C + 32 + read-write + 0x0 + 0xFF + + + CCAP3 + desc CCAP3 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP3L + desc CCAP3L + 0x40 + 32 + read-write + 0x0 + 0xFF + + + CCAP3 + desc CCAP3 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP4H + desc CCAP4H + 0x44 + 32 + read-write + 0x0 + 0xFF + + + CCAP4 + desc CCAP4 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP4L + desc CCAP4L + 0x48 + 32 + read-write + 0x0 + 0xFF + + + CCAP4 + desc CCAP4 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAPO + desc CCAPO + 0x4C + 32 + read-write + 0x0 + 0x1F + + + CCAPO0 + desc CCAPO0 + 0 + 0 + read-write + + + CCAPO1 + desc CCAPO1 + 1 + 1 + read-write + + + CCAPO2 + desc CCAPO2 + 2 + 2 + read-write + + + CCAPO3 + desc CCAPO3 + 3 + 3 + read-write + + + CCAPO4 + desc CCAPO4 + 4 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP0 + desc CCAP0 + 0x50 + 32 + read-write + 0x0 + 0xFFFF + + + CCAP0 + desc CCAP0 + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP1 + desc CCAP1 + 0x54 + 32 + read-write + 0x0 + 0xFFFF + + + CCAP1 + desc CCAP1 + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP2 + desc CCAP2 + 0x58 + 32 + read-write + 0x0 + 0xFFFF + + + CCAP2 + desc CCAP2 + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP3 + desc CCAP3 + 0x5C + 32 + read-write + 0x0 + 0xFFFF + + + CCAP3 + desc CCAP3 + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP4 + desc CCAP4 + 0x60 + 32 + read-write + 0x0 + 0xFFFF + + + CCAP4 + desc CCAP4 + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CARR + desc CARR + 0x64 + 32 + read-write + 0x0 + 0xFFFF + + + CARR + desc CARR + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + EPWM + desc EPWM + 0x68 + 32 + read-write + 0x0 + 0x1 + + + EPWM + desc EPWM + 0 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + PCNT + desc PCNT + 0x40005400 + + 0x0 + 0x38 + + + + RUN + desc RUN + 0x0 + 32 + read-write + 0x0 + 0x1 + + + RUN + desc RUN + 0 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CTRL + desc CTRL + 0x4 + 32 + read-write + 0x0 + 0x7F + + + MODE + desc MODE + 1 + 0 + read-write + + + CLKSEL + desc CLKSEL + 3 + 2 + read-write + + + DIR + desc DIR + 4 + 4 + read-write + + + S0P + desc S0P + 5 + 5 + read-write + + + S1P + desc S1P + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + FLT + desc FLT + 0x8 + 32 + read-write + 0x2000 + 0x1FFFF + + + CLKDIV + desc CLKDIV + 12 + 0 + read-write + + + DEBTOP + desc DEBTOP + 15 + 13 + read-write + + + EN + desc EN + 16 + 16 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + TOCR + desc TOCR + 0xC + 32 + read-write + 0xFFF + 0x1FFFF + + + TH + desc TH + 11 + 0 + read-write + + + EN + desc EN + 16 + 16 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CMD + desc CMD + 0x10 + 32 + write-only + 0x0 + 0x7 + + + T2C + desc T2C + 0 + 0 + write-only + + + B2T + desc B2T + 1 + 1 + write-only + + + B2C + desc B2C + 2 + 2 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SR1 + desc SR1 + 0x14 + 32 + read-only + 0x0 + 0x1 + + + DIR + desc DIR + 0 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT + desc CNT + 0x18 + 32 + read-only + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + TOP + desc TOP + 0x1C + 32 + read-only + 0xFF + 0xFFFF + + + TOP + desc TOP + 15 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + BUF + desc BUF + 0x20 + 32 + read-write + 0xFF + 0xFFFF + + + BUF + desc BUF + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x24 + 32 + read-only + 0x0 + 0xFF + + + UF + desc UF + 0 + 0 + read-only + + + OV + desc OV + 1 + 1 + read-only + + + TO + desc TO + 2 + 2 + read-only + + + DIR + desc DIR + 3 + 3 + read-only + + + FE + desc FE + 4 + 4 + read-only + + + BB + desc BB + 5 + 5 + read-only + + + S0E + desc S0E + 6 + 6 + read-only + + + S1E + desc S1E + 7 + 7 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICR + desc ICR + 0x28 + 32 + write-only + 0x0 + 0xFF + + + UF + desc UF + 0 + 0 + write-only + + + OV + desc OV + 1 + 1 + write-only + + + TO + desc TO + 2 + 2 + write-only + + + DIR + desc DIR + 3 + 3 + write-only + + + FE + desc FE + 4 + 4 + write-only + + + BB + desc BB + 5 + 5 + write-only + + + S0E + desc S0E + 6 + 6 + write-only + + + S1E + desc S1E + 7 + 7 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IEN + desc IEN + 0x2C + 32 + read-write + 0x0 + 0xFF + + + UF + desc UF + 0 + 0 + read-write + + + OV + desc OV + 1 + 1 + read-write + + + TO + desc TO + 2 + 2 + read-write + + + DIR + desc DIR + 3 + 3 + read-write + + + FE + desc FE + 4 + 4 + read-write + + + BB + desc BB + 5 + 5 + read-write + + + S0E + desc S0E + 6 + 6 + read-write + + + S1E + desc S1E + 7 + 7 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SR2 + desc SR2 + 0x30 + 32 + read-only + 0x0 + 0x7 + + + T2C + desc T2C + 0 + 0 + read-only + + + B2T + desc B2T + 1 + 1 + read-only + + + B2C + desc B2C + 2 + 2 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DBG + desc DBG + 0x34 + 32 + read-write + 0x0 + 0x3 + + + DBG + desc DBG + 1 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + RAM + desc RAM + 0x40020400 + + 0x0 + 0x10 + + + + CR + desc CR + 0x0 + 32 + read-write + 0x0 + 0x3 + + + IE + desc IE + 1 + 1 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ERRADDR + desc ERRADDR + 0x4 + 32 + read-only + 0x0 + 0x1FFF + + + ERRADDR + desc ERRADDR + 13 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x8 + 32 + read-only + 0x0 + 0x1 + + + ERR + desc ERR + 0 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + ICLR + desc ICLR + 0xC + 32 + write-only + 0x1 + 0x1 + + + ERRCLR + desc ERRCLR + 0 + 0 + write-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + + + RESET + desc RESET + 0x4000201C + + 0x0 + 0x10 + + + + RESET_FLAG + desc RESET_FLAG + 0x0 + 32 + read-write + 0x11 + 0xFF + + + POR5V + desc POR5V + 0 + 0 + read-write + + + POR15V + desc POR15V + 1 + 1 + read-write + + + LVD + desc LVD + 2 + 2 + read-write + + + WDT + desc WDT + 3 + 3 + read-write + + + PCA + desc PCA + 4 + 4 + read-write + + + LOCKUP + desc LOCKUP + 5 + 5 + read-write + + + SYSREQ + desc SYSREQ + 6 + 6 + read-write + + + RSTB + desc RSTB + 7 + 7 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PERI_RESET0 + desc PERI_RESET0 + 0xC + 32 + read-write + 0x7F7F6FFF + 0x7FFF6FFF + + + UART0 + desc UART0 + 0 + 0 + read-write + + + UART1 + desc UART1 + 1 + 1 + read-write + + + LPUART0 + desc LPUART0 + 2 + 2 + read-write + + + LPUART1 + desc LPUART1 + 3 + 3 + read-write + + + I2C0 + desc I2C0 + 4 + 4 + read-write + + + I2C1 + desc I2C1 + 5 + 5 + read-write + + + SPI0 + desc SPI0 + 6 + 6 + read-write + + + SPI1 + desc SPI1 + 7 + 7 + read-write + + + BASETIM + desc BASETIM + 8 + 8 + read-write + + + LPTIM0 + desc LPTIM0 + 9 + 9 + read-write + + + ADVTIM + desc ADVTIM + 10 + 10 + read-write + + + TIM3 + desc TIM3 + 11 + 11 + read-write + + + OPA + desc OPA + 13 + 13 + read-write + + + PCA + desc PCA + 14 + 14 + read-write + + + ADC + desc ADC + 16 + 16 + read-write + + + VC + desc VC + 17 + 17 + read-write + + + RNG + desc RNG + 18 + 18 + read-write + + + PCNT + desc PCNT + 19 + 19 + read-write + + + RTC + desc RTC + 20 + 20 + read-write + + + TRIM + desc TRIM + 21 + 21 + read-write + + + LCD + desc LCD + 22 + 22 + read-write + + + TICK + desc TICK + 24 + 24 + read-write + + + SWD + desc SWD + 25 + 25 + read-write + + + CRC + desc CRC + 26 + 26 + read-write + + + AES + desc AES + 27 + 27 + read-write + + + GPIO + desc GPIO + 28 + 28 + read-write + + + DMA + desc DMA + 29 + 29 + read-write + + + + + PERI_RESET1 + desc PERI_RESET1 + 0x10 + 32 + read-write + 0x3FF + 0x3FFF + + + DAC + desc DAC + 3 + 3 + read-write + + + LPTIM1 + desc LPTIM1 + 4 + 4 + read-write + + + UART2 + desc UART2 + 8 + 8 + read-write + + + UART3 + desc UART3 + 9 + 9 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + RTC + desc RTC + 0x40001400 + + 0x0 + 0x38 + + + + CR0 + desc CR0 + 0x0 + 32 + read-write + 0x0 + 0x7FEF + + + PRDS + desc PRDS + 2 + 0 + read-write + + + AMPM + desc AMPM + 3 + 3 + read-write + + + HZ1OE + desc HZ1OE + 5 + 5 + read-write + + + HZ1SEL + desc HZ1SEL + 6 + 6 + read-write + + + START + desc START + 7 + 7 + read-write + + + PRDX + desc PRDX + 13 + 8 + read-write + + + PRDSEL + desc PRDSEL + 14 + 14 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CR1 + desc CR1 + 0x4 + 32 + read-write + 0x0 + 0x7FB + + + WAIT + desc WAIT + 0 + 0 + read-write + + + WAITF + desc WAITF + 1 + 1 + read-write + + + PRDF + desc PRDF + 3 + 3 + read-write + + + ALMF + desc ALMF + 4 + 4 + read-write + + + ALMIE + desc ALMIE + 6 + 6 + read-write + + + ALMEN + desc ALMEN + 7 + 7 + read-write + + + CKSEL + desc CKSEL + 10 + 8 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SEC + desc SEC + 0x8 + 32 + read-write + 0x0 + 0x7F + + + SECL + desc SECL + 3 + 0 + read-write + + + SECH + desc SECH + 6 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + MIN + desc MIN + 0xC + 32 + read-write + 0x0 + 0x7F + + + MINL + desc MINL + 3 + 0 + read-write + + + MINH + desc MINH + 6 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + HOUR + desc HOUR + 0x10 + 32 + read-write + 0x0 + 0x7F + + + HOURL + desc HOURL + 3 + 0 + read-write + + + HOURH + desc HOURH + 5 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + WEEK + desc WEEK + 0x14 + 32 + read-write + 0x0 + 0x7 + + + WEEK + desc WEEK + 2 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DAY + desc DAY + 0x18 + 32 + read-write + 0x0 + 0x3F + + + DAYL + desc DAYL + 3 + 0 + read-write + + + DAYH + desc DAYH + 5 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + MON + desc MON + 0x1C + 32 + read-write + 0x0 + 0x1F + + + MON + desc MON + 4 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + YEAR + desc YEAR + 0x20 + 32 + read-write + 0x0 + 0xFF + + + YEARL + desc YEARL + 3 + 0 + read-write + + + YEARH + desc YEARH + 7 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ALMMIN + desc ALMMIN + 0x24 + 32 + read-write + 0x0 + 0x7F + + + ALMMINL + desc ALMMINL + 3 + 0 + read-write + + + ALMMINH + desc ALMMINH + 6 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ALMHOUR + desc ALMHOUR + 0x28 + 32 + read-write + 0x0 + 0x3F + + + ALMHOURL + desc ALMHOURL + 3 + 0 + read-write + + + ALMHOURH + desc ALMHOURH + 5 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ALMWEEK + desc ALMWEEK + 0x2C + 32 + read-write + 0x0 + 0x7F + + + ALMWEEK + desc ALMWEEK + 6 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + COMPEN + desc COMPEN + 0x30 + 32 + read-write + 0x20 + 0x81FF + + + CR + desc CR + 8 + 0 + read-write + + + EN + desc EN + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ALMSEC + desc ALMSEC + 0x34 + 32 + read-write + 0x0 + 0xFF + + + ALMSECL + desc ALMSECL + 3 + 0 + read-write + + + ALMSECH + desc ALMSECH + 6 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + SPI0 + desc SPI + 0x40000800 + + 0x0 + 0x18 + + + + CR + desc CR + 0x0 + 32 + read-write + 0x0 + 0xDF + + + SPR0 + desc SPR0 + 0 + 0 + read-write + + + SPR1 + desc SPR1 + 1 + 1 + read-write + + + CPHA + desc CPHA + 2 + 2 + read-write + + + CPOL + desc CPOL + 3 + 3 + read-write + + + MSTR + desc MSTR + 4 + 4 + read-write + + + SPEN + desc SPEN + 6 + 6 + read-write + + + SPR2 + desc SPR2 + 7 + 7 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SSN + desc SSN + 0x4 + 32 + read-write + 0x1 + 0x1 + + + SSN + desc SSN + 0 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + STAT + desc STAT + 0x8 + 32 + read-only + 0x0 + 0xBE + + + RXNE + desc RXNE + 1 + 1 + read-only + + + TXE + desc TXE + 2 + 2 + read-only + + + BUSY + desc BUSY + 3 + 3 + read-only + + + MDF + desc MDF + 4 + 4 + read-only + + + SSERR + desc SSERR + 5 + 5 + read-only + + + SPIF + desc SPIF + 7 + 7 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DATA + desc DATA + 0xC + 32 + read-write + 0x0 + 0xFF + + + DAT + desc DAT + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CR2 + desc CR2 + 0x10 + 32 + read-write + 0x3 + 0x7C + + + INT_EN + desc INT_EN + 2 + 2 + read-write + + + HDMA_RX + desc HDMA_RX + 3 + 3 + read-write + + + HDMA_TX + desc HDMA_TX + 4 + 4 + read-write + + + TXEIE + desc TXEIE + 5 + 5 + read-write + + + RXNEIE + desc RXNEIE + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFFFFFF + 0x1 + + + INT_CLR + desc INT_CLR + 0 + 0 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + SPI1 + desc SPI + 0x40004800 + + 0x0 + 0x18 + + + + SYSCTRL + desc SYSCTRL + 0x40002000 + + 0x0 + 0x5C + + + + SYSCTRL0 + desc SYSCTRL0 + 0x0 + 32 + read-write + 0x1 + 0x9FFF + + + RCH_EN + desc RCH_EN + 0 + 0 + read-write + + + XTH_EN + desc XTH_EN + 1 + 1 + read-write + + + RCL_EN + desc RCL_EN + 2 + 2 + read-write + + + XTL_EN + desc XTL_EN + 3 + 3 + read-write + + + PLL_EN + desc PLL_EN + 4 + 4 + read-write + + + CLKSW + desc CLKSW + 7 + 5 + read-write + + + HCLK_PRS + desc HCLK_PRS + 10 + 8 + read-write + + + PCLK_PRS + desc PCLK_PRS + 12 + 11 + read-write + + + WAKEUP_BYRCH + desc WAKEUP_BYRCH + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SYSCTRL1 + desc SYSCTRL1 + 0x4 + 32 + read-write + 0x8 + 0xF7E + + + EXTH_EN + desc EXTH_EN + 1 + 1 + read-write + + + EXTL_EN + desc EXTL_EN + 2 + 2 + read-write + + + XTL_ALWAYS_ON + desc XTL_ALWAYS_ON + 3 + 3 + read-write + + + RTC_LPW + desc RTC_LPW + 5 + 5 + read-write + + + LOCKUP_EN + desc LOCKUP_EN + 6 + 6 + read-write + + + SWD_USE_IO + desc SWD_USE_IO + 8 + 8 + read-write + + + RTC_FREQ_ADJUST + desc RTC_FREQ_ADJUST + 11 + 9 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SYSCTRL2 + desc SYSCTRL2 + 0x8 + 32 + write-only + 0x0 + 0xFFFF + + + SYSCTRL2 + desc SYSCTRL2 + 15 + 0 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + RCH_CR + desc RCH_CR + 0xC + 32 + read-write + 0x126 + 0xFFF + + + TRIM + desc TRIM + 10 + 0 + read-write + + + STABLE + desc STABLE + 11 + 11 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + XTH_CR + desc XTH_CR + 0x10 + 32 + read-write + 0x22 + 0x7F + + + DRIVER + desc DRIVER + 1 + 0 + read-write + + + XTH_FSEL + desc XTH_FSEL + 3 + 2 + read-write + + + STARTUP + desc STARTUP + 5 + 4 + read-write + + + STABLE + desc STABLE + 6 + 6 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + RCL_CR + desc RCL_CR + 0x14 + 32 + read-write + 0x33F + 0x1FFF + + + TRIM + desc TRIM + 9 + 0 + read-write + + + STARTUP + desc STARTUP + 11 + 10 + read-write + + + STABLE + desc STABLE + 12 + 12 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + XTL_CR + desc XTL_CR + 0x18 + 32 + read-write + 0x21 + 0x7F + + + DRIVER + desc DRIVER + 1 + 0 + read-write + + + AMP_SEL + desc AMP_SEL + 3 + 2 + read-write + + + STARTUP + desc STARTUP + 5 + 4 + read-write + + + STABLE + desc STABLE + 6 + 6 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PERI_CLKEN0 + desc PERI_CLKEN0 + 0x20 + 32 + read-write + 0x80800000 + 0xFF7FEFFF + + + UART0 + desc UART0 + 0 + 0 + read-write + + + UART1 + desc UART1 + 1 + 1 + read-write + + + LPUART0 + desc LPUART0 + 2 + 2 + read-write + + + LPUART1 + desc LPUART1 + 3 + 3 + read-write + + + I2C0 + desc I2C0 + 4 + 4 + read-write + + + I2C1 + desc I2C1 + 5 + 5 + read-write + + + SPI0 + desc SPI0 + 6 + 6 + read-write + + + SPI1 + desc SPI1 + 7 + 7 + read-write + + + BASETIM + desc BASETIM + 8 + 8 + read-write + + + LPTIM0 + desc LPTIM0 + 9 + 9 + read-write + + + ADVTIM + desc ADVTIM + 10 + 10 + read-write + + + TIM3 + desc TIM3 + 11 + 11 + read-write + + + OPA + desc OPA + 13 + 13 + read-write + + + PCA + desc PCA + 14 + 14 + read-write + + + WDT + desc WDT + 15 + 15 + read-write + + + ADC + desc ADC + 16 + 16 + read-write + + + VC + desc VC + 17 + 17 + read-write + + + RNG + desc RNG + 18 + 18 + read-write + + + PCNT + desc PCNT + 19 + 19 + read-write + + + RTC + desc RTC + 20 + 20 + read-write + + + TRIM + desc TRIM + 21 + 21 + read-write + + + LCD + desc LCD + 22 + 22 + read-write + + + TICK + desc TICK + 24 + 24 + read-write + + + SWD + desc SWD + 25 + 25 + read-write + + + CRC + desc CRC + 26 + 26 + read-write + + + AES + desc AES + 27 + 27 + read-write + + + GPIO + desc GPIO + 28 + 28 + read-write + + + DMA + desc DMA + 29 + 29 + read-write + + + FLASH + desc FLASH + 31 + 31 + read-write + + + + + PERI_CLKEN1 + desc PERI_CLKEN1 + 0x24 + 32 + read-write + 0x0 + 0xFFF + + + DAC + desc DAC + 3 + 3 + read-write + + + LPTIM1 + desc LPTIM1 + 4 + 4 + read-write + + + UART2 + desc UART2 + 8 + 8 + read-write + + + UART3 + desc UART3 + 9 + 9 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PLL_CR + desc PLL_CR + 0x3C + 32 + read-write + 0x10B0F + 0x3FFFF + + + REFSEL + desc REFSEL + 1 + 0 + read-write + + + FOSC + desc FOSC + 4 + 2 + read-write + + + DIVN + desc DIVN + 8 + 5 + read-write + + + IBSEL + desc IBSEL + 10 + 9 + read-write + + + LFSEL + desc LFSEL + 12 + 11 + read-write + + + FRSEL + desc FRSEL + 14 + 13 + read-write + + + STARTUP + desc STARTUP + 17 + 15 + read-write + + + STABLE + desc STABLE + 18 + 18 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TIM0_MODE0 + desc TIM0_MODE0 + 0x40000C00 + + 0x0 + 0x34 + + + + ARR + desc ARR + 0x0 + 32 + read-write + 0x0 + 0xFFFF + + + ARR + desc ARR + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT32 + desc CNT32 + 0x8 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + CNT32 + desc CNT32 + 31 + 0 + read-write + + + + + M0CR + desc M0CR + 0xC + 32 + read-write + 0x600008 + 0x377F + + + CTEN + desc CTEN + 0 + 0 + read-write + + + MD + desc MD + 1 + 1 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + TOGEN + desc TOGEN + 3 + 3 + read-write + + + PRS + desc PRS + 6 + 4 + read-write + + + GATE + desc GATE + 8 + 8 + read-write + + + GATEP + desc GATEP + 9 + 9 + read-write + + + UIE + desc UIE + 10 + 10 + read-write + + + MODE + desc MODE + 13 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0x1 + + + UIF + desc UIF + 0 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFF + 0x1 + + + UIF + desc UIF + 0 + 0 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DTR + desc DTR + 0x30 + 32 + read-write + 0x0 + 0x1000 + + + MOE + desc MOE + 12 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TIM0_MODE1 + desc TIM0_MODE1 + 0x40000C00 + TIM0_MODE0 + + 0x0 + 0x40 + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + M1CR + desc M1CR + 0xC + 32 + read-write + 0x600008 + 0x7775 + + + CTEN + desc CTEN + 0 + 0 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + PRS + desc PRS + 6 + 4 + read-write + + + EDG1ST + desc EDG1ST + 8 + 8 + read-write + + + EDG2ND + desc EDG2ND + 9 + 9 + read-write + + + UIE + desc UIE + 10 + 10 + read-write + + + MODE + desc MODE + 13 + 12 + read-write + + + ONESHOT + desc ONESHOT + 14 + 14 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0x5 + + + UIF + desc UIF + 0 + 0 + read-only + + + CA0F + desc CA0F + 2 + 2 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFF + 0x5 + + + UIF + desc UIF + 0 + 0 + write-only + + + CA0F + desc CA0F + 2 + 2 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + MSCR + desc MSCR + 0x18 + 32 + read-write + 0x0 + 0x18E0 + + + TS + desc TS + 7 + 5 + read-write + + + IA0S + desc IA0S + 11 + 11 + read-write + + + IB0S + desc IB0S + 12 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + FLTR + desc FLTR + 0x1C + 32 + read-write + 0x0 + 0xF0000077 + + + FLTA0 + desc FLTA0 + 2 + 0 + read-write + + + FLTB0 + desc FLTB0 + 6 + 4 + read-write + + + FLTET + desc FLTET + 30 + 28 + read-write + + + ETP + desc ETP + 31 + 31 + read-write + + + + + CR0 + desc CR0 + 0x24 + 32 + read-write + 0x3000 + 0x100 + + + CIEA + desc CIEA + 8 + 8 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR0A + desc CCR0A + 0x3C + 32 + read-write + 0x0 + 0xFFFF + + + CCR0A + desc CCR0A + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TIM0_MODE23 + desc TIM0_MODE23 + 0x40000C00 + TIM0_MODE0 + + 0x0 + 0x44 + + + + ARR + desc ARR + 0x0 + 32 + read-write + 0x0 + 0xFFFF + + + ARR + desc ARR + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + M23CR + desc M23CR + 0xC + 32 + read-write + 0x600008 + 0xFFFFFFF + + + CTEN + desc CTEN + 0 + 0 + read-write + + + COMP + desc COMP + 1 + 1 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + PWM2S + desc PWM2S + 3 + 3 + read-write + + + PRS + desc PRS + 6 + 4 + read-write + + + BUFPEN + desc BUFPEN + 7 + 7 + read-write + + + CRG + desc CRG + 8 + 8 + read-write + + + CFG + desc CFG + 9 + 9 + read-write + + + UIE + desc UIE + 10 + 10 + read-write + + + UDE + desc UDE + 11 + 11 + read-write + + + MODE + desc MODE + 13 + 12 + read-write + + + ONESHOT + desc ONESHOT + 14 + 14 + read-write + + + CSG + desc CSG + 15 + 15 + read-write + + + OCCS + desc OCCS + 16 + 16 + read-write + + + URS + desc URS + 17 + 17 + read-write + + + TDE + desc TDE + 18 + 18 + read-write + + + TIE + desc TIE + 19 + 19 + read-write + + + BIE + desc BIE + 20 + 20 + read-write + + + CIS + desc CIS + 22 + 21 + read-write + + + OCCE + desc OCCE + 23 + 23 + read-write + + + TG + desc TG + 24 + 24 + write-only + + + UG + desc UG + 25 + 25 + write-only + + + BG + desc BG + 26 + 26 + write-only + + + DIR + desc DIR + 27 + 27 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0xC925 + + + UIF + desc UIF + 0 + 0 + read-only + + + CA0F + desc CA0F + 2 + 2 + read-only + + + CB0F + desc CB0F + 5 + 5 + read-only + + + CA0E + desc CA0E + 8 + 8 + read-only + + + CB0E + desc CB0E + 11 + 11 + read-only + + + BIF + desc BIF + 14 + 14 + read-only + + + TIF + desc TIF + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFF + 0xC925 + + + UIF + desc UIF + 0 + 0 + write-only + + + CA0F + desc CA0F + 2 + 2 + write-only + + + CB0F + desc CB0F + 5 + 5 + write-only + + + CA0E + desc CA0E + 8 + 8 + write-only + + + CB0E + desc CB0E + 11 + 11 + write-only + + + BIF + desc BIF + 14 + 14 + write-only + + + TIF + desc TIF + 15 + 15 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + MSCR + desc MSCR + 0x18 + 32 + read-write + 0x0 + 0x1FFF + + + MMS + desc MMS + 2 + 0 + read-write + + + CCDS + desc CCDS + 3 + 3 + read-write + + + MSM + desc MSM + 4 + 4 + read-write + + + TS + desc TS + 7 + 5 + read-write + + + SMS + desc SMS + 10 + 8 + read-write + + + IA0S + desc IA0S + 11 + 11 + read-write + + + IB0S + desc IB0S + 12 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + FLTR + desc FLTR + 0x1C + 32 + read-write + 0x0 + 0xFFFFFFFF + + + OCMA0_FLTA0 + desc OCMA0_FLTA0 + 2 + 0 + read-write + + + CCPA0 + desc CCPA0 + 3 + 3 + read-write + + + OCMB0_FLTB0 + desc OCMB0_FLTB0 + 6 + 4 + read-write + + + CCPB0 + desc CCPB0 + 7 + 7 + read-write + + + FLTBK + desc FLTBK + 26 + 24 + read-write + + + BKP + desc BKP + 27 + 27 + read-write + + + FLTET + desc FLTET + 30 + 28 + read-write + + + ETP + desc ETP + 31 + 31 + read-write + + + + + ADTR + desc ADTR + 0x20 + 32 + read-write + 0x0 + 0x93 + + + UEVE + desc UEVE + 0 + 0 + read-write + + + CMA0E + desc CMA0E + 1 + 1 + read-write + + + CMB0E + desc CMB0E + 4 + 4 + read-write + + + ADTE + desc ADTE + 7 + 7 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CRCH0 + desc CRCH0 + 0x24 + 32 + read-write + 0x3000 + 0xFFFF + + + CFA_CRA_BKSA + desc CFA_CRA_BKSA + 1 + 0 + read-write + + + CFB_CRB_BKSB + desc CFB_CRB_BKSB + 3 + 2 + read-write + + + CSA + desc CSA + 4 + 4 + read-write + + + CSB + desc CSB + 5 + 5 + read-write + + + BUFEA + desc BUFEA + 6 + 6 + read-write + + + BUFEB + desc BUFEB + 7 + 7 + read-write + + + CIEA + desc CIEA + 8 + 8 + read-write + + + CIEB + desc CIEB + 9 + 9 + read-write + + + CDEA + desc CDEA + 10 + 10 + read-write + + + CDEB + desc CDEB + 11 + 11 + read-write + + + CISB + desc CISB + 13 + 12 + read-write + + + CCGA + desc CCGA + 14 + 14 + read-write + + + CCGB + desc CCGB + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DTR + desc DTR + 0x30 + 32 + read-write + 0x0 + 0xFFFF + + + DTR + desc DTR + 7 + 0 + read-write + + + BKSEL + desc BKSEL + 8 + 8 + read-write + + + DTEN + desc DTEN + 9 + 9 + read-write + + + BKE + desc BKE + 10 + 10 + read-write + + + AOE + desc AOE + 11 + 11 + read-write + + + MOE + desc MOE + 12 + 12 + read-write + + + SAFEEN + desc SAFEEN + 13 + 13 + read-write + + + VCE + desc VCE + 14 + 14 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + RCR + desc RCR + 0x34 + 32 + read-write + 0x0 + 0xFF + + + RCR + desc RCR + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ARRDM + desc ARRDM + 0x38 + 32 + read-write + 0x0 + 0xFFFF + + + ARRDM + desc ARRDM + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR0A + desc CCR0A + 0x3C + 32 + read-write + 0x0 + 0xFFFF + + + CCR0A + desc CCR0A + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR0B + desc CCR0B + 0x40 + 32 + read-write + 0x0 + 0xFFFF + + + CCR0B + desc CCR0B + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TIM1_MODE0 + desc TIM1_MODE0 + 0x40000D00 + + 0x0 + 0x34 + + + + ARR + desc ARR + 0x0 + 32 + read-write + 0x0 + 0xFFFF + + + ARR + desc ARR + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT32 + desc CNT32 + 0x8 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + CNT32 + desc CNT32 + 31 + 0 + read-write + + + + + M0CR + desc M0CR + 0xC + 32 + read-write + 0x600008 + 0x377F + + + CTEN + desc CTEN + 0 + 0 + read-write + + + MD + desc MD + 1 + 1 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + TOGEN + desc TOGEN + 3 + 3 + read-write + + + PRS + desc PRS + 6 + 4 + read-write + + + GATE + desc GATE + 8 + 8 + read-write + + + GATEP + desc GATEP + 9 + 9 + read-write + + + UIE + desc UIE + 10 + 10 + read-write + + + MODE + desc MODE + 13 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0x1 + + + UIF + desc UIF + 0 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFF + 0x1 + + + UIF + desc UIF + 0 + 0 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DTR + desc DTR + 0x30 + 32 + read-write + 0x0 + 0x1000 + + + MOE + desc MOE + 12 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TIM1_MODE1 + desc TIM1_MODE1 + 0x40000D00 + TIM1_MODE0 + + 0x0 + 0x40 + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + M1CR + desc M1CR + 0xC + 32 + read-write + 0x600008 + 0x7775 + + + CTEN + desc CTEN + 0 + 0 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + PRS + desc PRS + 6 + 4 + read-write + + + EDG1ST + desc EDG1ST + 8 + 8 + read-write + + + EDG2ND + desc EDG2ND + 9 + 9 + read-write + + + UIE + desc UIE + 10 + 10 + read-write + + + MODE + desc MODE + 13 + 12 + read-write + + + ONESHOT + desc ONESHOT + 14 + 14 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0x5 + + + UIF + desc UIF + 0 + 0 + read-only + + + CA0F + desc CA0F + 2 + 2 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFF + 0x5 + + + UIF + desc UIF + 0 + 0 + write-only + + + CA0F + desc CA0F + 2 + 2 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + MSCR + desc MSCR + 0x18 + 32 + read-write + 0x0 + 0x18E0 + + + TS + desc TS + 7 + 5 + read-write + + + IA0S + desc IA0S + 11 + 11 + read-write + + + IB0S + desc IB0S + 12 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + FLTR + desc FLTR + 0x1C + 32 + read-write + 0x0 + 0xF0000077 + + + FLTA0 + desc FLTA0 + 2 + 0 + read-write + + + FLTB0 + desc FLTB0 + 6 + 4 + read-write + + + FLTET + desc FLTET + 30 + 28 + read-write + + + ETP + desc ETP + 31 + 31 + read-write + + + + + CR0 + desc CR0 + 0x24 + 32 + read-write + 0x3000 + 0x100 + + + CIEA + desc CIEA + 8 + 8 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR0A + desc CCR0A + 0x3C + 32 + read-write + 0x0 + 0xFFFF + + + CCR0A + desc CCR0A + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TIM1_MODE23 + desc TIM1_MODE23 + 0x40000D00 + TIM1_MODE0 + + 0x0 + 0x44 + + + + ARR + desc ARR + 0x0 + 32 + read-write + 0x0 + 0xFFFF + + + ARR + desc ARR + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + M23CR + desc M23CR + 0xC + 32 + read-write + 0x600008 + 0xFFFFFFF + + + CTEN + desc CTEN + 0 + 0 + read-write + + + COMP + desc COMP + 1 + 1 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + PWM2S + desc PWM2S + 3 + 3 + read-write + + + PRS + desc PRS + 6 + 4 + read-write + + + BUFPEN + desc BUFPEN + 7 + 7 + read-write + + + CRG + desc CRG + 8 + 8 + read-write + + + CFG + desc CFG + 9 + 9 + read-write + + + UIE + desc UIE + 10 + 10 + read-write + + + UDE + desc UDE + 11 + 11 + read-write + + + MODE + desc MODE + 13 + 12 + read-write + + + ONESHOT + desc ONESHOT + 14 + 14 + read-write + + + CSG + desc CSG + 15 + 15 + read-write + + + OCCS + desc OCCS + 16 + 16 + read-write + + + URS + desc URS + 17 + 17 + read-write + + + TDE + desc TDE + 18 + 18 + read-write + + + TIE + desc TIE + 19 + 19 + read-write + + + BIE + desc BIE + 20 + 20 + read-write + + + CIS + desc CIS + 22 + 21 + read-write + + + OCCE + desc OCCE + 23 + 23 + read-write + + + TG + desc TG + 24 + 24 + write-only + + + UG + desc UG + 25 + 25 + write-only + + + BG + desc BG + 26 + 26 + write-only + + + DIR + desc DIR + 27 + 27 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0xC925 + + + UIF + desc UIF + 0 + 0 + read-only + + + CA0F + desc CA0F + 2 + 2 + read-only + + + CB0F + desc CB0F + 5 + 5 + read-only + + + CA0E + desc CA0E + 8 + 8 + read-only + + + CB0E + desc CB0E + 11 + 11 + read-only + + + BIF + desc BIF + 14 + 14 + read-only + + + TIF + desc TIF + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFF + 0xC925 + + + UIF + desc UIF + 0 + 0 + write-only + + + CA0F + desc CA0F + 2 + 2 + write-only + + + CB0F + desc CB0F + 5 + 5 + write-only + + + CA0E + desc CA0E + 8 + 8 + write-only + + + CB0E + desc CB0E + 11 + 11 + write-only + + + BIF + desc BIF + 14 + 14 + write-only + + + TIF + desc TIF + 15 + 15 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + MSCR + desc MSCR + 0x18 + 32 + read-write + 0x0 + 0x1FFF + + + MMS + desc MMS + 2 + 0 + read-write + + + CCDS + desc CCDS + 3 + 3 + read-write + + + MSM + desc MSM + 4 + 4 + read-write + + + TS + desc TS + 7 + 5 + read-write + + + SMS + desc SMS + 10 + 8 + read-write + + + IA0S + desc IA0S + 11 + 11 + read-write + + + IB0S + desc IB0S + 12 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + FLTR + desc FLTR + 0x1C + 32 + read-write + 0x0 + 0xFFFFFFFF + + + OCMA0_FLTA0 + desc OCMA0_FLTA0 + 2 + 0 + read-write + + + CCPA0 + desc CCPA0 + 3 + 3 + read-write + + + OCMB0_FLTB0 + desc OCMB0_FLTB0 + 6 + 4 + read-write + + + CCPB0 + desc CCPB0 + 7 + 7 + read-write + + + FLTBK + desc FLTBK + 26 + 24 + read-write + + + BKP + desc BKP + 27 + 27 + read-write + + + FLTET + desc FLTET + 30 + 28 + read-write + + + ETP + desc ETP + 31 + 31 + read-write + + + + + ADTR + desc ADTR + 0x20 + 32 + read-write + 0x0 + 0x93 + + + UEVE + desc UEVE + 0 + 0 + read-write + + + CMA0E + desc CMA0E + 1 + 1 + read-write + + + CMB0E + desc CMB0E + 4 + 4 + read-write + + + ADTE + desc ADTE + 7 + 7 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CRCH0 + desc CRCH0 + 0x24 + 32 + read-write + 0x3000 + 0xFFFF + + + CFA_CRA_BKSA + desc CFA_CRA_BKSA + 1 + 0 + read-write + + + CFB_CRB_BKSB + desc CFB_CRB_BKSB + 3 + 2 + read-write + + + CSA + desc CSA + 4 + 4 + read-write + + + CSB + desc CSB + 5 + 5 + read-write + + + BUFEA + desc BUFEA + 6 + 6 + read-write + + + BUFEB + desc BUFEB + 7 + 7 + read-write + + + CIEA + desc CIEA + 8 + 8 + read-write + + + CIEB + desc CIEB + 9 + 9 + read-write + + + CDEA + desc CDEA + 10 + 10 + read-write + + + CDEB + desc CDEB + 11 + 11 + read-write + + + CISB + desc CISB + 13 + 12 + read-write + + + CCGA + desc CCGA + 14 + 14 + read-write + + + CCGB + desc CCGB + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DTR + desc DTR + 0x30 + 32 + read-write + 0x0 + 0xFFFF + + + DTR + desc DTR + 7 + 0 + read-write + + + BKSEL + desc BKSEL + 8 + 8 + read-write + + + DTEN + desc DTEN + 9 + 9 + read-write + + + BKE + desc BKE + 10 + 10 + read-write + + + AOE + desc AOE + 11 + 11 + read-write + + + MOE + desc MOE + 12 + 12 + read-write + + + SAFEEN + desc SAFEEN + 13 + 13 + read-write + + + VCE + desc VCE + 14 + 14 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + RCR + desc RCR + 0x34 + 32 + read-write + 0x0 + 0xFF + + + RCR + desc RCR + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ARRDM + desc ARRDM + 0x38 + 32 + read-write + 0x0 + 0xFFFF + + + ARRDM + desc ARRDM + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR0A + desc CCR0A + 0x3C + 32 + read-write + 0x0 + 0xFFFF + + + CCR0A + desc CCR0A + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR0B + desc CCR0B + 0x40 + 32 + read-write + 0x0 + 0xFFFF + + + CCR0B + desc CCR0B + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TIM2_MODE0 + desc TIM2_MODE0 + 0x40000E00 + + 0x0 + 0x34 + + + + ARR + desc ARR + 0x0 + 32 + read-write + 0x0 + 0xFFFF + + + ARR + desc ARR + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT32 + desc CNT32 + 0x8 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + CNT32 + desc CNT32 + 31 + 0 + read-write + + + + + M0CR + desc M0CR + 0xC + 32 + read-write + 0x600008 + 0x377F + + + CTEN + desc CTEN + 0 + 0 + read-write + + + MD + desc MD + 1 + 1 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + TOGEN + desc TOGEN + 3 + 3 + read-write + + + PRS + desc PRS + 6 + 4 + read-write + + + GATE + desc GATE + 8 + 8 + read-write + + + GATEP + desc GATEP + 9 + 9 + read-write + + + UIE + desc UIE + 10 + 10 + read-write + + + MODE + desc MODE + 13 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0x1 + + + UIF + desc UIF + 0 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFF + 0x1 + + + UIF + desc UIF + 0 + 0 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DTR + desc DTR + 0x30 + 32 + read-write + 0x0 + 0x1000 + + + MOE + desc MOE + 12 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TIM2_MODE1 + desc TIM2_MODE1 + 0x40000E00 + TIM2_MODE0 + + 0x0 + 0x40 + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + M1CR + desc M1CR + 0xC + 32 + read-write + 0x600008 + 0x7775 + + + CTEN + desc CTEN + 0 + 0 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + PRS + desc PRS + 6 + 4 + read-write + + + EDG1ST + desc EDG1ST + 8 + 8 + read-write + + + EDG2ND + desc EDG2ND + 9 + 9 + read-write + + + UIE + desc UIE + 10 + 10 + read-write + + + MODE + desc MODE + 13 + 12 + read-write + + + ONESHOT + desc ONESHOT + 14 + 14 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0x5 + + + UIF + desc UIF + 0 + 0 + read-only + + + CA0F + desc CA0F + 2 + 2 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFF + 0x5 + + + UIF + desc UIF + 0 + 0 + write-only + + + CA0F + desc CA0F + 2 + 2 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + MSCR + desc MSCR + 0x18 + 32 + read-write + 0x0 + 0x18E0 + + + TS + desc TS + 7 + 5 + read-write + + + IA0S + desc IA0S + 11 + 11 + read-write + + + IB0S + desc IB0S + 12 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + FLTR + desc FLTR + 0x1C + 32 + read-write + 0x0 + 0xF0000077 + + + FLTA0 + desc FLTA0 + 2 + 0 + read-write + + + FLTB0 + desc FLTB0 + 6 + 4 + read-write + + + FLTET + desc FLTET + 30 + 28 + read-write + + + ETP + desc ETP + 31 + 31 + read-write + + + + + CR0 + desc CR0 + 0x24 + 32 + read-write + 0x3000 + 0x100 + + + CIEA + desc CIEA + 8 + 8 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR0A + desc CCR0A + 0x3C + 32 + read-write + 0x0 + 0xFFFF + + + CCR0A + desc CCR0A + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TIM2_MODE23 + desc TIM2_MODE23 + 0x40000E00 + TIM2_MODE0 + + 0x0 + 0x44 + + + + ARR + desc ARR + 0x0 + 32 + read-write + 0x0 + 0xFFFF + + + ARR + desc ARR + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + M23CR + desc M23CR + 0xC + 32 + read-write + 0x600008 + 0xFFFFFFF + + + CTEN + desc CTEN + 0 + 0 + read-write + + + COMP + desc COMP + 1 + 1 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + PWM2S + desc PWM2S + 3 + 3 + read-write + + + PRS + desc PRS + 6 + 4 + read-write + + + BUFPEN + desc BUFPEN + 7 + 7 + read-write + + + CRG + desc CRG + 8 + 8 + read-write + + + CFG + desc CFG + 9 + 9 + read-write + + + UIE + desc UIE + 10 + 10 + read-write + + + UDE + desc UDE + 11 + 11 + read-write + + + MODE + desc MODE + 13 + 12 + read-write + + + ONESHOT + desc ONESHOT + 14 + 14 + read-write + + + CSG + desc CSG + 15 + 15 + read-write + + + OCCS + desc OCCS + 16 + 16 + read-write + + + URS + desc URS + 17 + 17 + read-write + + + TDE + desc TDE + 18 + 18 + read-write + + + TIE + desc TIE + 19 + 19 + read-write + + + BIE + desc BIE + 20 + 20 + read-write + + + CIS + desc CIS + 22 + 21 + read-write + + + OCCE + desc OCCE + 23 + 23 + read-write + + + TG + desc TG + 24 + 24 + write-only + + + UG + desc UG + 25 + 25 + write-only + + + BG + desc BG + 26 + 26 + write-only + + + DIR + desc DIR + 27 + 27 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0xC925 + + + UIF + desc UIF + 0 + 0 + read-only + + + CA0F + desc CA0F + 2 + 2 + read-only + + + CB0F + desc CB0F + 5 + 5 + read-only + + + CA0E + desc CA0E + 8 + 8 + read-only + + + CB0E + desc CB0E + 11 + 11 + read-only + + + BIF + desc BIF + 14 + 14 + read-only + + + TIF + desc TIF + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFF + 0xC925 + + + UIF + desc UIF + 0 + 0 + write-only + + + CA0F + desc CA0F + 2 + 2 + write-only + + + CB0F + desc CB0F + 5 + 5 + write-only + + + CA0E + desc CA0E + 8 + 8 + write-only + + + CB0E + desc CB0E + 11 + 11 + write-only + + + BIF + desc BIF + 14 + 14 + write-only + + + TIF + desc TIF + 15 + 15 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + MSCR + desc MSCR + 0x18 + 32 + read-write + 0x0 + 0x1FFF + + + MMS + desc MMS + 2 + 0 + read-write + + + CCDS + desc CCDS + 3 + 3 + read-write + + + MSM + desc MSM + 4 + 4 + read-write + + + TS + desc TS + 7 + 5 + read-write + + + SMS + desc SMS + 10 + 8 + read-write + + + IA0S + desc IA0S + 11 + 11 + read-write + + + IB0S + desc IB0S + 12 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + FLTR + desc FLTR + 0x1C + 32 + read-write + 0x0 + 0xFFFFFFFF + + + OCMA0_FLTA0 + desc OCMA0_FLTA0 + 2 + 0 + read-write + + + CCPA0 + desc CCPA0 + 3 + 3 + read-write + + + OCMB0_FLTB0 + desc OCMB0_FLTB0 + 6 + 4 + read-write + + + CCPB0 + desc CCPB0 + 7 + 7 + read-write + + + FLTBK + desc FLTBK + 26 + 24 + read-write + + + BKP + desc BKP + 27 + 27 + read-write + + + FLTET + desc FLTET + 30 + 28 + read-write + + + ETP + desc ETP + 31 + 31 + read-write + + + + + ADTR + desc ADTR + 0x20 + 32 + read-write + 0x0 + 0x93 + + + UEVE + desc UEVE + 0 + 0 + read-write + + + CMA0E + desc CMA0E + 1 + 1 + read-write + + + CMB0E + desc CMB0E + 4 + 4 + read-write + + + ADTE + desc ADTE + 7 + 7 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CRCH0 + desc CRCH0 + 0x24 + 32 + read-write + 0x3000 + 0xFFFF + + + CFA_CRA_BKSA + desc CFA_CRA_BKSA + 1 + 0 + read-write + + + CFB_CRB_BKSB + desc CFB_CRB_BKSB + 3 + 2 + read-write + + + CSA + desc CSA + 4 + 4 + read-write + + + CSB + desc CSB + 5 + 5 + read-write + + + BUFEA + desc BUFEA + 6 + 6 + read-write + + + BUFEB + desc BUFEB + 7 + 7 + read-write + + + CIEA + desc CIEA + 8 + 8 + read-write + + + CIEB + desc CIEB + 9 + 9 + read-write + + + CDEA + desc CDEA + 10 + 10 + read-write + + + CDEB + desc CDEB + 11 + 11 + read-write + + + CISB + desc CISB + 13 + 12 + read-write + + + CCGA + desc CCGA + 14 + 14 + read-write + + + CCGB + desc CCGB + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DTR + desc DTR + 0x30 + 32 + read-write + 0x0 + 0xFFFF + + + DTR + desc DTR + 7 + 0 + read-write + + + BKSEL + desc BKSEL + 8 + 8 + read-write + + + DTEN + desc DTEN + 9 + 9 + read-write + + + BKE + desc BKE + 10 + 10 + read-write + + + AOE + desc AOE + 11 + 11 + read-write + + + MOE + desc MOE + 12 + 12 + read-write + + + SAFEEN + desc SAFEEN + 13 + 13 + read-write + + + VCE + desc VCE + 14 + 14 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + RCR + desc RCR + 0x34 + 32 + read-write + 0x0 + 0xFF + + + RCR + desc RCR + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ARRDM + desc ARRDM + 0x38 + 32 + read-write + 0x0 + 0xFFFF + + + ARRDM + desc ARRDM + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR0A + desc CCR0A + 0x3C + 32 + read-write + 0x0 + 0xFFFF + + + CCR0A + desc CCR0A + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR0B + desc CCR0B + 0x40 + 32 + read-write + 0x0 + 0xFFFF + + + CCR0B + desc CCR0B + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TIM3_MODE0 + desc TIM3_MODE0 + 0x40005800 + + 0x0 + 0x34 + + + + ARR + desc ARR + 0x0 + 32 + read-write + 0x0 + 0xFFFF + + + ARR + desc ARR + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT32 + desc CNT32 + 0x8 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + CNT32 + desc CNT32 + 31 + 0 + read-write + + + + + M0CR + desc M0CR + 0xC + 32 + read-write + 0x600008 + 0x377F + + + CTEN + desc CTEN + 0 + 0 + read-write + + + MD + desc MD + 1 + 1 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + TOGEN + desc TOGEN + 3 + 3 + read-write + + + PRS + desc PRS + 6 + 4 + read-write + + + GATE + desc GATE + 8 + 8 + read-write + + + GATEP + desc GATEP + 9 + 9 + read-write + + + UIE + desc UIE + 10 + 10 + read-write + + + MODE + desc MODE + 13 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0x1 + + + UIF + desc UIF + 0 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFF + 0x1 + + + UIF + desc UIF + 0 + 0 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DTR + desc DTR + 0x30 + 32 + read-write + 0x0 + 0x1000 + + + MOE + desc MOE + 12 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TIM3_MODE1 + desc TIM3_MODE1 + 0x40005800 + TIM3_MODE0 + + 0x0 + 0x40 + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + M1CR + desc M1CR + 0xC + 32 + read-write + 0x600008 + 0x7775 + + + CTEN + desc CTEN + 0 + 0 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + PRS + desc PRS + 6 + 4 + read-write + + + EDG1ST + desc EDG1ST + 8 + 8 + read-write + + + EDG2ND + desc EDG2ND + 9 + 9 + read-write + + + UIE + desc UIE + 10 + 10 + read-write + + + MODE + desc MODE + 13 + 12 + read-write + + + ONESHOT + desc ONESHOT + 14 + 14 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0x5 + + + UIF + desc UIF + 0 + 0 + read-only + + + CA0F + desc CA0F + 2 + 2 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFF + 0x5 + + + UIF + desc UIF + 0 + 0 + write-only + + + CA0F + desc CA0F + 2 + 2 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + MSCR + desc MSCR + 0x18 + 32 + read-write + 0x0 + 0x18E0 + + + TS + desc TS + 7 + 5 + read-write + + + IA0S + desc IA0S + 11 + 11 + read-write + + + IB0S + desc IB0S + 12 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + FLTR + desc FLTR + 0x1C + 32 + read-write + 0x0 + 0xF0000077 + + + FLTA0 + desc FLTA0 + 2 + 0 + read-write + + + FLTB0 + desc FLTB0 + 6 + 4 + read-write + + + FLTET + desc FLTET + 30 + 28 + read-write + + + ETP + desc ETP + 31 + 31 + read-write + + + + + CR0 + desc CR0 + 0x24 + 32 + read-write + 0x3000 + 0x100 + + + CIEA + desc CIEA + 8 + 8 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR0A + desc CCR0A + 0x3C + 32 + read-write + 0x0 + 0xFFFF + + + CCR0A + desc CCR0A + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TIM3_MODE23 + desc TIM3_MODE23 + 0x40005800 + TIM3_MODE0 + + 0x0 + 0x54 + + + + ARR + desc ARR + 0x0 + 32 + read-write + 0x0 + 0xFFFF + + + ARR + desc ARR + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + M23CR + desc M23CR + 0xC + 32 + read-write + 0x600008 + 0xFFFFFFF + + + CTEN + desc CTEN + 0 + 0 + read-write + + + COMP + desc COMP + 1 + 1 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + PWM2S + desc PWM2S + 3 + 3 + read-write + + + PRS + desc PRS + 6 + 4 + read-write + + + BUFPEN + desc BUFPEN + 7 + 7 + read-write + + + CRG + desc CRG + 8 + 8 + read-write + + + CFG + desc CFG + 9 + 9 + read-write + + + UIE + desc UIE + 10 + 10 + read-write + + + UDE + desc UDE + 11 + 11 + read-write + + + MODE + desc MODE + 13 + 12 + read-write + + + ONESHOT + desc ONESHOT + 14 + 14 + read-write + + + CSG + desc CSG + 15 + 15 + read-write + + + OCCS + desc OCCS + 16 + 16 + read-write + + + URS + desc URS + 17 + 17 + read-write + + + TDE + desc TDE + 18 + 18 + read-write + + + TIE + desc TIE + 19 + 19 + read-write + + + BIE + desc BIE + 20 + 20 + read-write + + + CIS + desc CIS + 22 + 21 + read-write + + + OCCE + desc OCCE + 23 + 23 + read-write + + + TG + desc TG + 24 + 24 + write-only + + + UG + desc UG + 25 + 25 + write-only + + + BG + desc BG + 26 + 26 + write-only + + + DIR + desc DIR + 27 + 27 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0xFFFD + + + UIF + desc UIF + 0 + 0 + read-only + + + CA0F + desc CA0F + 2 + 2 + read-only + + + CA1F + desc CA1F + 3 + 3 + read-only + + + CA2F + desc CA2F + 4 + 4 + read-only + + + CB0F + desc CB0F + 5 + 5 + read-only + + + CB1F + desc CB1F + 6 + 6 + read-only + + + CB2F + desc CB2F + 7 + 7 + read-only + + + CA0E + desc CA0E + 8 + 8 + read-only + + + CA1E + desc CA1E + 9 + 9 + read-only + + + CA2E + desc CA2E + 10 + 10 + read-only + + + CB0E + desc CB0E + 11 + 11 + read-only + + + CB1E + desc CB1E + 12 + 12 + read-only + + + CB2E + desc CB2E + 13 + 13 + read-only + + + BIF + desc BIF + 14 + 14 + read-only + + + TIF + desc TIF + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFF + 0xFFFD + + + UIF + desc UIF + 0 + 0 + write-only + + + CA0F + desc CA0F + 2 + 2 + write-only + + + CA1F + desc CA1F + 3 + 3 + write-only + + + CA2F + desc CA2F + 4 + 4 + write-only + + + CB0F + desc CB0F + 5 + 5 + write-only + + + CB1F + desc CB1F + 6 + 6 + write-only + + + CB2F + desc CB2F + 7 + 7 + write-only + + + CA0E + desc CA0E + 8 + 8 + write-only + + + CA1E + desc CA1E + 9 + 9 + write-only + + + CA2E + desc CA2E + 10 + 10 + write-only + + + CB0E + desc CB0E + 11 + 11 + write-only + + + CB1E + desc CB1E + 12 + 12 + write-only + + + CB2E + desc CB2E + 13 + 13 + write-only + + + BIF + desc BIF + 14 + 14 + write-only + + + TIF + desc TIF + 15 + 15 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + MSCR + desc MSCR + 0x18 + 32 + read-write + 0x0 + 0x1FFF + + + MMS + desc MMS + 2 + 0 + read-write + + + CCDS + desc CCDS + 3 + 3 + read-write + + + MSM + desc MSM + 4 + 4 + read-write + + + TS + desc TS + 7 + 5 + read-write + + + SMS + desc SMS + 10 + 8 + read-write + + + IA0S + desc IA0S + 11 + 11 + read-write + + + IB0S + desc IB0S + 12 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + FLTR + desc FLTR + 0x1C + 32 + read-write + 0x0 + 0xFFFFFFFF + + + OCMA0_FLTA0 + desc OCMA0_FLTA0 + 2 + 0 + read-write + + + CCPA0 + desc CCPA0 + 3 + 3 + read-write + + + OCMB0_FLTB0 + desc OCMB0_FLTB0 + 6 + 4 + read-write + + + CCPB0 + desc CCPB0 + 7 + 7 + read-write + + + OCMA1_FLTA1 + desc OCMA1_FLTA1 + 10 + 8 + read-write + + + CCPA1 + desc CCPA1 + 11 + 11 + read-write + + + OCMB1_FLTB1 + desc OCMB1_FLTB1 + 14 + 12 + read-write + + + CCPB1 + desc CCPB1 + 15 + 15 + read-write + + + OCMA2_FLTA2 + desc OCMA2_FLTA2 + 18 + 16 + read-write + + + CCPA2 + desc CCPA2 + 19 + 19 + read-write + + + OCMB2_FLTB2 + desc OCMB2_FLTB2 + 22 + 20 + read-write + + + CCPB2 + desc CCPB2 + 23 + 23 + read-write + + + FLTBK + desc FLTBK + 26 + 24 + read-write + + + BKP + desc BKP + 27 + 27 + read-write + + + FLTET + desc FLTET + 30 + 28 + read-write + + + ETP + desc ETP + 31 + 31 + read-write + + + + + ADTR + desc ADTR + 0x20 + 32 + read-write + 0x0 + 0xFF + + + UEVE + desc UEVE + 0 + 0 + read-write + + + CMA0E + desc CMA0E + 1 + 1 + read-write + + + CMA1E + desc CMA1E + 2 + 2 + read-write + + + CMA2E + desc CMA2E + 3 + 3 + read-write + + + CMB0E + desc CMB0E + 4 + 4 + read-write + + + CMB1E + desc CMB1E + 5 + 5 + read-write + + + CMB2E + desc CMB2E + 6 + 6 + read-write + + + ADTE + desc ADTE + 7 + 7 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CRCH0 + desc CRCH0 + 0x24 + 32 + read-write + 0x3000 + 0xFFFF + + + CFA_CRA_BKSA + desc CFA_CRA_BKSA + 1 + 0 + read-write + + + CFB_CRB_BKSB + desc CFB_CRB_BKSB + 3 + 2 + read-write + + + CSA + desc CSA + 4 + 4 + read-write + + + CSB + desc CSB + 5 + 5 + read-write + + + BUFEA + desc BUFEA + 6 + 6 + read-write + + + BUFEB + desc BUFEB + 7 + 7 + read-write + + + CIEA + desc CIEA + 8 + 8 + read-write + + + CIEB + desc CIEB + 9 + 9 + read-write + + + CDEA + desc CDEA + 10 + 10 + read-write + + + CDEB + desc CDEB + 11 + 11 + read-write + + + CISB + desc CISB + 13 + 12 + read-write + + + CCGA + desc CCGA + 14 + 14 + read-write + + + CCGB + desc CCGB + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CRCH1 + desc CRCH1 + 0x28 + 32 + read-write + 0x3000 + 0xFFFF + + + CFA_CRA_BKSA + desc CFA_CRA_BKSA + 1 + 0 + read-write + + + CFB_CRB_BKSB + desc CFB_CRB_BKSB + 3 + 2 + read-write + + + CSA + desc CSA + 4 + 4 + read-write + + + CSB + desc CSB + 5 + 5 + read-write + + + BUFEA + desc BUFEA + 6 + 6 + read-write + + + BUFEB + desc BUFEB + 7 + 7 + read-write + + + CIEA + desc CIEA + 8 + 8 + read-write + + + CIEB + desc CIEB + 9 + 9 + read-write + + + CDEA + desc CDEA + 10 + 10 + read-write + + + CDEB + desc CDEB + 11 + 11 + read-write + + + CISB + desc CISB + 13 + 12 + read-write + + + CCGA + desc CCGA + 14 + 14 + read-write + + + CCGB + desc CCGB + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CRCH2 + desc CRCH2 + 0x2C + 32 + read-write + 0x3000 + 0xFFFF + + + CFA_CRA_BKSA + desc CFA_CRA_BKSA + 1 + 0 + read-write + + + CFB_CRB_BKSB + desc CFB_CRB_BKSB + 3 + 2 + read-write + + + CSA + desc CSA + 4 + 4 + read-write + + + CSB + desc CSB + 5 + 5 + read-write + + + BUFEA + desc BUFEA + 6 + 6 + read-write + + + BUFEB + desc BUFEB + 7 + 7 + read-write + + + CIEA + desc CIEA + 8 + 8 + read-write + + + CIEB + desc CIEB + 9 + 9 + read-write + + + CDEA + desc CDEA + 10 + 10 + read-write + + + CDEB + desc CDEB + 11 + 11 + read-write + + + CISB + desc CISB + 13 + 12 + read-write + + + CCGA + desc CCGA + 14 + 14 + read-write + + + CCGB + desc CCGB + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DTR + desc DTR + 0x30 + 32 + read-write + 0x0 + 0xFFFF + + + DTR + desc DTR + 7 + 0 + read-write + + + BKSEL + desc BKSEL + 8 + 8 + read-write + + + DTEN + desc DTEN + 9 + 9 + read-write + + + BKE + desc BKE + 10 + 10 + read-write + + + AOE + desc AOE + 11 + 11 + read-write + + + MOE + desc MOE + 12 + 12 + read-write + + + SAFEEN + desc SAFEEN + 13 + 13 + read-write + + + VCE + desc VCE + 14 + 14 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + RCR + desc RCR + 0x34 + 32 + read-write + 0x0 + 0xFF + + + RCR + desc RCR + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ARRDM + desc ARRDM + 0x38 + 32 + read-write + 0x0 + 0xFFFF + + + ARRDM + desc ARRDM + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR0A + desc CCR0A + 0x3C + 32 + read-write + 0x0 + 0xFFFF + + + CCR0A + desc CCR0A + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR0B + desc CCR0B + 0x40 + 32 + read-write + 0x0 + 0xFFFF + + + CCR0B + desc CCR0B + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR1A + desc CCR1A + 0x44 + 32 + read-write + 0x0 + 0xFFFF + + + CCR1A + desc CCR1A + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR1B + desc CCR1B + 0x48 + 32 + read-write + 0x0 + 0xFFFF + + + CCR1B + desc CCR1B + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR2A + desc CCR2A + 0x4C + 32 + read-write + 0x0 + 0xFFFF + + + CCR2A + desc CCR2A + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCR2B + desc CCR2B + 0x50 + 32 + read-write + 0x0 + 0xFFFF + + + CCR2B + desc CCR2B + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TRNG + desc TRNG + 0x40004C00 + + 0x0 + 0x14 + + + + CR + desc CR + 0x0 + 32 + read-write + 0x0 + 0x3 + + + RNGCIR_EN + desc RNGCIR_EN + 0 + 0 + read-write + + + RNG_RUN + desc RNG_RUN + 1 + 1 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + MODE + desc MODE + 0x4 + 32 + read-write + 0x10 + 0x1F + + + LOAD + desc LOAD + 0 + 0 + read-write + + + FDBK + desc FDBK + 1 + 1 + read-write + + + CNT + desc CNT + 4 + 2 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DATA0 + desc DATA0 + 0xC + 32 + read-only + 0x0 + 0xFFFFFFFF + + + DATA0 + desc DATA0 + 31 + 0 + read-only + + + + + DATA1 + desc DATA1 + 0x10 + 32 + read-only + 0x0 + 0xFFFFFFFF + + + DATA1 + desc DATA1 + 31 + 0 + read-only + + + + + + + UART0 + desc UART + 0x40000000 + + 0x0 + 0x1C + + + + SBUF + desc SBUF + 0x0 + 32 + read-write + 0x0 + 0x1FF + + + DATA + desc DATA + 7 + 0 + read-write + + + DATA8 + desc DATA8 + 8 + 8 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SCON + desc SCON + 0x4 + 32 + read-write + 0x0 + 0x7FE3FF + + + RCIE + desc RCIE + 0 + 0 + read-write + + + TCIE + desc TCIE + 1 + 1 + read-write + + + B8CONT + desc B8CONT + 3 + 2 + read-write + + + REN + desc REN + 4 + 4 + read-write + + + ADRDET + desc ADRDET + 5 + 5 + read-write + + + SM + desc SM + 7 + 6 + read-write + + + TXEIE + desc TXEIE + 8 + 8 + read-write + + + OVER + desc OVER + 9 + 9 + read-write + + + PEIE + desc PEIE + 13 + 13 + read-write + + + STOPBIT + desc STOPBIT + 15 + 14 + read-write + + + DMARXEN + desc DMARXEN + 16 + 16 + read-write + + + DMATXEN + desc DMATXEN + 17 + 17 + read-write + + + RTSEN + desc RTSEN + 18 + 18 + read-write + + + CTSEN + desc CTSEN + 19 + 19 + read-write + + + CTSIE + desc CTSIE + 20 + 20 + read-write + + + FEIE + desc FEIE + 21 + 21 + read-write + + + HDSEL + desc HDSEL + 22 + 22 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SADDR + desc SADDR + 0x8 + 32 + read-write + 0x0 + 0xFF + + + SADDR + desc SADDR + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SADEN + desc SADEN + 0xC + 32 + read-write + 0x0 + 0xFF + + + SADEN + desc SADEN + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ISR + desc ISR + 0x10 + 32 + read-only + 0x8 + 0x7F + + + RC + desc RC + 0 + 0 + read-only + + + TC + desc TC + 1 + 1 + read-only + + + FE + desc FE + 2 + 2 + read-only + + + TXE + desc TXE + 3 + 3 + read-only + + + PE + desc PE + 4 + 4 + read-only + + + CTSIF + desc CTSIF + 5 + 5 + read-only + + + CTS + desc CTS + 6 + 6 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICR + desc ICR + 0x14 + 32 + write-only + 0x0 + 0x37 + + + RCCF + desc RCCF + 0 + 0 + write-only + + + TCCF + desc TCCF + 1 + 1 + write-only + + + FECF + desc FECF + 2 + 2 + write-only + + + PECF + desc PECF + 4 + 4 + write-only + + + CTSIFCF + desc CTSIFCF + 5 + 5 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SCNT + desc SCNT + 0x18 + 32 + read-write + 0x0 + 0xFFFF + + + SCNT + desc SCNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + UART1 + desc UART + 0x40000100 + + 0x0 + 0x1C + + + + UART2 + desc UART + 0x40006000 + + 0x0 + 0x1C + + + + UART3 + desc UART + 0x40006400 + + 0x0 + 0x1C + + + + VC + desc VC + 0x40002400 + ADC + + 0x0 + 0x158 + + + + CR + desc CR + 0x10 + 32 + read-write + 0x20 + 0xFFFFF + + + DIV + desc DIV + 5 + 0 + read-write + + + DIV_EN + desc DIV_EN + 6 + 6 + read-write + + + REF2P5_SEL + desc REF2P5_SEL + 7 + 7 + read-write + + + VC0_BIAS_SEL + desc VC0_BIAS_SEL + 9 + 8 + read-write + + + VC0_HYS_SEL + desc VC0_HYS_SEL + 11 + 10 + read-write + + + VC1_BIAS_SEL + desc VC1_BIAS_SEL + 13 + 12 + read-write + + + VC1_HYS_SEL + desc VC1_HYS_SEL + 15 + 14 + read-write + + + VC2_BIAS_SEL + desc VC2_BIAS_SEL + 17 + 16 + read-write + + + VC2_HYS_SEL + desc VC2_HYS_SEL + 19 + 18 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + VC0_CR + desc VC0_CR + 0x14 + 32 + read-write + 0x0 + 0x1FFFF + + + P_SEL + desc P_SEL + 3 + 0 + read-write + + + N_SEL + desc N_SEL + 7 + 4 + read-write + + + FLTEN + desc FLTEN + 8 + 8 + read-write + + + DEBOUNCE_TIME + desc DEBOUNCE_TIME + 11 + 9 + read-write + + + FALLING + desc FALLING + 12 + 12 + read-write + + + RISING + desc RISING + 13 + 13 + read-write + + + LEVEL + desc LEVEL + 14 + 14 + read-write + + + IE + desc IE + 15 + 15 + read-write + + + EN + desc EN + 16 + 16 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + VC1_CR + desc VC1_CR + 0x18 + 32 + read-write + 0x0 + 0x1FFFF + + + P_SEL + desc P_SEL + 3 + 0 + read-write + + + N_SEL + desc N_SEL + 7 + 4 + read-write + + + FLTEN + desc FLTEN + 8 + 8 + read-write + + + DEBOUNCE_TIME + desc DEBOUNCE_TIME + 11 + 9 + read-write + + + FALLING + desc FALLING + 12 + 12 + read-write + + + RISING + desc RISING + 13 + 13 + read-write + + + LEVEL + desc LEVEL + 14 + 14 + read-write + + + IE + desc IE + 15 + 15 + read-write + + + EN + desc EN + 16 + 16 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + VC0_OUT_CFG + desc VC0_OUT_CFG + 0x1C + 32 + read-write + 0x0 + 0xFE3F + + + INV_TIMER + desc INV_TIMER + 0 + 0 + read-write + + + TIM0RCLR + desc TIM0RCLR + 1 + 1 + read-write + + + TIM1RCLR + desc TIM1RCLR + 2 + 2 + read-write + + + TIM2RCLR + desc TIM2RCLR + 3 + 3 + read-write + + + TIM3RCLR + desc TIM3RCLR + 4 + 4 + read-write + + + TIMBK + desc TIMBK + 5 + 5 + read-write + + + INV_TIM4 + desc INV_TIM4 + 9 + 9 + read-write + + + TIM4 + desc TIM4 + 10 + 10 + read-write + + + INV_TIM5 + desc INV_TIM5 + 11 + 11 + read-write + + + TIM5 + desc TIM5 + 12 + 12 + read-write + + + INV_TIM6 + desc INV_TIM6 + 13 + 13 + read-write + + + TIM6 + desc TIM6 + 14 + 14 + read-write + + + BRAKE + desc BRAKE + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + VC1_OUT_CFG + desc VC1_OUT_CFG + 0x20 + 32 + read-write + 0x0 + 0xFEFF + + + INV_TIMER + desc INV_TIMER + 0 + 0 + read-write + + + TIM0RCLR + desc TIM0RCLR + 1 + 1 + read-write + + + TIM1RCLR + desc TIM1RCLR + 2 + 2 + read-write + + + TIM2RCLR + desc TIM2RCLR + 3 + 3 + read-write + + + TIM3RCLR + desc TIM3RCLR + 4 + 4 + read-write + + + TIMBK + desc TIMBK + 5 + 5 + read-write + + + INV_TIM4 + desc INV_TIM4 + 9 + 9 + read-write + + + TIM4 + desc TIM4 + 10 + 10 + read-write + + + INV_TIM5 + desc INV_TIM5 + 11 + 11 + read-write + + + TIM5 + desc TIM5 + 12 + 12 + read-write + + + INV_TIM6 + desc INV_TIM6 + 13 + 13 + read-write + + + TIM6 + desc TIM6 + 14 + 14 + read-write + + + BRAKE + desc BRAKE + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x24 + 32 + read-write + 0x0 + 0x3F + + + VC0_INTF + desc VC0_INTF + 0 + 0 + read-write + + + VC1_INTF + desc VC1_INTF + 1 + 1 + read-write + + + VC0_FILTER + desc VC0_FILTER + 2 + 2 + read-only + + + VC1_FILTER + desc VC1_FILTER + 3 + 3 + read-only + + + VC2_INTF + desc VC2_INTF + 4 + 4 + read-write + + + VC2_FILTER + desc VC2_FILTER + 5 + 5 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + VC2_CR + desc VC2_CR + 0x150 + 32 + read-write + 0x0 + 0x1FFFF + + + P_SEL + desc P_SEL + 3 + 0 + read-write + + + N_SEL + desc N_SEL + 7 + 4 + read-write + + + FLTEN + desc FLTEN + 8 + 8 + read-write + + + DEBOUNCE_TIME + desc DEBOUNCE_TIME + 11 + 9 + read-write + + + FALLING + desc FALLING + 12 + 12 + read-write + + + RISING + desc RISING + 13 + 13 + read-write + + + LEVEL + desc LEVEL + 14 + 14 + read-write + + + IE + desc IE + 15 + 15 + read-write + + + EN + desc EN + 16 + 16 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + VC2_OUT_CFG + desc VC2_OUT_CFG + 0x154 + 32 + read-write + 0x0 + 0xFEFF + + + INV_TIMER + desc INV_TIMER + 0 + 0 + read-write + + + TIM0RCLR + desc TIM0RCLR + 1 + 1 + read-write + + + TIM1RCLR + desc TIM1RCLR + 2 + 2 + read-write + + + TIM2RCLR + desc TIM2RCLR + 3 + 3 + read-write + + + TIM3RCLR + desc TIM3RCLR + 4 + 4 + read-write + + + TIMBK + desc TIMBK + 5 + 5 + read-write + + + INV_TIM4 + desc INV_TIM4 + 9 + 9 + read-write + + + TIM4 + desc TIM4 + 10 + 10 + read-write + + + INV_TIM5 + desc INV_TIM5 + 11 + 11 + read-write + + + TIM5 + desc TIM5 + 12 + 12 + read-write + + + INV_TIM6 + desc INV_TIM6 + 13 + 13 + read-write + + + TIM6 + desc TIM6 + 14 + 14 + read-write + + + BRAKE + desc BRAKE + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + WDT + desc WDT + 0x40000F00 + LPTIMER0 + + 0x0 + 0x88 + + + + RST + desc RST + 0x80 + 32 + write-only + 0x0 + 0xFF + + + RST + desc RST + 7 + 0 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CON + desc CON + 0x84 + 32 + read-write + 0xF + 0xFFBF + + + WOV + desc WOV + 3 + 0 + read-write + + + R + desc R + 4 + 4 + read-only + + + WINT_EN + desc WINT_EN + 5 + 5 + read-write + + + INT + desc INT + 7 + 7 + read-only + + + WCNTL + desc WCNTL + 15 + 8 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + diff --git a/mcu/EWARM/config/flashloader/FlashHC32L17X.flash b/mcu/EWARM/config/flashloader/FlashHC32L17X.flash new file mode 100644 index 0000000..74ef3c3 --- /dev/null +++ b/mcu/EWARM/config/flashloader/FlashHC32L17X.flash @@ -0,0 +1,10 @@ + + + + $PROJ_DIR$\config\flashloader\FlashHC32L17X.out + 1 + 256 0x200 + 0x00000000 + $PROJ_DIR$\config\flashloader\FlashHC32L17X.mac + 0 + diff --git a/mcu/EWARM/config/flashloader/FlashHC32L17X.mac b/mcu/EWARM/config/flashloader/FlashHC32L17X.mac new file mode 100644 index 0000000..b321dac --- /dev/null +++ b/mcu/EWARM/config/flashloader/FlashHC32L17X.mac @@ -0,0 +1,23 @@ +setup() +{ + __message "----- setup hardware for Flashloader -----\n"; + /*Wait*/ + __delay(5); + __emulatorSpeed(0); + + /*Vectors at RAM*/ + __writeMemory32(0x20000000, 0xE000ED08, "Memory"); +} + +execUserPreload() +{ + __message "----- execUserPreload -----\n"; + setup(); +} + +execUserFlashInit() // Called by debugger before loading flash loader in RAM. +{ + __message "----- execUserFlashInit -----\n"; + setup(); +} + diff --git a/mcu/EWARM/config/flashloader/HC32L17X.board b/mcu/EWARM/config/flashloader/HC32L17X.board new file mode 100644 index 0000000..792e0b8 --- /dev/null +++ b/mcu/EWARM/config/flashloader/HC32L17X.board @@ -0,0 +1,8 @@ + + + + + $PROJ_DIR$\config\flashloader\FlashHC32L17X.flash + CODE 0x00000000 0x0001FFFF + + diff --git a/mcu/EWARM/config/hc32l17x_ram.icf b/mcu/EWARM/config/hc32l17x_ram.icf new file mode 100644 index 0000000..82d0b02 --- /dev/null +++ b/mcu/EWARM/config/hc32l17x_ram.icf @@ -0,0 +1,29 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x20000000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_ROM_start__ = 0x20000000; +define symbol __ICFEDIT_region_ROM_end__ = 0x20001FFF; +define symbol __ICFEDIT_region_RAM_start__ = 0x20002000; +define symbol __ICFEDIT_region_RAM_end__ = 0x20003FFF; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x200; +define symbol __ICFEDIT_size_heap__ = 0x200; +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__]; +define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; + +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + +initialize by copy { readwrite }; +do not initialize { section .noinit }; + +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; + +place in ROM_region { readonly }; +place in RAM_region { readwrite, block CSTACK, block HEAP }; \ No newline at end of file diff --git a/mcu/EWARM/config/reset.mac b/mcu/EWARM/config/reset.mac new file mode 100644 index 0000000..8604cd0 --- /dev/null +++ b/mcu/EWARM/config/reset.mac @@ -0,0 +1,8 @@ +execUserReset() +{ + __message("Executing __hwReset"); + __hwReset(0); + __message("__hwReset done"); + + __hwResetWithStrategy(0, 2); +} diff --git a/mcu/MDK/HC32L17X.sfr b/mcu/MDK/HC32L17X.sfr new file mode 100644 index 0000000000000000000000000000000000000000..ec519254564080c25aa100d04ae212a5a5d95138 GIT binary patch literal 804549 zcmcef378~BmH4YFukN{TL2+kxMOIxLr+ZFz|10z{!}L-!U3T>#Dmo~LqM$C|fve2O zjUXT*hk&3WDuN&gA}ELVJ$T>9q2hsx;sJ{E|Gjt-nJ>ihk8bU5n0V%)uRijbqoeHuH;#5kwr(6*IoKXpd%*Ie4n5@G zmNgy)y7&WdV@FH=qw%dHcYPuL|1W-AF99yD(QJHkr?8;8jVne)18-_iK+_f{>o+%& z)>B?EeAv;;R=jZ8#B-NDZJ%W;-mq%LiWP&aR;+sZvO`{a)WOTvZ(i1TbKlVD$kvgG z6^$(2y|E7(M*U@thS0NZ+qT*51dO<(7-{b}I<`Nk{tr}r)UuV!mk)Z?lkl>}u|?KM zvyx+CW@gQ1qIzd})=HXLA}?Y0EX`&o`LXlr6okL;Pn!J?PEAdrR#cg_(xlk;wTJEh z;=>y=lcJfFyri#xb~{nRX`?NU9n=+RcKB%&>;pyZI11pv<-^*(S5REfI zzh;86YaTmSn0h#1f|AEfpsq+WLDt?ME_87^yai40R1sRJ zq-fa8bLLbk!PNV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}nepzT8ga6M4D`eJ@d`+1|xCT-I>cEy#gCJFQI>a<>-K&PXQ<)7}U_^p2kd zWExU9TJ;-D0>A#KkPXZ6;v5x>u8fM`#i-y&Tce^+9D0=Xr{-XwNPbNFrNk8OrGmWA z_iYhx3rUFgA)QyB54j zv*-ydborafEGEf*n>5RwM*}`~#wez2A9#~y(JT0X@GR5r;1a!a*DVH28~nXs(je(v z0N)cFETfpRY49e^qDibyzHI35&6Lf9=Gd9Vdp&*B;N^|zp2df +#include +#include +#include +#include + + +/*****************************************************************************/ +/* Global pre-processor symbols/macros ('#define') */ +/*****************************************************************************/ +#ifndef TRUE + /** Value is true (boolean_t type) */ + #define TRUE ((boolean_t) 1u) +#endif + +#ifndef FALSE + /** Value is false (boolean_t type) */ + #define FALSE ((boolean_t) 0u) +#endif + +/** Returns the minimum value out of two values */ +#define MINIMUM( X, Y ) ((X) < (Y) ? (X) : (Y)) + +/** Returns the maximum value out of two values */ +#define MAXIMUM( X, Y ) ((X) > (Y) ? (X) : (Y)) + +/** Returns the dimension of an array */ +#define ARRAY_SZ( X ) (sizeof(X) / sizeof((X)[0])) + +#ifdef __DEBUG_ASSERT + #define ASSERT(x) do{ assert((x)> 0u) ; }while(0); +#else + #define ASSERT(x) {} +#endif +/****************************************************************************** + * Global type definitions + ******************************************************************************/ + +/** logical datatype (only values are TRUE and FALSE) */ +typedef uint8_t boolean_t; + +/** single precision floating point number (4 byte) */ +typedef float float32_t; + +/** double precision floating point number (8 byte) */ +typedef double float64_t; + +/** ASCII character for string generation (8 bit) */ +typedef char char_t; + +/** function pointer type to void/void function */ +typedef void (*func_ptr_t)(void); + +/** function pointer type to void/uint8_t function */ +typedef void (*func_ptr_arg1_t)(uint8_t u8Param); + +/** generic error codes */ +typedef enum en_result +{ + Ok = 0u, ///< No error + Error = 1u, ///< Non-specific error code + ErrorAddressAlignment = 2u, ///< Address alignment does not match + ErrorAccessRights = 3u, ///< Wrong mode (e.g. user/system) mode is set + ErrorInvalidParameter = 4u, ///< Provided parameter is not valid + ErrorOperationInProgress = 5u, ///< A conflicting or requested operation is still in progress + ErrorInvalidMode = 6u, ///< Operation not allowed in current mode + ErrorUninitialized = 7u, ///< Module (or part of it) was not initialized properly + ErrorBufferFull = 8u, ///< Circular buffer can not be written because the buffer is full + ErrorTimeout = 9u, ///< Time Out error occurred (e.g. I2C arbitration lost, Flash time-out, etc.) + ErrorNotReady = 10u, ///< A requested final state is not reached + OperationInProgress = 11u ///< Indicator for operation in progress +} en_result_t; + + +/*****************************************************************************/ +/* Global variable declarations ('extern', definition in C source) */ +/*****************************************************************************/ + +/*****************************************************************************/ +/* Global function prototypes ('extern', definition in C source) */ +/*****************************************************************************/ + +#endif /* __BASE_TYPES_H__ */ + +/******************************************************************************/ +/* EOF (not truncated) */ +/******************************************************************************/ + + + diff --git a/mcu/common/board_stkhc32l17x.h b/mcu/common/board_stkhc32l17x.h new file mode 100644 index 0000000..1ed42e7 --- /dev/null +++ b/mcu/common/board_stkhc32l17x.h @@ -0,0 +1,130 @@ +/****************************************************************************** +* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file stkhc32l17x.h + ** + ** stk board common define. + ** @link SampleGroup Some description @endlink + ** + ** - 2018-03-09 1.0 Lux First version. + ** + ******************************************************************************/ +#ifndef __BOARD_STKHC32L17X_H__ +#define __BOARD_STKHC32L17X_H__ + +///< STK GPIO DEFINE +///< USER KEY +#define STK_USER_PORT GpioPortA +#define STK_USER_PIN GpioPin7 + +///< LED +#define STK_LED_PORT GpioPortD +#define STK_LED_PIN GpioPin14 + +///< XTH +#define SYSTEM_XTH (8*1000*1000u) ///< 32MHz + +#define STK_XTHI_PORT GpioPortF +#define STK_XTHI_PIN GpioPin0 +#define STK_XTHO_PORT GpioPortF +#define STK_XTHO_PIN GpioPin1 + +///< XTL +#define SYSTEM_XTL (32768u) ///< 32768Hz +#define STK_XTLI_PORT GpioPortC +#define STK_XTLI_PIN GpioPin14 +#define STK_XTLO_PORT GpioPortC +#define STK_XTLO_PIN GpioPin15 + +///< LCD +#define STK_LCD_COM0_PORT GpioPortA +#define STK_LCD_COM0_PIN GpioPin9 +#define STK_LCD_COM1_PORT GpioPortA +#define STK_LCD_COM1_PIN GpioPin10 +#define STK_LCD_COM2_PORT GpioPortA +#define STK_LCD_COM2_PIN GpioPin11 +#define STK_LCD_COM3_PORT GpioPortA +#define STK_LCD_COM3_PIN GpioPin12 +#define STK_LCD_SEG0_PORT GpioPortA +#define STK_LCD_SEG0_PIN GpioPin8 +#define STK_LCD_SEG1_PORT GpioPortC +#define STK_LCD_SEG1_PIN GpioPin9 +#define STK_LCD_SEG2_PORT GpioPortC +#define STK_LCD_SEG2_PIN GpioPin8 +#define STK_LCD_SEG3_PORT GpioPortC +#define STK_LCD_SEG3_PIN GpioPin7 +#define STK_LCD_SEG4_PORT GpioPortC +#define STK_LCD_SEG4_PIN GpioPin6 +#define STK_LCD_SEG5_PORT GpioPortB +#define STK_LCD_SEG5_PIN GpioPin15 +#define STK_LCD_SEG6_PORT GpioPortB +#define STK_LCD_SEG6_PIN GpioPin14 +#define STK_LCD_SEG7_PORT GpioPortB +#define STK_LCD_SEG7_PIN GpioPin13 + +///< I2C EEPROM +#define EVB_I2C0_EEPROM_SCL_PORT GpioPortB +#define EVB_I2C0_EEPROM_SCL_PIN GpioPin6 +#define EVB_I2C0_EEPROM_SDA_PORT GpioPortB +#define EVB_I2C0_EEPROM_SDA_PIN GpioPin7 + +///< SPI0 +#define STK_SPI0_CS_PORT GpioPortE +#define STK_SPI0_CS_PIN GpioPin12 +#define STK_SPI0_SCK_PORT GpioPortE +#define STK_SPI0_SCK_PIN GpioPin13 +#define STK_SPI0_MISO_PORT GpioPortE +#define STK_SPI0_MISO_PIN GpioPin14 +#define STK_SPI0_MOSI_PORT GpioPortE +#define STK_SPI0_MOSI_PIN GpioPin15 + +///< SPI1 +#define STK_SPI1_CS_PORT GpioPortB +#define STK_SPI1_CS_PIN GpioPin12 +#define STK_SPI1_SCK_PORT GpioPortB +#define STK_SPI1_SCK_PIN GpioPin13 +#define STK_SPI1_MISO_PORT GpioPortB +#define STK_SPI1_MISO_PIN GpioPin14 +#define STK_SPI1_MOSI_PORT GpioPortB +#define STK_SPI1_MOSI_PIN GpioPin15 + +#endif diff --git a/mcu/common/hc32l17x.h b/mcu/common/hc32l17x.h new file mode 100644 index 0000000..d871b73 --- /dev/null +++ b/mcu/common/hc32l17x.h @@ -0,0 +1,10833 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \\file HC32L17X.h +** +** Auto generate. +** Headerfile for HC32L17X series MCU +** +** History: +** +** - 2019-07-01 0.1 Lux First version. +** +******************************************************************************/ + +#ifndef __HC32L17X_H__ +#define __HC32L17X_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************** +* Configuration of the Cortex-M0P Processor and Core Peripherals +******************************************************************************/ +#define __MPU_PRESENT 0 /* No MPU */ +#define __NVIC_PRIO_BITS 2 /* M0P uses 2 Bits for the Priority Levels */ +#define __Vendor_SysTickConfig 0 /* Set to 1 if different SysTick Config is used */ + +/****************************************************************************** +* Interrupt Number Definition +******************************************************************************/ +typedef enum IRQn +{ + NMI_IRQn = -14, /* 2 Non Maskable */ + HardFault_IRQn = -13, /* 3 Hard Fault */ + SVC_IRQn = -5, /* 11 SV Call */ + PendSV_IRQn = -2, /* 14 Pend SV */ + SysTick_IRQn = -1, /* 15 System Tick */ + + PORTA_IRQn = 0 , + PORTB_IRQn = 1 , + PORTC_E_IRQn = 2 , + PORTD_F_IRQn = 3 , + DMAC_IRQn = 4 , + TIM3_IRQn = 5 , + UART0_2_IRQn = 6 , + UART1_3_IRQn = 7 , + LPUART0_IRQn = 8 , + LPUART1_IRQn = 9 , + SPI0_IRQn = 10, + SPI1_IRQn = 11, + I2C0_IRQn = 12, + I2C1_IRQn = 13, + TIM0_IRQn = 14, + TIM1_IRQn = 15, + TIM2_IRQn = 16, + LPTIM_0_1_IRQn = 17, + ADTIM4_IRQn = 18, + ADTIM5_IRQn = 19, + ADTIM6_IRQn = 20, + PCA_IRQn = 21, + WDT_IRQn = 22, + RTC_IRQn = 23, + ADC_DAC_IRQn = 24, + PCNT_IRQn = 25, + VC0_IRQn = 26, + VC1_2_IRQn = 27, + LVD_IRQn = 28, + LCD_IRQn = 29, + FLASH_RAM_IRQn = 30, + CLKTRIM_IRQn = 31, + + +} IRQn_Type; + + +#include +#include + +#define SUCCESS (0) +#define ERROR (-1) + +#ifndef NULL +#define NULL (0) +#endif + + +/******************************************************************************/ +/* Device Specific Peripheral Registers structures */ +/******************************************************************************/ + +#if defined ( __CC_ARM ) +#pragma anon_unions +#endif + +typedef struct +{ + __IO uint32_t EN : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CLKDIV : 2; + __IO uint32_t SGLMUX : 5; + __IO uint32_t REF : 2; + __IO uint32_t BUF : 1; + __IO uint32_t SAM : 2; + __IO uint32_t INREFEN : 1; + __IO uint32_t IE : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adc_cr0_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 2; + __IO uint32_t ALIGN : 1; + __IO uint32_t THCH : 5; + __IO uint32_t DMASQR : 1; + __IO uint32_t DMAJQR : 1; + __IO uint32_t MODE : 1; + __IO uint32_t RACCEN : 1; + __IO uint32_t LTCMP : 1; + __IO uint32_t HTCMP : 1; + __IO uint32_t REGCMP : 1; + __IO uint32_t RACCCLR : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adc_cr1_field_t; + +typedef struct +{ + __IO uint32_t CH0MUX : 5; + __IO uint32_t CH1MUX : 5; + __IO uint32_t CH2MUX : 5; + __IO uint32_t CH3MUX : 5; + __IO uint32_t CH4MUX : 5; + __IO uint32_t CH5MUX : 5; + uint32_t RESERVED30 : 1; + __IO uint32_t RSV : 1; +} stc_adc_sqr0_field_t; + +typedef struct +{ + __IO uint32_t CH6MUX : 5; + __IO uint32_t CH7MUX : 5; + __IO uint32_t CH8MUX : 5; + __IO uint32_t CH9MUX : 5; + __IO uint32_t CH10MUX : 5; + __IO uint32_t CH11MUX : 5; + uint32_t RESERVED30 : 1; + __IO uint32_t RSV : 1; +} stc_adc_sqr1_field_t; + +typedef struct +{ + __IO uint32_t CH12MUX : 5; + __IO uint32_t CH13MUX : 5; + __IO uint32_t CH14MUX : 5; + __IO uint32_t CH15MUX : 5; + __IO uint32_t CNT : 4; + uint32_t RESERVED24 : 7; + __IO uint32_t RSV : 1; +} stc_adc_sqr2_field_t; + +typedef struct +{ + __IO uint32_t CH0MUX : 5; + __IO uint32_t CH1MUX : 5; + __IO uint32_t CH2MUX : 5; + __IO uint32_t CH3MUX : 5; + __IO uint32_t CNT : 2; + uint32_t RESERVED22 : 9; + __IO uint32_t RSV : 1; +} stc_adc_jqr_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult0_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult1_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult2_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult3_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult4_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult5_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult6_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult7_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult8_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult9_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult10_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult11_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult12_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqr_result13_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult14_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_sqrresult15_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_jqrresult0_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_jqrresult1_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_jqrresult2_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_jqrresult3_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_result_field_t; + +typedef struct +{ + __IO uint32_t RESULTACC :20; + uint32_t RESERVED20 :11; + __IO uint32_t RSV : 1; +} stc_adc_resultacc_field_t; + +typedef struct +{ + __IO uint32_t HT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_ht_field_t; + +typedef struct +{ + __IO uint32_t LT :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_adc_lt_field_t; + +typedef struct +{ + __IO uint32_t SGLIF : 1; + __IO uint32_t LTIF : 1; + __IO uint32_t HTIF : 1; + __IO uint32_t REGIF : 1; + __IO uint32_t SQRIF : 1; + __IO uint32_t JQRIF : 1; + uint32_t RESERVED6 :25; + __IO uint32_t RSV : 1; +} stc_adc_ifr_field_t; + +typedef struct +{ + __IO uint32_t SGLIC : 1; + __IO uint32_t LTIC : 1; + __IO uint32_t HTIC : 1; + __IO uint32_t REGIC : 1; + __IO uint32_t SQRIC : 1; + __IO uint32_t JQRIC : 1; + uint32_t RESERVED6 :25; + __IO uint32_t RSV : 1; +} stc_adc_icr_field_t; + +typedef struct +{ + __IO uint32_t TIM0 : 1; + __IO uint32_t TIM1 : 1; + __IO uint32_t TIM2 : 1; + __IO uint32_t TIM3 : 1; + __IO uint32_t TIM4 : 1; + __IO uint32_t TIM5 : 1; + __IO uint32_t TIM6 : 1; + __IO uint32_t UART0 : 1; + __IO uint32_t UART1 : 1; + __IO uint32_t LPUART0 : 1; + __IO uint32_t LPUART1 : 1; + __IO uint32_t VC0 : 1; + __IO uint32_t VC1 : 1; + __IO uint32_t RTC : 1; + __IO uint32_t PCA : 1; + __IO uint32_t SPI0 : 1; + __IO uint32_t SPI1 : 1; + __IO uint32_t DMA : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PA15 : 1; + __IO uint32_t PB15 : 1; + __IO uint32_t PC15 : 1; +} stc_adc_exttrigger0_field_t; + +typedef struct +{ + __IO uint32_t TIM0 : 1; + __IO uint32_t TIM1 : 1; + __IO uint32_t TIM2 : 1; + __IO uint32_t TIM3 : 1; + __IO uint32_t TIM4 : 1; + __IO uint32_t TIM5 : 1; + __IO uint32_t TIM6 : 1; + __IO uint32_t UART0 : 1; + __IO uint32_t UART1 : 1; + __IO uint32_t LPUART0 : 1; + __IO uint32_t LPUART1 : 1; + __IO uint32_t VC0 : 1; + __IO uint32_t VC1 : 1; + __IO uint32_t RTC : 1; + __IO uint32_t PCA : 1; + __IO uint32_t SPI0 : 1; + __IO uint32_t SPI1 : 1; + __IO uint32_t DMA : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PA15 : 1; + __IO uint32_t PB15 : 1; + __IO uint32_t PC15 : 1; +} stc_adc_exttrigger1_field_t; + +typedef struct +{ + __IO uint32_t START : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_adc_sglstart_field_t; + +typedef struct +{ + __IO uint32_t START : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_adc_sqrstart_field_t; + +typedef struct +{ + __IO uint32_t START : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_adc_jqrstart_field_t; + +typedef struct +{ + __IO uint32_t START : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_adc_allstart_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_cnter_field_t; + +typedef struct +{ + __IO uint32_t PERA :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_perar_field_t; + +typedef struct +{ + __IO uint32_t PERB :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_perbr_field_t; + +typedef struct +{ + __IO uint32_t GCMA :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_gcmar_field_t; + +typedef struct +{ + __IO uint32_t GCMB :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_gcmbr_field_t; + +typedef struct +{ + __IO uint32_t GCMC :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_gcmcr_field_t; + +typedef struct +{ + __IO uint32_t GCMD :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_gcmdr_field_t; + +typedef struct +{ + __IO uint32_t SCMA :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_scmar_field_t; + +typedef struct +{ + __IO uint32_t SCMB :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_scmbr_field_t; + +typedef struct +{ + __IO uint32_t DTUA :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_dtuar_field_t; + +typedef struct +{ + __IO uint32_t DTDA :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_dtdar_field_t; + +typedef struct +{ + __IO uint32_t START : 1; + __IO uint32_t MODE : 3; + __IO uint32_t CKDIV : 3; + uint32_t RESERVED7 : 1; + __IO uint32_t DIR : 1; + uint32_t RESERVED9 : 7; + __IO uint32_t ZMSKREV : 1; + __IO uint32_t ZMSKPOS : 1; + __IO uint32_t ZMSK : 2; + uint32_t RESERVED20 :11; + __IO uint32_t RSV : 1; +} stc_adtim_gconr_field_t; + +typedef struct +{ + __IO uint32_t INTENA : 1; + __IO uint32_t INTENB : 1; + __IO uint32_t INTENC : 1; + __IO uint32_t INTEND : 1; + uint32_t RESERVED4 : 2; + __IO uint32_t INTENOVF : 1; + __IO uint32_t INTENUDF : 1; + __IO uint32_t INTENDE : 1; + uint32_t RESERVED9 : 5; + __IO uint32_t INTENSAML : 1; + __IO uint32_t INTENSAMH : 1; + __IO uint32_t INTENSAU : 1; + __IO uint32_t INTENSAD : 1; + __IO uint32_t INTENSBU : 1; + __IO uint32_t INTENSBD : 1; + uint32_t RESERVED20 :11; + __IO uint32_t RSV : 1; +} stc_adtim_iconr_field_t; + +typedef struct +{ + __IO uint32_t CAPCA : 1; + __IO uint32_t STACA : 1; + __IO uint32_t STPCA : 1; + __IO uint32_t STASTPSA : 1; + __IO uint32_t CMPCA : 2; + __IO uint32_t PERCA : 2; + __IO uint32_t OUTENA : 1; + __IO uint32_t DISSELA : 2; + __IO uint32_t DISVALA : 2; + uint32_t RESERVED13 : 3; + __IO uint32_t CAPCB : 1; + __IO uint32_t STACB : 1; + __IO uint32_t STPCB : 1; + __IO uint32_t STASTPSB : 1; + __IO uint32_t CMPCB : 2; + __IO uint32_t PERCB : 2; + __IO uint32_t OUTENB : 1; + __IO uint32_t DISSELB : 2; + __IO uint32_t DISVALB : 2; + uint32_t RESERVED29 : 2; + __IO uint32_t RSV : 1; +} stc_adtim_pconr_field_t; + +typedef struct +{ + __IO uint32_t BENA : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t BENB : 1; + uint32_t RESERVED3 : 5; + __IO uint32_t BENP : 1; + uint32_t RESERVED9 :22; + __IO uint32_t RSV : 1; +} stc_adtim_bconr_field_t; + +typedef struct +{ + __IO uint32_t DTCEN : 1; + uint32_t RESERVED1 : 7; + __IO uint32_t SEPA : 1; + uint32_t RESERVED9 :22; + __IO uint32_t RSV : 1; +} stc_adtim_dconr_field_t; + +typedef struct +{ + __IO uint32_t NOFIENGA : 1; + __IO uint32_t NOFICKGA : 2; + uint32_t RESERVED3 : 1; + __IO uint32_t NOFIENGB : 1; + __IO uint32_t NOFICKGB : 2; + uint32_t RESERVED7 : 9; + __IO uint32_t NOFIENTA : 1; + __IO uint32_t NOFICKTA : 2; + uint32_t RESERVED19 : 1; + __IO uint32_t NOFIENTB : 1; + __IO uint32_t NOFICKTB : 2; + uint32_t RESERVED23 : 1; + __IO uint32_t NOFIENTC : 1; + __IO uint32_t NOFICKTC : 2; + uint32_t RESERVED27 : 1; + __IO uint32_t NOFIENTD : 1; + __IO uint32_t NOFICKTD : 2; + __IO uint32_t RSV : 1; +} stc_adtim_fconr_field_t; + +typedef struct +{ + __IO uint32_t GEPERIA : 1; + __IO uint32_t GEPERIB : 1; + __IO uint32_t GEPERIC : 1; + __IO uint32_t GEPERID : 1; + uint32_t RESERVED4 :12; + __IO uint32_t PCNTE : 2; + __IO uint32_t PCNTS : 3; + uint32_t RESERVED21 :10; + __IO uint32_t RSV : 1; +} stc_adtim_vperr_field_t; + +typedef struct +{ + __IO uint32_t CMAF : 1; + __IO uint32_t CMBF : 1; + __IO uint32_t CMCF : 1; + __IO uint32_t CMDF : 1; + uint32_t RESERVED4 : 2; + __IO uint32_t OVFF : 1; + __IO uint32_t UDFF : 1; + __IO uint32_t DTEF : 1; + __IO uint32_t CMSAUF : 1; + __IO uint32_t CMSADF : 1; + __IO uint32_t CMSBUF : 1; + __IO uint32_t CMSBDF : 1; + uint32_t RESERVED13 : 8; + __IO uint32_t VPERNUM : 3; + uint32_t RESERVED24 : 7; + __IO uint32_t DIRF : 1; +} stc_adtim_stflr_field_t; + +typedef struct +{ + __IO uint32_t HSTA0 : 1; + __IO uint32_t HSTA1 : 1; + __IO uint32_t HSTA2 : 1; + __IO uint32_t HSTA3 : 1; + __IO uint32_t HSTA4 : 1; + __IO uint32_t HSTA5 : 1; + __IO uint32_t HSTA6 : 1; + __IO uint32_t HSTA7 : 1; + __IO uint32_t HSTA8 : 1; + __IO uint32_t HSTA9 : 1; + __IO uint32_t HSTA10 : 1; + __IO uint32_t HSTA11 : 1; + __IO uint32_t HSTA12 : 1; + __IO uint32_t HSTA13 : 1; + __IO uint32_t HSTA14 : 1; + __IO uint32_t HSTA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t STARTS : 1; +} stc_adtim_hstar_field_t; + +typedef struct +{ + __IO uint32_t HSTP0 : 1; + __IO uint32_t HSTP1 : 1; + __IO uint32_t HSTP2 : 1; + __IO uint32_t HSTP3 : 1; + __IO uint32_t HSTP4 : 1; + __IO uint32_t HSTP5 : 1; + __IO uint32_t HSTP6 : 1; + __IO uint32_t HSTP7 : 1; + __IO uint32_t HSTP8 : 1; + __IO uint32_t HSTP9 : 1; + __IO uint32_t HSTP10 : 1; + __IO uint32_t HSTP11 : 1; + __IO uint32_t HSTP12 : 1; + __IO uint32_t HSTP13 : 1; + __IO uint32_t HSTP14 : 1; + __IO uint32_t HSTP15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t STOPS : 1; +} stc_adtim_hstpr_field_t; + +typedef struct +{ + __IO uint32_t HCEL0 : 1; + __IO uint32_t HCEL1 : 1; + __IO uint32_t HCEL2 : 1; + __IO uint32_t HCEL3 : 1; + __IO uint32_t HCEL4 : 1; + __IO uint32_t HCEL5 : 1; + __IO uint32_t HCEL6 : 1; + __IO uint32_t HCEL7 : 1; + __IO uint32_t HCEL8 : 1; + __IO uint32_t HCEL9 : 1; + __IO uint32_t HCEL10 : 1; + __IO uint32_t HCEL11 : 1; + __IO uint32_t HCEL12 : 1; + __IO uint32_t HCEL13 : 1; + __IO uint32_t HCEL14 : 1; + __IO uint32_t HCEL15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t CLEARS : 1; +} stc_adtim_hcelr_field_t; + +typedef struct +{ + __IO uint32_t HCPA0 : 1; + __IO uint32_t HCPA1 : 1; + __IO uint32_t HCPA2 : 1; + __IO uint32_t HCPA3 : 1; + __IO uint32_t HCPA4 : 1; + __IO uint32_t HCPA5 : 1; + __IO uint32_t HCPA6 : 1; + __IO uint32_t HCPA7 : 1; + __IO uint32_t HCPA8 : 1; + __IO uint32_t HCPA9 : 1; + __IO uint32_t HCPA10 : 1; + __IO uint32_t HCPA11 : 1; + __IO uint32_t HCPA12 : 1; + __IO uint32_t HCPA13 : 1; + __IO uint32_t HCPA14 : 1; + __IO uint32_t HCPA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_hcpar_field_t; + +typedef struct +{ + __IO uint32_t HCPB0 : 1; + __IO uint32_t HCPB1 : 1; + __IO uint32_t HCPB2 : 1; + __IO uint32_t HCPB3 : 1; + __IO uint32_t HCPB4 : 1; + __IO uint32_t HCPB5 : 1; + __IO uint32_t HCPB6 : 1; + __IO uint32_t HCPB7 : 1; + __IO uint32_t HCPB8 : 1; + __IO uint32_t HCPB9 : 1; + __IO uint32_t HCPB10 : 1; + __IO uint32_t HCPB11 : 1; + __IO uint32_t HCPB12 : 1; + __IO uint32_t HCPB13 : 1; + __IO uint32_t HCPB14 : 1; + __IO uint32_t HCPB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_hcpbr_field_t; + +typedef struct +{ + __IO uint32_t HCUP0 : 1; + __IO uint32_t HCUP1 : 1; + __IO uint32_t HCUP2 : 1; + __IO uint32_t HCUP3 : 1; + __IO uint32_t HCUP4 : 1; + __IO uint32_t HCUP5 : 1; + __IO uint32_t HCUP6 : 1; + __IO uint32_t HCUP7 : 1; + __IO uint32_t HCUP8 : 1; + __IO uint32_t HCUP9 : 1; + __IO uint32_t HCUP10 : 1; + __IO uint32_t HCUP11 : 1; + __IO uint32_t HCUP12 : 1; + __IO uint32_t HCUP13 : 1; + __IO uint32_t HCUP14 : 1; + __IO uint32_t HCUP15 : 1; + __IO uint32_t HCUP16 : 1; + __IO uint32_t HCUP17 : 1; + __IO uint32_t HCUP18 : 1; + __IO uint32_t HCUP19 : 1; + uint32_t RESERVED20 :11; + __IO uint32_t RSV : 1; +} stc_adtim_hcupr_field_t; + +typedef struct +{ + __IO uint32_t HCDO0 : 1; + __IO uint32_t HCDO1 : 1; + __IO uint32_t HCDO2 : 1; + __IO uint32_t HCDO3 : 1; + __IO uint32_t HCDO4 : 1; + __IO uint32_t HCDO5 : 1; + __IO uint32_t HCDO6 : 1; + __IO uint32_t HCDO7 : 1; + __IO uint32_t HCDO8 : 1; + __IO uint32_t HCDO9 : 1; + __IO uint32_t HCDO10 : 1; + __IO uint32_t HCDO11 : 1; + __IO uint32_t HCDO12 : 1; + __IO uint32_t HCDO13 : 1; + __IO uint32_t HCDO14 : 1; + __IO uint32_t HCDO15 : 1; + __IO uint32_t HCDO16 : 1; + __IO uint32_t HCDO17 : 1; + __IO uint32_t HCDO18 : 1; + __IO uint32_t HCDO19 : 1; + uint32_t RESERVED20 :11; + __IO uint32_t RSV : 1; +} stc_adtim_hcdor_field_t; + +typedef struct +{ + __IO uint32_t CMAF : 1; + __IO uint32_t CMBF : 1; + __IO uint32_t CMCF : 1; + __IO uint32_t CMDF : 1; + uint32_t RESERVED4 : 2; + __IO uint32_t OVFF : 1; + __IO uint32_t UDFF : 1; + __IO uint32_t DTEF : 1; + uint32_t RESERVED9 : 5; + __IO uint32_t SAMLF : 1; + __IO uint32_t SAMHF : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_ifr_field_t; + +typedef struct +{ + __IO uint32_t CMAC : 1; + __IO uint32_t CMBC : 1; + __IO uint32_t CMCC : 1; + __IO uint32_t CMDC : 1; + uint32_t RESERVED4 : 2; + __IO uint32_t OVFC : 1; + __IO uint32_t UDFC : 1; + __IO uint32_t DTEC : 1; + uint32_t RESERVED9 : 5; + __IO uint32_t SAMLC : 1; + __IO uint32_t SAMHC : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_iclr_field_t; + +typedef struct +{ + __IO uint32_t CMAE : 1; + __IO uint32_t CMBE : 1; + __IO uint32_t CMCE : 1; + __IO uint32_t CMDE : 1; + uint32_t RESERVED4 : 2; + __IO uint32_t OVFE : 1; + __IO uint32_t UDFE : 1; + __IO uint32_t DITENA : 1; + __IO uint32_t DITENB : 1; + __IO uint32_t DITENS : 1; + __IO uint32_t CMSAE : 1; + __IO uint32_t CMSBE : 1; + __IO uint32_t DMA_G_CMA : 1; + __IO uint32_t DMA_G_CMB : 1; + __IO uint32_t DMA_G_CMC : 1; + __IO uint32_t DMA_G_CMD : 1; + uint32_t RESERVED17 : 2; + __IO uint32_t DMA_G_OVF : 1; + __IO uint32_t DMA_G_UDF : 1; + __IO uint32_t DMA_S_CMA : 1; + __IO uint32_t DMA_S_CMB : 1; + uint32_t RESERVED23 : 8; + __IO uint32_t RSV : 1; +} stc_adtim_cr_field_t; + +typedef struct +{ + __IO uint32_t FBRAKE : 1; + __IO uint32_t FSAME : 1; + __IO uint32_t BFILTS : 2; + __IO uint32_t BFILTEN : 1; + uint32_t RESERVED5 : 2; + __IO uint32_t SOFTBK : 1; + __IO uint32_t SML0 : 1; + __IO uint32_t SML1 : 1; + __IO uint32_t SML2 : 1; + __IO uint32_t SMH0 : 1; + __IO uint32_t SMH1 : 1; + __IO uint32_t SMH2 : 1; + uint32_t RESERVED14 :17; + __IO uint32_t RSV : 1; +} stc_adtim_aossr_field_t; + +typedef struct +{ + __IO uint32_t FBRAKE : 1; + __IO uint32_t FSAME : 1; + uint32_t RESERVED2 :29; + __IO uint32_t RSV : 1; +} stc_adtim_aoscl_field_t; + +typedef struct +{ + __IO uint32_t EN0 : 1; + __IO uint32_t EN1 : 1; + __IO uint32_t EN2 : 1; + __IO uint32_t EN3 : 1; + __IO uint32_t EN4 : 1; + __IO uint32_t EN5 : 1; + __IO uint32_t EN6 : 1; + __IO uint32_t EN7 : 1; + __IO uint32_t EN8 : 1; + __IO uint32_t EN9 : 1; + __IO uint32_t EN10 : 1; + __IO uint32_t EN11 : 1; + __IO uint32_t EN12 : 1; + __IO uint32_t EN13 : 1; + __IO uint32_t EN14 : 1; + __IO uint32_t EN15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_ptbks_field_t; + +typedef struct +{ + __IO uint32_t TRIGAS : 4; + __IO uint32_t TRIGBS : 4; + __IO uint32_t TRIGCS : 4; + __IO uint32_t TRIGDS : 4; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_ttrig_field_t; + +typedef struct +{ + __IO uint32_t IAOS0S : 4; + __IO uint32_t IAOS1S : 4; + __IO uint32_t IAOS2S : 4; + __IO uint32_t IAOS3S : 4; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_itrig_field_t; + +typedef struct +{ + __IO uint32_t POL0 : 1; + __IO uint32_t POL1 : 1; + __IO uint32_t POL2 : 1; + __IO uint32_t POL3 : 1; + __IO uint32_t POL4 : 1; + __IO uint32_t POL5 : 1; + __IO uint32_t POL6 : 1; + __IO uint32_t POL7 : 1; + __IO uint32_t POL8 : 1; + __IO uint32_t POL9 : 1; + __IO uint32_t POL10 : 1; + __IO uint32_t POL11 : 1; + __IO uint32_t POL12 : 1; + __IO uint32_t POL13 : 1; + __IO uint32_t POL14 : 1; + __IO uint32_t POL15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_ptbkp_field_t; + +typedef struct +{ + __IO uint32_t SSTA0 : 1; + __IO uint32_t SSTA1 : 1; + __IO uint32_t SSTA2 : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_adtim_sstar_field_t; + +typedef struct +{ + __IO uint32_t SSTP0 : 1; + __IO uint32_t SSTP1 : 1; + __IO uint32_t SSTP2 : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_adtim_sstpr_field_t; + +typedef struct +{ + __IO uint32_t SCLR0 : 1; + __IO uint32_t SCLR1 : 1; + __IO uint32_t SCLR2 : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_adtim_sclrr_field_t; + +typedef struct +{ + __IO uint32_t START : 1; + __IO uint32_t MODE : 1; + uint32_t RESERVED2 : 1; + __IO uint32_t KEYSIZE : 2; + uint32_t RESERVED5 :26; + __IO uint32_t RSV : 1; +} stc_aes_cr_field_t; + +typedef struct +{ + __IO uint32_t DATA0 :32; +} stc_aes_data0_field_t; + +typedef struct +{ + __IO uint32_t DATA0 :32; +} stc_aes_data1_field_t; + +typedef struct +{ + __IO uint32_t DATA0 :32; +} stc_aes_data2_field_t; + +typedef struct +{ + __IO uint32_t DATA0 :32; +} stc_aes_data3_field_t; + +typedef struct +{ + __IO uint32_t KEY0 :32; +} stc_aes_key0_field_t; + +typedef struct +{ + __IO uint32_t KEY0 :32; +} stc_aes_key1_field_t; + +typedef struct +{ + __IO uint32_t KEY0 :32; +} stc_aes_key2_field_t; + +typedef struct +{ + __IO uint32_t KEY0 :32; +} stc_aes_key3_field_t; + +typedef struct +{ + __IO uint32_t KEY0 :32; +} stc_aes_key4_field_t; + +typedef struct +{ + __IO uint32_t KEY0 :32; +} stc_aes_key5_field_t; + +typedef struct +{ + __IO uint32_t KEY0 :32; +} stc_aes_key6_field_t; + +typedef struct +{ + __IO uint32_t KEY0 :32; +} stc_aes_key7_field_t; + +typedef struct +{ + __IO uint32_t BGR_EN : 1; + __IO uint32_t TS_EN : 1; + uint32_t RESERVED2 :29; + __IO uint32_t RSV : 1; +} stc_bgr_cr_field_t; + +typedef struct +{ + __IO uint32_t TRIM_START : 1; + __IO uint32_t REFCLK_SEL : 3; + __IO uint32_t CALCLK_SEL : 2; + __IO uint32_t MON_EN : 1; + __IO uint32_t IE : 1; + __IO uint32_t CALCLK_SEL2 : 1; + uint32_t RESERVED9 :22; + __IO uint32_t RSV : 1; +} stc_clk_trim_cr_field_t; + +typedef struct +{ + __IO uint32_t RCNTVAL :32; +} stc_clk_trim_refcon_field_t; + +typedef struct +{ + __IO uint32_t REFCNT :32; +} stc_clk_trim_refcnt_field_t; + +typedef struct +{ + __IO uint32_t CALCNT :32; +} stc_clk_trim_calcnt_field_t; + +typedef struct +{ + __IO uint32_t STOP : 1; + __IO uint32_t CALCNT_OF : 1; + __IO uint32_t XTL_FAULT : 1; + __IO uint32_t XTH_FAULT : 1; + __IO uint32_t PLL_FAULT : 1; + uint32_t RESERVED5 :26; + __IO uint32_t RSV : 1; +} stc_clk_trim_ifr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 2; + __IO uint32_t XTL_FAULT_CLR : 1; + __IO uint32_t XTH_FAULT_CLR : 1; + __IO uint32_t PLL_FAULT_CLR : 1; + uint32_t RESERVED5 :26; + __IO uint32_t RSV : 1; +} stc_clk_trim_iclr_field_t; + +typedef struct +{ + __IO uint32_t CCNTVAL :32; +} stc_clk_trim_calcon_field_t; + +typedef struct +{ + __IO uint32_t CR : 1; + __IO uint32_t FLAG : 1; + uint32_t RESERVED2 :29; + __IO uint32_t RSV : 1; +} stc_crc_cr_field_t; + +typedef struct +{ + __IO uint32_t RESULT :32; +} stc_crc_result_field_t; + +typedef struct +{ + __IO uint32_t DATA :32; +} stc_crc_data_field_t; + +typedef struct +{ + __IO uint32_t EN0 : 1; + __IO uint32_t BOFF0 : 1; + __IO uint32_t TEN0 : 1; + __IO uint32_t TSEL0 : 3; + __IO uint32_t WAVE0 : 2; + __IO uint32_t MAMP0 : 4; + __IO uint32_t DMAEN0 : 1; + __IO uint32_t DMAUDRIE0 : 1; + __IO uint32_t SREF0 : 2; +} stc_dac_cr0_field_t; + +typedef struct +{ + __IO uint32_t SWTRIG0 : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_dac_swtrigr_field_t; + +typedef struct +{ + __IO uint32_t DHR0 :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_dac_dhr12r0_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t DHR0 :12; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_dac_dhr12l0_field_t; + +typedef struct +{ + __IO uint32_t DHR0 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_dac_dhr8r0_field_t; + +typedef struct +{ + __IO uint32_t DOR0 :12; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_dac_dor0_field_t; + +typedef struct +{ + uint32_t RESERVED0 :13; + __IO uint32_t DMAUDR0 : 1; + uint32_t RESERVED14 :17; + __IO uint32_t RSV : 1; +} stc_dac_sr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t PTRIGSEL : 3; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_dac_etrs_field_t; + +typedef struct +{ + __IO uint32_t TIM0 : 1; + __IO uint32_t TIM1 : 1; + __IO uint32_t TIM2 : 1; + __IO uint32_t LPTIM0 : 1; + __IO uint32_t TIM4 : 1; + __IO uint32_t TIM5 : 1; + __IO uint32_t TIM6 : 1; + __IO uint32_t PCA : 1; + __IO uint32_t WDT : 1; + __IO uint32_t RTC : 1; + uint32_t RESERVED10 : 1; + __IO uint32_t TIM3 : 1; + __IO uint32_t LPTIM1 : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_debug_active_field_t; + +typedef struct +{ + uint32_t RESERVED0 :24; + __IO uint32_t HALT : 4; + __IO uint32_t PRIO : 1; + uint32_t RESERVED29 : 1; + __IO uint32_t ST : 1; + __IO uint32_t EN : 1; +} stc_dmac_conf_field_t; + +typedef struct +{ + __IO uint32_t TC :16; + __IO uint32_t BC : 4; + uint32_t RESERVED20 : 2; + __IO uint32_t TRI_SEL : 7; + __IO uint32_t ST : 1; + __IO uint32_t PAS : 1; + __IO uint32_t ENS : 1; +} stc_dmac_confa0_field_t; + +typedef struct +{ + __IO uint32_t MSK : 1; + uint32_t RESERVED1 :15; + __IO uint32_t STAT : 3; + __IO uint32_t FIS_IE : 1; + __IO uint32_t ERR_IE : 1; + __IO uint32_t RD : 1; + __IO uint32_t RS : 1; + __IO uint32_t RC : 1; + __IO uint32_t FD : 1; + __IO uint32_t FS : 1; + __IO uint32_t WIDTH : 2; + __IO uint32_t MODE : 2; +} stc_dmac_confb0_field_t; + +typedef struct +{ + __IO uint32_t SRCADR :32; +} stc_dmac_srcadr0_field_t; + +typedef struct +{ + __IO uint32_t DSTADR :32; +} stc_dmac_dstadr0_field_t; + +typedef struct +{ + __IO uint32_t TC :16; + __IO uint32_t BC : 4; + uint32_t RESERVED20 : 2; + __IO uint32_t TRI_SEL : 7; + __IO uint32_t ST : 1; + __IO uint32_t PAS : 1; + __IO uint32_t ENS : 1; +} stc_dmac_confa1_field_t; + +typedef struct +{ + __IO uint32_t MSK : 1; + uint32_t RESERVED1 :15; + __IO uint32_t STAT : 3; + __IO uint32_t FIS_IE : 1; + __IO uint32_t ERR_IE : 1; + __IO uint32_t RD : 1; + __IO uint32_t RS : 1; + __IO uint32_t RC : 1; + __IO uint32_t FD : 1; + __IO uint32_t FS : 1; + __IO uint32_t WIDTH : 2; + __IO uint32_t MODE : 2; +} stc_dmac_confb1_field_t; + +typedef struct +{ + __IO uint32_t SRCADR :32; +} stc_dmac_srcadr1_field_t; + +typedef struct +{ + __IO uint32_t DSTADR :32; +} stc_dmac_dstadr1_field_t; + +typedef struct +{ + __IO uint32_t TNVS : 9; + __IO uint32_t RSV :23; +} stc_flash_tnvs_field_t; + +typedef struct +{ + __IO uint32_t TPGS : 8; + __IO uint32_t RSV :24; +} stc_flash_tpgs_field_t; + +typedef struct +{ + __IO uint32_t TPROG : 9; + __IO uint32_t RSV :23; +} stc_flash_tprog_field_t; + +typedef struct +{ + __IO uint32_t TSERASE :18; + __IO uint32_t RSV :14; +} stc_flash_tserase_field_t; + +typedef struct +{ + __IO uint32_t TMERASE :21; + __IO uint32_t RSV :11; +} stc_flash_tmerase_field_t; + +typedef struct +{ + __IO uint32_t TPRCV :12; + __IO uint32_t RSV :20; +} stc_flash_tprcv_field_t; + +typedef struct +{ + __IO uint32_t TSRCV :12; + __IO uint32_t RSV :20; +} stc_flash_tsrcv_field_t; + +typedef struct +{ + __IO uint32_t TMRCV :14; + __IO uint32_t RSV :18; +} stc_flash_tmrcv_field_t; + +typedef struct +{ + __IO uint32_t OP : 2; + __IO uint32_t WAIT : 2; + __IO uint32_t BUSY : 1; + __IO uint32_t IE : 2; + uint32_t RESERVED7 : 2; + __IO uint32_t DPSTB_EN : 1; + __IO uint32_t RSV :22; +} stc_flash_cr_field_t; + +typedef struct +{ + __IO uint32_t IF0 : 1; + __IO uint32_t IF1 : 1; + __IO uint32_t RSV :30; +} stc_flash_ifr_field_t; + +typedef struct +{ + __IO uint32_t ICLR0 : 1; + __IO uint32_t ICLR1 : 1; + __IO uint32_t RSV :30; +} stc_flash_iclr_field_t; + +typedef struct +{ + __IO uint32_t BYSEQ :16; + __IO uint32_t RSV :16; +} stc_flash_bypass_field_t; + +typedef struct +{ + __IO uint32_t SLOCK :32; +} stc_flash_slock0_field_t; + +typedef struct +{ + __IO uint32_t SLOCK :32; +} stc_flash_slock1_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa00_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa01_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa02_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa03_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa04_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa05_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa06_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa07_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa08_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa09_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa10_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa11_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa12_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa13_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa14_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pa15_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb00_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb01_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb02_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb03_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb04_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb05_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb06_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb07_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb08_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb09_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb10_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb11_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb12_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb13_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb14_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pb15_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc00_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc01_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc02_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc03_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc04_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc05_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc06_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc07_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc08_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc09_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc10_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc11_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc12_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc13_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc14_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pc15_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd00_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd01_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd02_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd03_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd04_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd05_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd06_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd07_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd08_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd09_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd10_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd11_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd12_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd13_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd14_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pd15_sel_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_padir_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pain_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_paout_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_paads_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pabset_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pabclr_field_t; + +typedef struct +{ + __IO uint32_t PABCLR :16; + __IO uint32_t PABSET :16; +} stc_gpio_pabsetclr_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_padr_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_papu_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_papd_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_paod_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pahie_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_palie_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_parie_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pafie_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pbdir_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pbin_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pbout_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pbads_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pbbset_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pbbclr_field_t; + +typedef struct +{ + __IO uint32_t PBBCLR :16; + __IO uint32_t PBBSET :16; +} stc_gpio_pbbsetclr_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pbdr_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pbpu_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pbpd_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pbod_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pbhie_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pblie_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pbrie_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pbfie_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pcdir_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pcin_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pcout_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pcads_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pcbset_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pcbclr_field_t; + +typedef struct +{ + __IO uint32_t PCBCLR :16; + __IO uint32_t PCBSET :16; +} stc_gpio_pcbsetclr_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pcdr_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pcpu_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pcpd_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pcod_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pchie_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pclie_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pcrie_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pcfie_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pddir_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pdin_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pdout_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pdads_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pdbset_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pdbclr_field_t; + +typedef struct +{ + __IO uint32_t PDBCLR :16; + __IO uint32_t PDBSET :16; +} stc_gpio_pdbsetclr_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pddr_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pdpu_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pdpd_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pdod_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pdhie_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pdlie_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pdrie_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pdfie_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pa_stat_field_t; + +typedef struct +{ + __IO uint32_t PA00 : 1; + __IO uint32_t PA01 : 1; + __IO uint32_t PA02 : 1; + __IO uint32_t PA03 : 1; + __IO uint32_t PA04 : 1; + __IO uint32_t PA05 : 1; + __IO uint32_t PA06 : 1; + __IO uint32_t PA07 : 1; + __IO uint32_t PA08 : 1; + __IO uint32_t PA09 : 1; + __IO uint32_t PA10 : 1; + __IO uint32_t PA11 : 1; + __IO uint32_t PA12 : 1; + __IO uint32_t PA13 : 1; + __IO uint32_t PA14 : 1; + __IO uint32_t PA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pa_iclr_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pb_stat_field_t; + +typedef struct +{ + __IO uint32_t PB00 : 1; + __IO uint32_t PB01 : 1; + __IO uint32_t PB02 : 1; + __IO uint32_t PB03 : 1; + __IO uint32_t PB04 : 1; + __IO uint32_t PB05 : 1; + __IO uint32_t PB06 : 1; + __IO uint32_t PB07 : 1; + __IO uint32_t PB08 : 1; + __IO uint32_t PB09 : 1; + __IO uint32_t PB10 : 1; + __IO uint32_t PB11 : 1; + __IO uint32_t PB12 : 1; + __IO uint32_t PB13 : 1; + __IO uint32_t PB14 : 1; + __IO uint32_t PB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pb_iclr_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pc_stat_field_t; + +typedef struct +{ + __IO uint32_t PC00 : 1; + __IO uint32_t PC01 : 1; + __IO uint32_t PC02 : 1; + __IO uint32_t PC03 : 1; + __IO uint32_t PC04 : 1; + __IO uint32_t PC05 : 1; + __IO uint32_t PC06 : 1; + __IO uint32_t PC07 : 1; + __IO uint32_t PC08 : 1; + __IO uint32_t PC09 : 1; + __IO uint32_t PC10 : 1; + __IO uint32_t PC11 : 1; + __IO uint32_t PC12 : 1; + __IO uint32_t PC13 : 1; + __IO uint32_t PC14 : 1; + __IO uint32_t PC15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pc_iclr_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pd_stat_field_t; + +typedef struct +{ + __IO uint32_t PD00 : 1; + __IO uint32_t PD01 : 1; + __IO uint32_t PD02 : 1; + __IO uint32_t PD03 : 1; + __IO uint32_t PD04 : 1; + __IO uint32_t PD05 : 1; + __IO uint32_t PD06 : 1; + __IO uint32_t PD07 : 1; + __IO uint32_t PD08 : 1; + __IO uint32_t PD09 : 1; + __IO uint32_t PD10 : 1; + __IO uint32_t PD11 : 1; + __IO uint32_t PD12 : 1; + __IO uint32_t PD13 : 1; + __IO uint32_t PD14 : 1; + __IO uint32_t PD15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pd_iclr_field_t; + +typedef struct +{ + __IO uint32_t IESEL : 1; +} stc_gpio_ctrl0_field_t; + +typedef struct +{ + __IO uint32_t EXT_CLK_SEL : 4; + __IO uint32_t SSN0_SEL : 4; + __IO uint32_t PCLK_SEL : 2; + __IO uint32_t HCLK_SEL : 2; + __IO uint32_t PCLK_EN : 1; + __IO uint32_t HCLK_EN : 1; + __IO uint32_t IR_POL : 1; + uint32_t RESERVED15 :16; + __IO uint32_t RSV : 1; +} stc_gpio_ctrl1_field_t; + +typedef struct +{ + __IO uint32_t SSN1_SEL : 4; + __IO uint32_t TCLK_SEL : 2; + __IO uint32_t TCLK_DIV : 2; + uint32_t RESERVED8 : 7; + __IO uint32_t AHB_SEL : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_ctrl2_field_t; + +typedef struct +{ + __IO uint32_t TIM0_G : 3; + __IO uint32_t TIM1_G : 3; + __IO uint32_t TIM2_G : 3; + __IO uint32_t TIM3_G : 3; + __IO uint32_t LPTIM0_G : 3; + uint32_t RESERVED15 :16; + __IO uint32_t RSV : 1; +} stc_gpio_timgs_field_t; + +typedef struct +{ + __IO uint32_t TIM0_E : 3; + __IO uint32_t TIM1_E : 3; + __IO uint32_t TIM2_E : 3; + __IO uint32_t TIM3_E : 3; + __IO uint32_t LPTIM0_E : 3; + uint32_t RESERVED15 :16; + __IO uint32_t RSV : 1; +} stc_gpio_times_field_t; + +typedef struct +{ + __IO uint32_t TIM0_CA : 3; + __IO uint32_t TIM1_CA : 3; + __IO uint32_t TIM2_CA : 3; + __IO uint32_t TIM3_CA : 3; + __IO uint32_t TIM3_CB : 3; + uint32_t RESERVED15 :16; + __IO uint32_t RSV : 1; +} stc_gpio_timcps_field_t; + +typedef struct +{ + __IO uint32_t PCA_CH0 : 3; + __IO uint32_t PCA_ECI : 3; + __IO uint32_t LPTIM1_G : 3; + __IO uint32_t LPTIM1_E : 3; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pcas_field_t; + +typedef struct +{ + __IO uint32_t PCNT_S0 : 2; + __IO uint32_t PCNT_S1 : 2; + uint32_t RESERVED4 :27; + __IO uint32_t RSV : 1; +} stc_gpio_pcnt_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe00_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe01_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe02_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe03_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe04_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe05_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe06_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe07_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe08_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe09_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe10_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe11_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe12_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe13_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe14_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pe15_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pf00_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pf01_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pf02_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pf03_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pf04_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pf05_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pf06_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pf07_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pf08_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pf09_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pf10_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_gpio_pf11_sel_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pedir_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pein_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_peout_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_peads_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pebset_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pebclr_field_t; + +typedef struct +{ + __IO uint32_t PEBCLR :16; + __IO uint32_t PEBSET :16; +} stc_gpio_pebsetclr_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pedr_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pepu_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pepd_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_peod_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pehie_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pelie_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_perie_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pefie_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pfdir_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pfin_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pfout_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pfads_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pfbset_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pfbclr_field_t; + +typedef struct +{ + __IO uint32_t PFBCLR :12; + uint32_t RESERVED12 : 4; + __IO uint32_t PFBSET :12; +} stc_gpio_pfbsetclr_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pfdr_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pfpu_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pfpd_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pfod_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pfhie_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pflie_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pfrie_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pffie_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pe_stat_field_t; + +typedef struct +{ + __IO uint32_t PE00 : 1; + __IO uint32_t PE01 : 1; + __IO uint32_t PE02 : 1; + __IO uint32_t PE03 : 1; + __IO uint32_t PE04 : 1; + __IO uint32_t PE05 : 1; + __IO uint32_t PE06 : 1; + __IO uint32_t PE07 : 1; + __IO uint32_t PE08 : 1; + __IO uint32_t PE09 : 1; + __IO uint32_t PE10 : 1; + __IO uint32_t PE11 : 1; + __IO uint32_t PE12 : 1; + __IO uint32_t PE13 : 1; + __IO uint32_t PE14 : 1; + __IO uint32_t PE15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_gpio_pe_iclr_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pf_stat_field_t; + +typedef struct +{ + __IO uint32_t PF00 : 1; + __IO uint32_t PF01 : 1; + __IO uint32_t PF02 : 1; + __IO uint32_t PF03 : 1; + __IO uint32_t PF04 : 1; + __IO uint32_t PF05 : 1; + __IO uint32_t PF06 : 1; + __IO uint32_t PF07 : 1; + __IO uint32_t PF08 : 1; + __IO uint32_t PF09 : 1; + __IO uint32_t PF10 : 1; + __IO uint32_t PF11 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_gpio_pf_iclr_field_t; + +typedef struct +{ + __IO uint32_t TME : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_i2c_tmrun_field_t; + +typedef struct +{ + __IO uint32_t TM : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_i2c_tm_field_t; + +typedef struct +{ + __IO uint32_t H1M : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t AA : 1; + __IO uint32_t SI : 1; + __IO uint32_t STO : 1; + __IO uint32_t STA : 1; + __IO uint32_t ENS : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_i2c_cr_field_t; + +typedef struct +{ + __IO uint32_t DAT : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_i2c_data_field_t; + +typedef struct +{ + __IO uint32_t GC : 1; + __IO uint32_t ADR : 7; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_i2c_addr_field_t; + +typedef struct +{ + __IO uint32_t STA : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_i2c_stat_field_t; + +typedef struct +{ + __IO uint32_t EN : 1; + __IO uint32_t LCDCLK : 2; + __IO uint32_t CPCLK : 2; + __IO uint32_t BIAS : 1; + __IO uint32_t DUTY : 3; + __IO uint32_t BSEL : 3; + __IO uint32_t CONTRAST : 4; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_lcd_cr0_field_t; + +typedef struct +{ + __IO uint32_t BLINKCNT : 6; + __IO uint32_t BLINKEN : 1; + __IO uint32_t CLKSRC : 1; + __IO uint32_t MODE : 1; + __IO uint32_t IE : 1; + __IO uint32_t DMAEN : 1; + __IO uint32_t INTF : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_lcd_cr1_field_t; + +typedef struct +{ + uint32_t RESERVED0 :10; + __IO uint32_t INTF : 1; + uint32_t RESERVED11 :20; + __IO uint32_t RSV : 1; +} stc_lcd_intclr_field_t; + +typedef struct +{ + __IO uint32_t S0 : 1; + __IO uint32_t S1 : 1; + __IO uint32_t S2 : 1; + __IO uint32_t S3 : 1; + __IO uint32_t S4 : 1; + __IO uint32_t S5 : 1; + __IO uint32_t S6 : 1; + __IO uint32_t S7 : 1; + __IO uint32_t S8 : 1; + __IO uint32_t S9 : 1; + __IO uint32_t S10 : 1; + __IO uint32_t S11 : 1; + __IO uint32_t S12 : 1; + __IO uint32_t S13 : 1; + __IO uint32_t S14 : 1; + __IO uint32_t S15 : 1; + __IO uint32_t S16 : 1; + __IO uint32_t S17 : 1; + __IO uint32_t S18 : 1; + __IO uint32_t S19 : 1; + __IO uint32_t S20 : 1; + __IO uint32_t S21 : 1; + __IO uint32_t S22 : 1; + __IO uint32_t S23 : 1; + __IO uint32_t S24 : 1; + __IO uint32_t S25 : 1; + __IO uint32_t S26 : 1; + __IO uint32_t S27 : 1; + __IO uint32_t S28 : 1; + __IO uint32_t S29 : 1; + __IO uint32_t S30 : 1; + __IO uint32_t S31 : 1; +} stc_lcd_poen0_field_t; + +typedef struct +{ + __IO uint32_t S32 : 1; + __IO uint32_t S33 : 1; + __IO uint32_t S34 : 1; + __IO uint32_t S35 : 1; + __IO uint32_t S36C7 : 1; + __IO uint32_t S37C6 : 1; + __IO uint32_t S38C5 : 1; + __IO uint32_t S39C4 : 1; + __IO uint32_t S40 : 1; + __IO uint32_t S41 : 1; + __IO uint32_t S42 : 1; + __IO uint32_t S43 : 1; + __IO uint32_t MUX : 1; + __IO uint32_t S44 : 1; + __IO uint32_t S45 : 1; + __IO uint32_t S46 : 1; + __IO uint32_t S47 : 1; + __IO uint32_t S48 : 1; + __IO uint32_t S49 : 1; + __IO uint32_t S50 : 1; + __IO uint32_t S51 : 1; + __IO uint32_t C0 : 1; + __IO uint32_t C1 : 1; + __IO uint32_t C2 : 1; + __IO uint32_t C3 : 1; +} stc_lcd_poen1_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t D24 : 1; + __IO uint32_t D25 : 1; + __IO uint32_t D26 : 1; + __IO uint32_t D27 : 1; + __IO uint32_t D28 : 1; + __IO uint32_t D29 : 1; + __IO uint32_t D30 : 1; + __IO uint32_t D31 : 1; +} stc_lcd_ram0_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t D24 : 1; + __IO uint32_t D25 : 1; + __IO uint32_t D26 : 1; + __IO uint32_t D27 : 1; + __IO uint32_t D28 : 1; + __IO uint32_t D29 : 1; + __IO uint32_t D30 : 1; + __IO uint32_t D31 : 1; +} stc_lcd_ram1_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t D24 : 1; + __IO uint32_t D25 : 1; + __IO uint32_t D26 : 1; + __IO uint32_t D27 : 1; + __IO uint32_t D28 : 1; + __IO uint32_t D29 : 1; + __IO uint32_t D30 : 1; + __IO uint32_t D31 : 1; +} stc_lcd_ram2_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t D24 : 1; + __IO uint32_t D25 : 1; + __IO uint32_t D26 : 1; + __IO uint32_t D27 : 1; + __IO uint32_t D28 : 1; + __IO uint32_t D29 : 1; + __IO uint32_t D30 : 1; + __IO uint32_t D31 : 1; +} stc_lcd_ram3_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t D24 : 1; + __IO uint32_t D25 : 1; + __IO uint32_t D26 : 1; + __IO uint32_t D27 : 1; + __IO uint32_t D28 : 1; + __IO uint32_t D29 : 1; + __IO uint32_t D30 : 1; + __IO uint32_t D31 : 1; +} stc_lcd_ram4_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t D24 : 1; + __IO uint32_t D25 : 1; + __IO uint32_t D26 : 1; + __IO uint32_t D27 : 1; + __IO uint32_t D28 : 1; + __IO uint32_t D29 : 1; + __IO uint32_t D30 : 1; + __IO uint32_t D31 : 1; +} stc_lcd_ram5_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t D24 : 1; + __IO uint32_t D25 : 1; + __IO uint32_t D26 : 1; + __IO uint32_t D27 : 1; + __IO uint32_t D28 : 1; + __IO uint32_t D29 : 1; + __IO uint32_t D30 : 1; + __IO uint32_t D31 : 1; +} stc_lcd_ram6_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t D24 : 1; + __IO uint32_t D25 : 1; + __IO uint32_t D26 : 1; + __IO uint32_t D27 : 1; + __IO uint32_t D28 : 1; + __IO uint32_t D29 : 1; + __IO uint32_t D30 : 1; + __IO uint32_t D31 : 1; +} stc_lcd_ram7_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t RSV : 8; +} stc_lcd_ram8_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t RSV : 8; +} stc_lcd_ram9_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t RSV : 8; +} stc_lcd_rama_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t RSV : 8; +} stc_lcd_ramb_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t RSV : 8; +} stc_lcd_ramc_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t RSV : 8; +} stc_lcd_ramd_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t RSV : 8; +} stc_lcd_rame_field_t; + +typedef struct +{ + __IO uint32_t D0 : 1; + __IO uint32_t D1 : 1; + __IO uint32_t D2 : 1; + __IO uint32_t D3 : 1; + __IO uint32_t D4 : 1; + __IO uint32_t D5 : 1; + __IO uint32_t D6 : 1; + __IO uint32_t D7 : 1; + __IO uint32_t D8 : 1; + __IO uint32_t D9 : 1; + __IO uint32_t D10 : 1; + __IO uint32_t D11 : 1; + __IO uint32_t D12 : 1; + __IO uint32_t D13 : 1; + __IO uint32_t D14 : 1; + __IO uint32_t D15 : 1; + __IO uint32_t D16 : 1; + __IO uint32_t D17 : 1; + __IO uint32_t D18 : 1; + __IO uint32_t D19 : 1; + __IO uint32_t D20 : 1; + __IO uint32_t D21 : 1; + __IO uint32_t D22 : 1; + __IO uint32_t D23 : 1; + __IO uint32_t RSV : 8; +} stc_lcd_ramf_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_lptimer_cnt_field_t; + +typedef struct +{ + __IO uint32_t ARR :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_lptimer_arr_field_t; + +typedef struct +{ + __IO uint32_t TR : 1; + __IO uint32_t MD : 1; + __IO uint32_t CT : 1; + __IO uint32_t TOG_EN : 1; + __IO uint32_t TCK_SEL : 2; + uint32_t RESERVED6 : 1; + __IO uint32_t WT_FLAG : 1; + __IO uint32_t GATE : 1; + __IO uint32_t GATE_P : 1; + __IO uint32_t IE : 1; + __IO uint32_t PRS : 3; + uint32_t RESERVED14 :17; + __IO uint32_t RSV : 1; +} stc_lptimer_cr_field_t; + +typedef struct +{ + __IO uint32_t TF : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_lptimer_ifr_field_t; + +typedef struct +{ + __IO uint32_t TFC : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_lptimer_iclr_field_t; + +typedef struct +{ + __IO uint32_t DATA : 8; + __IO uint32_t DATA8 : 1; + uint32_t RESERVED9 :22; + __IO uint32_t RSV : 1; +} stc_lpuart_sbuf_field_t; + +typedef struct +{ + __IO uint32_t RCIE : 1; + __IO uint32_t TCIE : 1; + __IO uint32_t B8CONT : 2; + __IO uint32_t REN : 1; + __IO uint32_t ADRDET : 1; + __IO uint32_t SM : 2; + __IO uint32_t TXEIE : 1; + __IO uint32_t OVER : 2; + __IO uint32_t SCLKSEL : 2; + __IO uint32_t PEIE : 1; + __IO uint32_t STOPBIT : 2; + __IO uint32_t DMARXEN : 1; + __IO uint32_t DMATXEN : 1; + __IO uint32_t RTSEN : 1; + __IO uint32_t CTSEN : 1; + __IO uint32_t CTSIE : 1; + __IO uint32_t FEIE : 1; + __IO uint32_t HDSEL : 1; + uint32_t RESERVED23 : 8; + __IO uint32_t RSV : 1; +} stc_lpuart_scon_field_t; + +typedef struct +{ + __IO uint32_t SADDR : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_lpuart_saddr_field_t; + +typedef struct +{ + __IO uint32_t SADEN : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_lpuart_saden_field_t; + +typedef struct +{ + __IO uint32_t RC : 1; + __IO uint32_t TC : 1; + __IO uint32_t FE : 1; + __IO uint32_t TXE : 1; + __IO uint32_t PE : 1; + __IO uint32_t CTSIF : 1; + __IO uint32_t CTS : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_lpuart_isr_field_t; + +typedef struct +{ + __IO uint32_t RCCF : 1; + __IO uint32_t TCCF : 1; + __IO uint32_t FECF : 1; + uint32_t RESERVED3 : 1; + __IO uint32_t PECF : 1; + __IO uint32_t CTSIFCF : 1; + uint32_t RESERVED6 :25; + __IO uint32_t RSV : 1; +} stc_lpuart_icr_field_t; + +typedef struct +{ + __IO uint32_t SCNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_lpuart_scnt_field_t; + +typedef struct +{ + __IO uint32_t LVDEN : 1; + __IO uint32_t ACT : 1; + __IO uint32_t SOURCE_SEL : 2; + __IO uint32_t VTDS : 4; + __IO uint32_t FLTEN : 1; + __IO uint32_t DEBOUNCE_TIME : 3; + __IO uint32_t FTEN : 1; + __IO uint32_t RTEN : 1; + __IO uint32_t HTEN : 1; + __IO uint32_t IE : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_lvd_cr_field_t; + +typedef struct +{ + __IO uint32_t INTF : 1; + __IO uint32_t FILTER : 1; + uint32_t RESERVED2 :29; + __IO uint32_t RSV : 1; +} stc_lvd_ifr_field_t; + +typedef struct +{ + __IO uint32_t EN : 1; + __IO uint32_t AZEN : 1; + __IO uint32_t BUFEN : 1; + __IO uint32_t OEN1 : 1; + __IO uint32_t OEN2 : 1; + __IO uint32_t OEN3 : 1; + __IO uint32_t OEN4 : 1; + __IO uint32_t BIASSEL : 3; + uint32_t RESERVED10 :21; + __IO uint32_t RSV : 1; +} stc_opa_cr0_field_t; + +typedef struct +{ + __IO uint32_t ADCTR_EN : 1; + __IO uint32_t TRIGGER : 1; + __IO uint32_t AZ_PULSE : 1; + __IO uint32_t CLK_SW_SET : 1; + __IO uint32_t CLK_SEL : 4; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_opa_cr1_field_t; + +typedef struct +{ + __IO uint32_t CCF0 : 1; + __IO uint32_t CCF1 : 1; + __IO uint32_t CCF2 : 1; + __IO uint32_t CCF3 : 1; + __IO uint32_t CCF4 : 1; + uint32_t RESERVED5 : 1; + __IO uint32_t CR : 1; + __IO uint32_t CF : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccon_field_t; + +typedef struct +{ + __IO uint32_t CFIE : 1; + __IO uint32_t CPS : 3; + uint32_t RESERVED4 : 2; + __IO uint32_t WDTE : 1; + __IO uint32_t CIDL : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_cmod_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pca_cnt_field_t; + +typedef struct +{ + __IO uint32_t CCF0 : 1; + __IO uint32_t CCF1 : 1; + __IO uint32_t CCF2 : 1; + __IO uint32_t CCF3 : 1; + __IO uint32_t CCF4 : 1; + uint32_t RESERVED5 : 2; + __IO uint32_t CF : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_iclr_field_t; + +typedef struct +{ + __IO uint32_t CCIE : 1; + __IO uint32_t PWM : 1; + __IO uint32_t TOG : 1; + __IO uint32_t MAT : 1; + __IO uint32_t CAPN : 1; + __IO uint32_t CAPP : 1; + __IO uint32_t ECOM : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_pca_ccapm0_field_t; + +typedef struct +{ + __IO uint32_t CCIE : 1; + __IO uint32_t PWM : 1; + __IO uint32_t TOG : 1; + __IO uint32_t MAT : 1; + __IO uint32_t CAPN : 1; + __IO uint32_t CAPP : 1; + __IO uint32_t ECOM : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_pca_ccapm1_field_t; + +typedef struct +{ + __IO uint32_t CCIE : 1; + __IO uint32_t PWM : 1; + __IO uint32_t TOG : 1; + __IO uint32_t MAT : 1; + __IO uint32_t CAPN : 1; + __IO uint32_t CAPP : 1; + __IO uint32_t ECOM : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_pca_ccapm2_field_t; + +typedef struct +{ + __IO uint32_t CCIE : 1; + __IO uint32_t PWM : 1; + __IO uint32_t TOG : 1; + __IO uint32_t MAT : 1; + __IO uint32_t CAPN : 1; + __IO uint32_t CAPP : 1; + __IO uint32_t ECOM : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_pca_ccapm3_field_t; + +typedef struct +{ + __IO uint32_t CCIE : 1; + __IO uint32_t PWM : 1; + __IO uint32_t TOG : 1; + __IO uint32_t MAT : 1; + __IO uint32_t CAPN : 1; + __IO uint32_t CAPP : 1; + __IO uint32_t ECOM : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_pca_ccapm4_field_t; + +typedef struct +{ + __IO uint32_t CCAP0 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap0h_field_t; + +typedef struct +{ + __IO uint32_t CCAP0 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap0l_field_t; + +typedef struct +{ + __IO uint32_t CCAP1 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap1h_field_t; + +typedef struct +{ + __IO uint32_t CCAP1 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap1l_field_t; + +typedef struct +{ + __IO uint32_t CCAP2 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap2h_field_t; + +typedef struct +{ + __IO uint32_t CCAP2 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap2l_field_t; + +typedef struct +{ + __IO uint32_t CCAP3 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap3h_field_t; + +typedef struct +{ + __IO uint32_t CCAP3 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap3l_field_t; + +typedef struct +{ + __IO uint32_t CCAP4 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap4h_field_t; + +typedef struct +{ + __IO uint32_t CCAP4 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap4l_field_t; + +typedef struct +{ + __IO uint32_t CCAPO0 : 1; + __IO uint32_t CCAPO1 : 1; + __IO uint32_t CCAPO2 : 1; + __IO uint32_t CCAPO3 : 1; + __IO uint32_t CCAPO4 : 1; + uint32_t RESERVED5 :26; + __IO uint32_t RSV : 1; +} stc_pca_ccapo_field_t; + +typedef struct +{ + __IO uint32_t CCAP0 :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pca_ccap0_field_t; + +typedef struct +{ + __IO uint32_t CCAP1 :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pca_ccap1_field_t; + +typedef struct +{ + __IO uint32_t CCAP2 :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pca_ccap2_field_t; + +typedef struct +{ + __IO uint32_t CCAP3 :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pca_ccap3_field_t; + +typedef struct +{ + __IO uint32_t CCAP4 :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pca_ccap4_field_t; + +typedef struct +{ + __IO uint32_t CARR :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pca_carr_field_t; + +typedef struct +{ + __IO uint32_t EPWM : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_pca_epwm_field_t; + +typedef struct +{ + __IO uint32_t RUN : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_pcnt_run_field_t; + +typedef struct +{ + __IO uint32_t MODE : 2; + __IO uint32_t CLKSEL : 2; + __IO uint32_t DIR : 1; + __IO uint32_t S0P : 1; + __IO uint32_t S1P : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_pcnt_ctrl_field_t; + +typedef struct +{ + __IO uint32_t CLKDIV :13; + __IO uint32_t DEBTOP : 3; + __IO uint32_t EN : 1; + uint32_t RESERVED17 :14; + __IO uint32_t RSV : 1; +} stc_pcnt_flt_field_t; + +typedef struct +{ + __IO uint32_t TH :12; + uint32_t RESERVED12 : 4; + __IO uint32_t EN : 1; + uint32_t RESERVED17 :14; + __IO uint32_t RSV : 1; +} stc_pcnt_tocr_field_t; + +typedef struct +{ + __IO uint32_t T2C : 1; + __IO uint32_t B2T : 1; + __IO uint32_t B2C : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_pcnt_cmd_field_t; + +typedef struct +{ + __IO uint32_t DIR : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_pcnt_sr1_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pcnt_cnt_field_t; + +typedef struct +{ + __IO uint32_t TOP :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pcnt_top_field_t; + +typedef struct +{ + __IO uint32_t BUF :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pcnt_buf_field_t; + +typedef struct +{ + __IO uint32_t UF : 1; + __IO uint32_t OV : 1; + __IO uint32_t TO : 1; + __IO uint32_t DIR : 1; + __IO uint32_t FE : 1; + __IO uint32_t BB : 1; + __IO uint32_t S0E : 1; + __IO uint32_t S1E : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pcnt_ifr_field_t; + +typedef struct +{ + __IO uint32_t UF : 1; + __IO uint32_t OV : 1; + __IO uint32_t TO : 1; + __IO uint32_t DIR : 1; + __IO uint32_t FE : 1; + __IO uint32_t BB : 1; + __IO uint32_t S0E : 1; + __IO uint32_t S1E : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pcnt_icr_field_t; + +typedef struct +{ + __IO uint32_t UF : 1; + __IO uint32_t OV : 1; + __IO uint32_t TO : 1; + __IO uint32_t DIR : 1; + __IO uint32_t FE : 1; + __IO uint32_t BB : 1; + __IO uint32_t S0E : 1; + __IO uint32_t S1E : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pcnt_ien_field_t; + +typedef struct +{ + __IO uint32_t T2C : 1; + __IO uint32_t B2T : 1; + __IO uint32_t B2C : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_pcnt_sr2_field_t; + +typedef struct +{ + __IO uint32_t DBG : 2; + uint32_t RESERVED2 :29; + __IO uint32_t RSV : 1; +} stc_pcnt_dbg_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t IE : 1; + uint32_t RESERVED2 :29; + __IO uint32_t RSV : 1; +} stc_ram_cr_field_t; + +typedef struct +{ + __IO uint32_t ERRADDR :14; + uint32_t RESERVED14 :17; + __IO uint32_t RSV : 1; +} stc_ram_erraddr_field_t; + +typedef struct +{ + __IO uint32_t ERR : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_ram_ifr_field_t; + +typedef struct +{ + __IO uint32_t ERRCLR : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_ram_iclr_field_t; + +typedef struct +{ + __IO uint32_t POR5V : 1; + __IO uint32_t POR15V : 1; + __IO uint32_t LVD : 1; + __IO uint32_t WDT : 1; + __IO uint32_t PCA : 1; + __IO uint32_t LOCKUP : 1; + __IO uint32_t SYSREQ : 1; + __IO uint32_t RSTB : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_reset_flag_field_t; + +typedef struct +{ + __IO uint32_t UART0 : 1; + __IO uint32_t UART1 : 1; + __IO uint32_t LPUART0 : 1; + __IO uint32_t LPUART1 : 1; + __IO uint32_t I2C0 : 1; + __IO uint32_t I2C1 : 1; + __IO uint32_t SPI0 : 1; + __IO uint32_t SPI1 : 1; + __IO uint32_t BASETIM : 1; + __IO uint32_t LPTIM0 : 1; + __IO uint32_t ADVTIM : 1; + __IO uint32_t TIM3 : 1; + uint32_t RESERVED12 : 1; + __IO uint32_t OPA : 1; + __IO uint32_t PCA : 1; + uint32_t RESERVED15 : 1; + __IO uint32_t ADC : 1; + __IO uint32_t VC : 1; + __IO uint32_t RNG : 1; + __IO uint32_t PCNT : 1; + __IO uint32_t RTC : 1; + __IO uint32_t TRIM : 1; + __IO uint32_t LCD : 1; + uint32_t RESERVED23 : 1; + __IO uint32_t TICK : 1; + __IO uint32_t SWD : 1; + __IO uint32_t CRC : 1; + __IO uint32_t AES : 1; + __IO uint32_t GPIO : 1; + __IO uint32_t DMA : 1; +} stc_reset_peri_reset0_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t DAC : 1; + __IO uint32_t LPTIM1 : 1; + uint32_t RESERVED5 : 3; + __IO uint32_t UART2 : 1; + __IO uint32_t UART3 : 1; + uint32_t RESERVED10 :21; + __IO uint32_t RSV : 1; +} stc_reset_peri_reset1_field_t; + +typedef struct +{ + __IO uint32_t PRDS : 3; + __IO uint32_t AMPM : 1; + uint32_t RESERVED4 : 1; + __IO uint32_t HZ1OE : 1; + __IO uint32_t HZ1SEL : 1; + __IO uint32_t START : 1; + __IO uint32_t PRDX : 6; + __IO uint32_t PRDSEL : 1; + uint32_t RESERVED15 :16; + __IO uint32_t RSV : 1; +} stc_rtc_cr0_field_t; + +typedef struct +{ + __IO uint32_t WAIT : 1; + __IO uint32_t WAITF : 1; + uint32_t RESERVED2 : 1; + __IO uint32_t PRDF : 1; + __IO uint32_t ALMF : 1; + uint32_t RESERVED5 : 1; + __IO uint32_t ALMIE : 1; + __IO uint32_t ALMEN : 1; + __IO uint32_t CKSEL : 3; + uint32_t RESERVED11 :20; + __IO uint32_t RSV : 1; +} stc_rtc_cr1_field_t; + +typedef struct +{ + __IO uint32_t SECL : 4; + __IO uint32_t SECH : 3; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_rtc_sec_field_t; + +typedef struct +{ + __IO uint32_t MINL : 4; + __IO uint32_t MINH : 3; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_rtc_min_field_t; + +typedef struct +{ + __IO uint32_t HOURL : 4; + __IO uint32_t HOURH : 2; + uint32_t RESERVED6 :25; + __IO uint32_t RSV : 1; +} stc_rtc_hour_field_t; + +typedef struct +{ + __IO uint32_t WEEK : 3; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_rtc_week_field_t; + +typedef struct +{ + __IO uint32_t DAYL : 4; + __IO uint32_t DAYH : 2; + uint32_t RESERVED6 :25; + __IO uint32_t RSV : 1; +} stc_rtc_day_field_t; + +typedef struct +{ + __IO uint32_t MON : 5; + uint32_t RESERVED5 :26; + __IO uint32_t RSV : 1; +} stc_rtc_mon_field_t; + +typedef struct +{ + __IO uint32_t YEARL : 4; + __IO uint32_t YEARH : 4; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_rtc_year_field_t; + +typedef struct +{ + __IO uint32_t ALMMINL : 4; + __IO uint32_t ALMMINH : 3; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_rtc_almmin_field_t; + +typedef struct +{ + __IO uint32_t ALMHOURL : 4; + __IO uint32_t ALMHOURH : 2; + uint32_t RESERVED6 :25; + __IO uint32_t RSV : 1; +} stc_rtc_almhour_field_t; + +typedef struct +{ + __IO uint32_t ALMWEEK : 7; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_rtc_almweek_field_t; + +typedef struct +{ + __IO uint32_t CR : 9; + uint32_t RESERVED9 : 6; + __IO uint32_t EN : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_rtc_compen_field_t; + +typedef struct +{ + __IO uint32_t ALMSECL : 4; + __IO uint32_t ALMSECH : 3; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_rtc_almsec_field_t; + +typedef struct +{ + __IO uint32_t SPR0 : 1; + __IO uint32_t SPR1 : 1; + __IO uint32_t CPHA : 1; + __IO uint32_t CPOL : 1; + __IO uint32_t MSTR : 1; + uint32_t RESERVED5 : 1; + __IO uint32_t SPEN : 1; + __IO uint32_t SPR2 : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_spi_cr_field_t; + +typedef struct +{ + __IO uint32_t SSN : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_spi_ssn_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t RXNE : 1; + __IO uint32_t TXE : 1; + __IO uint32_t BUSY : 1; + __IO uint32_t MDF : 1; + __IO uint32_t SSERR : 1; + uint32_t RESERVED6 : 1; + __IO uint32_t SPIF : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_spi_stat_field_t; + +typedef struct +{ + __IO uint32_t DAT : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_spi_data_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 2; + __IO uint32_t INT_EN : 1; + __IO uint32_t HDMA_RX : 1; + __IO uint32_t HDMA_TX : 1; + __IO uint32_t TXEIE : 1; + __IO uint32_t RXNEIE : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_spi_cr2_field_t; + +typedef struct +{ + __IO uint32_t INT_CLR : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_spi_iclr_field_t; + +typedef struct +{ + __IO uint32_t RCH_EN : 1; + __IO uint32_t XTH_EN : 1; + __IO uint32_t RCL_EN : 1; + __IO uint32_t XTL_EN : 1; + __IO uint32_t PLL_EN : 1; + __IO uint32_t CLKSW : 3; + __IO uint32_t HCLK_PRS : 3; + __IO uint32_t PCLK_PRS : 2; + uint32_t RESERVED13 : 2; + __IO uint32_t WAKEUP_BYRCH : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_sysctrl_sysctrl0_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t EXTH_EN : 1; + __IO uint32_t EXTL_EN : 1; + __IO uint32_t XTL_ALWAYS_ON : 1; + uint32_t RESERVED4 : 1; + __IO uint32_t RTC_LPW : 1; + __IO uint32_t LOCKUP_EN : 1; + uint32_t RESERVED7 : 1; + __IO uint32_t SWD_USE_IO : 1; + __IO uint32_t RTC_FREQ_ADJUST : 3; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_sysctrl_sysctrl1_field_t; + +typedef struct +{ + __IO uint32_t SYSCTRL2 :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_sysctrl_sysctrl2_field_t; + +typedef struct +{ + __IO uint32_t TRIM :11; + __IO uint32_t STABLE : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_sysctrl_rch_cr_field_t; + +typedef struct +{ + __IO uint32_t DRIVER : 2; + __IO uint32_t XTH_FSEL : 2; + __IO uint32_t STARTUP : 2; + __IO uint32_t STABLE : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_sysctrl_xth_cr_field_t; + +typedef struct +{ + __IO uint32_t TRIM :10; + __IO uint32_t STARTUP : 2; + __IO uint32_t STABLE : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_sysctrl_rcl_cr_field_t; + +typedef struct +{ + __IO uint32_t DRIVER : 2; + __IO uint32_t AMP_SEL : 2; + __IO uint32_t STARTUP : 2; + __IO uint32_t STABLE : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_sysctrl_xtl_cr_field_t; + +typedef struct +{ + __IO uint32_t UART0 : 1; + __IO uint32_t UART1 : 1; + __IO uint32_t LPUART0 : 1; + __IO uint32_t LPUART1 : 1; + __IO uint32_t I2C0 : 1; + __IO uint32_t I2C1 : 1; + __IO uint32_t SPI0 : 1; + __IO uint32_t SPI1 : 1; + __IO uint32_t BASETIM : 1; + __IO uint32_t LPTIM0 : 1; + __IO uint32_t ADVTIM : 1; + __IO uint32_t TIM3 : 1; + uint32_t RESERVED12 : 1; + __IO uint32_t OPA : 1; + __IO uint32_t PCA : 1; + __IO uint32_t WDT : 1; + __IO uint32_t ADC : 1; + __IO uint32_t VC : 1; + __IO uint32_t RNG : 1; + __IO uint32_t PCNT : 1; + __IO uint32_t RTC : 1; + __IO uint32_t TRIM : 1; + __IO uint32_t LCD : 1; + uint32_t RESERVED23 : 1; + __IO uint32_t TICK : 1; + __IO uint32_t SWD : 1; + __IO uint32_t CRC : 1; + __IO uint32_t AES : 1; + __IO uint32_t GPIO : 1; + __IO uint32_t DMA : 1; + uint32_t RESERVED30 : 1; + __IO uint32_t FLASH : 1; +} stc_sysctrl_peri_clken0_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t DAC : 1; + __IO uint32_t LPTIM1 : 1; + uint32_t RESERVED5 : 3; + __IO uint32_t UART2 : 1; + __IO uint32_t UART3 : 1; + uint32_t RESERVED10 :21; + __IO uint32_t RSV : 1; +} stc_sysctrl_peri_clken1_field_t; + +typedef struct +{ + __IO uint32_t REFSEL : 2; + __IO uint32_t FOSC : 3; + __IO uint32_t DIVN : 4; + __IO uint32_t IBSEL : 2; + __IO uint32_t LFSEL : 2; + __IO uint32_t FRSEL : 2; + __IO uint32_t STARTUP : 3; + __IO uint32_t STABLE : 1; + uint32_t RESERVED19 :12; + __IO uint32_t RSV : 1; +} stc_sysctrl_pll_cr_field_t; + +typedef struct +{ + __IO uint32_t ARR :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim0_mode0_arr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim0_mode0_cnt_field_t; + +typedef struct +{ + __IO uint32_t CNT32 :32; +} stc_tim0_mode0_cnt32_field_t; + +typedef struct +{ + __IO uint32_t CTEN : 1; + __IO uint32_t MD : 1; + __IO uint32_t CT : 1; + __IO uint32_t TOGEN : 1; + __IO uint32_t PRS : 3; + uint32_t RESERVED7 : 1; + __IO uint32_t GATE : 1; + __IO uint32_t GATEP : 1; + __IO uint32_t UIE : 1; + uint32_t RESERVED11 : 1; + __IO uint32_t MODE : 2; + uint32_t RESERVED14 :17; + __IO uint32_t RSV : 1; +} stc_tim0_mode0_m0cr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_tim0_mode0_ifr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_tim0_mode0_iclr_field_t; + +typedef struct +{ + uint32_t RESERVED0 :12; + __IO uint32_t MOE : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_tim0_mode0_dtr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim0_mode1_cnt_field_t; + +typedef struct +{ + __IO uint32_t CTEN : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CT : 1; + uint32_t RESERVED3 : 1; + __IO uint32_t PRS : 3; + uint32_t RESERVED7 : 1; + __IO uint32_t EDG1ST : 1; + __IO uint32_t EDG2ND : 1; + __IO uint32_t UIE : 1; + uint32_t RESERVED11 : 1; + __IO uint32_t MODE : 2; + __IO uint32_t ONESHOT : 1; + uint32_t RESERVED15 :16; + __IO uint32_t RSV : 1; +} stc_tim0_mode1_m1cr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_tim0_mode1_ifr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_tim0_mode1_iclr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 5; + __IO uint32_t TS : 3; + uint32_t RESERVED8 : 3; + __IO uint32_t IA0S : 1; + __IO uint32_t IB0S : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_tim0_mode1_mscr_field_t; + +typedef struct +{ + __IO uint32_t FLTA0 : 3; + uint32_t RESERVED3 : 1; + __IO uint32_t FLTB0 : 3; + uint32_t RESERVED7 :21; + __IO uint32_t FLTET : 3; + __IO uint32_t ETP : 1; +} stc_tim0_mode1_fltr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 8; + __IO uint32_t CIEA : 1; + uint32_t RESERVED9 :22; + __IO uint32_t RSV : 1; +} stc_tim0_mode1_cr0_field_t; + +typedef struct +{ + __IO uint32_t CCR0A :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim0_mode1_ccr0a_field_t; + +typedef struct +{ + __IO uint32_t ARR :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim0_mode23_arr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim0_mode23_cnt_field_t; + +typedef struct +{ + __IO uint32_t CTEN : 1; + __IO uint32_t COMP : 1; + __IO uint32_t CT : 1; + __IO uint32_t PWM2S : 1; + __IO uint32_t PRS : 3; + __IO uint32_t BUFPEN : 1; + __IO uint32_t CRG : 1; + __IO uint32_t CFG : 1; + __IO uint32_t UIE : 1; + __IO uint32_t UDE : 1; + __IO uint32_t MODE : 2; + __IO uint32_t ONESHOT : 1; + __IO uint32_t CSG : 1; + __IO uint32_t OCCS : 1; + __IO uint32_t URS : 1; + __IO uint32_t TDE : 1; + __IO uint32_t TIE : 1; + __IO uint32_t BIE : 1; + __IO uint32_t CIS : 2; + __IO uint32_t OCCE : 1; + __IO uint32_t TG : 1; + __IO uint32_t UG : 1; + __IO uint32_t BG : 1; + __IO uint32_t DIR : 1; + uint32_t RESERVED28 : 3; + __IO uint32_t RSV : 1; +} stc_tim0_mode23_m23cr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 : 2; + __IO uint32_t CB0F : 1; + uint32_t RESERVED6 : 2; + __IO uint32_t CA0E : 1; + uint32_t RESERVED9 : 2; + __IO uint32_t CB0E : 1; + uint32_t RESERVED12 : 2; + __IO uint32_t BIF : 1; + __IO uint32_t TIF : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim0_mode23_ifr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 : 2; + __IO uint32_t CB0F : 1; + uint32_t RESERVED6 : 2; + __IO uint32_t CA0E : 1; + uint32_t RESERVED9 : 2; + __IO uint32_t CB0E : 1; + uint32_t RESERVED12 : 2; + __IO uint32_t BIF : 1; + __IO uint32_t TIF : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim0_mode23_iclr_field_t; + +typedef struct +{ + __IO uint32_t MMS : 3; + __IO uint32_t CCDS : 1; + __IO uint32_t MSM : 1; + __IO uint32_t TS : 3; + __IO uint32_t SMS : 3; + __IO uint32_t IA0S : 1; + __IO uint32_t IB0S : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_tim0_mode23_mscr_field_t; + +typedef struct +{ + __IO uint32_t OCMA0_FLTA0 : 3; + __IO uint32_t CCPA0 : 1; + __IO uint32_t OCMB0_FLTB0 : 3; + __IO uint32_t CCPB0 : 1; + uint32_t RESERVED8 :16; + __IO uint32_t FLTBK : 3; + __IO uint32_t BKP : 1; + __IO uint32_t FLTET : 3; + __IO uint32_t ETP : 1; +} stc_tim0_mode23_fltr_field_t; + +typedef struct +{ + __IO uint32_t UEVE : 1; + __IO uint32_t CMA0E : 1; + uint32_t RESERVED2 : 2; + __IO uint32_t CMB0E : 1; + uint32_t RESERVED5 : 2; + __IO uint32_t ADTE : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_tim0_mode23_adtr_field_t; + +typedef struct +{ + __IO uint32_t CFA_CRA_BKSA : 2; + __IO uint32_t CFB_CRB_BKSB : 2; + __IO uint32_t CSA : 1; + __IO uint32_t CSB : 1; + __IO uint32_t BUFEA : 1; + __IO uint32_t BUFEB : 1; + __IO uint32_t CIEA : 1; + __IO uint32_t CIEB : 1; + __IO uint32_t CDEA : 1; + __IO uint32_t CDEB : 1; + __IO uint32_t CISB : 2; + __IO uint32_t CCGA : 1; + __IO uint32_t CCGB : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim0_mode23_crch0_field_t; + +typedef struct +{ + __IO uint32_t DTR : 8; + __IO uint32_t BKSEL : 1; + __IO uint32_t DTEN : 1; + __IO uint32_t BKE : 1; + __IO uint32_t AOE : 1; + __IO uint32_t MOE : 1; + __IO uint32_t SAFEEN : 1; + __IO uint32_t VCE : 1; + uint32_t RESERVED15 :16; + __IO uint32_t RSV : 1; +} stc_tim0_mode23_dtr_field_t; + +typedef struct +{ + __IO uint32_t RCR : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_tim0_mode23_rcr_field_t; + +typedef struct +{ + __IO uint32_t ARRDM :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim0_mode23_arrdm_field_t; + +typedef struct +{ + __IO uint32_t CCR0A :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim0_mode23_ccr0a_field_t; + +typedef struct +{ + __IO uint32_t CCR0B :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim0_mode23_ccr0b_field_t; + +typedef struct +{ + __IO uint32_t ARR :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim1_mode0_arr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim1_mode0_cnt_field_t; + +typedef struct +{ + __IO uint32_t CNT32 :32; +} stc_tim1_mode0_cnt32_field_t; + +typedef struct +{ + __IO uint32_t CTEN : 1; + __IO uint32_t MD : 1; + __IO uint32_t CT : 1; + __IO uint32_t TOGEN : 1; + __IO uint32_t PRS : 3; + uint32_t RESERVED7 : 1; + __IO uint32_t GATE : 1; + __IO uint32_t GATEP : 1; + __IO uint32_t UIE : 1; + uint32_t RESERVED11 : 1; + __IO uint32_t MODE : 2; + uint32_t RESERVED14 :17; + __IO uint32_t RSV : 1; +} stc_tim1_mode0_m0cr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_tim1_mode0_ifr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_tim1_mode0_iclr_field_t; + +typedef struct +{ + uint32_t RESERVED0 :12; + __IO uint32_t MOE : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_tim1_mode0_dtr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim1_mode1_cnt_field_t; + +typedef struct +{ + __IO uint32_t CTEN : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CT : 1; + uint32_t RESERVED3 : 1; + __IO uint32_t PRS : 3; + uint32_t RESERVED7 : 1; + __IO uint32_t EDG1ST : 1; + __IO uint32_t EDG2ND : 1; + __IO uint32_t UIE : 1; + uint32_t RESERVED11 : 1; + __IO uint32_t MODE : 2; + __IO uint32_t ONESHOT : 1; + uint32_t RESERVED15 :16; + __IO uint32_t RSV : 1; +} stc_tim1_mode1_m1cr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_tim1_mode1_ifr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_tim1_mode1_iclr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 5; + __IO uint32_t TS : 3; + uint32_t RESERVED8 : 3; + __IO uint32_t IA0S : 1; + __IO uint32_t IB0S : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_tim1_mode1_mscr_field_t; + +typedef struct +{ + __IO uint32_t FLTA0 : 3; + uint32_t RESERVED3 : 1; + __IO uint32_t FLTB0 : 3; + uint32_t RESERVED7 :21; + __IO uint32_t FLTET : 3; + __IO uint32_t ETP : 1; +} stc_tim1_mode1_fltr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 8; + __IO uint32_t CIEA : 1; + uint32_t RESERVED9 :22; + __IO uint32_t RSV : 1; +} stc_tim1_mode1_cr0_field_t; + +typedef struct +{ + __IO uint32_t CCR0A :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim1_mode1_ccr0a_field_t; + +typedef struct +{ + __IO uint32_t ARR :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim1_mode23_arr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim1_mode23_cnt_field_t; + +typedef struct +{ + __IO uint32_t CTEN : 1; + __IO uint32_t COMP : 1; + __IO uint32_t CT : 1; + __IO uint32_t PWM2S : 1; + __IO uint32_t PRS : 3; + __IO uint32_t BUFPEN : 1; + __IO uint32_t CRG : 1; + __IO uint32_t CFG : 1; + __IO uint32_t UIE : 1; + __IO uint32_t UDE : 1; + __IO uint32_t MODE : 2; + __IO uint32_t ONESHOT : 1; + __IO uint32_t CSG : 1; + __IO uint32_t OCCS : 1; + __IO uint32_t URS : 1; + __IO uint32_t TDE : 1; + __IO uint32_t TIE : 1; + __IO uint32_t BIE : 1; + __IO uint32_t CIS : 2; + __IO uint32_t OCCE : 1; + __IO uint32_t TG : 1; + __IO uint32_t UG : 1; + __IO uint32_t BG : 1; + __IO uint32_t DIR : 1; + uint32_t RESERVED28 : 3; + __IO uint32_t RSV : 1; +} stc_tim1_mode23_m23cr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 : 2; + __IO uint32_t CB0F : 1; + uint32_t RESERVED6 : 2; + __IO uint32_t CA0E : 1; + uint32_t RESERVED9 : 2; + __IO uint32_t CB0E : 1; + uint32_t RESERVED12 : 2; + __IO uint32_t BIF : 1; + __IO uint32_t TIF : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim1_mode23_ifr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 : 2; + __IO uint32_t CB0F : 1; + uint32_t RESERVED6 : 2; + __IO uint32_t CA0E : 1; + uint32_t RESERVED9 : 2; + __IO uint32_t CB0E : 1; + uint32_t RESERVED12 : 2; + __IO uint32_t BIF : 1; + __IO uint32_t TIF : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim1_mode23_iclr_field_t; + +typedef struct +{ + __IO uint32_t MMS : 3; + __IO uint32_t CCDS : 1; + __IO uint32_t MSM : 1; + __IO uint32_t TS : 3; + __IO uint32_t SMS : 3; + __IO uint32_t IA0S : 1; + __IO uint32_t IB0S : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_tim1_mode23_mscr_field_t; + +typedef struct +{ + __IO uint32_t OCMA0_FLTA0 : 3; + __IO uint32_t CCPA0 : 1; + __IO uint32_t OCMB0_FLTB0 : 3; + __IO uint32_t CCPB0 : 1; + uint32_t RESERVED8 :16; + __IO uint32_t FLTBK : 3; + __IO uint32_t BKP : 1; + __IO uint32_t FLTET : 3; + __IO uint32_t ETP : 1; +} stc_tim1_mode23_fltr_field_t; + +typedef struct +{ + __IO uint32_t UEVE : 1; + __IO uint32_t CMA0E : 1; + uint32_t RESERVED2 : 2; + __IO uint32_t CMB0E : 1; + uint32_t RESERVED5 : 2; + __IO uint32_t ADTE : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_tim1_mode23_adtr_field_t; + +typedef struct +{ + __IO uint32_t CFA_CRA_BKSA : 2; + __IO uint32_t CFB_CRB_BKSB : 2; + __IO uint32_t CSA : 1; + __IO uint32_t CSB : 1; + __IO uint32_t BUFEA : 1; + __IO uint32_t BUFEB : 1; + __IO uint32_t CIEA : 1; + __IO uint32_t CIEB : 1; + __IO uint32_t CDEA : 1; + __IO uint32_t CDEB : 1; + __IO uint32_t CISB : 2; + __IO uint32_t CCGA : 1; + __IO uint32_t CCGB : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim1_mode23_crch0_field_t; + +typedef struct +{ + __IO uint32_t DTR : 8; + __IO uint32_t BKSEL : 1; + __IO uint32_t DTEN : 1; + __IO uint32_t BKE : 1; + __IO uint32_t AOE : 1; + __IO uint32_t MOE : 1; + __IO uint32_t SAFEEN : 1; + __IO uint32_t VCE : 1; + uint32_t RESERVED15 :16; + __IO uint32_t RSV : 1; +} stc_tim1_mode23_dtr_field_t; + +typedef struct +{ + __IO uint32_t RCR : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_tim1_mode23_rcr_field_t; + +typedef struct +{ + __IO uint32_t ARRDM :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim1_mode23_arrdm_field_t; + +typedef struct +{ + __IO uint32_t CCR0A :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim1_mode23_ccr0a_field_t; + +typedef struct +{ + __IO uint32_t CCR0B :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim1_mode23_ccr0b_field_t; + +typedef struct +{ + __IO uint32_t ARR :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim2_mode0_arr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim2_mode0_cnt_field_t; + +typedef struct +{ + __IO uint32_t CNT32 :32; +} stc_tim2_mode0_cnt32_field_t; + +typedef struct +{ + __IO uint32_t CTEN : 1; + __IO uint32_t MD : 1; + __IO uint32_t CT : 1; + __IO uint32_t TOGEN : 1; + __IO uint32_t PRS : 3; + uint32_t RESERVED7 : 1; + __IO uint32_t GATE : 1; + __IO uint32_t GATEP : 1; + __IO uint32_t UIE : 1; + uint32_t RESERVED11 : 1; + __IO uint32_t MODE : 2; + uint32_t RESERVED14 :17; + __IO uint32_t RSV : 1; +} stc_tim2_mode0_m0cr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_tim2_mode0_ifr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_tim2_mode0_iclr_field_t; + +typedef struct +{ + uint32_t RESERVED0 :12; + __IO uint32_t MOE : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_tim2_mode0_dtr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim2_mode1_cnt_field_t; + +typedef struct +{ + __IO uint32_t CTEN : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CT : 1; + uint32_t RESERVED3 : 1; + __IO uint32_t PRS : 3; + uint32_t RESERVED7 : 1; + __IO uint32_t EDG1ST : 1; + __IO uint32_t EDG2ND : 1; + __IO uint32_t UIE : 1; + uint32_t RESERVED11 : 1; + __IO uint32_t MODE : 2; + __IO uint32_t ONESHOT : 1; + uint32_t RESERVED15 :16; + __IO uint32_t RSV : 1; +} stc_tim2_mode1_m1cr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_tim2_mode1_ifr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_tim2_mode1_iclr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 5; + __IO uint32_t TS : 3; + uint32_t RESERVED8 : 3; + __IO uint32_t IA0S : 1; + __IO uint32_t IB0S : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_tim2_mode1_mscr_field_t; + +typedef struct +{ + __IO uint32_t FLTA0 : 3; + uint32_t RESERVED3 : 1; + __IO uint32_t FLTB0 : 3; + uint32_t RESERVED7 :21; + __IO uint32_t FLTET : 3; + __IO uint32_t ETP : 1; +} stc_tim2_mode1_fltr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 8; + __IO uint32_t CIEA : 1; + uint32_t RESERVED9 :22; + __IO uint32_t RSV : 1; +} stc_tim2_mode1_cr0_field_t; + +typedef struct +{ + __IO uint32_t CCR0A :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim2_mode1_ccr0a_field_t; + +typedef struct +{ + __IO uint32_t ARR :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim2_mode23_arr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim2_mode23_cnt_field_t; + +typedef struct +{ + __IO uint32_t CTEN : 1; + __IO uint32_t COMP : 1; + __IO uint32_t CT : 1; + __IO uint32_t PWM2S : 1; + __IO uint32_t PRS : 3; + __IO uint32_t BUFPEN : 1; + __IO uint32_t CRG : 1; + __IO uint32_t CFG : 1; + __IO uint32_t UIE : 1; + __IO uint32_t UDE : 1; + __IO uint32_t MODE : 2; + __IO uint32_t ONESHOT : 1; + __IO uint32_t CSG : 1; + __IO uint32_t OCCS : 1; + __IO uint32_t URS : 1; + __IO uint32_t TDE : 1; + __IO uint32_t TIE : 1; + __IO uint32_t BIE : 1; + __IO uint32_t CIS : 2; + __IO uint32_t OCCE : 1; + __IO uint32_t TG : 1; + __IO uint32_t UG : 1; + __IO uint32_t BG : 1; + __IO uint32_t DIR : 1; + uint32_t RESERVED28 : 3; + __IO uint32_t RSV : 1; +} stc_tim2_mode23_m23cr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 : 2; + __IO uint32_t CB0F : 1; + uint32_t RESERVED6 : 2; + __IO uint32_t CA0E : 1; + uint32_t RESERVED9 : 2; + __IO uint32_t CB0E : 1; + uint32_t RESERVED12 : 2; + __IO uint32_t BIF : 1; + __IO uint32_t TIF : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim2_mode23_ifr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 : 2; + __IO uint32_t CB0F : 1; + uint32_t RESERVED6 : 2; + __IO uint32_t CA0E : 1; + uint32_t RESERVED9 : 2; + __IO uint32_t CB0E : 1; + uint32_t RESERVED12 : 2; + __IO uint32_t BIF : 1; + __IO uint32_t TIF : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim2_mode23_iclr_field_t; + +typedef struct +{ + __IO uint32_t MMS : 3; + __IO uint32_t CCDS : 1; + __IO uint32_t MSM : 1; + __IO uint32_t TS : 3; + __IO uint32_t SMS : 3; + __IO uint32_t IA0S : 1; + __IO uint32_t IB0S : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_tim2_mode23_mscr_field_t; + +typedef struct +{ + __IO uint32_t OCMA0_FLTA0 : 3; + __IO uint32_t CCPA0 : 1; + __IO uint32_t OCMB0_FLTB0 : 3; + __IO uint32_t CCPB0 : 1; + uint32_t RESERVED8 :16; + __IO uint32_t FLTBK : 3; + __IO uint32_t BKP : 1; + __IO uint32_t FLTET : 3; + __IO uint32_t ETP : 1; +} stc_tim2_mode23_fltr_field_t; + +typedef struct +{ + __IO uint32_t UEVE : 1; + __IO uint32_t CMA0E : 1; + uint32_t RESERVED2 : 2; + __IO uint32_t CMB0E : 1; + uint32_t RESERVED5 : 2; + __IO uint32_t ADTE : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_tim2_mode23_adtr_field_t; + +typedef struct +{ + __IO uint32_t CFA_CRA_BKSA : 2; + __IO uint32_t CFB_CRB_BKSB : 2; + __IO uint32_t CSA : 1; + __IO uint32_t CSB : 1; + __IO uint32_t BUFEA : 1; + __IO uint32_t BUFEB : 1; + __IO uint32_t CIEA : 1; + __IO uint32_t CIEB : 1; + __IO uint32_t CDEA : 1; + __IO uint32_t CDEB : 1; + __IO uint32_t CISB : 2; + __IO uint32_t CCGA : 1; + __IO uint32_t CCGB : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim2_mode23_crch0_field_t; + +typedef struct +{ + __IO uint32_t DTR : 8; + __IO uint32_t BKSEL : 1; + __IO uint32_t DTEN : 1; + __IO uint32_t BKE : 1; + __IO uint32_t AOE : 1; + __IO uint32_t MOE : 1; + __IO uint32_t SAFEEN : 1; + __IO uint32_t VCE : 1; + uint32_t RESERVED15 :16; + __IO uint32_t RSV : 1; +} stc_tim2_mode23_dtr_field_t; + +typedef struct +{ + __IO uint32_t RCR : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_tim2_mode23_rcr_field_t; + +typedef struct +{ + __IO uint32_t ARRDM :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim2_mode23_arrdm_field_t; + +typedef struct +{ + __IO uint32_t CCR0A :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim2_mode23_ccr0a_field_t; + +typedef struct +{ + __IO uint32_t CCR0B :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim2_mode23_ccr0b_field_t; + +typedef struct +{ + __IO uint32_t ARR :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode0_arr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode0_cnt_field_t; + +typedef struct +{ + __IO uint32_t CNT32 :32; +} stc_tim3_mode0_cnt32_field_t; + +typedef struct +{ + __IO uint32_t CTEN : 1; + __IO uint32_t MD : 1; + __IO uint32_t CT : 1; + __IO uint32_t TOGEN : 1; + __IO uint32_t PRS : 3; + uint32_t RESERVED7 : 1; + __IO uint32_t GATE : 1; + __IO uint32_t GATEP : 1; + __IO uint32_t UIE : 1; + uint32_t RESERVED11 : 1; + __IO uint32_t MODE : 2; + uint32_t RESERVED14 :17; + __IO uint32_t RSV : 1; +} stc_tim3_mode0_m0cr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_tim3_mode0_ifr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_tim3_mode0_iclr_field_t; + +typedef struct +{ + uint32_t RESERVED0 :12; + __IO uint32_t MOE : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_tim3_mode0_dtr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode1_cnt_field_t; + +typedef struct +{ + __IO uint32_t CTEN : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CT : 1; + uint32_t RESERVED3 : 1; + __IO uint32_t PRS : 3; + uint32_t RESERVED7 : 1; + __IO uint32_t EDG1ST : 1; + __IO uint32_t EDG2ND : 1; + __IO uint32_t UIE : 1; + uint32_t RESERVED11 : 1; + __IO uint32_t MODE : 2; + __IO uint32_t ONESHOT : 1; + uint32_t RESERVED15 :16; + __IO uint32_t RSV : 1; +} stc_tim3_mode1_m1cr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_tim3_mode1_ifr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_tim3_mode1_iclr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 5; + __IO uint32_t TS : 3; + uint32_t RESERVED8 : 3; + __IO uint32_t IA0S : 1; + __IO uint32_t IB0S : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_tim3_mode1_mscr_field_t; + +typedef struct +{ + __IO uint32_t FLTA0 : 3; + uint32_t RESERVED3 : 1; + __IO uint32_t FLTB0 : 3; + uint32_t RESERVED7 :21; + __IO uint32_t FLTET : 3; + __IO uint32_t ETP : 1; +} stc_tim3_mode1_fltr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 8; + __IO uint32_t CIEA : 1; + uint32_t RESERVED9 :22; + __IO uint32_t RSV : 1; +} stc_tim3_mode1_cr0_field_t; + +typedef struct +{ + __IO uint32_t CCR0A :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode1_ccr0a_field_t; + +typedef struct +{ + __IO uint32_t ARR :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_arr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_cnt_field_t; + +typedef struct +{ + __IO uint32_t CTEN : 1; + __IO uint32_t COMP : 1; + __IO uint32_t CT : 1; + __IO uint32_t PWM2S : 1; + __IO uint32_t PRS : 3; + __IO uint32_t BUFPEN : 1; + __IO uint32_t CRG : 1; + __IO uint32_t CFG : 1; + __IO uint32_t UIE : 1; + __IO uint32_t UDE : 1; + __IO uint32_t MODE : 2; + __IO uint32_t ONESHOT : 1; + __IO uint32_t CSG : 1; + __IO uint32_t OCCS : 1; + __IO uint32_t URS : 1; + __IO uint32_t TDE : 1; + __IO uint32_t TIE : 1; + __IO uint32_t BIE : 1; + __IO uint32_t CIS : 2; + __IO uint32_t OCCE : 1; + __IO uint32_t TG : 1; + __IO uint32_t UG : 1; + __IO uint32_t BG : 1; + __IO uint32_t DIR : 1; + uint32_t RESERVED28 : 3; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_m23cr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + __IO uint32_t CA1F : 1; + __IO uint32_t CA2F : 1; + __IO uint32_t CB0F : 1; + __IO uint32_t CB1F : 1; + __IO uint32_t CB2F : 1; + __IO uint32_t CA0E : 1; + __IO uint32_t CA1E : 1; + __IO uint32_t CA2E : 1; + __IO uint32_t CB0E : 1; + __IO uint32_t CB1E : 1; + __IO uint32_t CB2E : 1; + __IO uint32_t BIF : 1; + __IO uint32_t TIF : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_ifr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t CA0F : 1; + __IO uint32_t CA1F : 1; + __IO uint32_t CA2F : 1; + __IO uint32_t CB0F : 1; + __IO uint32_t CB1F : 1; + __IO uint32_t CB2F : 1; + __IO uint32_t CA0E : 1; + __IO uint32_t CA1E : 1; + __IO uint32_t CA2E : 1; + __IO uint32_t CB0E : 1; + __IO uint32_t CB1E : 1; + __IO uint32_t CB2E : 1; + __IO uint32_t BIF : 1; + __IO uint32_t TIF : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_iclr_field_t; + +typedef struct +{ + __IO uint32_t MMS : 3; + __IO uint32_t CCDS : 1; + __IO uint32_t MSM : 1; + __IO uint32_t TS : 3; + __IO uint32_t SMS : 3; + __IO uint32_t IA0S : 1; + __IO uint32_t IB0S : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_mscr_field_t; + +typedef struct +{ + __IO uint32_t OCMA0_FLTA0 : 3; + __IO uint32_t CCPA0 : 1; + __IO uint32_t OCMB0_FLTB0 : 3; + __IO uint32_t CCPB0 : 1; + __IO uint32_t OCMA1_FLTA1 : 3; + __IO uint32_t CCPA1 : 1; + __IO uint32_t OCMB1_FLTB1 : 3; + __IO uint32_t CCPB1 : 1; + __IO uint32_t OCMA2_FLTA2 : 3; + __IO uint32_t CCPA2 : 1; + __IO uint32_t OCMB2_FLTB2 : 3; + __IO uint32_t CCPB2 : 1; + __IO uint32_t FLTBK : 3; + __IO uint32_t BKP : 1; + __IO uint32_t FLTET : 3; + __IO uint32_t ETP : 1; +} stc_tim3_mode23_fltr_field_t; + +typedef struct +{ + __IO uint32_t UEVE : 1; + __IO uint32_t CMA0E : 1; + __IO uint32_t CMA1E : 1; + __IO uint32_t CMA2E : 1; + __IO uint32_t CMB0E : 1; + __IO uint32_t CMB1E : 1; + __IO uint32_t CMB2E : 1; + __IO uint32_t ADTE : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_adtr_field_t; + +typedef struct +{ + __IO uint32_t CFA_CRA_BKSA : 2; + __IO uint32_t CFB_CRB_BKSB : 2; + __IO uint32_t CSA : 1; + __IO uint32_t CSB : 1; + __IO uint32_t BUFEA : 1; + __IO uint32_t BUFEB : 1; + __IO uint32_t CIEA : 1; + __IO uint32_t CIEB : 1; + __IO uint32_t CDEA : 1; + __IO uint32_t CDEB : 1; + __IO uint32_t CISB : 2; + __IO uint32_t CCGA : 1; + __IO uint32_t CCGB : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_crch0_field_t; + +typedef struct +{ + __IO uint32_t CFA_CRA_BKSA : 2; + __IO uint32_t CFB_CRB_BKSB : 2; + __IO uint32_t CSA : 1; + __IO uint32_t CSB : 1; + __IO uint32_t BUFEA : 1; + __IO uint32_t BUFEB : 1; + __IO uint32_t CIEA : 1; + __IO uint32_t CIEB : 1; + __IO uint32_t CDEA : 1; + __IO uint32_t CDEB : 1; + __IO uint32_t CISB : 2; + __IO uint32_t CCGA : 1; + __IO uint32_t CCGB : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_crch1_field_t; + +typedef struct +{ + __IO uint32_t CFA_CRA_BKSA : 2; + __IO uint32_t CFB_CRB_BKSB : 2; + __IO uint32_t CSA : 1; + __IO uint32_t CSB : 1; + __IO uint32_t BUFEA : 1; + __IO uint32_t BUFEB : 1; + __IO uint32_t CIEA : 1; + __IO uint32_t CIEB : 1; + __IO uint32_t CDEA : 1; + __IO uint32_t CDEB : 1; + __IO uint32_t CISB : 2; + __IO uint32_t CCGA : 1; + __IO uint32_t CCGB : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_crch2_field_t; + +typedef struct +{ + __IO uint32_t DTR : 8; + __IO uint32_t BKSEL : 1; + __IO uint32_t DTEN : 1; + __IO uint32_t BKE : 1; + __IO uint32_t AOE : 1; + __IO uint32_t MOE : 1; + __IO uint32_t SAFEEN : 1; + __IO uint32_t VCE : 1; + uint32_t RESERVED15 :16; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_dtr_field_t; + +typedef struct +{ + __IO uint32_t RCR : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_rcr_field_t; + +typedef struct +{ + __IO uint32_t ARRDM :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_arrdm_field_t; + +typedef struct +{ + __IO uint32_t CCR0A :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_ccr0a_field_t; + +typedef struct +{ + __IO uint32_t CCR0B :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_ccr0b_field_t; + +typedef struct +{ + __IO uint32_t CCR1A :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_ccr1a_field_t; + +typedef struct +{ + __IO uint32_t CCR1B :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_ccr1b_field_t; + +typedef struct +{ + __IO uint32_t CCR2A :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_ccr2a_field_t; + +typedef struct +{ + __IO uint32_t CCR2B :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim3_mode23_ccr2b_field_t; + +typedef struct +{ + __IO uint32_t RNGCIR_EN : 1; + __IO uint32_t RNG_RUN : 1; + uint32_t RESERVED2 :29; + __IO uint32_t RSV : 1; +} stc_trng_cr_field_t; + +typedef struct +{ + __IO uint32_t LOAD : 1; + __IO uint32_t FDBK : 1; + __IO uint32_t CNT : 3; + uint32_t RESERVED5 :26; + __IO uint32_t RSV : 1; +} stc_trng_mode_field_t; + +typedef struct +{ + __IO uint32_t DATA0 :32; +} stc_trng_data0_field_t; + +typedef struct +{ + __IO uint32_t DATA1 :32; +} stc_trng_data1_field_t; + +typedef struct +{ + __IO uint32_t DATA : 8; + __IO uint32_t DATA8 : 1; + uint32_t RESERVED9 :22; + __IO uint32_t RSV : 1; +} stc_uart_sbuf_field_t; + +typedef struct +{ + __IO uint32_t RCIE : 1; + __IO uint32_t TCIE : 1; + __IO uint32_t B8CONT : 2; + __IO uint32_t REN : 1; + __IO uint32_t ADRDET : 1; + __IO uint32_t SM : 2; + __IO uint32_t TXEIE : 1; + __IO uint32_t OVER : 1; + uint32_t RESERVED10 : 3; + __IO uint32_t PEIE : 1; + __IO uint32_t STOPBIT : 2; + __IO uint32_t DMARXEN : 1; + __IO uint32_t DMATXEN : 1; + __IO uint32_t RTSEN : 1; + __IO uint32_t CTSEN : 1; + __IO uint32_t CTSIE : 1; + __IO uint32_t FEIE : 1; + __IO uint32_t HDSEL : 1; + uint32_t RESERVED23 : 8; + __IO uint32_t RSV : 1; +} stc_uart_scon_field_t; + +typedef struct +{ + __IO uint32_t SADDR : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_uart_saddr_field_t; + +typedef struct +{ + __IO uint32_t SADEN : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_uart_saden_field_t; + +typedef struct +{ + __IO uint32_t RC : 1; + __IO uint32_t TC : 1; + __IO uint32_t FE : 1; + __IO uint32_t TXE : 1; + __IO uint32_t PE : 1; + __IO uint32_t CTSIF : 1; + __IO uint32_t CTS : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_uart_isr_field_t; + +typedef struct +{ + __IO uint32_t RCCF : 1; + __IO uint32_t TCCF : 1; + __IO uint32_t FECF : 1; + uint32_t RESERVED3 : 1; + __IO uint32_t PECF : 1; + __IO uint32_t CTSIFCF : 1; + uint32_t RESERVED6 :25; + __IO uint32_t RSV : 1; +} stc_uart_icr_field_t; + +typedef struct +{ + __IO uint32_t SCNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_uart_scnt_field_t; + +typedef struct +{ + __IO uint32_t DIV : 6; + __IO uint32_t DIV_EN : 1; + __IO uint32_t REF2P5_SEL : 1; + __IO uint32_t VC0_BIAS_SEL : 2; + __IO uint32_t VC0_HYS_SEL : 2; + __IO uint32_t VC1_BIAS_SEL : 2; + __IO uint32_t VC1_HYS_SEL : 2; + __IO uint32_t VC2_BIAS_SEL : 2; + __IO uint32_t VC2_HYS_SEL : 2; + uint32_t RESERVED20 :11; + __IO uint32_t RSV : 1; +} stc_vc_cr_field_t; + +typedef struct +{ + __IO uint32_t P_SEL : 4; + __IO uint32_t N_SEL : 4; + __IO uint32_t FLTEN : 1; + __IO uint32_t DEBOUNCE_TIME : 3; + __IO uint32_t FALLING : 1; + __IO uint32_t RISING : 1; + __IO uint32_t LEVEL : 1; + __IO uint32_t IE : 1; + __IO uint32_t EN : 1; + uint32_t RESERVED17 :14; + __IO uint32_t RSV : 1; +} stc_vc_vc0_cr_field_t; + +typedef struct +{ + __IO uint32_t P_SEL : 4; + __IO uint32_t N_SEL : 4; + __IO uint32_t FLTEN : 1; + __IO uint32_t DEBOUNCE_TIME : 3; + __IO uint32_t FALLING : 1; + __IO uint32_t RISING : 1; + __IO uint32_t LEVEL : 1; + __IO uint32_t IE : 1; + __IO uint32_t EN : 1; + uint32_t RESERVED17 :14; + __IO uint32_t RSV : 1; +} stc_vc_vc1_cr_field_t; + +typedef struct +{ + __IO uint32_t INV_TIMER : 1; + __IO uint32_t TIM0RCLR : 1; + __IO uint32_t TIM1RCLR : 1; + __IO uint32_t TIM2RCLR : 1; + __IO uint32_t TIM3RCLR : 1; + __IO uint32_t TIMBK : 1; + uint32_t RESERVED6 : 3; + __IO uint32_t INV_TIM4 : 1; + __IO uint32_t TIM4 : 1; + __IO uint32_t INV_TIM5 : 1; + __IO uint32_t TIM5 : 1; + __IO uint32_t INV_TIM6 : 1; + __IO uint32_t TIM6 : 1; + __IO uint32_t BRAKE : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_vc_vc0_out_cfg_field_t; + +typedef struct +{ + __IO uint32_t INV_TIMER : 1; + __IO uint32_t TIM0RCLR : 1; + __IO uint32_t TIM1RCLR : 1; + __IO uint32_t TIM2RCLR : 1; + __IO uint32_t TIM3RCLR : 1; + __IO uint32_t TIMBK : 1; + uint32_t RESERVED6 : 3; + __IO uint32_t INV_TIM4 : 1; + __IO uint32_t TIM4 : 1; + __IO uint32_t INV_TIM5 : 1; + __IO uint32_t TIM5 : 1; + __IO uint32_t INV_TIM6 : 1; + __IO uint32_t TIM6 : 1; + __IO uint32_t BRAKE : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_vc_vc1_out_cfg_field_t; + +typedef struct +{ + __IO uint32_t VC0_INTF : 1; + __IO uint32_t VC1_INTF : 1; + __IO uint32_t VC0_FILTER : 1; + __IO uint32_t VC1_FILTER : 1; + __IO uint32_t VC2_INTF : 1; + __IO uint32_t VC2_FILTER : 1; + uint32_t RESERVED6 :25; + __IO uint32_t RSV : 1; +} stc_vc_ifr_field_t; + +typedef struct +{ + __IO uint32_t P_SEL : 4; + __IO uint32_t N_SEL : 4; + __IO uint32_t FLTEN : 1; + __IO uint32_t DEBOUNCE_TIME : 3; + __IO uint32_t FALLING : 1; + __IO uint32_t RISING : 1; + __IO uint32_t LEVEL : 1; + __IO uint32_t IE : 1; + __IO uint32_t EN : 1; + uint32_t RESERVED17 :14; + __IO uint32_t RSV : 1; +} stc_vc_vc2_cr_field_t; + +typedef struct +{ + __IO uint32_t INV_TIMER : 1; + __IO uint32_t TIM0RCLR : 1; + __IO uint32_t TIM1RCLR : 1; + __IO uint32_t TIM2RCLR : 1; + __IO uint32_t TIM3RCLR : 1; + __IO uint32_t TIMBK : 1; + uint32_t RESERVED6 : 3; + __IO uint32_t INV_TIM4 : 1; + __IO uint32_t TIM4 : 1; + __IO uint32_t INV_TIM5 : 1; + __IO uint32_t TIM5 : 1; + __IO uint32_t INV_TIM6 : 1; + __IO uint32_t TIM6 : 1; + __IO uint32_t BRAKE : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_vc_vc2_out_cfg_field_t; + +typedef struct +{ + __IO uint32_t RST : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_wdt_rst_field_t; + +typedef struct +{ + __IO uint32_t WOV : 4; + __IO uint32_t R : 1; + __IO uint32_t WINT_EN : 1; + uint32_t RESERVED6 : 1; + __IO uint32_t INT : 1; + __IO uint32_t WCNTL : 8; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_wdt_con_field_t; + + +typedef struct +{ + uint8_t RESERVED0[4]; + union + { + __IO uint32_t CR0; + stc_adc_cr0_field_t CR0_f; + }; + union + { + __IO uint32_t CR1; + stc_adc_cr1_field_t CR1_f; + }; + uint8_t RESERVED2[52]; + union + { + __IO uint32_t SQR0; + stc_adc_sqr0_field_t SQR0_f; + }; + union + { + __IO uint32_t SQR1; + stc_adc_sqr1_field_t SQR1_f; + }; + union + { + __IO uint32_t SQR2; + stc_adc_sqr2_field_t SQR2_f; + }; + union + { + __IO uint32_t JQR; + stc_adc_jqr_field_t JQR_f; + }; + union + { + __IO uint32_t SQRRESULT0; + stc_adc_sqrresult0_field_t SQRRESULT0_f; + }; + union + { + __IO uint32_t SQRRESULT1; + stc_adc_sqrresult1_field_t SQRRESULT1_f; + }; + union + { + __IO uint32_t SQRRESULT2; + stc_adc_sqrresult2_field_t SQRRESULT2_f; + }; + union + { + __IO uint32_t SQRRESULT3; + stc_adc_sqrresult3_field_t SQRRESULT3_f; + }; + union + { + __IO uint32_t SQRRESULT4; + stc_adc_sqrresult4_field_t SQRRESULT4_f; + }; + union + { + __IO uint32_t SQRRESULT5; + stc_adc_sqrresult5_field_t SQRRESULT5_f; + }; + union + { + __IO uint32_t SQRRESULT6; + stc_adc_sqrresult6_field_t SQRRESULT6_f; + }; + union + { + __IO uint32_t SQRRESULT7; + stc_adc_sqrresult7_field_t SQRRESULT7_f; + }; + union + { + __IO uint32_t SQRRESULT8; + stc_adc_sqrresult8_field_t SQRRESULT8_f; + }; + union + { + __IO uint32_t SQRRESULT9; + stc_adc_sqrresult9_field_t SQRRESULT9_f; + }; + union + { + __IO uint32_t SQRRESULT10; + stc_adc_sqrresult10_field_t SQRRESULT10_f; + }; + union + { + __IO uint32_t SQRRESULT11; + stc_adc_sqrresult11_field_t SQRRESULT11_f; + }; + union + { + __IO uint32_t SQRRESULT12; + stc_adc_sqrresult12_field_t SQRRESULT12_f; + }; + union + { + __IO uint32_t SQR_RESULT13; + stc_adc_sqr_result13_field_t SQR_RESULT13_f; + }; + union + { + __IO uint32_t SQRRESULT14; + stc_adc_sqrresult14_field_t SQRRESULT14_f; + }; + union + { + __IO uint32_t SQRRESULT15; + stc_adc_sqrresult15_field_t SQRRESULT15_f; + }; + union + { + __IO uint32_t JQRRESULT0; + stc_adc_jqrresult0_field_t JQRRESULT0_f; + }; + union + { + __IO uint32_t JQRRESULT1; + stc_adc_jqrresult1_field_t JQRRESULT1_f; + }; + union + { + __IO uint32_t JQRRESULT2; + stc_adc_jqrresult2_field_t JQRRESULT2_f; + }; + union + { + __IO uint32_t JQRRESULT3; + stc_adc_jqrresult3_field_t JQRRESULT3_f; + }; + union + { + __IO uint32_t RESULT; + stc_adc_result_field_t RESULT_f; + }; + union + { + __IO uint32_t RESULTACC; + stc_adc_resultacc_field_t RESULTACC_f; + }; + union + { + __IO uint32_t HT; + stc_adc_ht_field_t HT_f; + }; + union + { + __IO uint32_t LT; + stc_adc_lt_field_t LT_f; + }; + union + { + __IO uint32_t IFR; + stc_adc_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICR; + stc_adc_icr_field_t ICR_f; + }; + union + { + __IO uint32_t EXTTRIGGER0; + stc_adc_exttrigger0_field_t EXTTRIGGER0_f; + }; + union + { + __IO uint32_t EXTTRIGGER1; + stc_adc_exttrigger1_field_t EXTTRIGGER1_f; + }; + union + { + __IO uint32_t SGLSTART; + stc_adc_sglstart_field_t SGLSTART_f; + }; + union + { + __IO uint32_t SQRSTART; + stc_adc_sqrstart_field_t SQRSTART_f; + }; + union + { + __IO uint32_t JQRSTART; + stc_adc_jqrstart_field_t JQRSTART_f; + }; + union + { + __IO uint32_t ALLSTART; + stc_adc_allstart_field_t ALLSTART_f; + }; +}M0P_ADC_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CNTER; + stc_adtim_cnter_field_t CNTER_f; + }; + union + { + __IO uint32_t PERAR; + stc_adtim_perar_field_t PERAR_f; + }; + union + { + __IO uint32_t PERBR; + stc_adtim_perbr_field_t PERBR_f; + }; + uint8_t RESERVED3[4]; + union + { + __IO uint32_t GCMAR; + stc_adtim_gcmar_field_t GCMAR_f; + }; + union + { + __IO uint32_t GCMBR; + stc_adtim_gcmbr_field_t GCMBR_f; + }; + union + { + __IO uint32_t GCMCR; + stc_adtim_gcmcr_field_t GCMCR_f; + }; + union + { + __IO uint32_t GCMDR; + stc_adtim_gcmdr_field_t GCMDR_f; + }; + uint8_t RESERVED7[8]; + union + { + __IO uint32_t SCMAR; + stc_adtim_scmar_field_t SCMAR_f; + }; + union + { + __IO uint32_t SCMBR; + stc_adtim_scmbr_field_t SCMBR_f; + }; + uint8_t RESERVED9[16]; + union + { + __IO uint32_t DTUAR; + stc_adtim_dtuar_field_t DTUAR_f; + }; + union + { + __IO uint32_t DTDAR; + stc_adtim_dtdar_field_t DTDAR_f; + }; + uint8_t RESERVED11[8]; + union + { + __IO uint32_t GCONR; + stc_adtim_gconr_field_t GCONR_f; + }; + union + { + __IO uint32_t ICONR; + stc_adtim_iconr_field_t ICONR_f; + }; + union + { + __IO uint32_t PCONR; + stc_adtim_pconr_field_t PCONR_f; + }; + union + { + __IO uint32_t BCONR; + stc_adtim_bconr_field_t BCONR_f; + }; + union + { + __IO uint32_t DCONR; + stc_adtim_dconr_field_t DCONR_f; + }; + uint8_t RESERVED16[4]; + union + { + __IO uint32_t FCONR; + stc_adtim_fconr_field_t FCONR_f; + }; + union + { + __IO uint32_t VPERR; + stc_adtim_vperr_field_t VPERR_f; + }; + union + { + __IO uint32_t STFLR; + stc_adtim_stflr_field_t STFLR_f; + }; + union + { + __IO uint32_t HSTAR; + stc_adtim_hstar_field_t HSTAR_f; + }; + union + { + __IO uint32_t HSTPR; + stc_adtim_hstpr_field_t HSTPR_f; + }; + union + { + __IO uint32_t HCELR; + stc_adtim_hcelr_field_t HCELR_f; + }; + union + { + __IO uint32_t HCPAR; + stc_adtim_hcpar_field_t HCPAR_f; + }; + union + { + __IO uint32_t HCPBR; + stc_adtim_hcpbr_field_t HCPBR_f; + }; + union + { + __IO uint32_t HCUPR; + stc_adtim_hcupr_field_t HCUPR_f; + }; + union + { + __IO uint32_t HCDOR; + stc_adtim_hcdor_field_t HCDOR_f; + }; + uint8_t RESERVED26[112]; + union + { + __IO uint32_t IFR; + stc_adtim_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_adtim_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t CR; + stc_adtim_cr_field_t CR_f; + }; + uint8_t RESERVED29[4]; + union + { + __IO uint32_t AOSSR; + stc_adtim_aossr_field_t AOSSR_f; + }; + union + { + __IO uint32_t AOSCL; + stc_adtim_aoscl_field_t AOSCL_f; + }; + union + { + __IO uint32_t PTBKS; + stc_adtim_ptbks_field_t PTBKS_f; + }; + union + { + __IO uint32_t TTRIG; + stc_adtim_ttrig_field_t TTRIG_f; + }; + union + { + __IO uint32_t ITRIG; + stc_adtim_itrig_field_t ITRIG_f; + }; + union + { + __IO uint32_t PTBKP; + stc_adtim_ptbkp_field_t PTBKP_f; + }; + uint8_t RESERVED35[716]; + union + { + __IO uint32_t SSTAR; + stc_adtim_sstar_field_t SSTAR_f; + }; + union + { + __IO uint32_t SSTPR; + stc_adtim_sstpr_field_t SSTPR_f; + }; + union + { + __IO uint32_t SCLRR; + stc_adtim_sclrr_field_t SCLRR_f; + }; +}M0P_ADTIM_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CR; + stc_aes_cr_field_t CR_f; + }; + uint8_t RESERVED1[12]; + union + { + __IO uint32_t DATA0; + stc_aes_data0_field_t DATA0_f; + }; + union + { + __IO uint32_t DATA1; + stc_aes_data1_field_t DATA1_f; + }; + union + { + __IO uint32_t DATA2; + stc_aes_data2_field_t DATA2_f; + }; + union + { + __IO uint32_t DATA3; + stc_aes_data3_field_t DATA3_f; + }; + union + { + __IO uint32_t KEY0; + stc_aes_key0_field_t KEY0_f; + }; + union + { + __IO uint32_t KEY1; + stc_aes_key1_field_t KEY1_f; + }; + union + { + __IO uint32_t KEY2; + stc_aes_key2_field_t KEY2_f; + }; + union + { + __IO uint32_t KEY3; + stc_aes_key3_field_t KEY3_f; + }; + union + { + __IO uint32_t KEY4; + stc_aes_key4_field_t KEY4_f; + }; + union + { + __IO uint32_t KEY5; + stc_aes_key5_field_t KEY5_f; + }; + union + { + __IO uint32_t KEY6; + stc_aes_key6_field_t KEY6_f; + }; + union + { + __IO uint32_t KEY7; + stc_aes_key7_field_t KEY7_f; + }; +}M0P_AES_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CR; + stc_bgr_cr_field_t CR_f; + }; +}M0P_BGR_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CR; + stc_clk_trim_cr_field_t CR_f; + }; + union + { + __IO uint32_t REFCON; + stc_clk_trim_refcon_field_t REFCON_f; + }; + union + { + __IO uint32_t REFCNT; + stc_clk_trim_refcnt_field_t REFCNT_f; + }; + union + { + __IO uint32_t CALCNT; + stc_clk_trim_calcnt_field_t CALCNT_f; + }; + union + { + __IO uint32_t IFR; + stc_clk_trim_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_clk_trim_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t CALCON; + stc_clk_trim_calcon_field_t CALCON_f; + }; +}M0P_CLK_TRIM_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CR; + stc_crc_cr_field_t CR_f; + }; + union + { + __IO uint32_t RESULT; + stc_crc_result_field_t RESULT_f; + }; + uint8_t RESERVED2[120]; + union + { + __IO uint32_t DATA; + stc_crc_data_field_t DATA_f; + }; +}M0P_CRC_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CR0; + stc_dac_cr0_field_t CR0_f; + }; + union + { + __IO uint32_t SWTRIGR; + stc_dac_swtrigr_field_t SWTRIGR_f; + }; + union + { + __IO uint32_t DHR12R0; + stc_dac_dhr12r0_field_t DHR12R0_f; + }; + union + { + __IO uint32_t DHR12L0; + stc_dac_dhr12l0_field_t DHR12L0_f; + }; + union + { + __IO uint32_t DHR8R0; + stc_dac_dhr8r0_field_t DHR8R0_f; + }; + uint8_t RESERVED5[24]; + union + { + __IO uint32_t DOR0; + stc_dac_dor0_field_t DOR0_f; + }; + uint8_t RESERVED6[4]; + union + { + __IO uint32_t SR; + stc_dac_sr_field_t SR_f; + }; + union + { + __IO uint32_t ETRS; + stc_dac_etrs_field_t ETRS_f; + }; +}M0P_DAC_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t DEBUG_ACTIVE; + stc_debug_active_field_t DEBUG_ACTIVE_f; + }; +}M0P_DEBUG_ACTIVE_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CONF; + stc_dmac_conf_field_t CONF_f; + }; + uint8_t RESERVED1[12]; + union + { + __IO uint32_t CONFA0; + stc_dmac_confa0_field_t CONFA0_f; + }; + union + { + __IO uint32_t CONFB0; + stc_dmac_confb0_field_t CONFB0_f; + }; + union + { + __IO uint32_t SRCADR0; + stc_dmac_srcadr0_field_t SRCADR0_f; + }; + union + { + __IO uint32_t DSTADR0; + stc_dmac_dstadr0_field_t DSTADR0_f; + }; + union + { + __IO uint32_t CONFA1; + stc_dmac_confa1_field_t CONFA1_f; + }; + union + { + __IO uint32_t CONFB1; + stc_dmac_confb1_field_t CONFB1_f; + }; + union + { + __IO uint32_t SRCADR1; + stc_dmac_srcadr1_field_t SRCADR1_f; + }; + union + { + __IO uint32_t DSTADR1; + stc_dmac_dstadr1_field_t DSTADR1_f; + }; +}M0P_DMAC_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t TNVS; + stc_flash_tnvs_field_t TNVS_f; + }; + union + { + __IO uint32_t TPGS; + stc_flash_tpgs_field_t TPGS_f; + }; + union + { + __IO uint32_t TPROG; + stc_flash_tprog_field_t TPROG_f; + }; + union + { + __IO uint32_t TSERASE; + stc_flash_tserase_field_t TSERASE_f; + }; + union + { + __IO uint32_t TMERASE; + stc_flash_tmerase_field_t TMERASE_f; + }; + union + { + __IO uint32_t TPRCV; + stc_flash_tprcv_field_t TPRCV_f; + }; + union + { + __IO uint32_t TSRCV; + stc_flash_tsrcv_field_t TSRCV_f; + }; + union + { + __IO uint32_t TMRCV; + stc_flash_tmrcv_field_t TMRCV_f; + }; + union + { + __IO uint32_t CR; + stc_flash_cr_field_t CR_f; + }; + union + { + __IO uint32_t IFR; + stc_flash_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_flash_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t BYPASS; + stc_flash_bypass_field_t BYPASS_f; + }; + union + { + __IO uint32_t SLOCK0; + stc_flash_slock0_field_t SLOCK0_f; + }; + union + { + __IO uint32_t SLOCK1; + stc_flash_slock1_field_t SLOCK1_f; + }; +}M0P_FLASH_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t PA00_SEL; + stc_gpio_pa00_sel_field_t PA00_SEL_f; + }; + union + { + __IO uint32_t PA01_SEL; + stc_gpio_pa01_sel_field_t PA01_SEL_f; + }; + union + { + __IO uint32_t PA02_SEL; + stc_gpio_pa02_sel_field_t PA02_SEL_f; + }; + union + { + __IO uint32_t PA03_SEL; + stc_gpio_pa03_sel_field_t PA03_SEL_f; + }; + union + { + __IO uint32_t PA04_SEL; + stc_gpio_pa04_sel_field_t PA04_SEL_f; + }; + union + { + __IO uint32_t PA05_SEL; + stc_gpio_pa05_sel_field_t PA05_SEL_f; + }; + union + { + __IO uint32_t PA06_SEL; + stc_gpio_pa06_sel_field_t PA06_SEL_f; + }; + union + { + __IO uint32_t PA07_SEL; + stc_gpio_pa07_sel_field_t PA07_SEL_f; + }; + union + { + __IO uint32_t PA08_SEL; + stc_gpio_pa08_sel_field_t PA08_SEL_f; + }; + union + { + __IO uint32_t PA09_SEL; + stc_gpio_pa09_sel_field_t PA09_SEL_f; + }; + union + { + __IO uint32_t PA10_SEL; + stc_gpio_pa10_sel_field_t PA10_SEL_f; + }; + union + { + __IO uint32_t PA11_SEL; + stc_gpio_pa11_sel_field_t PA11_SEL_f; + }; + union + { + __IO uint32_t PA12_SEL; + stc_gpio_pa12_sel_field_t PA12_SEL_f; + }; + union + { + __IO uint32_t PA13_SEL; + stc_gpio_pa13_sel_field_t PA13_SEL_f; + }; + union + { + __IO uint32_t PA14_SEL; + stc_gpio_pa14_sel_field_t PA14_SEL_f; + }; + union + { + __IO uint32_t PA15_SEL; + stc_gpio_pa15_sel_field_t PA15_SEL_f; + }; + union + { + __IO uint32_t PB00_SEL; + stc_gpio_pb00_sel_field_t PB00_SEL_f; + }; + union + { + __IO uint32_t PB01_SEL; + stc_gpio_pb01_sel_field_t PB01_SEL_f; + }; + union + { + __IO uint32_t PB02_SEL; + stc_gpio_pb02_sel_field_t PB02_SEL_f; + }; + union + { + __IO uint32_t PB03_SEL; + stc_gpio_pb03_sel_field_t PB03_SEL_f; + }; + union + { + __IO uint32_t PB04_SEL; + stc_gpio_pb04_sel_field_t PB04_SEL_f; + }; + union + { + __IO uint32_t PB05_SEL; + stc_gpio_pb05_sel_field_t PB05_SEL_f; + }; + union + { + __IO uint32_t PB06_SEL; + stc_gpio_pb06_sel_field_t PB06_SEL_f; + }; + union + { + __IO uint32_t PB07_SEL; + stc_gpio_pb07_sel_field_t PB07_SEL_f; + }; + union + { + __IO uint32_t PB08_SEL; + stc_gpio_pb08_sel_field_t PB08_SEL_f; + }; + union + { + __IO uint32_t PB09_SEL; + stc_gpio_pb09_sel_field_t PB09_SEL_f; + }; + union + { + __IO uint32_t PB10_SEL; + stc_gpio_pb10_sel_field_t PB10_SEL_f; + }; + union + { + __IO uint32_t PB11_SEL; + stc_gpio_pb11_sel_field_t PB11_SEL_f; + }; + union + { + __IO uint32_t PB12_SEL; + stc_gpio_pb12_sel_field_t PB12_SEL_f; + }; + union + { + __IO uint32_t PB13_SEL; + stc_gpio_pb13_sel_field_t PB13_SEL_f; + }; + union + { + __IO uint32_t PB14_SEL; + stc_gpio_pb14_sel_field_t PB14_SEL_f; + }; + union + { + __IO uint32_t PB15_SEL; + stc_gpio_pb15_sel_field_t PB15_SEL_f; + }; + union + { + __IO uint32_t PC00_SEL; + stc_gpio_pc00_sel_field_t PC00_SEL_f; + }; + union + { + __IO uint32_t PC01_SEL; + stc_gpio_pc01_sel_field_t PC01_SEL_f; + }; + union + { + __IO uint32_t PC02_SEL; + stc_gpio_pc02_sel_field_t PC02_SEL_f; + }; + union + { + __IO uint32_t PC03_SEL; + stc_gpio_pc03_sel_field_t PC03_SEL_f; + }; + union + { + __IO uint32_t PC04_SEL; + stc_gpio_pc04_sel_field_t PC04_SEL_f; + }; + union + { + __IO uint32_t PC05_SEL; + stc_gpio_pc05_sel_field_t PC05_SEL_f; + }; + union + { + __IO uint32_t PC06_SEL; + stc_gpio_pc06_sel_field_t PC06_SEL_f; + }; + union + { + __IO uint32_t PC07_SEL; + stc_gpio_pc07_sel_field_t PC07_SEL_f; + }; + union + { + __IO uint32_t PC08_SEL; + stc_gpio_pc08_sel_field_t PC08_SEL_f; + }; + union + { + __IO uint32_t PC09_SEL; + stc_gpio_pc09_sel_field_t PC09_SEL_f; + }; + union + { + __IO uint32_t PC10_SEL; + stc_gpio_pc10_sel_field_t PC10_SEL_f; + }; + union + { + __IO uint32_t PC11_SEL; + stc_gpio_pc11_sel_field_t PC11_SEL_f; + }; + union + { + __IO uint32_t PC12_SEL; + stc_gpio_pc12_sel_field_t PC12_SEL_f; + }; + union + { + __IO uint32_t PC13_SEL; + stc_gpio_pc13_sel_field_t PC13_SEL_f; + }; + union + { + __IO uint32_t PC14_SEL; + stc_gpio_pc14_sel_field_t PC14_SEL_f; + }; + union + { + __IO uint32_t PC15_SEL; + stc_gpio_pc15_sel_field_t PC15_SEL_f; + }; + union + { + __IO uint32_t PD00_SEL; + stc_gpio_pd00_sel_field_t PD00_SEL_f; + }; + union + { + __IO uint32_t PD01_SEL; + stc_gpio_pd01_sel_field_t PD01_SEL_f; + }; + union + { + __IO uint32_t PD02_SEL; + stc_gpio_pd02_sel_field_t PD02_SEL_f; + }; + union + { + __IO uint32_t PD03_SEL; + stc_gpio_pd03_sel_field_t PD03_SEL_f; + }; + union + { + __IO uint32_t PD04_SEL; + stc_gpio_pd04_sel_field_t PD04_SEL_f; + }; + union + { + __IO uint32_t PD05_SEL; + stc_gpio_pd05_sel_field_t PD05_SEL_f; + }; + union + { + __IO uint32_t PD06_SEL; + stc_gpio_pd06_sel_field_t PD06_SEL_f; + }; + union + { + __IO uint32_t PD07_SEL; + stc_gpio_pd07_sel_field_t PD07_SEL_f; + }; + union + { + __IO uint32_t PD08_SEL; + stc_gpio_pd08_sel_field_t PD08_SEL_f; + }; + union + { + __IO uint32_t PD09_SEL; + stc_gpio_pd09_sel_field_t PD09_SEL_f; + }; + union + { + __IO uint32_t PD10_SEL; + stc_gpio_pd10_sel_field_t PD10_SEL_f; + }; + union + { + __IO uint32_t PD11_SEL; + stc_gpio_pd11_sel_field_t PD11_SEL_f; + }; + union + { + __IO uint32_t PD12_SEL; + stc_gpio_pd12_sel_field_t PD12_SEL_f; + }; + union + { + __IO uint32_t PD13_SEL; + stc_gpio_pd13_sel_field_t PD13_SEL_f; + }; + union + { + __IO uint32_t PD14_SEL; + stc_gpio_pd14_sel_field_t PD14_SEL_f; + }; + union + { + __IO uint32_t PD15_SEL; + stc_gpio_pd15_sel_field_t PD15_SEL_f; + }; + union + { + __IO uint32_t PADIR; + stc_gpio_padir_field_t PADIR_f; + }; + union + { + __IO uint32_t PAIN; + stc_gpio_pain_field_t PAIN_f; + }; + union + { + __IO uint32_t PAOUT; + stc_gpio_paout_field_t PAOUT_f; + }; + union + { + __IO uint32_t PAADS; + stc_gpio_paads_field_t PAADS_f; + }; + union + { + __IO uint32_t PABSET; + stc_gpio_pabset_field_t PABSET_f; + }; + union + { + __IO uint32_t PABCLR; + stc_gpio_pabclr_field_t PABCLR_f; + }; + union + { + __IO uint32_t PABSETCLR; + stc_gpio_pabsetclr_field_t PABSETCLR_f; + }; + union + { + __IO uint32_t PADR; + stc_gpio_padr_field_t PADR_f; + }; + union + { + __IO uint32_t PAPU; + stc_gpio_papu_field_t PAPU_f; + }; + union + { + __IO uint32_t PAPD; + stc_gpio_papd_field_t PAPD_f; + }; + uint8_t RESERVED74[4]; + union + { + __IO uint32_t PAOD; + stc_gpio_paod_field_t PAOD_f; + }; + union + { + __IO uint32_t PAHIE; + stc_gpio_pahie_field_t PAHIE_f; + }; + union + { + __IO uint32_t PALIE; + stc_gpio_palie_field_t PALIE_f; + }; + union + { + __IO uint32_t PARIE; + stc_gpio_parie_field_t PARIE_f; + }; + union + { + __IO uint32_t PAFIE; + stc_gpio_pafie_field_t PAFIE_f; + }; + union + { + __IO uint32_t PBDIR; + stc_gpio_pbdir_field_t PBDIR_f; + }; + union + { + __IO uint32_t PBIN; + stc_gpio_pbin_field_t PBIN_f; + }; + union + { + __IO uint32_t PBOUT; + stc_gpio_pbout_field_t PBOUT_f; + }; + union + { + __IO uint32_t PBADS; + stc_gpio_pbads_field_t PBADS_f; + }; + union + { + __IO uint32_t PBBSET; + stc_gpio_pbbset_field_t PBBSET_f; + }; + union + { + __IO uint32_t PBBCLR; + stc_gpio_pbbclr_field_t PBBCLR_f; + }; + union + { + __IO uint32_t PBBSETCLR; + stc_gpio_pbbsetclr_field_t PBBSETCLR_f; + }; + union + { + __IO uint32_t PBDR; + stc_gpio_pbdr_field_t PBDR_f; + }; + union + { + __IO uint32_t PBPU; + stc_gpio_pbpu_field_t PBPU_f; + }; + union + { + __IO uint32_t PBPD; + stc_gpio_pbpd_field_t PBPD_f; + }; + uint8_t RESERVED89[4]; + union + { + __IO uint32_t PBOD; + stc_gpio_pbod_field_t PBOD_f; + }; + union + { + __IO uint32_t PBHIE; + stc_gpio_pbhie_field_t PBHIE_f; + }; + union + { + __IO uint32_t PBLIE; + stc_gpio_pblie_field_t PBLIE_f; + }; + union + { + __IO uint32_t PBRIE; + stc_gpio_pbrie_field_t PBRIE_f; + }; + union + { + __IO uint32_t PBFIE; + stc_gpio_pbfie_field_t PBFIE_f; + }; + union + { + __IO uint32_t PCDIR; + stc_gpio_pcdir_field_t PCDIR_f; + }; + union + { + __IO uint32_t PCIN; + stc_gpio_pcin_field_t PCIN_f; + }; + union + { + __IO uint32_t PCOUT; + stc_gpio_pcout_field_t PCOUT_f; + }; + union + { + __IO uint32_t PCADS; + stc_gpio_pcads_field_t PCADS_f; + }; + union + { + __IO uint32_t PCBSET; + stc_gpio_pcbset_field_t PCBSET_f; + }; + union + { + __IO uint32_t PCBCLR; + stc_gpio_pcbclr_field_t PCBCLR_f; + }; + union + { + __IO uint32_t PCBSETCLR; + stc_gpio_pcbsetclr_field_t PCBSETCLR_f; + }; + union + { + __IO uint32_t PCDR; + stc_gpio_pcdr_field_t PCDR_f; + }; + union + { + __IO uint32_t PCPU; + stc_gpio_pcpu_field_t PCPU_f; + }; + union + { + __IO uint32_t PCPD; + stc_gpio_pcpd_field_t PCPD_f; + }; + uint8_t RESERVED104[4]; + union + { + __IO uint32_t PCOD; + stc_gpio_pcod_field_t PCOD_f; + }; + union + { + __IO uint32_t PCHIE; + stc_gpio_pchie_field_t PCHIE_f; + }; + union + { + __IO uint32_t PCLIE; + stc_gpio_pclie_field_t PCLIE_f; + }; + union + { + __IO uint32_t PCRIE; + stc_gpio_pcrie_field_t PCRIE_f; + }; + union + { + __IO uint32_t PCFIE; + stc_gpio_pcfie_field_t PCFIE_f; + }; + union + { + __IO uint32_t PDDIR; + stc_gpio_pddir_field_t PDDIR_f; + }; + union + { + __IO uint32_t PDIN; + stc_gpio_pdin_field_t PDIN_f; + }; + union + { + __IO uint32_t PDOUT; + stc_gpio_pdout_field_t PDOUT_f; + }; + union + { + __IO uint32_t PDADS; + stc_gpio_pdads_field_t PDADS_f; + }; + union + { + __IO uint32_t PDBSET; + stc_gpio_pdbset_field_t PDBSET_f; + }; + union + { + __IO uint32_t PDBCLR; + stc_gpio_pdbclr_field_t PDBCLR_f; + }; + union + { + __IO uint32_t PDBSETCLR; + stc_gpio_pdbsetclr_field_t PDBSETCLR_f; + }; + union + { + __IO uint32_t PDDR; + stc_gpio_pddr_field_t PDDR_f; + }; + union + { + __IO uint32_t PDPU; + stc_gpio_pdpu_field_t PDPU_f; + }; + union + { + __IO uint32_t PDPD; + stc_gpio_pdpd_field_t PDPD_f; + }; + uint8_t RESERVED119[4]; + union + { + __IO uint32_t PDOD; + stc_gpio_pdod_field_t PDOD_f; + }; + union + { + __IO uint32_t PDHIE; + stc_gpio_pdhie_field_t PDHIE_f; + }; + union + { + __IO uint32_t PDLIE; + stc_gpio_pdlie_field_t PDLIE_f; + }; + union + { + __IO uint32_t PDRIE; + stc_gpio_pdrie_field_t PDRIE_f; + }; + union + { + __IO uint32_t PDFIE; + stc_gpio_pdfie_field_t PDFIE_f; + }; + union + { + __IO uint32_t PA_STAT; + stc_gpio_pa_stat_field_t PA_STAT_f; + }; + uint8_t RESERVED125[12]; + union + { + __IO uint32_t PA_ICLR; + stc_gpio_pa_iclr_field_t PA_ICLR_f; + }; + uint8_t RESERVED126[44]; + union + { + __IO uint32_t PB_STAT; + stc_gpio_pb_stat_field_t PB_STAT_f; + }; + uint8_t RESERVED127[12]; + union + { + __IO uint32_t PB_ICLR; + stc_gpio_pb_iclr_field_t PB_ICLR_f; + }; + uint8_t RESERVED128[44]; + union + { + __IO uint32_t PC_STAT; + stc_gpio_pc_stat_field_t PC_STAT_f; + }; + uint8_t RESERVED129[12]; + union + { + __IO uint32_t PC_ICLR; + stc_gpio_pc_iclr_field_t PC_ICLR_f; + }; + uint8_t RESERVED130[44]; + union + { + __IO uint32_t PD_STAT; + stc_gpio_pd_stat_field_t PD_STAT_f; + }; + uint8_t RESERVED131[12]; + union + { + __IO uint32_t PD_ICLR; + stc_gpio_pd_iclr_field_t PD_ICLR_f; + }; + uint8_t RESERVED132[44]; + union + { + __IO uint32_t CTRL0; + stc_gpio_ctrl0_field_t CTRL0_f; + }; + union + { + __IO uint32_t CTRL1; + stc_gpio_ctrl1_field_t CTRL1_f; + }; + union + { + __IO uint32_t CTRL2; + stc_gpio_ctrl2_field_t CTRL2_f; + }; + union + { + __IO uint32_t TIMGS; + stc_gpio_timgs_field_t TIMGS_f; + }; + union + { + __IO uint32_t TIMES; + stc_gpio_times_field_t TIMES_f; + }; + union + { + __IO uint32_t TIMCPS; + stc_gpio_timcps_field_t TIMCPS_f; + }; + union + { + __IO uint32_t PCAS; + stc_gpio_pcas_field_t PCAS_f; + }; + union + { + __IO uint32_t PCNT; + stc_gpio_pcnt_field_t PCNT_f; + }; + uint8_t RESERVED140[3296]; + union + { + __IO uint32_t PE00_SEL; + stc_gpio_pe00_sel_field_t PE00_SEL_f; + }; + union + { + __IO uint32_t PE01_SEL; + stc_gpio_pe01_sel_field_t PE01_SEL_f; + }; + union + { + __IO uint32_t PE02_SEL; + stc_gpio_pe02_sel_field_t PE02_SEL_f; + }; + union + { + __IO uint32_t PE03_SEL; + stc_gpio_pe03_sel_field_t PE03_SEL_f; + }; + union + { + __IO uint32_t PE04_SEL; + stc_gpio_pe04_sel_field_t PE04_SEL_f; + }; + union + { + __IO uint32_t PE05_SEL; + stc_gpio_pe05_sel_field_t PE05_SEL_f; + }; + union + { + __IO uint32_t PE06_SEL; + stc_gpio_pe06_sel_field_t PE06_SEL_f; + }; + union + { + __IO uint32_t PE07_SEL; + stc_gpio_pe07_sel_field_t PE07_SEL_f; + }; + union + { + __IO uint32_t PE08_SEL; + stc_gpio_pe08_sel_field_t PE08_SEL_f; + }; + union + { + __IO uint32_t PE09_SEL; + stc_gpio_pe09_sel_field_t PE09_SEL_f; + }; + union + { + __IO uint32_t PE10_SEL; + stc_gpio_pe10_sel_field_t PE10_SEL_f; + }; + union + { + __IO uint32_t PE11_SEL; + stc_gpio_pe11_sel_field_t PE11_SEL_f; + }; + union + { + __IO uint32_t PE12_SEL; + stc_gpio_pe12_sel_field_t PE12_SEL_f; + }; + union + { + __IO uint32_t PE13_SEL; + stc_gpio_pe13_sel_field_t PE13_SEL_f; + }; + union + { + __IO uint32_t PE14_SEL; + stc_gpio_pe14_sel_field_t PE14_SEL_f; + }; + union + { + __IO uint32_t PE15_SEL; + stc_gpio_pe15_sel_field_t PE15_SEL_f; + }; + union + { + __IO uint32_t PF00_SEL; + stc_gpio_pf00_sel_field_t PF00_SEL_f; + }; + union + { + __IO uint32_t PF01_SEL; + stc_gpio_pf01_sel_field_t PF01_SEL_f; + }; + union + { + __IO uint32_t PF02_SEL; + stc_gpio_pf02_sel_field_t PF02_SEL_f; + }; + union + { + __IO uint32_t PF03_SEL; + stc_gpio_pf03_sel_field_t PF03_SEL_f; + }; + union + { + __IO uint32_t PF04_SEL; + stc_gpio_pf04_sel_field_t PF04_SEL_f; + }; + union + { + __IO uint32_t PF05_SEL; + stc_gpio_pf05_sel_field_t PF05_SEL_f; + }; + union + { + __IO uint32_t PF06_SEL; + stc_gpio_pf06_sel_field_t PF06_SEL_f; + }; + union + { + __IO uint32_t PF07_SEL; + stc_gpio_pf07_sel_field_t PF07_SEL_f; + }; + union + { + __IO uint32_t PF08_SEL; + stc_gpio_pf08_sel_field_t PF08_SEL_f; + }; + union + { + __IO uint32_t PF09_SEL; + stc_gpio_pf09_sel_field_t PF09_SEL_f; + }; + union + { + __IO uint32_t PF10_SEL; + stc_gpio_pf10_sel_field_t PF10_SEL_f; + }; + union + { + __IO uint32_t PF11_SEL; + stc_gpio_pf11_sel_field_t PF11_SEL_f; + }; + uint8_t RESERVED168[144]; + union + { + __IO uint32_t PEDIR; + stc_gpio_pedir_field_t PEDIR_f; + }; + union + { + __IO uint32_t PEIN; + stc_gpio_pein_field_t PEIN_f; + }; + union + { + __IO uint32_t PEOUT; + stc_gpio_peout_field_t PEOUT_f; + }; + union + { + __IO uint32_t PEADS; + stc_gpio_peads_field_t PEADS_f; + }; + union + { + __IO uint32_t PEBSET; + stc_gpio_pebset_field_t PEBSET_f; + }; + union + { + __IO uint32_t PEBCLR; + stc_gpio_pebclr_field_t PEBCLR_f; + }; + union + { + __IO uint32_t PEBSETCLR; + stc_gpio_pebsetclr_field_t PEBSETCLR_f; + }; + union + { + __IO uint32_t PEDR; + stc_gpio_pedr_field_t PEDR_f; + }; + union + { + __IO uint32_t PEPU; + stc_gpio_pepu_field_t PEPU_f; + }; + union + { + __IO uint32_t PEPD; + stc_gpio_pepd_field_t PEPD_f; + }; + uint8_t RESERVED178[4]; + union + { + __IO uint32_t PEOD; + stc_gpio_peod_field_t PEOD_f; + }; + union + { + __IO uint32_t PEHIE; + stc_gpio_pehie_field_t PEHIE_f; + }; + union + { + __IO uint32_t PELIE; + stc_gpio_pelie_field_t PELIE_f; + }; + union + { + __IO uint32_t PERIE; + stc_gpio_perie_field_t PERIE_f; + }; + union + { + __IO uint32_t PEFIE; + stc_gpio_pefie_field_t PEFIE_f; + }; + union + { + __IO uint32_t PFDIR; + stc_gpio_pfdir_field_t PFDIR_f; + }; + union + { + __IO uint32_t PFIN; + stc_gpio_pfin_field_t PFIN_f; + }; + union + { + __IO uint32_t PFOUT; + stc_gpio_pfout_field_t PFOUT_f; + }; + union + { + __IO uint32_t PFADS; + stc_gpio_pfads_field_t PFADS_f; + }; + union + { + __IO uint32_t PFBSET; + stc_gpio_pfbset_field_t PFBSET_f; + }; + union + { + __IO uint32_t PFBCLR; + stc_gpio_pfbclr_field_t PFBCLR_f; + }; + union + { + __IO uint32_t PFBSETCLR; + stc_gpio_pfbsetclr_field_t PFBSETCLR_f; + }; + union + { + __IO uint32_t PFDR; + stc_gpio_pfdr_field_t PFDR_f; + }; + union + { + __IO uint32_t PFPU; + stc_gpio_pfpu_field_t PFPU_f; + }; + union + { + __IO uint32_t PFPD; + stc_gpio_pfpd_field_t PFPD_f; + }; + uint8_t RESERVED193[4]; + union + { + __IO uint32_t PFOD; + stc_gpio_pfod_field_t PFOD_f; + }; + union + { + __IO uint32_t PFHIE; + stc_gpio_pfhie_field_t PFHIE_f; + }; + union + { + __IO uint32_t PFLIE; + stc_gpio_pflie_field_t PFLIE_f; + }; + union + { + __IO uint32_t PFRIE; + stc_gpio_pfrie_field_t PFRIE_f; + }; + union + { + __IO uint32_t PFFIE; + stc_gpio_pffie_field_t PFFIE_f; + }; + uint8_t RESERVED198[128]; + union + { + __IO uint32_t PE_STAT; + stc_gpio_pe_stat_field_t PE_STAT_f; + }; + uint8_t RESERVED199[12]; + union + { + __IO uint32_t PE_ICLR; + stc_gpio_pe_iclr_field_t PE_ICLR_f; + }; + uint8_t RESERVED200[44]; + union + { + __IO uint32_t PF_STAT; + stc_gpio_pf_stat_field_t PF_STAT_f; + }; + uint8_t RESERVED201[12]; + union + { + __IO uint32_t PF_ICLR; + stc_gpio_pf_iclr_field_t PF_ICLR_f; + }; +}M0P_GPIO_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t TMRUN; + stc_i2c_tmrun_field_t TMRUN_f; + }; + union + { + __IO uint32_t TM; + stc_i2c_tm_field_t TM_f; + }; + union + { + __IO uint32_t CR; + stc_i2c_cr_field_t CR_f; + }; + union + { + __IO uint32_t DATA; + stc_i2c_data_field_t DATA_f; + }; + union + { + __IO uint32_t ADDR; + stc_i2c_addr_field_t ADDR_f; + }; + union + { + __IO uint32_t STAT; + stc_i2c_stat_field_t STAT_f; + }; +}M0P_I2C_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CR0; + stc_lcd_cr0_field_t CR0_f; + }; + union + { + __IO uint32_t CR1; + stc_lcd_cr1_field_t CR1_f; + }; + union + { + __IO uint32_t INTCLR; + stc_lcd_intclr_field_t INTCLR_f; + }; + union + { + __IO uint32_t POEN0; + stc_lcd_poen0_field_t POEN0_f; + }; + union + { + __IO uint32_t POEN1; + stc_lcd_poen1_field_t POEN1_f; + }; + uint8_t RESERVED5[44]; + union + { + __IO uint32_t RAM0; + stc_lcd_ram0_field_t RAM0_f; + }; + union + { + __IO uint32_t RAM1; + stc_lcd_ram1_field_t RAM1_f; + }; + union + { + __IO uint32_t RAM2; + stc_lcd_ram2_field_t RAM2_f; + }; + union + { + __IO uint32_t RAM3; + stc_lcd_ram3_field_t RAM3_f; + }; + union + { + __IO uint32_t RAM4; + stc_lcd_ram4_field_t RAM4_f; + }; + union + { + __IO uint32_t RAM5; + stc_lcd_ram5_field_t RAM5_f; + }; + union + { + __IO uint32_t RAM6; + stc_lcd_ram6_field_t RAM6_f; + }; + union + { + __IO uint32_t RAM7; + stc_lcd_ram7_field_t RAM7_f; + }; + union + { + __IO uint32_t RAM8; + stc_lcd_ram8_field_t RAM8_f; + }; + union + { + __IO uint32_t RAM9; + stc_lcd_ram9_field_t RAM9_f; + }; + union + { + __IO uint32_t RAMA; + stc_lcd_rama_field_t RAMA_f; + }; + union + { + __IO uint32_t RAMB; + stc_lcd_ramb_field_t RAMB_f; + }; + union + { + __IO uint32_t RAMC; + stc_lcd_ramc_field_t RAMC_f; + }; + union + { + __IO uint32_t RAMD; + stc_lcd_ramd_field_t RAMD_f; + }; + union + { + __IO uint32_t RAME; + stc_lcd_rame_field_t RAME_f; + }; + union + { + __IO uint32_t RAMF; + stc_lcd_ramf_field_t RAMF_f; + }; +}M0P_LCD_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CNT; + stc_lptimer_cnt_field_t CNT_f; + }; + union + { + __IO uint32_t ARR; + stc_lptimer_arr_field_t ARR_f; + }; + uint8_t RESERVED2[4]; + union + { + __IO uint32_t CR; + stc_lptimer_cr_field_t CR_f; + }; + union + { + __IO uint32_t IFR; + stc_lptimer_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_lptimer_iclr_field_t ICLR_f; + }; +}M0P_LPTIMER_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t SBUF; + stc_lpuart_sbuf_field_t SBUF_f; + }; + union + { + __IO uint32_t SCON; + stc_lpuart_scon_field_t SCON_f; + }; + union + { + __IO uint32_t SADDR; + stc_lpuart_saddr_field_t SADDR_f; + }; + union + { + __IO uint32_t SADEN; + stc_lpuart_saden_field_t SADEN_f; + }; + union + { + __IO uint32_t ISR; + stc_lpuart_isr_field_t ISR_f; + }; + union + { + __IO uint32_t ICR; + stc_lpuart_icr_field_t ICR_f; + }; + union + { + __IO uint32_t SCNT; + stc_lpuart_scnt_field_t SCNT_f; + }; +}M0P_LPUART_TypeDef; + +typedef struct +{ + uint8_t RESERVED0[40]; + union + { + __IO uint32_t CR; + stc_lvd_cr_field_t CR_f; + }; + union + { + __IO uint32_t IFR; + stc_lvd_ifr_field_t IFR_f; + }; +}M0P_LVD_TypeDef; + +typedef struct +{ + uint8_t RESERVED0[48]; + union + { + __IO uint32_t CR0; + stc_opa_cr0_field_t CR0_f; + }; + uint8_t RESERVED1[8]; + union + { + __IO uint32_t CR1; + stc_opa_cr1_field_t CR1_f; + }; +}M0P_OPA_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CCON; + stc_pca_ccon_field_t CCON_f; + }; + union + { + __IO uint32_t CMOD; + stc_pca_cmod_field_t CMOD_f; + }; + union + { + __IO uint32_t CNT; + stc_pca_cnt_field_t CNT_f; + }; + union + { + __IO uint32_t ICLR; + stc_pca_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t CCAPM0; + stc_pca_ccapm0_field_t CCAPM0_f; + }; + union + { + __IO uint32_t CCAPM1; + stc_pca_ccapm1_field_t CCAPM1_f; + }; + union + { + __IO uint32_t CCAPM2; + stc_pca_ccapm2_field_t CCAPM2_f; + }; + union + { + __IO uint32_t CCAPM3; + stc_pca_ccapm3_field_t CCAPM3_f; + }; + union + { + __IO uint32_t CCAPM4; + stc_pca_ccapm4_field_t CCAPM4_f; + }; + union + { + __IO uint32_t CCAP0H; + stc_pca_ccap0h_field_t CCAP0H_f; + }; + union + { + __IO uint32_t CCAP0L; + stc_pca_ccap0l_field_t CCAP0L_f; + }; + union + { + __IO uint32_t CCAP1H; + stc_pca_ccap1h_field_t CCAP1H_f; + }; + union + { + __IO uint32_t CCAP1L; + stc_pca_ccap1l_field_t CCAP1L_f; + }; + union + { + __IO uint32_t CCAP2H; + stc_pca_ccap2h_field_t CCAP2H_f; + }; + union + { + __IO uint32_t CCAP2L; + stc_pca_ccap2l_field_t CCAP2L_f; + }; + union + { + __IO uint32_t CCAP3H; + stc_pca_ccap3h_field_t CCAP3H_f; + }; + union + { + __IO uint32_t CCAP3L; + stc_pca_ccap3l_field_t CCAP3L_f; + }; + union + { + __IO uint32_t CCAP4H; + stc_pca_ccap4h_field_t CCAP4H_f; + }; + union + { + __IO uint32_t CCAP4L; + stc_pca_ccap4l_field_t CCAP4L_f; + }; + union + { + __IO uint32_t CCAPO; + stc_pca_ccapo_field_t CCAPO_f; + }; + union + { + __IO uint32_t CCAP0; + stc_pca_ccap0_field_t CCAP0_f; + }; + union + { + __IO uint32_t CCAP1; + stc_pca_ccap1_field_t CCAP1_f; + }; + union + { + __IO uint32_t CCAP2; + stc_pca_ccap2_field_t CCAP2_f; + }; + union + { + __IO uint32_t CCAP3; + stc_pca_ccap3_field_t CCAP3_f; + }; + union + { + __IO uint32_t CCAP4; + stc_pca_ccap4_field_t CCAP4_f; + }; + union + { + __IO uint32_t CARR; + stc_pca_carr_field_t CARR_f; + }; + union + { + __IO uint32_t EPWM; + stc_pca_epwm_field_t EPWM_f; + }; +}M0P_PCA_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t RUN; + stc_pcnt_run_field_t RUN_f; + }; + union + { + __IO uint32_t CTRL; + stc_pcnt_ctrl_field_t CTRL_f; + }; + union + { + __IO uint32_t FLT; + stc_pcnt_flt_field_t FLT_f; + }; + union + { + __IO uint32_t TOCR; + stc_pcnt_tocr_field_t TOCR_f; + }; + union + { + __IO uint32_t CMD; + stc_pcnt_cmd_field_t CMD_f; + }; + union + { + __IO uint32_t SR1; + stc_pcnt_sr1_field_t SR1_f; + }; + union + { + __IO uint32_t CNT; + stc_pcnt_cnt_field_t CNT_f; + }; + union + { + __IO uint32_t TOP; + stc_pcnt_top_field_t TOP_f; + }; + union + { + __IO uint32_t BUF; + stc_pcnt_buf_field_t BUF_f; + }; + union + { + __IO uint32_t IFR; + stc_pcnt_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICR; + stc_pcnt_icr_field_t ICR_f; + }; + union + { + __IO uint32_t IEN; + stc_pcnt_ien_field_t IEN_f; + }; + union + { + __IO uint32_t SR2; + stc_pcnt_sr2_field_t SR2_f; + }; + union + { + __IO uint32_t DBG; + stc_pcnt_dbg_field_t DBG_f; + }; +}M0P_PCNT_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CR; + stc_ram_cr_field_t CR_f; + }; + union + { + __IO uint32_t ERRADDR; + stc_ram_erraddr_field_t ERRADDR_f; + }; + union + { + __IO uint32_t IFR; + stc_ram_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_ram_iclr_field_t ICLR_f; + }; +}M0P_RAM_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t RESET_FLAG; + stc_reset_flag_field_t RESET_FLAG_f; + }; + uint8_t RESERVED1[8]; + union + { + __IO uint32_t PERI_RESET0; + stc_reset_peri_reset0_field_t PERI_RESET0_f; + }; + union + { + __IO uint32_t PERI_RESET1; + stc_reset_peri_reset1_field_t PERI_RESET1_f; + }; +}M0P_RESET_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CR0; + stc_rtc_cr0_field_t CR0_f; + }; + union + { + __IO uint32_t CR1; + stc_rtc_cr1_field_t CR1_f; + }; + union + { + __IO uint32_t SEC; + stc_rtc_sec_field_t SEC_f; + }; + union + { + __IO uint32_t MIN; + stc_rtc_min_field_t MIN_f; + }; + union + { + __IO uint32_t HOUR; + stc_rtc_hour_field_t HOUR_f; + }; + union + { + __IO uint32_t WEEK; + stc_rtc_week_field_t WEEK_f; + }; + union + { + __IO uint32_t DAY; + stc_rtc_day_field_t DAY_f; + }; + union + { + __IO uint32_t MON; + stc_rtc_mon_field_t MON_f; + }; + union + { + __IO uint32_t YEAR; + stc_rtc_year_field_t YEAR_f; + }; + union + { + __IO uint32_t ALMMIN; + stc_rtc_almmin_field_t ALMMIN_f; + }; + union + { + __IO uint32_t ALMHOUR; + stc_rtc_almhour_field_t ALMHOUR_f; + }; + union + { + __IO uint32_t ALMWEEK; + stc_rtc_almweek_field_t ALMWEEK_f; + }; + union + { + __IO uint32_t COMPEN; + stc_rtc_compen_field_t COMPEN_f; + }; + union + { + __IO uint32_t ALMSEC; + stc_rtc_almsec_field_t ALMSEC_f; + }; +}M0P_RTC_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CR; + stc_spi_cr_field_t CR_f; + }; + union + { + __IO uint32_t SSN; + stc_spi_ssn_field_t SSN_f; + }; + union + { + __IO uint32_t STAT; + stc_spi_stat_field_t STAT_f; + }; + union + { + __IO uint32_t DATA; + stc_spi_data_field_t DATA_f; + }; + union + { + __IO uint32_t CR2; + stc_spi_cr2_field_t CR2_f; + }; + union + { + __IO uint32_t ICLR; + stc_spi_iclr_field_t ICLR_f; + }; +}M0P_SPI_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t SYSCTRL0; + stc_sysctrl_sysctrl0_field_t SYSCTRL0_f; + }; + union + { + __IO uint32_t SYSCTRL1; + stc_sysctrl_sysctrl1_field_t SYSCTRL1_f; + }; + union + { + __IO uint32_t SYSCTRL2; + stc_sysctrl_sysctrl2_field_t SYSCTRL2_f; + }; + union + { + __IO uint32_t RCH_CR; + stc_sysctrl_rch_cr_field_t RCH_CR_f; + }; + union + { + __IO uint32_t XTH_CR; + stc_sysctrl_xth_cr_field_t XTH_CR_f; + }; + union + { + __IO uint32_t RCL_CR; + stc_sysctrl_rcl_cr_field_t RCL_CR_f; + }; + union + { + __IO uint32_t XTL_CR; + stc_sysctrl_xtl_cr_field_t XTL_CR_f; + }; + uint8_t RESERVED7[4]; + union + { + __IO uint32_t PERI_CLKEN0; + stc_sysctrl_peri_clken0_field_t PERI_CLKEN0_f; + }; + union + { + __IO uint32_t PERI_CLKEN1; + stc_sysctrl_peri_clken1_field_t PERI_CLKEN1_f; + }; + uint8_t RESERVED9[20]; + union + { + __IO uint32_t PLL_CR; + stc_sysctrl_pll_cr_field_t PLL_CR_f; + }; +}M0P_SYSCTRL_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t ARR; + stc_tim0_mode0_arr_field_t ARR_f; + }; + union + { + __IO uint32_t CNT; + stc_tim0_mode0_cnt_field_t CNT_f; + }; + union + { + __IO uint32_t CNT32; + stc_tim0_mode0_cnt32_field_t CNT32_f; + }; + union + { + __IO uint32_t M0CR; + stc_tim0_mode0_m0cr_field_t M0CR_f; + }; + union + { + __IO uint32_t IFR; + stc_tim0_mode0_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_tim0_mode0_iclr_field_t ICLR_f; + }; + uint8_t RESERVED6[24]; + union + { + __IO uint32_t DTR; + stc_tim0_mode0_dtr_field_t DTR_f; + }; +}M0P_TIM0_MODE0_TypeDef; + +typedef struct +{ + uint8_t RESERVED0[4]; + union + { + __IO uint32_t CNT; + stc_tim0_mode1_cnt_field_t CNT_f; + }; + uint8_t RESERVED1[4]; + union + { + __IO uint32_t M1CR; + stc_tim0_mode1_m1cr_field_t M1CR_f; + }; + union + { + __IO uint32_t IFR; + stc_tim0_mode1_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_tim0_mode1_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t MSCR; + stc_tim0_mode1_mscr_field_t MSCR_f; + }; + union + { + __IO uint32_t FLTR; + stc_tim0_mode1_fltr_field_t FLTR_f; + }; + uint8_t RESERVED6[4]; + union + { + __IO uint32_t CR0; + stc_tim0_mode1_cr0_field_t CR0_f; + }; + uint8_t RESERVED7[20]; + union + { + __IO uint32_t CCR0A; + stc_tim0_mode1_ccr0a_field_t CCR0A_f; + }; +}M0P_TIM0_MODE1_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t ARR; + stc_tim0_mode23_arr_field_t ARR_f; + }; + union + { + __IO uint32_t CNT; + stc_tim0_mode23_cnt_field_t CNT_f; + }; + uint8_t RESERVED2[4]; + union + { + __IO uint32_t M23CR; + stc_tim0_mode23_m23cr_field_t M23CR_f; + }; + union + { + __IO uint32_t IFR; + stc_tim0_mode23_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_tim0_mode23_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t MSCR; + stc_tim0_mode23_mscr_field_t MSCR_f; + }; + union + { + __IO uint32_t FLTR; + stc_tim0_mode23_fltr_field_t FLTR_f; + }; + union + { + __IO uint32_t ADTR; + stc_tim0_mode23_adtr_field_t ADTR_f; + }; + union + { + __IO uint32_t CRCH0; + stc_tim0_mode23_crch0_field_t CRCH0_f; + }; + uint8_t RESERVED9[8]; + union + { + __IO uint32_t DTR; + stc_tim0_mode23_dtr_field_t DTR_f; + }; + union + { + __IO uint32_t RCR; + stc_tim0_mode23_rcr_field_t RCR_f; + }; + union + { + __IO uint32_t ARRDM; + stc_tim0_mode23_arrdm_field_t ARRDM_f; + }; + union + { + __IO uint32_t CCR0A; + stc_tim0_mode23_ccr0a_field_t CCR0A_f; + }; + union + { + __IO uint32_t CCR0B; + stc_tim0_mode23_ccr0b_field_t CCR0B_f; + }; +}M0P_TIM0_MODE23_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t ARR; + stc_tim1_mode0_arr_field_t ARR_f; + }; + union + { + __IO uint32_t CNT; + stc_tim1_mode0_cnt_field_t CNT_f; + }; + union + { + __IO uint32_t CNT32; + stc_tim1_mode0_cnt32_field_t CNT32_f; + }; + union + { + __IO uint32_t M0CR; + stc_tim1_mode0_m0cr_field_t M0CR_f; + }; + union + { + __IO uint32_t IFR; + stc_tim1_mode0_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_tim1_mode0_iclr_field_t ICLR_f; + }; + uint8_t RESERVED6[24]; + union + { + __IO uint32_t DTR; + stc_tim1_mode0_dtr_field_t DTR_f; + }; +}M0P_TIM1_MODE0_TypeDef; + +typedef struct +{ + uint8_t RESERVED0[4]; + union + { + __IO uint32_t CNT; + stc_tim1_mode1_cnt_field_t CNT_f; + }; + uint8_t RESERVED1[4]; + union + { + __IO uint32_t M1CR; + stc_tim1_mode1_m1cr_field_t M1CR_f; + }; + union + { + __IO uint32_t IFR; + stc_tim1_mode1_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_tim1_mode1_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t MSCR; + stc_tim1_mode1_mscr_field_t MSCR_f; + }; + union + { + __IO uint32_t FLTR; + stc_tim1_mode1_fltr_field_t FLTR_f; + }; + uint8_t RESERVED6[4]; + union + { + __IO uint32_t CR0; + stc_tim1_mode1_cr0_field_t CR0_f; + }; + uint8_t RESERVED7[20]; + union + { + __IO uint32_t CCR0A; + stc_tim1_mode1_ccr0a_field_t CCR0A_f; + }; +}M0P_TIM1_MODE1_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t ARR; + stc_tim1_mode23_arr_field_t ARR_f; + }; + union + { + __IO uint32_t CNT; + stc_tim1_mode23_cnt_field_t CNT_f; + }; + uint8_t RESERVED2[4]; + union + { + __IO uint32_t M23CR; + stc_tim1_mode23_m23cr_field_t M23CR_f; + }; + union + { + __IO uint32_t IFR; + stc_tim1_mode23_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_tim1_mode23_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t MSCR; + stc_tim1_mode23_mscr_field_t MSCR_f; + }; + union + { + __IO uint32_t FLTR; + stc_tim1_mode23_fltr_field_t FLTR_f; + }; + union + { + __IO uint32_t ADTR; + stc_tim1_mode23_adtr_field_t ADTR_f; + }; + union + { + __IO uint32_t CRCH0; + stc_tim1_mode23_crch0_field_t CRCH0_f; + }; + uint8_t RESERVED9[8]; + union + { + __IO uint32_t DTR; + stc_tim1_mode23_dtr_field_t DTR_f; + }; + union + { + __IO uint32_t RCR; + stc_tim1_mode23_rcr_field_t RCR_f; + }; + union + { + __IO uint32_t ARRDM; + stc_tim1_mode23_arrdm_field_t ARRDM_f; + }; + union + { + __IO uint32_t CCR0A; + stc_tim1_mode23_ccr0a_field_t CCR0A_f; + }; + union + { + __IO uint32_t CCR0B; + stc_tim1_mode23_ccr0b_field_t CCR0B_f; + }; +}M0P_TIM1_MODE23_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t ARR; + stc_tim2_mode0_arr_field_t ARR_f; + }; + union + { + __IO uint32_t CNT; + stc_tim2_mode0_cnt_field_t CNT_f; + }; + union + { + __IO uint32_t CNT32; + stc_tim2_mode0_cnt32_field_t CNT32_f; + }; + union + { + __IO uint32_t M0CR; + stc_tim2_mode0_m0cr_field_t M0CR_f; + }; + union + { + __IO uint32_t IFR; + stc_tim2_mode0_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_tim2_mode0_iclr_field_t ICLR_f; + }; + uint8_t RESERVED6[24]; + union + { + __IO uint32_t DTR; + stc_tim2_mode0_dtr_field_t DTR_f; + }; +}M0P_TIM2_MODE0_TypeDef; + +typedef struct +{ + uint8_t RESERVED0[4]; + union + { + __IO uint32_t CNT; + stc_tim2_mode1_cnt_field_t CNT_f; + }; + uint8_t RESERVED1[4]; + union + { + __IO uint32_t M1CR; + stc_tim2_mode1_m1cr_field_t M1CR_f; + }; + union + { + __IO uint32_t IFR; + stc_tim2_mode1_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_tim2_mode1_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t MSCR; + stc_tim2_mode1_mscr_field_t MSCR_f; + }; + union + { + __IO uint32_t FLTR; + stc_tim2_mode1_fltr_field_t FLTR_f; + }; + uint8_t RESERVED6[4]; + union + { + __IO uint32_t CR0; + stc_tim2_mode1_cr0_field_t CR0_f; + }; + uint8_t RESERVED7[20]; + union + { + __IO uint32_t CCR0A; + stc_tim2_mode1_ccr0a_field_t CCR0A_f; + }; +}M0P_TIM2_MODE1_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t ARR; + stc_tim2_mode23_arr_field_t ARR_f; + }; + union + { + __IO uint32_t CNT; + stc_tim2_mode23_cnt_field_t CNT_f; + }; + uint8_t RESERVED2[4]; + union + { + __IO uint32_t M23CR; + stc_tim2_mode23_m23cr_field_t M23CR_f; + }; + union + { + __IO uint32_t IFR; + stc_tim2_mode23_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_tim2_mode23_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t MSCR; + stc_tim2_mode23_mscr_field_t MSCR_f; + }; + union + { + __IO uint32_t FLTR; + stc_tim2_mode23_fltr_field_t FLTR_f; + }; + union + { + __IO uint32_t ADTR; + stc_tim2_mode23_adtr_field_t ADTR_f; + }; + union + { + __IO uint32_t CRCH0; + stc_tim2_mode23_crch0_field_t CRCH0_f; + }; + uint8_t RESERVED9[8]; + union + { + __IO uint32_t DTR; + stc_tim2_mode23_dtr_field_t DTR_f; + }; + union + { + __IO uint32_t RCR; + stc_tim2_mode23_rcr_field_t RCR_f; + }; + union + { + __IO uint32_t ARRDM; + stc_tim2_mode23_arrdm_field_t ARRDM_f; + }; + union + { + __IO uint32_t CCR0A; + stc_tim2_mode23_ccr0a_field_t CCR0A_f; + }; + union + { + __IO uint32_t CCR0B; + stc_tim2_mode23_ccr0b_field_t CCR0B_f; + }; +}M0P_TIM2_MODE23_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t ARR; + stc_tim3_mode0_arr_field_t ARR_f; + }; + union + { + __IO uint32_t CNT; + stc_tim3_mode0_cnt_field_t CNT_f; + }; + union + { + __IO uint32_t CNT32; + stc_tim3_mode0_cnt32_field_t CNT32_f; + }; + union + { + __IO uint32_t M0CR; + stc_tim3_mode0_m0cr_field_t M0CR_f; + }; + union + { + __IO uint32_t IFR; + stc_tim3_mode0_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_tim3_mode0_iclr_field_t ICLR_f; + }; + uint8_t RESERVED6[24]; + union + { + __IO uint32_t DTR; + stc_tim3_mode0_dtr_field_t DTR_f; + }; +}M0P_TIM3_MODE0_TypeDef; + +typedef struct +{ + uint8_t RESERVED0[4]; + union + { + __IO uint32_t CNT; + stc_tim3_mode1_cnt_field_t CNT_f; + }; + uint8_t RESERVED1[4]; + union + { + __IO uint32_t M1CR; + stc_tim3_mode1_m1cr_field_t M1CR_f; + }; + union + { + __IO uint32_t IFR; + stc_tim3_mode1_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_tim3_mode1_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t MSCR; + stc_tim3_mode1_mscr_field_t MSCR_f; + }; + union + { + __IO uint32_t FLTR; + stc_tim3_mode1_fltr_field_t FLTR_f; + }; + uint8_t RESERVED6[4]; + union + { + __IO uint32_t CR0; + stc_tim3_mode1_cr0_field_t CR0_f; + }; + uint8_t RESERVED7[20]; + union + { + __IO uint32_t CCR0A; + stc_tim3_mode1_ccr0a_field_t CCR0A_f; + }; +}M0P_TIM3_MODE1_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t ARR; + stc_tim3_mode23_arr_field_t ARR_f; + }; + union + { + __IO uint32_t CNT; + stc_tim3_mode23_cnt_field_t CNT_f; + }; + uint8_t RESERVED2[4]; + union + { + __IO uint32_t M23CR; + stc_tim3_mode23_m23cr_field_t M23CR_f; + }; + union + { + __IO uint32_t IFR; + stc_tim3_mode23_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_tim3_mode23_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t MSCR; + stc_tim3_mode23_mscr_field_t MSCR_f; + }; + union + { + __IO uint32_t FLTR; + stc_tim3_mode23_fltr_field_t FLTR_f; + }; + union + { + __IO uint32_t ADTR; + stc_tim3_mode23_adtr_field_t ADTR_f; + }; + union + { + __IO uint32_t CRCH0; + stc_tim3_mode23_crch0_field_t CRCH0_f; + }; + union + { + __IO uint32_t CRCH1; + stc_tim3_mode23_crch1_field_t CRCH1_f; + }; + union + { + __IO uint32_t CRCH2; + stc_tim3_mode23_crch2_field_t CRCH2_f; + }; + union + { + __IO uint32_t DTR; + stc_tim3_mode23_dtr_field_t DTR_f; + }; + union + { + __IO uint32_t RCR; + stc_tim3_mode23_rcr_field_t RCR_f; + }; + union + { + __IO uint32_t ARRDM; + stc_tim3_mode23_arrdm_field_t ARRDM_f; + }; + union + { + __IO uint32_t CCR0A; + stc_tim3_mode23_ccr0a_field_t CCR0A_f; + }; + union + { + __IO uint32_t CCR0B; + stc_tim3_mode23_ccr0b_field_t CCR0B_f; + }; + union + { + __IO uint32_t CCR1A; + stc_tim3_mode23_ccr1a_field_t CCR1A_f; + }; + union + { + __IO uint32_t CCR1B; + stc_tim3_mode23_ccr1b_field_t CCR1B_f; + }; + union + { + __IO uint32_t CCR2A; + stc_tim3_mode23_ccr2a_field_t CCR2A_f; + }; + union + { + __IO uint32_t CCR2B; + stc_tim3_mode23_ccr2b_field_t CCR2B_f; + }; +}M0P_TIM3_MODE23_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CR; + stc_trng_cr_field_t CR_f; + }; + union + { + __IO uint32_t MODE; + stc_trng_mode_field_t MODE_f; + }; + uint8_t RESERVED2[4]; + union + { + __IO uint32_t DATA0; + stc_trng_data0_field_t DATA0_f; + }; + union + { + __IO uint32_t DATA1; + stc_trng_data1_field_t DATA1_f; + }; +}M0P_TRNG_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t SBUF; + stc_uart_sbuf_field_t SBUF_f; + }; + union + { + __IO uint32_t SCON; + stc_uart_scon_field_t SCON_f; + }; + union + { + __IO uint32_t SADDR; + stc_uart_saddr_field_t SADDR_f; + }; + union + { + __IO uint32_t SADEN; + stc_uart_saden_field_t SADEN_f; + }; + union + { + __IO uint32_t ISR; + stc_uart_isr_field_t ISR_f; + }; + union + { + __IO uint32_t ICR; + stc_uart_icr_field_t ICR_f; + }; + union + { + __IO uint32_t SCNT; + stc_uart_scnt_field_t SCNT_f; + }; +}M0P_UART_TypeDef; + +typedef struct +{ + uint8_t RESERVED0[16]; + union + { + __IO uint32_t CR; + stc_vc_cr_field_t CR_f; + }; + union + { + __IO uint32_t VC0_CR; + stc_vc_vc0_cr_field_t VC0_CR_f; + }; + union + { + __IO uint32_t VC1_CR; + stc_vc_vc1_cr_field_t VC1_CR_f; + }; + union + { + __IO uint32_t VC0_OUT_CFG; + stc_vc_vc0_out_cfg_field_t VC0_OUT_CFG_f; + }; + union + { + __IO uint32_t VC1_OUT_CFG; + stc_vc_vc1_out_cfg_field_t VC1_OUT_CFG_f; + }; + union + { + __IO uint32_t IFR; + stc_vc_ifr_field_t IFR_f; + }; + uint8_t RESERVED6[296]; + union + { + __IO uint32_t VC2_CR; + stc_vc_vc2_cr_field_t VC2_CR_f; + }; + union + { + __IO uint32_t VC2_OUT_CFG; + stc_vc_vc2_out_cfg_field_t VC2_OUT_CFG_f; + }; +}M0P_VC_TypeDef; + +typedef struct +{ + uint8_t RESERVED0[128]; + union + { + __IO uint32_t RST; + stc_wdt_rst_field_t RST_f; + }; + union + { + __IO uint32_t CON; + stc_wdt_con_field_t CON_f; + }; +}M0P_WDT_TypeDef; + + + +#define M0P_PERIPH_BASE (0x40000000UL) +#define M0P_ADC_BASE (M0P_PERIPH_BASE + 0x00002400UL) +#define M0P_ADTIM4_BASE (M0P_PERIPH_BASE + 0x00003000UL) +#define M0P_ADTIM5_BASE (M0P_PERIPH_BASE + 0x00003400UL) +#define M0P_ADTIM6_BASE (M0P_PERIPH_BASE + 0x00003800UL) +#define M0P_AES_BASE (M0P_PERIPH_BASE + 0x00021400UL) +#define M0P_BGR_BASE (M0P_PERIPH_BASE + 0x00002400UL) +#define M0P_CLK_TRIM_BASE (M0P_PERIPH_BASE + 0x00001800UL) +#define M0P_CRC_BASE (M0P_PERIPH_BASE + 0x00020900UL) +#define M0P_DAC_BASE (M0P_PERIPH_BASE + 0x00002500UL) +#define M0P_DEBUG_ACTIVE_BASE (M0P_PERIPH_BASE + 0x00002038UL) +#define M0P_DMAC_BASE (M0P_PERIPH_BASE + 0x00021000UL) +#define M0P_FLASH_BASE (M0P_PERIPH_BASE + 0x00020000UL) +#define M0P_GPIO_BASE (M0P_PERIPH_BASE + 0x00020C00UL) +#define M0P_I2C0_BASE (M0P_PERIPH_BASE + 0x00000400UL) +#define M0P_I2C1_BASE (M0P_PERIPH_BASE + 0x00004400UL) +#define M0P_LCD_BASE (M0P_PERIPH_BASE + 0x00005C00UL) +#define M0P_LPTIMER0_BASE (M0P_PERIPH_BASE + 0x00000F00UL) +#define M0P_LPTIMER1_BASE (M0P_PERIPH_BASE + 0x00000F40UL) +#define M0P_LPUART0_BASE (M0P_PERIPH_BASE + 0x00000200UL) +#define M0P_LPUART1_BASE (M0P_PERIPH_BASE + 0x00004000UL) +#define M0P_LVD_BASE (M0P_PERIPH_BASE + 0x00002400UL) +#define M0P_OPA_BASE (M0P_PERIPH_BASE + 0x00002400UL) +#define M0P_PCA_BASE (M0P_PERIPH_BASE + 0x00001000UL) +#define M0P_PCNT_BASE (M0P_PERIPH_BASE + 0x00005400UL) +#define M0P_RAM_BASE (M0P_PERIPH_BASE + 0x00020400UL) +#define M0P_RESET_BASE (M0P_PERIPH_BASE + 0x0000201CUL) +#define M0P_RTC_BASE (M0P_PERIPH_BASE + 0x00001400UL) +#define M0P_SPI0_BASE (M0P_PERIPH_BASE + 0x00000800UL) +#define M0P_SPI1_BASE (M0P_PERIPH_BASE + 0x00004800UL) +#define M0P_SYSCTRL_BASE (M0P_PERIPH_BASE + 0x00002000UL) +#define M0P_TIM0_MODE0_BASE (M0P_PERIPH_BASE + 0x00000C00UL) +#define M0P_TIM0_MODE1_BASE (M0P_PERIPH_BASE + 0x00000C00UL) +#define M0P_TIM0_MODE23_BASE (M0P_PERIPH_BASE + 0x00000C00UL) +#define M0P_TIM1_MODE0_BASE (M0P_PERIPH_BASE + 0x00000D00UL) +#define M0P_TIM1_MODE1_BASE (M0P_PERIPH_BASE + 0x00000D00UL) +#define M0P_TIM1_MODE23_BASE (M0P_PERIPH_BASE + 0x00000D00UL) +#define M0P_TIM2_MODE0_BASE (M0P_PERIPH_BASE + 0x00000E00UL) +#define M0P_TIM2_MODE1_BASE (M0P_PERIPH_BASE + 0x00000E00UL) +#define M0P_TIM2_MODE23_BASE (M0P_PERIPH_BASE + 0x00000E00UL) +#define M0P_TIM3_MODE0_BASE (M0P_PERIPH_BASE + 0x00005800UL) +#define M0P_TIM3_MODE1_BASE (M0P_PERIPH_BASE + 0x00005800UL) +#define M0P_TIM3_MODE23_BASE (M0P_PERIPH_BASE + 0x00005800UL) +#define M0P_TRNG_BASE (M0P_PERIPH_BASE + 0x00004C00UL) +#define M0P_UART0_BASE (M0P_PERIPH_BASE + 0x00000000UL) +#define M0P_UART1_BASE (M0P_PERIPH_BASE + 0x00000100UL) +#define M0P_UART2_BASE (M0P_PERIPH_BASE + 0x00006000UL) +#define M0P_UART3_BASE (M0P_PERIPH_BASE + 0x00006400UL) +#define M0P_VC_BASE (M0P_PERIPH_BASE + 0x00002400UL) +#define M0P_WDT_BASE (M0P_PERIPH_BASE + 0x00000F00UL) + + +#define M0P_ADC ((M0P_ADC_TypeDef *)0x40002400UL) +#define M0P_ADTIM4 ((M0P_ADTIM_TypeDef *)0x40003000UL) +#define M0P_ADTIM5 ((M0P_ADTIM_TypeDef *)0x40003400UL) +#define M0P_ADTIM6 ((M0P_ADTIM_TypeDef *)0x40003800UL) +#define M0P_AES ((M0P_AES_TypeDef *)0x40021400UL) +#define M0P_BGR ((M0P_BGR_TypeDef *)0x40002400UL) +#define M0P_CLK_TRIM ((M0P_CLK_TRIM_TypeDef *)0x40001800UL) +#define M0P_CRC ((M0P_CRC_TypeDef *)0x40020900UL) +#define M0P_DAC ((M0P_DAC_TypeDef *)0x40002500UL) +#define M0P_DEBUG_ACTIVE ((M0P_DEBUG_ACTIVE_TypeDef *)0x40002038UL) +#define M0P_DMAC ((M0P_DMAC_TypeDef *)0x40021000UL) +#define M0P_FLASH ((M0P_FLASH_TypeDef *)0x40020000UL) +#define M0P_GPIO ((M0P_GPIO_TypeDef *)0x40020C00UL) +#define M0P_I2C0 ((M0P_I2C_TypeDef *)0x40000400UL) +#define M0P_I2C1 ((M0P_I2C_TypeDef *)0x40004400UL) +#define M0P_LCD ((M0P_LCD_TypeDef *)0x40005C00UL) +#define M0P_LPTIMER0 ((M0P_LPTIMER_TypeDef *)0x40000F00UL) +#define M0P_LPTIMER1 ((M0P_LPTIMER_TypeDef *)0x40000F40UL) +#define M0P_LPUART0 ((M0P_LPUART_TypeDef *)0x40000200UL) +#define M0P_LPUART1 ((M0P_LPUART_TypeDef *)0x40004000UL) +#define M0P_LVD ((M0P_LVD_TypeDef *)0x40002400UL) +#define M0P_OPA ((M0P_OPA_TypeDef *)0x40002400UL) +#define M0P_PCA ((M0P_PCA_TypeDef *)0x40001000UL) +#define M0P_PCNT ((M0P_PCNT_TypeDef *)0x40005400UL) +#define M0P_RAM ((M0P_RAM_TypeDef *)0x40020400UL) +#define M0P_RESET ((M0P_RESET_TypeDef *)0x4000201CUL) +#define M0P_RTC ((M0P_RTC_TypeDef *)0x40001400UL) +#define M0P_SPI0 ((M0P_SPI_TypeDef *)0x40000800UL) +#define M0P_SPI1 ((M0P_SPI_TypeDef *)0x40004800UL) +#define M0P_SYSCTRL ((M0P_SYSCTRL_TypeDef *)0x40002000UL) +#define M0P_TIM0_MODE0 ((M0P_TIM0_MODE0_TypeDef *)0x40000C00UL) +#define M0P_TIM0_MODE1 ((M0P_TIM0_MODE1_TypeDef *)0x40000C00UL) +#define M0P_TIM0_MODE23 ((M0P_TIM0_MODE23_TypeDef *)0x40000C00UL) +#define M0P_TIM1_MODE0 ((M0P_TIM1_MODE0_TypeDef *)0x40000D00UL) +#define M0P_TIM1_MODE1 ((M0P_TIM1_MODE1_TypeDef *)0x40000D00UL) +#define M0P_TIM1_MODE23 ((M0P_TIM1_MODE23_TypeDef *)0x40000D00UL) +#define M0P_TIM2_MODE0 ((M0P_TIM2_MODE0_TypeDef *)0x40000E00UL) +#define M0P_TIM2_MODE1 ((M0P_TIM2_MODE1_TypeDef *)0x40000E00UL) +#define M0P_TIM2_MODE23 ((M0P_TIM2_MODE23_TypeDef *)0x40000E00UL) +#define M0P_TIM3_MODE0 ((M0P_TIM3_MODE0_TypeDef *)0x40005800UL) +#define M0P_TIM3_MODE1 ((M0P_TIM3_MODE1_TypeDef *)0x40005800UL) +#define M0P_TIM3_MODE23 ((M0P_TIM3_MODE23_TypeDef *)0x40005800UL) +#define M0P_TRNG ((M0P_TRNG_TypeDef *)0x40004C00UL) +#define M0P_UART0 ((M0P_UART_TypeDef *)0x40000000UL) +#define M0P_UART1 ((M0P_UART_TypeDef *)0x40000100UL) +#define M0P_UART2 ((M0P_UART_TypeDef *)0x40006000UL) +#define M0P_UART3 ((M0P_UART_TypeDef *)0x40006400UL) +#define M0P_VC ((M0P_VC_TypeDef *)0x40002400UL) +#define M0P_WDT ((M0P_WDT_TypeDef *)0x40000F00UL) + + +#ifdef __cplusplus +} +#endif + +#endif /* __HC32L17X_H__ */ + diff --git a/mcu/common/interrupts_hc32l17x.c b/mcu/common/interrupts_hc32l17x.c new file mode 100644 index 0000000..a37b82b --- /dev/null +++ b/mcu/common/interrupts_hc32l17x.c @@ -0,0 +1,610 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file interrupts_hc32l136.c + ** + ** Interrupt management + ** @link Driver Group Some description @endlink + ** + ** - 2018-04-15 1.0 Lux First version. + ** + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "ddl.h" +#include "interrupts_hc32l17x.h" + +/******************************************************************************* + * IRQ WEAK DEFINE + ******************************************************************************/ +__WEAK void SysTick_IRQHandler(void); + + +__WEAK void PortA_IRQHandler(void); +__WEAK void PortB_IRQHandler(void); +__WEAK void PortC_IRQHandler(void); +__WEAK void PortD_IRQHandler(void); +__WEAK void PortE_IRQHandler(void); +__WEAK void PortF_IRQHandler(void); +__WEAK void Dmac_IRQHandler(void); +__WEAK void Tim3_IRQHandler(void); +__WEAK void Uart0_IRQHandler(void); +__WEAK void Uart1_IRQHandler(void); +__WEAK void Uart2_IRQHandler(void); +__WEAK void Uart3_IRQHandler(void); +__WEAK void LpUart0_IRQHandler(void); +__WEAK void LpUart1_IRQHandler(void); +__WEAK void Spi0_IRQHandler(void); +__WEAK void Spi1_IRQHandler(void); +__WEAK void I2c0_IRQHandler(void); +__WEAK void I2c1_IRQHandler(void); +__WEAK void Tim0_IRQHandler(void); +__WEAK void Tim1_IRQHandler(void); +__WEAK void Tim2_IRQHandler(void); +__WEAK void LpTim0_IRQHandler(void); +__WEAK void LpTim1_IRQHandler(void); +__WEAK void Tim4_IRQHandler(void); +__WEAK void Tim5_IRQHandler(void); +__WEAK void Tim6_IRQHandler(void); +__WEAK void Pca_IRQHandler(void); +__WEAK void Wdt_IRQHandler(void); +__WEAK void Rtc_IRQHandler(void); +__WEAK void Adc_IRQHandler(void); +__WEAK void Dac_IRQHandler(void); +__WEAK void Pcnt_IRQHandler(void); +__WEAK void Vc0_IRQHandler(void); +__WEAK void Vc1_IRQHandler(void); +__WEAK void Vc2_IRQHandler(void); +__WEAK void Lvd_IRQHandler(void); +__WEAK void Lcd_IRQHandler(void); +__WEAK void Flash_IRQHandler(void); +__WEAK void Ram_IRQHandler(void); +__WEAK void ClkTrim_IRQHandler(void); + +/** + ******************************************************************************* + ** \brief NVIC 涓柇浣胯兘 + ** + ** \param [in] enIrq 涓柇鍙锋灇涓剧被鍨 + ** \param [in] enLevel 涓柇浼樺厛绾ф灇涓剧被鍨 + ** \param [in] bEn 涓柇寮鍏 + ** \retval Ok 璁剧疆鎴愬姛 + ** 鍏朵粬鍊 璁剧疆澶辫触 + ******************************************************************************/ +void EnableNvic(IRQn_Type enIrq, en_irq_level_t enLevel, boolean_t bEn) +{ + NVIC_ClearPendingIRQ(enIrq); + NVIC_SetPriority(enIrq, enLevel); + if (TRUE == bEn) + { + NVIC_EnableIRQ(enIrq); + } + else + { + NVIC_DisableIRQ(enIrq); + } +} + +/** + ******************************************************************************* + ** \brief NVIC hardware fault 涓柇瀹炵幇 + ** + ** + ** \retval + ******************************************************************************/ +void HardFault_Handler(void) +{ + volatile int a = 0; + + while( 0 == a) + { + ; + } + +} + + +/** + ******************************************************************************* + ** \brief NVIC SysTick 涓柇瀹炵幇 + ** + ** \retval + ******************************************************************************/ +void SysTick_Handler(void) +{ + SysTick_IRQHandler(); +} + +/** + ******************************************************************************* + ** \brief GPIO PortA 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void PORTA_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_PORTA) + PortA_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief GPIO PortB 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void PORTB_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_PORTB) + PortB_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief GPIO PortC/E 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void PORTC_E_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_PORTC) + PortC_IRQHandler(); +#endif + +#if (INT_CALLBACK_ON == INT_CALLBACK_PORTE) + PortE_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief GPIO PortD/F 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void PORTD_F_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_PORTD) + PortD_IRQHandler(); +#endif + +#if (INT_CALLBACK_ON == INT_CALLBACK_PORTF) + PortF_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief DMAC 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void DMAC_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_DMAC) + Dmac_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM3 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void TIM3_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM3) + Tim3_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief UART0/2 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void UART0_2_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_UART0) + Uart0_IRQHandler(); +#endif + +#if (INT_CALLBACK_ON == INT_CALLBACK_UART2) + Uart2_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief UART1/3 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void UART1_3_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_UART1) + Uart1_IRQHandler(); +#endif + +#if (INT_CALLBACK_ON == INT_CALLBACK_UART3) + Uart3_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief LPUART0 浣庡姛鑰椾覆鍙0 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void LPUART0_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_LPUART0) + LpUart0_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief LPUART1 浣庡姛鑰椾覆鍙1 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void LPUART1_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_LPUART1) + LpUart1_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief SPI0 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void SPI0_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_SPI0) + Spi0_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief SPI1 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void SPI1_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_SPI1) + Spi1_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief I2C0 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void I2C0_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_I2C0) + I2c0_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief I2C1 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void I2C1_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_I2C1) + I2c1_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM0 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void TIM0_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM0) + Tim0_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM1 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void TIM1_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM1) + Tim1_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM2 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void TIM2_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM2) + Tim2_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief LPTIM0/1 浣庡姛鑰楁椂閽 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void LPTIM0_1_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_LPTIM0) + LpTim0_IRQHandler(); +#endif + +#if (INT_CALLBACK_ON == INT_CALLBACK_LPTIM1) + LpTim1_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM4 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void TIM4_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM4) + Tim4_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM5 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void TIM5_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM5) + Tim5_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM6 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void TIM6_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM6) + Tim6_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief PCA 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void PCA_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_PCA) + Pca_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief WDT 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void WDT_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_WDT) + Wdt_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief RTC 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void RTC_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_RTC) + Rtc_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief ADC/DAC 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void ADC_DAC_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_ADC) + Adc_IRQHandler(); +#endif + +#if (INT_CALLBACK_ON == INT_CALLBACK_DAC) + Dac_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief PCNT 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void PCNT_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_PCNT) + Pcnt_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief VC0 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void VC0_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_VC0) + Vc0_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief VC1/2 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void VC1_2_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_VC1) + Vc1_IRQHandler(); +#endif + +#if (INT_CALLBACK_ON == INT_CALLBACK_VC2) + Vc2_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief LVD 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void LVD_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_LVD) + Lvd_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief LCD 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void LCD_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_LCD) + Lcd_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief FLASH/RAM 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void FLASH_RAM_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_FLASH) + Flash_IRQHandler(); +#endif + +#if (INT_CALLBACK_ON == INT_CALLBACK_RAM) + Ram_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief CLKTRIM 涓柇澶勭悊鍑芥暟 + ** + ** \retval + ******************************************************************************/ +void CLKTRIM_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_CLKTRIM) + ClkTrim_IRQHandler(); +#endif +} + +/******************************************************************************/ +/* EOF (not truncated) */ +/******************************************************************************/ diff --git a/mcu/common/interrupts_hc32l17x.h b/mcu/common/interrupts_hc32l17x.h new file mode 100644 index 0000000..568efbb --- /dev/null +++ b/mcu/common/interrupts_hc32l17x.h @@ -0,0 +1,150 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file interrupts_hc32l17x.h + ** + ** Interrupt common define. + ** @link IRQGroup Some description @endlink + ** + ** - 2019-03-01 1.0 Lux First version. + ** + ******************************************************************************/ +#ifndef __INTERRUPTS_HC32L17X_H__ +#define __INTERRUPTS_HC32L17X_H__ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "ddl.h" + +/* C binding of definitions if building with C++ compiler */ +#ifdef __cplusplus +extern "C" +{ +#endif + +/******************************************************************************/ +/* Global pre-processor symbols/macros ('#define') */ +/******************************************************************************/ +#define DDL_IRQ_LEVEL_DEFAULT 3u + +//<<姝ら夐」浼氭墦寮interrupt_hc32xxx.c涓殑涓柇鍥炶皟鍑芥暟锛岀敤鎴峰鏋滈渶瑕佸疄鐜颁腑鏂湇鍔″嚱鏁帮紝 +//<<鍙湪婧愮爜鏂囦欢涓畾涔夎鏂囦欢涓敤"__WEAK"澹版槑鐨勫悓鍚嶄腑鏂湇鍔″嚱鏁板嵆鍙 +#define INT_CALLBACK_ON 1u //<<(榛樿鍊) +//<<姝ら夐」浼氬叧闂璱nterrupt_hc32xxx.c涓殑涓柇鍥炶皟鍑芥暟锛屾鏃剁敤鎴峰彲鍦ㄨ鏂囦欢涓嚜琛屽畾涔変腑鏂湇鍔″嚱鏁扮殑瀹炵幇銆 +#define INT_CALLBACK_OFF 0u +/****************************************************************************** + * Global type definitions + ******************************************************************************/ +#define INT_CALLBACK_PORTA INT_CALLBACK_ON +#define INT_CALLBACK_PORTB INT_CALLBACK_ON +#define INT_CALLBACK_PORTC INT_CALLBACK_ON +#define INT_CALLBACK_PORTD INT_CALLBACK_OFF +#define INT_CALLBACK_PORTE INT_CALLBACK_OFF +#define INT_CALLBACK_PORTF INT_CALLBACK_ON +#define INT_CALLBACK_DMAC INT_CALLBACK_ON +#define INT_CALLBACK_TIM3 INT_CALLBACK_ON +#define INT_CALLBACK_UART0 INT_CALLBACK_ON +#define INT_CALLBACK_UART1 INT_CALLBACK_ON +#define INT_CALLBACK_UART2 INT_CALLBACK_ON +#define INT_CALLBACK_UART3 INT_CALLBACK_ON +#define INT_CALLBACK_LPUART0 INT_CALLBACK_ON +#define INT_CALLBACK_LPUART1 INT_CALLBACK_ON +#define INT_CALLBACK_SPI0 INT_CALLBACK_ON +#define INT_CALLBACK_SPI1 INT_CALLBACK_ON +#define INT_CALLBACK_I2C0 INT_CALLBACK_ON +#define INT_CALLBACK_I2C1 INT_CALLBACK_ON +#define INT_CALLBACK_TIM0 INT_CALLBACK_ON +#define INT_CALLBACK_TIM1 INT_CALLBACK_ON +#define INT_CALLBACK_TIM2 INT_CALLBACK_ON +#define INT_CALLBACK_LPTIM0 INT_CALLBACK_ON +#define INT_CALLBACK_LPTIM1 INT_CALLBACK_ON +#define INT_CALLBACK_TIM4 INT_CALLBACK_ON +#define INT_CALLBACK_TIM5 INT_CALLBACK_ON +#define INT_CALLBACK_TIM6 INT_CALLBACK_ON +#define INT_CALLBACK_PCA INT_CALLBACK_ON +#define INT_CALLBACK_WDT INT_CALLBACK_ON +#define INT_CALLBACK_RTC INT_CALLBACK_ON +#define INT_CALLBACK_ADC INT_CALLBACK_ON +#define INT_CALLBACK_DAC INT_CALLBACK_ON +#define INT_CALLBACK_PCNT INT_CALLBACK_ON +#define INT_CALLBACK_VC0 INT_CALLBACK_ON +#define INT_CALLBACK_VC1 INT_CALLBACK_ON +#define INT_CALLBACK_VC2 INT_CALLBACK_ON +#define INT_CALLBACK_LVD INT_CALLBACK_ON +#define INT_CALLBACK_LCD INT_CALLBACK_ON +#define INT_CALLBACK_FLASH INT_CALLBACK_ON +#define INT_CALLBACK_RAM INT_CALLBACK_ON +#define INT_CALLBACK_CLKTRIM INT_CALLBACK_ON + + +/** + ******************************************************************************* + ** \brief 涓柇浼樺厛绾ф暟鎹被鍨嬪畾涔 + ** \note + ******************************************************************************/ +typedef enum en_irq_level +{ + IrqLevel0 = 0u, ///< 浼樺厛绾0 + IrqLevel1 = 1u, ///< 浼樺厛绾1 + IrqLevel2 = 2u, ///< 浼樺厛绾2 + IrqLevel3 = 3u, ///< 浼樺厛绾3 +} en_irq_level_t; + + +/****************************************************************************** + * Global function prototypes (definition in C source) + ******************************************************************************/ +///< 绯荤粺涓柇浣胯兘寮鍏 +extern void EnableNvic(IRQn_Type enIrq, en_irq_level_t enLevel, boolean_t bEn); + + +#ifdef __cplusplus +} +#endif + + +#endif /* __INTERRUPTS_HC32L17X_H__ */ + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ diff --git a/mcu/common/system_hc32l17x.c b/mcu/common/system_hc32l17x.c new file mode 100644 index 0000000..c0cb41d --- /dev/null +++ b/mcu/common/system_hc32l17x.c @@ -0,0 +1,212 @@ +/******************************************************************************* +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file system_hc32l136.c + ** + ** System clock initialization. + ** @link SampleGroup Some description @endlink + ** + ** - 2019-03-01 1.0 Lux First version. + ** + ******************************************************************************/ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "base_types.h" +#include "hc32l17x.h" +#include "system_hc32l17x.h" +#include "sysctrl.h" + +/** + ****************************************************************************** + ** System Clock Frequency (Core Clock) Variable according CMSIS + ******************************************************************************/ +uint32_t SystemCoreClock = 4000000; + + +//add clock source. +void SystemCoreClockUpdate (void) // Update SystemCoreClock variable +{ + SystemCoreClock = Sysctrl_GetHClkFreq(); +} + +/** + ****************************************************************************** + ** \brief 瀵筂CU鏈紩鍑篒O绔彛杩涜榛樿閰嶇疆. + ** + ** \param none + ** \return none + ******************************************************************************/ +static void _InitHidePin(void) +{ + uint32_t tmpReg = M0P_SYSCTRL->PERI_CLKEN0; + + M0P_SYSCTRL->PERI_CLKEN0_f.GPIO = 1; + +#if defined(HC32L17xPxxx) //100PIN MCU + M0P_GPIO->PFADS &= 0xFF4F; ///< PF04/PF05/PF07閰嶇疆涓烘暟瀛楃鍙 + + M0P_GPIO->PFDIR |= 0x00B0; ///< PF04/PF05/PF07閰嶇疆涓虹鍙h緭鍏 + + M0P_GPIO->PFPU |= 0x00B0; ///< PF04/PF05/PF07閰嶇疆涓轰笂鎷 + +#elif defined(HC32L17xMxxx) //80PIN MCU + M0P_GPIO->PDADS &= 0x0F1F; ///< PD05~07/PD12~15閰嶇疆涓烘暟瀛楃鍙 + M0P_GPIO->PEADS &= 0x783C; ///< PE00/PE01/PE06~10/PE15閰嶇疆涓烘暟瀛楃鍙 + M0P_GPIO->PFADS &= 0xF9F3; ///< PF02/PF03/PF09/PF10閰嶇疆涓烘暟瀛楃鍙 + + M0P_GPIO->PDDIR |= 0xF0E0; ///< PD05~07/PD12~15閰嶇疆涓虹鍙h緭鍏 + M0P_GPIO->PEDIR |= 0x87C3; ///< PE00/PE01/PE06~10/PE15閰嶇疆涓虹鍙h緭鍏 + M0P_GPIO->PFDIR |= 0x060C; ///< PF02/PF03/PF09/PF10閰嶇疆涓烘暟瀛楃鍙 + + + M0P_GPIO->PDPU |= 0xF0E0; ///< PD05~07/PD12~15閰嶇疆涓轰笂鎷 + M0P_GPIO->PEPU |= 0x87C3; ///< PE00/PE01/PE06~10/PE15閰嶇疆涓轰笂鎷 + M0P_GPIO->PFPU |= 0x060C; ///< PF02/PF03/PF09/PF10閰嶇疆涓烘暟瀛楃鍙 + +#elif defined(HC32L17xKxxx) //64PIN MCU + M0P_GPIO->PDADS &= 0x0004; ///< PD00/PD01/PD03~15閰嶇疆涓烘暟瀛楃鍙 + M0P_GPIO->PEADS &= 0x0000; ///< PE00~15閰嶇疆涓烘暟瀛楃鍙 + M0P_GPIO->PFADS &= 0xF9F3; ///< PF02/PF03/PF09/PF10閰嶇疆涓烘暟瀛楃鍙 + + M0P_GPIO->PDDIR |= 0xFFFB; ///< PD00/PD01/PD03~15閰嶇疆涓虹鍙h緭鍏 + M0P_GPIO->PEDIR |= 0xFFFF; ///< PE00~15閰嶇疆涓虹鍙h緭鍏 + M0P_GPIO->PFDIR |= 0x060C; ///< PF02/PF03/PF09/PF10閰嶇疆涓烘暟瀛楃鍙 + + M0P_GPIO->PDPU |= 0xFFFB; ///< PD00/PD01/PD03~15閰嶇疆涓轰笂鎷 + M0P_GPIO->PEPU |= 0xFFFF; ///< PE00~15閰嶇疆涓轰笂鎷 + M0P_GPIO->PFPU |= 0x060C; ///< PF02/PF03/PF09/PF10閰嶇疆涓烘暟瀛楃鍙 + +#elif defined(HC32L17xJxxx) //48PIN MCU + M0P_GPIO->PCADS &= 0xE000; ///< PC00~12閰嶇疆涓烘暟瀛楃鍙 + M0P_GPIO->PDADS &= 0x0000; ///< PD00~15閰嶇疆涓烘暟瀛楃鍙 + M0P_GPIO->PEADS &= 0x0000; ///< PE00~15閰嶇疆涓烘暟瀛楃鍙 + M0P_GPIO->PFADS &= 0xF9C3; ///< PF02~05/PF09/PF10閰嶇疆涓烘暟瀛楃鍙 + + M0P_GPIO->PCDIR |= 0x1FFF; ///< PC00~12閰嶇疆涓虹鍙h緭鍏 + M0P_GPIO->PDDIR |= 0xFFFF; ///< PD00~15閰嶇疆涓虹鍙h緭鍏 + M0P_GPIO->PEDIR |= 0xFFFF; ///< PE00~15閰嶇疆涓虹鍙h緭鍏 + M0P_GPIO->PFDIR |= 0x063C; ///< PF02~05/PF09/PF10閰嶇疆涓烘暟瀛楃鍙 + + + M0P_GPIO->PCPU |= 0x1FFF; ///< PC00~12閰嶇疆涓轰笂鎷 + M0P_GPIO->PDPU |= 0xFFFF; ///< PD00~15閰嶇疆涓轰笂鎷 + M0P_GPIO->PEPU |= 0xFFFF; ///< PE00~15閰嶇疆涓轰笂鎷 + M0P_GPIO->PFPU |= 0x063C; ///< PF02~05/PF09/PF10閰嶇疆涓烘暟瀛楃鍙 + +#elif defined(HC32L17xFxxx) //32PIN MCU + M0P_GPIO->PAADS &= 0xFFF4; ///< PA00/PA01/PA03閰嶇疆涓烘暟瀛楃鍙 + M0P_GPIO->PBADS &= 0x08FB; ///< PB02/PB08~10/PB12~15閰嶇疆涓烘暟瀛楃鍙 + M0P_GPIO->PCADS &= 0xC000; ///< PC00~13閰嶇疆涓烘暟瀛楃鍙 + M0P_GPIO->PDADS &= 0x0000; ///< PD00~15閰嶇疆涓烘暟瀛楃鍙 + M0P_GPIO->PEADS &= 0x0000; ///< PE00~15閰嶇疆涓烘暟瀛楃鍙 + M0P_GPIO->PFADS &= 0xF903; ///< PF02~07/PF09/PF10閰嶇疆涓烘暟瀛楃鍙 + + M0P_GPIO->PADIR |= 0x000B; ///< PA00/PA01/PA03閰嶇疆涓虹鍙h緭鍏 + M0P_GPIO->PBDIR |= 0xF704; ///< PB02/PB08~10/PB12~15閰嶇疆涓虹鍙h緭鍏 + M0P_GPIO->PCDIR |= 0x3FFF; ///< PC00~13閰嶇疆涓虹鍙h緭鍏 + M0P_GPIO->PDDIR |= 0xFFFF; ///< PD00~15閰嶇疆涓虹鍙h緭鍏 + M0P_GPIO->PEDIR |= 0xFFFF; ///< PE00~15閰嶇疆涓虹鍙h緭鍏 + M0P_GPIO->PFDIR |= 0x06FC; ///< PF02~07/PF09/PF10閰嶇疆涓烘暟瀛楃鍙 + + M0P_GPIO->PAPU |= 0x000B; ///< PA00/PA01/PA03閰嶇疆涓轰笂鎷 + M0P_GPIO->PBPU |= 0xF704; ///< PB02/PB08~10/PB12~15閰嶇疆涓轰笂鎷 + M0P_GPIO->PCPU |= 0x3FFF; ///< PC00~13閰嶇疆涓轰笂鎷 + M0P_GPIO->PDPU |= 0xFFFF; ///< PD00~15閰嶇疆涓轰笂鎷 + M0P_GPIO->PEPU |= 0xFFFF; ///< PE00~15閰嶇疆涓轰笂鎷 + M0P_GPIO->PFPU |= 0x06FC; ///< PF02~07/PF09/PF10閰嶇疆涓烘暟瀛楃鍙 + +#endif + + M0P_SYSCTRL->PERI_CLKEN0 = tmpReg; +} + +/** + ****************************************************************************** + ** \brief Setup the microcontroller system. Initialize the System and update + ** the SystemCoreClock variable. + ** + ** \param none + ** \return none + ******************************************************************************/ +void SystemInit(void) +{ + M0P_SYSCTRL->RCL_CR_f.TRIM = (*((volatile uint16_t*) (0x00100C22ul))); + M0P_SYSCTRL->RCH_CR_f.TRIM = (*((volatile uint16_t*) (0x00100C08ul))); + SystemCoreClockUpdate(); + _InitHidePin(); +} + + +#if defined (__CC_ARM) +extern int32_t $Super$$main(void); +/* re-define main function */ +int $Sub$$main(void) +{ + SystemInit(); + $Super$$main(); + return 0; +} +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) +extern int32_t $Super$$main(void); +/* re-define main function */ +int $Sub$$main(void) +{ + SystemInit(); + $Super$$main(); + return 0; +} +#elif defined(__ICCARM__) +extern int32_t main(void); +/* __low_level_init will auto called by IAR cstartup */ +extern void __iar_data_init3(void); +int __low_level_init(void) +{ + // call IAR table copy function. + __iar_data_init3(); + SystemInit(); + main(); + return 0; +} +#endif + diff --git a/mcu/common/system_hc32l17x.h b/mcu/common/system_hc32l17x.h new file mode 100644 index 0000000..6ff8efb --- /dev/null +++ b/mcu/common/system_hc32l17x.h @@ -0,0 +1,116 @@ +/******************************************************************************* +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file system_hc32l17x.h + ** + ** A detailed description is available at + ** @link SampleGroup Some description @endlink + ** + ** - 2019-03-01 1.0 Lux First version. + ** + ******************************************************************************/ + +#ifndef __SYSTEM_HC32L17X_H__ +#define __SYSTEM_HC32L17X_H__ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************/ +/* Global pre-processor symbols/macros ('define') */ +/******************************************************************************/ +#define HWWD_DISABLE (1) + + + +/** + ****************************************************************************** + ** \brief Clock Setup macro definition + ** + ** - 0: CLOCK_SETTING_NONE - User provides own clock setting in application + ** - 1: CLOCK_SETTING_CMSIS - + ******************************************************************************/ +#define CLOCK_SETTING_NONE 0u +#define CLOCK_SETTING_CMSIS 1u + +//#define HC32L17xPxxx //100PIN +//#define HC32L17xMxxx //80PIN +//#define HC32L17xKxxx //64PIN +//#define HC32L17xJxxx //48PIN +#define HC32L17xFxxx //32PIN + +/******************************************************************************/ +/* */ +/* START OF USER SETTINGS HERE */ +/* =========================== */ +/* */ +/* All lines with '<<<' can be set by user. */ +/* */ +/******************************************************************************/ + +/******************************************************************************/ +/* Global function prototypes ('extern', definition in C source) */ +/******************************************************************************/ + + +extern uint32_t SystemCoreClock; // System Clock Frequency (Core Clock) +extern void SystemInit (void); // Initialize the system +extern void SystemCoreClockUpdate (void); // Update SystemCoreClock variable + +#ifdef __cplusplus +} +#endif + +#endif /* __SYSTEM_HC32L17X _H__ */ + + + + + + + diff --git a/source/ddl_device.h b/source/ddl_device.h new file mode 100644 index 0000000..582bd95 --- /dev/null +++ b/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32L17X + + +/** + ******************************************************************************* + ** \brief Global package definition + ** + ** \note This definition is used for device package settings + ******************************************************************************/ +#define DDL_MCU_PACKAGE DDL_DEVICE_PACKAGE_HC_K + +#endif /* __DDL_DEVICE_H__ */ + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/source/inc/Algorithm.h b/source/inc/Algorithm.h new file mode 100644 index 0000000..dd97796 --- /dev/null +++ b/source/inc/Algorithm.h @@ -0,0 +1,55 @@ +#ifndef __ALGORITHM_H +#define __ALGORITHM_H + +#include +#include +#include +#include +#include +#include + +#define CRC16_BASE 0xA001 + + +// 峰值谷值检查结果结构体 +typedef struct { + bool peaks_positive; // 所有峰值是否大于0 + bool valleys_negative; // 所有谷值是否小于0 + int peak_count; // 检测到的峰值数量 + int valley_count; // 检测到的谷值数量 +} PeakValleyCheck; + +// 趋势分析结果结构体 +typedef struct { + double slope; // 线性斜率 + int sign_changes; // 符号变化次数 + char trend_type; // 趋势类型 + char steepness; // 陡峭度 +} TrendResult; + +PeakValleyCheck check_peaks_valleys(int data[], int length); +TrendResult analyze_trend(int data[], int length); +float calculateAverage(int *arr, int size); +double slope(int32_t *x_data, int32_t *y_data, int n) ; +long long power(int base, unsigned int exponent); +int IntFilter_16t(int16_t *Data, uint8_t Cnt, uint8_t FilterCnt); +int IntFilter_32t(int32_t *Data, uint8_t Cnt, uint8_t FilterCnt); +uint32_t IntFilter_u32t(uint32_t *Data, uint8_t Cnt, uint8_t FilterCnt); +float IntFilter_Float(float *Data, uint8_t Cnt, uint8_t FilterCnt); +uint32_t AverageFilter_u32t(uint32_t *Data, uint8_t Cnt); +int AverageFilter_32t(int32_t *Data, uint8_t Cnt); +void Fitting_Polynomial(double *AD, double *Actual, uint8_t Cnt); +float get_K(uint8_t count , int32_t *dataCol_X, int32_t *dataRow_Y); +int8_t TrendAnalyse(int32_t *Data, uint8_t Cnt, int32_t VPT); +void Waveform_Up(int32_t *Data, uint8_t dCnt, uint8_t pCnt, int32_t *vlue); +void Waveform_Down(int32_t *Data, uint8_t dCnt, uint8_t pCnt, int32_t *vlue); +bool count_most_greater(int32_t *arr, uint8_t size, int32_t target); +bool count_greater(int32_t *arr, uint8_t size, int32_t target); +bool count_smaller(int32_t *arr, uint8_t size, int32_t target); +uint16_t CRC_Modbus(uint16_t wBase, uint8_t *para, uint16_t length); +uint8_t CRC_Sum(uint8_t *_pbuff, uint16_t _cmdLen); +bool isAllZero(uint8_t *arr, int size); +#endif + + + diff --git a/source/inc/SGCP.h b/source/inc/SGCP.h new file mode 100644 index 0000000..448f0dc --- /dev/null +++ b/source/inc/SGCP.h @@ -0,0 +1,290 @@ +/* 传感器通用通讯协议V1.0*/ + +#ifndef __SGCP_H +#define __SGCP_H +#include "bsp.h" + +#define WORK_MODE 1 //工作模式选择,0、本机为查询模式,1、本机为上报模式(低功耗) +#define SGCP_SELECT 1 //协议选择,0、本机为单个主设备接多个子设备,1、本机为单个主设备不接子设备,2、本机为单个子设备 +#define LocalDataLen sizeof(SGCP.DevData.LaserTracing)//本机设备数据长度 +#define LocalType LASER_TRACING //本机设备类型 +#define CommWay LORA //本机通讯方式 +#define DeviceSign MASTER //本机设备标志 +#define AddNumber (0x000017 + DeviceSign)//本机地址编号,数字部分对应唯一地址编号 +//09 00 01 00 00 00 + +typedef struct {//网关与主设备固定帧 + uint8_t Header; + uint8_t GWAddr[6]; + uint8_t MDAddr[6]; + uint8_t Cmd; + uint16_t PayloadLen; +}__attribute__ ((packed))GatewayFrameHeader_t,*GatewayFrameHeader; + +typedef struct {//主设备与子设备固定帧 + uint8_t Header; + uint8_t Addr; + uint8_t Cmd; + uint8_t PayloadLen; +}__attribute__ ((packed))SubsetFrameHeader_t,*SubsetFrameHeader; + +typedef struct {//内部指令固定帧 + uint8_t Header; + uint8_t MAC[6]; + uint8_t Cmd; + uint8_t PayloadLen; +}__attribute__ ((packed))InsideFrameHeader_t,*InsideFrameHeader; + +typedef struct {//主设备固定包头 + uint8_t BatLevel; //电池电量 + int8_t RSSI; //信号强度 + int8_t Nsr; //信噪比 +}__attribute__ ((packed))MasterDev_T,*MasterDevDp; + +typedef struct {//0x0006 三维连续变形 + int16_t PitchAngle; //俯仰角 (范围±900)单位0.1° + int16_t RollAngle; //横滚角 (范围±900)单位0.1° + int16_t YawAngle; //偏航角 (范围0~3600)单位0.1° +}__attribute__ ((packed))ContDefor3D_T,*ContDefor3DDp; + +typedef struct {//0x0007 通讯单元 + MasterDev_T MasterDev; +}__attribute__ ((packed))CommUnit_T,*CommUnitDp; + +typedef struct {//0x0008 三维应力 + int16_t PitchAngle; //俯仰角(范围±900)单位0.1° + int16_t RollAngle; //横滚角(范围±900)单位0.1° + int16_t YawAngle; //偏航角(范围0~3600)单位0.1° + int32_t Strain1; //X轴应力值(范围±10MPa,单位Pa) + int32_t Strain2; //Y轴应力值(范围±10MPa,单位Pa) + int32_t Strain3; //Z轴应力值(范围±10MPa,单位Pa) +}__attribute__ ((packed))Force3D_T,*Force3DDp; + +typedef struct {//0x0009 激光示踪 + MasterDev_T MasterDev; + int16_t PitchAngle; //俯仰角 (范围±900)单位0.1° + int16_t RollAngle; //横滚角 (范围±900)单位0.1° + int16_t YawAngle; //偏航角 (范围0~3600)单位0.1° +}__attribute__ ((packed))LaserTracing_T,*LaserTracingDp; + +typedef struct {//0x000E 裂缝仪 + int16_t XwiseDist; //横向位移量(范围0~150mm) + int16_t LgthwysDist; //纵向位移距离(范围0~150mm) + int16_t RotationDist; //旋转位移距离(范围0~150mm) +}__attribute__ ((packed))Crack_T,*CrackDp; + +typedef struct { + ContDefor3D_T ContDefor3D; + CommUnit_T CommUnit; + Force3D_T Force3D; + Crack_T Crack; + LaserTracing_T LaserTracing; +}__attribute__ ((packed))DeviceData_T,*DeviceDp; //设备数据 + +/*接收子设备数据状态机*/ +typedef enum { + SUB_STATUS_IDLE, + SUB_STATUS_BROADCAST_CALI, + SUB_STATUS_READMASTER_DATA, + SUB_STATUS_READSUBSET_DATA, + SUB_STATUS_WAIT_READSUBSET, + SUB_STATUS_MASTER_QUERY, + SUB_STATUS_SUBSET_QUERY, + SUB_STATUS_WAIT_SUBSET_QUERY, + SUB_STATUS_BROADCAST_SET_COLTIME, + SUB_STATUS_BROADCAST_SYNC_TIME, +}SubStatus_m; + +/*接收网关数据状态机*/ +typedef enum { + GW_STATUS_IDLE, + GW_STATUS_WAIT_SUBIDLE, + GW_STATUS_LOGIN, + GW_STATUS_WAIT_LOGIN, + GW_STATUS_CALI, + GW_STATUS_READ_SENSOR, + GW_STATUS_SET_COL_TIME, + GW_STATUS_SYNC_TIME, + GW_STATUS_UPLOAD_SENSOR,//主动上报模式时会使用该状态 + GW_STATUS_WAIT_UPLOAD,//主动上报模式时会使用该状态 + GW_STATUS_LASER_STARES,//激光状态回应 +}GWStatus_m; +/*接收主设备数据状态机*/ +typedef enum { + MAS_STATUS_IDLE, + MAS_STATUS_CALI, + MAS_STATUS_READ_SENSOR, + MAS_STATUS_DEVICE_INQUIRE, + MAS_STATUS_SET_COL_TIME, + MAS_STATUS_SYNC_TIME, +}MasStatus_m; +/*内部指令数据状态机*/ +typedef enum { + IN_STATUS_IDLE, + IN_STATUS_UPDATE, + IN_STATUS_ALTER_485ADDR, +}InStatus_m; +/*网关到主设备命令集*/ +typedef enum { + GWTOMD_CMD_LOGIN = 0x00, //0x00,设备注册 + GWTOMD_CMD_CALI = 0x01, //0x01, 校准指令 + GWTOMD_CMD_READ_UPLOAD_SENSOR = 0x02, //0x02,读取数据指令or上传数据指令 + GWTOMD_CMD_SET_COL_TIME = 0x05, //0x05,设置采集时间间隔 + GWTOMD_CMD_SYNC_TIME = 0x06, //0x06,时间同步 + GWTOMD_CMD_SET_LASER = 0x08,//打开or关闭激光 +}GWTOMD_CMD_M; + +/*主设备到子设备命令集*/ +typedef enum { + MDTOSD_CMD_CALI = 0x01, //0x01, 校准指令 + MDTOSD_CMD_READ_DATA = 0x02, //0x02,读取数据指令 + MDTOSD_CMD_INQUIRE = 0x03, //0x03, 设备查询指令 + MDTOSD_CMD_SET_COL_TIME = 0x05, //0x05,设置采集时间间隔 + MDTOSD_CMD_SYNC_TIME = 0x06, //0x06,时间同步 +}MDTOSD_CMD_M; +/*内部指令命令集*/ +typedef enum { + INSIDE_CMD_UPDATE = 0x81, //0x81,升级程序下发请求,由主机发起,从机应答 + INSIDE_CMD_ALTER_485ADDR = 0x04, //0x04, 设置设备485地址 +}INSIDE_CMD_M; +/*设备类型*/ +typedef enum { + NUL, //0x0000 空设备 + FORCE_6D, //0x0001 六维应力 + OSMOTIC_PRESSURE, //0x0002 渗透压 + ELASTIC_WAVEGUIDE, //0x0003 弹性波导 + DIELECTRIC_MASS, //0x0004 介电质普 + _0x0005, //0x0005 保留 + CONT_DEFOR_3D, //0x0006 三维连续变形 + COMM_UNIT, //0x0007 通讯单元 + FORCE_3D, //0x0008 三维应力 + LASER_TRACING, //0x0009 激光示踪 + _0x000A, //0x000A 保留 + _0x000B, //0x000B 保留 + _0x000C, //0x000C 保留 + MULTI_PARAMETER_FUSION, //0x000D 多参数融合 + CRACK_DETECTION, //0x000E 裂缝仪 + _0x000F, //0x000F 保留 + ATTITUDE_MONITOR, //0x0010 姿态检测 + LASER_DISPLACE, //0x0011 激光位移 + REBAR_STRESS, //0x0012 钢筋应力 + ANCHOR_ROD_STRESS, //0x0013 锚杆轴力 + SURFACE_STRESS, //0x0014 表面应力 + PRESSURE, //0x0015 压力 + MICROWAVE_DISPLACE, //0x0016 微波测距 +}DEVICE_TYPE_M; +/*通讯方式*/ +typedef enum { + LORA = 0x01, //0x01 LORA通讯 + RS485 = 0x02, //0x02 RS485通讯 + RS232 = 0x03, //0x03 RS232通讯 + CAN = 0x04, //0x04 CAN通讯 + _4G = 0x05, //0x05 _4G通讯 + BLE = 0x06, //0x06 BLE通讯 + WIFI = 0x07, //0x07 WIFI通讯 + UART = 0x08, //0x08 UART通讯 +}COMM_WAY_M; +/*设备标志*/ +typedef enum { + MASTER = 0x000000, //0x000000 主设备 + SUBSET = 0x800000, //0x800000 子设备 +}DEVICE_SIGN_M; +typedef struct { + __IO GWTOMD_CMD_M rCmdGWToMD; //网关下发命令 + __IO GWTOMD_CMD_M sCmdMDToGW; //主设备返回命令 + __IO uint16_t rPayLen; + __IO bool HeaderFrame; + __IO uint8_t RxLen; + uint8_t RxBuff[256]; +}GWTOMD_Rx_T; + +typedef struct { + __IO MDTOSD_CMD_M rCmdSDToMD; //子设备返回命令 + __IO MDTOSD_CMD_M sCmdMDToSD; //主设备下发命令 + __IO uint8_t rPayLen; + __IO bool HeaderFrame; + __IO uint8_t RxLen; + uint8_t RxBuff[256]; +}MDTOSD_Rx_T; + +typedef struct { + uint32_t LpUart0Delay1mSCnt; + uint32_t LoraDelay1mSCnt; + uint32_t Uart1Delay1mSCnt; + uint32_t GW1mSDelayCnt; + uint32_t SD1mSDelayCnt; + uint32_t In1mSDelayCnt; + + GWTOMD_Rx_T GWRS485Rx; + uint8_t GatewayBuffLen; + uint8_t GatewayBuff[256]; + uint8_t GatewayRevTimeoutCnt; //网关串口接收超时计数 + + MDTOSD_Rx_T SDRS485Rx; + uint8_t SubsetBuffLen; + uint8_t SubsetBuff[256]; + uint8_t SubsetRevTimeoutCnt; //子设备串口接收超时计数 + + uint8_t InsidePayLen; + uint8_t InsideBuffLen; + uint8_t InsideBuff[256]; + uint8_t InsidePay[256]; + + SubStatus_m SubStatus; + SubStatus_m NextSubStatus; + GWStatus_m GWStatus; + GWStatus_m NextGWStatus; + MasStatus_m MasStatus; + InStatus_m InStatus; + + DeviceData_T DevData; + + bool SubsetCaliOk; //子设备校准标志位 + bool MasterCaliOk; //主设备标校标志位 + + uint8_t ReadDataAdd; //获取数据地址 + uint16_t DeviceDataLen; //在线设备采集到的数据长度总和 + uint8_t DeviceDataBuff[512]; //在线设备采集到的数据缓存(主设备的数据永远排在最前面) + uint8_t DeviceData[512]; //在线设备采集到的数据(主设备的数据永远排在最前面) + bool SubsetReadDataOk; //子设备读取数据成功标志位 + bool DeviceReadDataOk; //设备读取数据完成标志位 + + uint8_t DeviceN; //在线设备数量(最多32个子设备,1个主设备) + uint8_t Dev485Addr; //在线设备485地址(最多32个子设备,1个主设备) + uint8_t Dev485Addrs[16]; //在线设备485地址缓存,0位为0x00广播地址 + uint8_t DeviceMAC[16][6]; //在线设备的唯一MAC地址(主设备的MAC永远排在最前面) + bool SubsetMACOk; //在线子设备MAC获取成功标志位 + bool DeviceMACOk; //在线设备获取完成标志位 + + bool CollTimeSetOk; //采集时间设置成功标志位 + uint8_t CollTimeAdd; //设置采集时间地址 + + bool SyncTimeOk; //时间同步成功标志位 + uint8_t SyncTimeAdd; //时间同步设备地址 + + bool BroadCmd; //广播命令 + + bool LoginOk; //注册成功标志位 + bool LoginMess; + + bool UploadOk; //上传成功标志位 + bool UploadMess; + + bool Gateway_IRQ_Status; //网关接收中断 + bool Subset_IRQ_Status; //子设备接收中断 + bool TimingAcquisition; //采集传感器数据 + + /**激光示踪私有**/ + bool LaserOnOff; //打开与关闭激光标志位 +}SGCP_t; +extern SGCP_t SGCP; + +void SGCP1mSRoutine(void); + +void GwRevLoopHandler(void); +void MasRevLoopHandler(void); +void SubRevLoopHandler(void); +void InRevLoopHandler(void); +#endif + + diff --git a/source/inc/Update.h b/source/inc/Update.h new file mode 100644 index 0000000..2bf53aa --- /dev/null +++ b/source/inc/Update.h @@ -0,0 +1,61 @@ +#ifndef __UPDATE_H +#define __UPDATE_H + +#include +#include "bsp.h" +#include "UartDebug.h" + +#define APP_START_FLAG 0x55AA5A5A +#define APP_UPDATE_FLAG 0xA5A5AA55 + +#define FLASH_SECTOR_SIZE 0x200ul +#define FLASH_BASE ((uint32_t)0x00000000) +#define FLASH_SIZE (256u * FLASH_SECTOR_SIZE) + +#define SRAM_BASE ((uint32_t)0x20000000) +#define RAM_SIZE 0x2000ul + +#define BOOT_ADDRESS FLASH_BASE +#define BOOT_SIZE (20 * FLASH_SECTOR_SIZE) +#define DEV_MAC_ADDRESS (BOOT_ADDRESS + BOOT_SIZE) //0x00002800 +#define DEV_MAC_SIZE FLASH_SECTOR_SIZE +#define APP_ADDRESS (DEV_MAC_ADDRESS + DEV_MAC_SIZE) + +#define BOOT_PARA_ADDRESS (0x0001FC00)//(FLASH_BASE + BOOT_SIZE) +#define BOOT_PARA_SIZE (FLASH_SECTOR_SIZE) + +typedef struct { + uint32_t AppFlag; + uint32_t UpdateFlag; + uint32_t PackageCnt; + uint32_t AppSize; + uint32_t Crc32Check; +}BootPara_t, *BootPara; + +//主机下发升级请求载荷结构体 +typedef struct { + uint16_t PackageNum; + uint32_t AppSize; + uint32_t AppCrc32; +}__attribute__ ((packed))UpDataRequset_t, *UDReq; + +//帧头结构体 +typedef struct { + uint8_t Header; + uint8_t DevMac[6]; + uint8_t Cmd; + uint8_t PayloadLen; +}__attribute__((packed))UpdateFrameHeader_t,*pUpdateFrameHeader; + + +//输入接口函数定义,需根据接口重新定义 +#define U_DBG_LOG(...) DBG_LOG(__VA_ARGS__) +#define U_DELAY_MS(x) delay_ms(x) +#define U_SYSTEM_TESET() SystemReset() +#define SAVE_BOOT_PARA(addr) FlashWrite(BOOT_PARA_ADDRESS, addr, sizeof(BLPara) / 4) +#define READ_BOOT_PARA(addr) FlashRead(BOOT_PARA_ADDRESS, addr, sizeof(BLPara) / 4) + +//输出接口 +void Update(uint8_t *PayLoad); +void UpdateInit(void); +#endif \ No newline at end of file diff --git a/source/inc/bsp.h b/source/inc/bsp.h new file mode 100644 index 0000000..377ecdf --- /dev/null +++ b/source/inc/bsp.h @@ -0,0 +1,271 @@ +#ifndef _BSP_H +#define _BSP_H + +#include +#include +#include +#include "gpio.h" +#include "spi.h" + +/*模块启用与关闭*/ +#define USE_DEBUG 1 //调试串口选择,0、关闭,1、启用 +#define USE_VBAT_AD 1 //电池电压AD获取选择,0、关闭,1、启用 +#define USE_WDT 1 //看门狗选择,0、关闭,1启用 +#define USE_EXFALSE 0 //外部FALSE存储选择,0、关闭,1、启用 +#define USE_LED 1 //状态灯选择,0、关闭,1、启用 +#define USE_RTC 1 //RTC时钟开关,0、关闭,1、开启 + +#define USE_LPUART0 1 //LPUART0开关,0、关闭,1、启用 +#define USE_UART0 1 //UART0开关,0、关闭,1、启用 +#define USE_UART1 0 //UART0开关,0、关闭,1、启用 +#define USE_I2C0 1 //I2C0开关,0、关闭,1、启用 +#define USE_I2C1 1 //I2C1开关,0、关闭,1、启用 +#define USE_SPI0 1 //SPI1开关,0、关闭,1、启用 +#define USE_SPI1 0 //SPI1开关,0、关闭,1、启用 + +#define USE_BOOTLOADER 1 //BOOTLOADER开关,0、关闭,1、启用 +#define USE_LORA_CH 1 //0为测试通道 + +//<<---------------------------- MCU -------------------------------->> +//< UART0 +#define UART0_TX_PORT GpioPortA +#define UART0_TX_PIN GpioPin9 +#define UART0_TX_AF GpioAf1 + +#define UART0_RX_PORT GpioPortA +#define UART0_RX_PIN GpioPin10 +#define UART0_RX_AF GpioAf1 + +//< UART1 +#define UART1_TX_PORT GpioPortF +#define UART1_TX_PIN GpioPin0 +#define UART1_TX_AF GpioAf3 + +#define UART1_RX_PORT GpioPortF +#define UART1_RX_PIN GpioPin1 +#define UART1_RX_AF GpioAf3 + +//< 低功耗串口 +#define LPUart0_TxPortx GpioPortB //低功耗串口0通道 +#define LPUART0_TxPinx GpioPin10 //配置PB10为LPUART0_Tx +#define LPUART0_TX_AF GpioAf4 + +#define LPUart0_RxPortx GpioPortB //低功耗串口0通道 +#define LPUART0_RxPinx GpioPin11 //配置PB11为LPUART0_Rx +#define LPUART0_RX_AF GpioAf3 + +//< SPI0 +#define SPI0_NSS_PORTx GpioPortA //NSSIO口 +#define SPI0_NSS_PINx GpioPin15 //配置PA04为NSS +#define SET_SPI0_NSS() Gpio_SetIO(SPI0_NSS_PORTx, SPI0_NSS_PINx) //NSS拉高 +#define CLR_SPI0_NSS() Gpio_ClrIO(SPI0_NSS_PORTx, SPI0_NSS_PINx) //NSS拉低 +#define SPI0_NSS_AF GpioAf1 + +#define SPI0_SCK_PORTx GpioPortB //SCKIO口 +#define SPI0_SCK_PINx GpioPin3 //配置PA05为SCK +#define SET_SPI0_SCK() Gpio_SetIO(SPI0_SCK_PORTx, SPI0_SCK_PINx) //SCK拉高 +#define CLR_SPI0_SCK() Gpio_ClrIO(SPI0_SCK_PORTx, SPI0_SCK_PINx) //SCK拉低 +#define SPI0_SCK_AF GpioAf1 + +#define SPI0_MISO_PORTx GpioPortB //MISOIO口 +#define SPI0_MISO_PINx GpioPin4 //配置PA06为MISO +#define SET_SPI0_MISO() Gpio_SetIO(SPI0_MISO_PORTx, SPI0_MISO_PINx) //MISO拉高 +#define CLR_SPI0_MISO() Gpio_ClrIO(SPI0_MISO_PORTx, SPI0_MISO_PINx) //MISO拉低 +#define SPI0_MISO_AF GpioAf1 + +#define SPI0_MOSI_PORTx GpioPortB //MOSIIO口 +#define SPI0_MOSI_PINx GpioPin5 //配置PA07为MOSI +#define SET_SPI0_MOSI() Gpio_SetIO(SPI0_MOSI_PORTx, SPI0_MOSI_PINx) //MOSI拉高 +#define CLR_SPI0_MOSI() Gpio_ClrIO(SPI0_MOSI_PORTx, SPI0_MOSI_PINx) //MOSI拉低 +#define SPI0_MOSI_AF GpioAf1 + +//< SPI1 +#define SPI1_NSS_PORTx GpioPortB //NSSIO口 +#define SPI1_NSS_PINx GpioPin12 //配置PB12为NSS +#define SET_SPI1_NSS() Gpio_SetIO(SPI1_NSS_PORTx, SPI1_NSS_PINx) //NSS拉高 +#define CLR_SPI1_NSS() Gpio_ClrIO(SPI1_NSS_PORTx, SPI1_NSS_PINx) //NSS拉低 +#define SPI1_NSS_AF GpioAf1 + +#define SPI1_SCK_PORTx GpioPortB //SCKIO口 +#define SPI1_SCK_PINx GpioPin3 //配置PB13为SCK +#define SET_SPI1_SCK() Gpio_SetIO(SPI1_SCK_PORTx, SPI1_SCK_PINx) //SCK拉高 +#define CLR_SPI1_SCK() Gpio_ClrIO(SPI1_SCK_PORTx, SPI1_SCK_PINx) //SCK拉低 +#define SPI1_SCK_AF GpioAf1 + +#define SPI1_MISO_PORTx GpioPortB //MISOIO口 +#define SPI1_MISO_PINx GpioPin4 //配置PB14为MISO +#define SET_SPI1_MISO() Gpio_SetIO(SPI1_MISO_PORTx, SPI1_MISO_PINx) //MISO拉高 +#define CLR_SPI1_MISO() Gpio_ClrIO(SPI1_MISO_PORTx, SPI1_MISO_PINx) //MISO拉低 +#define SPI1_MISO_AF GpioAf1 + +#define SPI1_MOSI_PORTx GpioPortB //MOSIIO口 +#define SPI1_MOSI_PINx GpioPin5 //配置PB15为MOSI +#define SET_SPI1_MOSI() Gpio_SetIO(SPI1_MOSI_PORTx, SPI1_MOSI_PINx) //MOSI拉高 +#define CLR_SPI1_MOSI() Gpio_ClrIO(SPI1_MOSI_PORTx, SPI1_MOSI_PINx) //MOSI拉低 +#define SPI1_MOSI_AF GpioAf1 + +//< I2C0 +#define I2C0_SCL_PORTx GpioPortF //SCL的GPIO通道 +#define I2C0_SCL_PINx GpioPin1 //SCL的通道位 +#define I2C0_SCL_AF GpioAf1 +#define SET_I2C0_SCL() Gpio_SetIO(I2C0_SCL_PORTx, I2C0_SCL_PINx) +#define CLR_I2C0_SCL() Gpio_ClrIO(I2C0_SCL_PORTx, I2C0_SCL_PINx) + +#define I2C0_SDA_PORTx GpioPortF //SDA的GPIO通道 +#define I2C0_SDA_PINx GpioPin0 //SDA的通道位 +#define I2C0_SDA_AF GpioAf1 +#define SET_I2C0_SDA() Gpio_SetIO(I2C0_SDA_PORTx, I2C0_SDA_PINx) +#define CLR_I2C0_SDA() Gpio_ClrIO(I2C0_SDA_PORTx, I2C0_SDA_PINx) + +//< I2C1 +#define I2C1_SCL_PORTx GpioPortA //SCL的GPIO通道 +#define I2C1_SCL_PINx GpioPin11 //SCL的通道位 +#define I2C1_SCL_AF GpioAf3 +#define SET_I2C1_SCL() Gpio_SetIO(I2C1_SCL_PORTx, I2C1_SCL_PINx) +#define CLR_I2C1_SCL() Gpio_ClrIO(I2C1_SCL_PORTx, I2C1_SCL_PINx) + +#define I2C1_SDA_PORTx GpioPortA //SDA的GPIO通道 +#define I2C1_SDA_PINx GpioPin12 //SDA的通道位 +#define I2C1_SDA_AF GpioAf3 +#define SET_I2C1_SDA() Gpio_SetIO(I2C1_SDA_PORTx, I2C1_SDA_PINx) +#define CLR_I2C1_SDA() Gpio_ClrIO(I2C1_SDA_PORTx, I2C1_SDA_PINx) + +//<<---------------------------- 485 -------------------------------->> +//< LPUart0 +#define RS485_CTRL_PORTx GpioPortB //RS485_1通信控制 +#define RS485_CTRL_PINx GpioPin1 //配置PB02为RS485_1_CTRL +#define RS485_CTRL_TX() Gpio_SetIO(RS485_CTRL_PORTx, RS485_CTRL_PINx) //RS485_1_CTRL拉高发送 +#define RS485_CTRL_RX() Gpio_ClrIO(RS485_CTRL_PORTx, RS485_CTRL_PINx) //RS485_1_CTRL拉低接收 + +//<<---------------------------- LED -------------------------------->> +//< LED_State +#define LED_STATE_PORTx GpioPortF //状态指示灯IO通道 +#define LED_STATE_PINx GpioPin7 //状态指示灯脚位 +#define LED_ON() Gpio_SetIO(LED_STATE_PORTx, LED_STATE_PINx);//状态指示灯亮 +#define LED_OFF() Gpio_ClrIO(LED_STATE_PORTx, LED_STATE_PINx);//状态指示灯灭 + +//<<---------------------------- LORA --> SPI0 -------------------------------->> +//< LORA --> DIO0 +#define LORA_DIO0_PORTx GpioPortB //LORA_DIO0口 +#define LORA_DIO0_PINx GpioPin7 //配置PA01为DIO0 +#define GET_LORA_DIO0() Gpio_GetInputIO(LORA_DIO0_PORTx, LORA_DIO0_PINx) //获取LORA_DIO0电平状态 +//< LORA --> DIO1 +#define LORA_DIO1_PORTx GpioPortB //LORA_DIO0口 +#define LORA_DIO1_PINx GpioPin0 //配置PA01为DIO0 +#define GET_LORA_DIO1() Gpio_GetInputIO(LORA_DIO1_PORTx, LORA_DIO1_PINx) //获取LORA_DIO0电平状态 + +//< LORA --> RST +#define LORA_RST_PORTx GpioPortB //LORA_RST口 +#define LORA_RST_PINx GpioPin6 //配置PA00为RST +#define SET_LORA_RST() Gpio_SetIO(LORA_RST_PORTx, LORA_RST_PINx) //LORA复位脚拉高 +#define CLR_LORA_RST() Gpio_ClrIO(LORA_RST_PORTx, LORA_RST_PINx) //LORA复位脚拉低 + +//<<---------------------------- LSM6DSLTR --> I2C0 -------------------------------->> +//< ACC_INT1 +#define LSM6DSLTR_INT1_PORTx GpioPortC //LSM6DSLTR中断1IO通道 +#define LSM6DSLTR_INT1_PINx GpioPin15 //配置PB01为ACC_INT1 +#define GET_LSM6DSLTR_INT1() Gpio_GetInputIO(LSM6DSLTR_INT1_PORTx, LSM6DSLTR_INT1_PINx) //获取ACC_INT1电平状态 + +//< ACC_INT2 +#define LSM6DSLTR_INT2_PORTx GpioPortC //LSM6DSLTR中断1IO通道 +#define LSM6DSLTR_INT2_PINx GpioPin13 //配置PA08为ACC_INT2 +#define GET_LSM6DSLTR_INT2() Gpio_GetInputIO(LSM6DSLTR_INT2_PORTx, LSM6DSLTR_INT2_PINx) //获取ACC_INT2电平状态 + +//<<---------------------------- MMC5983MA --> I2C0 -------------------------------->> +//< MMC0_INT +#define MMC5983MA_INT_PORTx GpioPortC //MMC5983MA中断IO通道 +#define MMC5983MA_INT_PINx GpioPin14 //配置PB00为MMC_INT +#define GET_MMC5983MA_INT() Gpio_GetInputIO(MMC5983MA_INT_PORTx, MMC5983MA_INT_PINx) //获取ACC_INT2电平状态 + +//<<---------------------------- LASER -------------------------------->> +//< LASER1 +#define LASER1_ON_OFF_PORTx GpioPortB +#define LASER1_ON_OFF_PINx GpioPin14 +#define LASER1_ON() Gpio_SetIO(LASER1_ON_OFF_PORTx, LASER1_ON_OFF_PINx) //LORA复位脚拉高 +#define LASER1_OFF() Gpio_ClrIO(LASER1_ON_OFF_PORTx, LASER1_ON_OFF_PINx) //LORA复位脚拉低 +//< LASER2 +#define LASER2_ON_OFF_PORTx GpioPortB +#define LASER2_ON_OFF_PINx GpioPin13 +#define LASER2_ON() Gpio_SetIO(LASER2_ON_OFF_PORTx, LASER2_ON_OFF_PINx) //LORA复位脚拉高 +#define LASER2_OFF() Gpio_ClrIO(LASER2_ON_OFF_PORTx, LASER2_ON_OFF_PINx) //LORA复位脚拉低 +//< LASER3 +#define LASER3_ON_OFF_PORTx GpioPortB +#define LASER3_ON_OFF_PINx GpioPin12 +#define LASER3_ON() Gpio_SetIO(LASER3_ON_OFF_PORTx, LASER3_ON_OFF_PINx) //LORA复位脚拉高 +#define LASER3_OFF() Gpio_ClrIO(LASER3_ON_OFF_PORTx, LASER3_ON_OFF_PINx) //LORA复位脚拉低 + +//<<------------------------------ ADC ---------------------------------->> +#define AD_ON_OFF_PORTx GpioPortA +#define AD_ON_OFF_PINx GpioPin3 +#define AD_ON() Gpio_SetIO(AD_ON_OFF_PORTx, AD_ON_OFF_PINx) //LORA复位脚拉高 +#define AD_OFF() Gpio_ClrIO(AD_ON_OFF_PORTx, AD_ON_OFF_PINx) //LORA复位脚拉低 + +#define VBAT_PORTx GpioPortA +#define VBAT_PINx GpioPin4 +#define VBAT_ADC_PORTx AdcExInputCH4//采样通道 +#define VBAT_CAL 3.5 //电池电压校准 + +//< 电池电压 +extern float VBAT_8V4; +extern uint8_t VBAT_Percentage; + + +typedef struct { + uint16_t CollectTime; //数据采集时间间隔,设置范围30*N秒,1<=N<=240,(默认5分钟,N=10) + uint16_t ReportInterval; //上报时间间隔,设置范围,30*N秒,10<=N<=1440(默认20分钟,N=40) + uint8_t ERInterval; //紧急上报时间间隔,设置范围,30*N秒,2<=N<=10(默认2分钟,N=4) + uint8_t ERTime; //紧急上报时长,设置范围,30*N秒,20<=N<=240(默认20分钟,N=40) + uint32_t TimeStamp; //网关返回RTC时间戳 +}__attribute__((packed))LayoutPara_t,*LayoutPara;//上位机下发的配置参数 + +typedef struct { + int16_t PitchZero; //俯仰角零点 + int16_t RollZero; //横滚角零点 + int16_t YawZero; //偏航角零点 +}__attribute__ ((packed))CalibratePara_t, *CalibratePara; + +typedef struct { + LayoutPara_t Layout; + CalibratePara_t CaliPara; + uint32_t RS485Addr; //本机485地址 + uint32_t FactoryFlag;//出厂标志位 +}AppPara_T, *pAppPara; +#define APP_PARA_ADDRESS (0x0001FE00) +#define SAVE_APP_PARA(addr) FlashWrite(APP_PARA_ADDRESS, addr, sizeof(App.Para) / 4) +#define READ_APP_PARA(addr) FlashRead(APP_PARA_ADDRESS, addr, sizeof(App.Para) / 4) + +void BspInit(void); +void EnterDeepSleep(void); +void DBGUartSendByte(uint8_t sData); +void DBGUartSend(uint8_t *sData, int sLen); +void LPUart0SendArray(uint8_t *sData, uint8_t sLen); +void Uart1SendArray(uint8_t *sData, uint8_t sLen); + +uint32_t GetSysTick(void); +void delay_ms(uint32_t ms); +void Delay(uint32_t time); +void RTCInit(uint8_t sec); +void LPTimer0_ON(uint16_t _100ms); +void LPTimer0_OFF(void); +void WakeUpInit(void); +void FeedDog(void); +uint32_t TimeTs(void); +void TimeShow(uint32_t dwStamp); +void TimeSync(time_t ts); +void PrintfMess(void); +void SystemReset(void); +uint8_t Spi0SendReceive(uint8_t sData); +uint8_t Spi1SendReceive(uint8_t sData); +void FlashWrite(uint32_t Addr, uint32_t *wData, int wLen); +void FlashRead(uint32_t Addr, uint32_t *rData, int rLen); + +void ADCLoopHandler(void); +void LORA_RxCallBack(uint8_t *rBuff, uint8_t rlen); + +void GlobalIntEnable(void); +void GlobalIntDisable(void); +void LORAIntEnable(void); +void LORAIntDisable(void); +void ACCandMMCIntEnable(void); +void ACCandMMCIntDisable(void); +#endif diff --git a/source/inc/main.h b/source/inc/main.h new file mode 100644 index 0000000..f3c09e7 --- /dev/null +++ b/source/inc/main.h @@ -0,0 +1,107 @@ +#ifndef __MAIN_H +#define __MAIN_H +#include "bsp.h" +#include "UartDebug.h" +#include "Imu.h" + +#define X 0 +#define Y 1 +#define Z 2 +#define XYZ 3 + +#define SYSTEM_TIMING_LOGIN (86400 / 30) //系统定时注册时间(一天86400秒) +#define ERR_TIMING_LOGIN (1800 / 30) //注册错误重新注册时间(半个小时1800秒) + +#define TEST_TIME (60*60*1000) + +#define ERINTERVAL_VPT 10 //紧急上报阈值,单位0.1° +#define ERINTERVAL_VPT 10 //紧急上报阈值,单位0.1° + +typedef struct {//传感器原始数据 + float acce[XYZ]; + float gy[XYZ]; + float mag[XYZ]; +}__attribute__ ((packed))SensorData_T,*SensorDp;//传感器数据 + +typedef struct {//转换的数据 + int16_t Pitch; //俯仰角偏斜 (范围±900)单位0.1° + int16_t Roll; //横滚角偏斜 (范围±900)单位0.1° + int16_t Yaw; //偏航角偏斜 (范围0~3600)单位0.1° +// int16_t Temp; //温度值 +// int32_t AD; //AD值 +}__attribute__ ((packed))ConvertedData_T, *ConvertedDp; + +typedef struct {// 姿态角数据 + Rad_T Rad; + Deg_T Deg; +}__attribute__ ((packed))AHRSData_T,*AHRSDp; + +/*主程序状态机*/ +typedef enum { + APP_STATUS_IDLE, + APP_STATUS_SLEEP, + APP_STATUS_ON, + APP_STATUS_OFF, + APP_STATUS_ACTION, + APP_STATUS_WAIT_LOGIN, + APP_STATUS_WAIT_UPLOAD, +}AppStatus_m; + +/*数据读取状态机*/ +typedef enum { + READDATA_STATUS_IDLE, + READDATA_STATUS_UPDAING, + READDATA_STATUS_WAIT_UPDAING, + READDATA_STATUS_DATA_HANDLE, +}ReadDataStatus_m; + +typedef struct { + AppStatus_m Status;//状态 + ReadDataStatus_m RDStatus;//读取数据状态 + + uint32_t TD1mSDelayCnt; + uint8_t FeedDogDlyCnt; + uint32_t ReadData1mSDelayCnt; + uint32_t SysResetTimeCnt; + + SensorData_T Sensor; + AppPara_T Para; + AHRSData_T AHRSData; + ConvertedData_T ConvertedData; + + uint32_t RepeLoginCount; //24h重复注册计数 + uint8_t Login30MinCount; //注册30分定时计数 + uint8_t Login2Min30SCount; //注册100ms~2分+30s定时计数 + bool Login_RTC; //注册30分定时器启动标志位 + bool Login_LPTimer0; //注册100ms~2分+30s定时器启动标志位 + bool LoginFlag; //注册标志位 + + uint16_t Coll_N; //数据采集时间计数 + uint16_t Repor_N; //上报时间计数 + uint16_t ERInterval_N; //紧急上报时间间隔计数 + uint8_t ERTime_N; //紧急上报时间计数 + bool ERFlag; //紧急上报标志位 + + bool UploadFlag; //上传数据标志位 + uint8_t Upload45S10SCount; //上传数据超时计数 + bool Upload_LPTimer0; //上传100~10000ms+45秒定时器启动标志位 + + bool MagRead_EndFlag; + bool AccRead_EndFlag; + bool UpdateOk; //数据更新标志位 + + bool CaliFlag; //标校标志位 + + int16_t Nonce; //随机数 + + uint32_t TestTimeCnt; + uint8_t Tcnt; + bool LaserFlag; +}AppDetect_t; + +extern AppDetect_t App; +#endif + + + + diff --git a/source/src/Algorithm.c b/source/src/Algorithm.c new file mode 100644 index 0000000..c28bba9 --- /dev/null +++ b/source/src/Algorithm.c @@ -0,0 +1,783 @@ +#include "bsp.h" +#include "Algorithm.h" +#include "UartDebug.h" + +/***************************************************************************************** +* 函数名称: check_peaks_valleys_ratio +* 功能描述: 检查数据的峰值是否大于0,谷值是否小于0(忽略0值) +* 参 数: data, 数据 + length, 数据长度 +* 返 回 值: 结果返回峰值谷值检查结果结构体 +*****************************************************************************************/ +PeakValleyCheck check_peaks_valleys(int data[], int length) { + PeakValleyCheck result = {true, true, 0, 0}; + + // 如果数据长度小于3,无法形成有效的峰值/谷值 + if (length < 3) { + return result; + } + + int i = 0; + // 跳过开头的0值 + while (i < length && data[i] == 0) { + i++; + } + + // 遍历数据点 + while (i < length) { + // 1. 寻找下一个非零点作为起点 + int start = i; + while (i < length && data[i] == 0) { + i++; + } + if (i >= length) break; + + // 2. 寻找当前非零段的结束点 + int end = i; + while (end < length && data[end] != 0) { + end++; + } + end--; // 指向最后一个非零点 + + // 3. 在当前非零段中检测峰值和谷值 + for (int j = i; j <= end; j++) { + // 跳过边界点 + if (j == i || j == end) continue; + + // 检查是否为峰值(大于左右相邻的非零点) + if (data[j] > data[j-1] && data[j] > data[j+1]) { + result.peak_count++; + if (data[j] <= 0) { + result.peaks_positive = false; + } + } + + // 检查是否为谷值(小于左右相邻的非零点) + if (data[j] < data[j-1] && data[j] < data[j+1]) { + result.valley_count++; + if (data[j] >= 0) { + result.valleys_negative = false; + } + } + } + + // 移动到下一段 + i = end + 1; + } + + return result; +} +/***************************************************************************************** +* 函数名称: analyze_trend +* 功能描述: 趋势分析函数 +* 参 数: data, 数据 + length, 数据长度 +* 返 回 值: 结果返回趋势分析结构体 +*****************************************************************************************/ +TrendResult analyze_trend(int data[], int length) { + TrendResult result = {0}; + #if 1 + // 0. 检查有效数据长度 + if (length < 2) { + DBG_LOG("Data deficient\r\n"); + return result; + } + + // 1. 计算线性回归斜率 + double sum_x = 0, sum_y = 0, sum_xy = 0, sum_x2 = 0; + + for (int i = 0; i < length; i++) { + double x = i; // 时间序列 (0,1,2,...) + double y = data[i]; + sum_x += x; + sum_y += y; + sum_xy += x * y; + sum_x2 += x * x; + } + + double numerator = length * sum_xy - sum_x * sum_y; + double denominator = length * sum_x2 - sum_x * sum_x; + + // 处理分母为零的情况 + if (fabs(denominator) > 1e-10) { + result.slope = numerator / denominator; + } + #endif + #if 0 + // 2. 计算振荡特征(差分符号变化次数) + int sign_changes = 0; + int prev_sign = 0; // 0=未初始化, 1=正, -1=负 + + for (int i = 1; i < length; i++) { + int diff = data[i] - data[i-1]; + int curr_sign = (diff > 0) ? 1 : (diff < 0) ? -1 : 0; + + if (curr_sign != 0) { + if (prev_sign != 0 && curr_sign != prev_sign) { + sign_changes++; + } + prev_sign = curr_sign; + } + } + result.sign_changes = sign_changes; + #endif + #if 0 + // 3. 动态计算阈值(基于数据长度) + int oscillation_threshold = (int)(0.4 * (length - 1)); // 40%的变化率 + double slope_threshold = 0.05 * (length / 20.0); // 长度标准化 + #endif + #if 0 + // 4. 趋势判断 + if (sign_changes >= oscillation_threshold) { + //DBG_LOG("Oscillating trend\r\n");//振荡趋势 + result.trend_type = 0; + } else if (fabs(result.slope) < slope_threshold) { + //DBG_LOG("Smooth trend\r\n");//平稳趋势 + result.trend_type = 1; + } else if (result.slope > 0) { + //DBG_LOG("Up trend\r\n");//上升趋势 + result.trend_type = 2; + } else { + //DBG_LOG("Down trend\r\n");//下降趋势 + result.trend_type = 3; + } + #endif + #if 0 + // 5. 陡峭判断 + double abs_slope = fabs(result.slope); + if (abs_slope > 0.8) { + //DBG_LOG("Steeply");//陡峭 + result.sign_changes = 0; + } else if (abs_slope > 0.3) { + //DBG_LOG("Obvious");//明显 + result.sign_changes = 1; + } else if (abs_slope > 0.1) { + //DBG_LOG("Mild");//温和 + result.sign_changes = 2; + } else { + //DBG_LOG("gentle");//平缓 + result.sign_changes = 3; + } + #endif + return result; +} +/***************************************************************************************** +* 函数名称: calculateAverage +* 功能描述: 计算平均值 +* 参 数: arr, 数据 + size, 数据长度 +* 返 回 值: 结果返回 long long 防溢出 +*****************************************************************************************/ +float calculateAverage(int *arr, int size) +{ + int sum = 0; + for (int i = 0; i < size; i++) { + sum += arr[i]; // 累加数组中的每个元素 + } + return (float)sum / size; // 返回平均值 +} +/***************************************************************************************** +* 函数名称: slope +* 功能描述: 计算斜率 +* 参 数: x_data, x轴数据 + y_data, y轴数据 +* 返 回 值: 结果返回 long long 防溢出 +*****************************************************************************************/ +double slope(int32_t *x_data, int32_t *y_data, int n) +{ + double sum_x = 0, sum_y = 0, sum_xx = 0, sum_xy = 0; + for (int i = 0; i < n; i++) { + sum_x += x_data[i]; + sum_y += y_data[i]; + sum_xx += pow(x_data[i] - calculateAverage(x_data, n), 2); + sum_xy += (x_data[i] - calculateAverage(x_data, n)) * (y_data[i] - calculateAverage(y_data, n)); + } + + return sum_xy / sum_xx; +} +/***************************************************************************************** +* 函数名称: power +* 功能描述: 快速幂算法 +* 参 数: base, 滤波数据 + exponent, 滤波数据长度 +* 返 回 值: 结果返回 long long 防溢出 +*****************************************************************************************/ +long long power(int base, unsigned int exponent) { + long long result = 1; + while (exponent > 0) { + if (exponent % 2 == 1) { + result *= base; // 指数为奇数时累乘 + } + base *= base; // 底数平方 + exponent /= 2; // 指数折半 + } + return result; +} +/***************************************************************************************** +* 函数名称: IntFilter_16t +* 功能描述: 16位数据中值滤波函数 +* 参 数: Data, 滤波数据 + Cnt, 滤波数据长度 + FilterCnt, 滤除的数据长度,必须为2的倍数 +* 返 回 值: 滤波后的16位数据 +*****************************************************************************************/ +int IntFilter_16t(int16_t *Data, uint8_t Cnt, uint8_t FilterCnt) +{ + int32_t sum = 0; + int32_t temp; + + if(Cnt < 2) + return *Data; + + for(int j=0; j Data[i+1]) { + temp = Data[i]; + Data[i] = Data[i+1]; + Data[i+1] = temp; + } + } + } + + for(int count = FilterCnt / 2; count < Cnt - FilterCnt / 2; count++) + sum += Data[count]; + return (sum / (Cnt - FilterCnt)); +} + +/***************************************************************************************** +* 函数名称: IntFilter_32t +* 功能描述: 32位数据中值滤波函数 +* 参 数: Data, 滤波数据 + Cnt, 滤波数据长度 + FilterCnt, 滤除的数据长度,必须为2的倍数 +* 返 回 值: 滤波后的32位数据 +*****************************************************************************************/ +int IntFilter_32t(int32_t *Data, uint8_t Cnt, uint8_t FilterCnt) +{ + int32_t sum = 0; + int32_t temp; + + if(Cnt < 2) + return *Data; + + for(int j=0; j Data[i+1]) { + temp = Data[i]; + Data[i] = Data[i+1]; + Data[i+1] = temp; + } + } + } + + for(int count = FilterCnt / 2; count < Cnt - FilterCnt / 2; count++) + sum += Data[count]; + return (sum / (Cnt - FilterCnt)); +} +/***************************************************************************************** +* 函数名称: IntFilter_u32t +* 功能描述: 32位无符号位数据中值滤波函数 +* 参 数: Data, 滤波数据 + Cnt, 滤波数据长度 + FilterCnt, 滤除的数据长度,必须为2的倍数 +* 返 回 值: 滤波后的32位数据 +*****************************************************************************************/ +uint32_t IntFilter_u32t(uint32_t *Data, uint8_t Cnt, uint8_t FilterCnt) +{ + uint32_t sum = 0; + uint32_t temp; + + if(Cnt < 2) + return *Data; + + for(int j=0; j Data[i+1]) { + temp = Data[i]; + Data[i] = Data[i+1]; + Data[i+1] = temp; + } + } + } + + for(int count = FilterCnt / 2; count < Cnt - FilterCnt / 2; count++) + sum += Data[count]; + return (sum / (Cnt - FilterCnt)); +} +/***************************************************************************************** +* 函数名称: IntFilter_Float +* 功能描述: 32位浮点数数据中值滤波函数 +* 参 数: Data, 滤波数据 + Cnt, 滤波数据长度 + FilterCnt, 滤除的数据长度,必须为2的倍数 +* 返 回 值: 滤波后的32位数据 +*****************************************************************************************/ +float IntFilter_Float(float *Data, uint8_t Cnt, uint8_t FilterCnt) +{ + float sum = 0; + float temp; + + if(Cnt < 2) + return *Data; + + for(int j=0; j Data[i+1]) { + temp = Data[i]; + Data[i] = Data[i+1]; + Data[i+1] = temp; + } + } + } + + for(int count = FilterCnt / 2; count < Cnt - FilterCnt / 2; count++) + sum += Data[count]; + return (sum / (Cnt - FilterCnt)); +} +/***************************************************************************************** +* 函数名称: AverageFilter_u32t +* 功能描述: 32位数据均值滤波函数,去除了最大值和最小值 +* 参 数: Data, 滤波数据 + Cnt, 滤波数据长度 +* 返 回 值: 滤波后的32位数据 +*****************************************************************************************/ +uint32_t AverageFilter_u32t(uint32_t *Data, uint8_t Cnt) +{ + uint32_t sum = 0; + uint32_t temp; + uint32_t max = Data[0]; + uint32_t min = Data[0]; + + if(Cnt == 0) + return 0; + + if(Cnt == 1) + return Data[0]; + + if(Cnt == 2) + { + sum = Data[0] + Data[1]; + return sum / 2; + } + + for (uint8_t i = 0; i < Cnt; i++)//找出最大值 + { + if (Data[i] > max) + { + max = Data[i]; + } + } + + for (uint8_t i = 0; i < Cnt; i++)//找出最小值 + { + if (Data[i] < min) + { + min = Data[i]; + } + } + + for(int i = 0; i < Cnt; i++){//求和 + sum += Data[i]; + } + + return (sum - max - min) / (Cnt - 2); +} + +/***************************************************************************************** +* 函数名称: AverageFilter_32t +* 功能描述: 32位数据均值滤波函数,去除了最大值和最小值 +* 参 数: Data, 滤波数据 + Cnt, 滤波数据长度 +* 返 回 值: 滤波后的32位数据 +*****************************************************************************************/ +int AverageFilter_32t(int32_t *Data, uint8_t Cnt) +{ + int32_t sum = 0; + int32_t max = Data[0]; + int32_t min = Data[0]; + + if(Cnt == 0) + return 0; + + if(Cnt == 1) + return Data[0]; + + if(Cnt == 2) + { + sum = Data[0] + Data[1]; + return sum / 2; + } + + for (uint8_t i = 0; i < Cnt; i++)//找出最大值 + { + if (Data[i] > max) + { + max = Data[i]; + } + } + + for (uint8_t i = 0; i < Cnt; i++)//找出最小值 + { + if (Data[i] < min) + { + min = Data[i]; + } + } + + for(int i = 0; i < Cnt; i++){//求和 + sum += Data[i]; + } + + return (sum - max - min) / (Cnt - 2); +} +/***************************************************************************************** +* 函数名称: Fitting_Polynomial +* 功能描述: 根据数组AD[], Actual[]列出的一组数据,用最小二乘法求它的拟合曲线,默认3阶 + 近似解析表达式为y = a3*x^3 + a2*x^2 + a1*x + a0; +* 参 数: AD, AD芯片采样值 + Actual, 实际标校值 + Cnt, 拟合数据个数 +* 返 回 值: 无 +*****************************************************************************************/ +void Fitting_Polynomial(double *AD, double *Actual, uint8_t Cnt) +{ + static const uint8_t rank_ = 3;//拟合阶数3 + double atemp[2 * (rank_ + 1)], b[rank_ + 1], a[rank_ + 1][rank_ + 1]; + int i, j, k; + + for(i = 0; i < Cnt; i++){ + atemp[1] += AD[i]; + atemp[2] += pow(AD[i], 2); + atemp[3] += pow(AD[i], 3); + atemp[4] += pow(AD[i], 4); + atemp[5] += pow(AD[i], 5); + atemp[6] += pow(AD[i], 6); + b[0] += Actual[i]; + b[1] += AD[i] * Actual[i]; + b[2] += pow(AD[i], 2) * Actual[i]; + b[3] += pow(AD[i], 3) * Actual[i]; + } + + atemp[0] = Cnt; + + for(i = 0; i < rank_ + 1; i++){ //构建线性方程组系数矩阵,b[]不变 + k = i; + for(j = 0; j < rank_ + 1; j++) a[i][j] = atemp[k++]; + } + + //以下为高斯列主元消去法解线性方程组 + for(k = 0; k < rank_ + 1 - 1; k++){ //n - 1列 + int column = k; + double mainelement = a[k][k]; + + for(i = k; i < rank_ + 1; i++) //找主元素 + if(fabs(a[i][k]) > mainelement){ + mainelement = fabs(a[i][k]); + column = i; + } + for(j = k; j < rank_ + 1; j++){ //交换两行 + double atemp = a[k][j]; + a[k][j] = a[column][j]; + a[column][j] = atemp; + } + double btemp = b[k]; + b[k] = b[column]; + b[column] = btemp; + + for(i = k + 1; i < rank_ + 1; i++){ //消元过程 + double Mik = a[i][k] / a[k][k]; + for(j = k; j < rank_ + 1; j++) a[i][j] -= Mik * a[k][j]; + b[i] -= Mik * b[k]; + } + } + + b[rank_ + 1 - 1] /= a[rank_ + 1 - 1][rank_ + 1 - 1]; //回代过程 + for(i = rank_ + 1 - 2; i >= 0; i--){ + double sum = 0; + for(j = i + 1; j < rank_ + 1; j++) sum += a[i][j] * b[j]; + b[i] = (b[i] - sum) / a[i][i]; + }//高斯列主元消去法结束 + + DBG_LOG("P(x) = %.16fx^3%+.16fx^2%+.16fx%+.16f\r\n", b[3], b[2], b[1], b[0]); + +// App.Para.Cali.FitCoef[0] = b[0]; +// App.Para.Cali.FitCoef[1] = b[1]; +// App.Para.Cali.FitCoef[2] = b[2]; +// App.Para.Cali.FitCoef[3] = b[3]; + +} +/***************************************************************************************** +* 函数名称: get_K +* 功能描述: 斜率计算 +* 参 数: count,数据个数 数组行(列)的个数 数组的行列数目相等 + dataCol_X[count],数据的列数据 + dataRow_Y[count],数据的行数据 +* 返 回 值: k 斜率 +*****************************************************************************************/ +float get_K(uint8_t count , int32_t *dataCol_X, int32_t *dataRow_Y) +{ + float k = 0;//斜率 + float aveCol_X = 0;//列的平均值x + float aveRow_Y = 0;//行的平均值y + int32_t sum_XY = 0;//行列的总和xy + int32_t sumRow_Y = 0;//行的总和y + int32_t sumCol_X = 0;//列的总和x + int32_t sumCol_X2 = 0;//列的总和x^2 + + for(uint16_t i = 0 ; i < count ; i++) + { + sumCol_X += dataCol_X[i];//求列x的总和 + sumRow_Y += dataRow_Y[i];//求行y的总和 + sumCol_X2 += dataCol_X[i] * dataCol_X[i];//求x^2的总和 + sum_XY += (dataCol_X[i] * dataRow_Y[i]);//求xy的总和 + } + + aveCol_X = 1.0 * sumCol_X / count;//求平均值 + aveRow_Y = 1.0 * sumRow_Y / count; + + k = (sum_XY - aveCol_X * aveRow_Y * count) / //根据公式求斜率 + (sumCol_X2 - aveCol_X * aveCol_X * count); + + return k; +} +/***************************************************************************************** +* 函数名称: TrendAnalyse +* 功能描述: 判断数组中的值的总体趋势 +* 参 数: Data, + Cnt, + VPT, +* 返 回 值: true或false +*****************************************************************************************/ +int8_t TrendAnalyse(int32_t *Data, uint8_t Cnt, int32_t VPT) +{ + int8_t zero = 0,plus = 0, minus = 0, Trend = 0xEE; + + if(Cnt < 2) + return Trend; + + for(uint8_t i = 1; i < Cnt; i++) + { + if((Data[i] - Data[i - 1]) <= VPT && ((Data[i] - Data[i - 1]) >= (-VPT))) + { + zero++; + } + else if((Data[i] - Data[i - 1]) > VPT) + { + plus++; + } + else if((Data[i] - Data[i - 1]) < VPT) + { + minus++; + } + } + if(zero > (Cnt-(Cnt / 5))) + Trend = 0;//振荡趋势 + else if(plus > (Cnt-(Cnt/ 5))) + Trend = 1;//上升趋势 + else if(minus > (Cnt-(Cnt/ 5))) + Trend = -1;//下降趋势 + + return Trend;//总趋势 +} +/***************************************************************************************** +* 函数名称: Waveform_Up +* 功能描述: 找出一段波形的波峰值 + dCnt, 波形数据长度 + pCnt, 要查找波峰数 + vlue, 返回的波峰值 +* 返 回 值: true或false +*****************************************************************************************/ +void Waveform_Up(int32_t *Data, uint8_t dCnt, uint8_t pCnt, int32_t *vlue) +{ + uint8_t peak[pCnt]; + for(uint8_t i = 0, j = 0; i < dCnt; i++)//找出峰值地址 + { + if(Data[i] < Data[i + 1] && Data[i + 1] > Data[i + 2]) + { + peak[j++] = i; + } + if(j == pCnt) + break; + } + for(uint8_t i = 0; i < pCnt; i++) + { + vlue[i] = Data[peak[i]]; + } +} +/***************************************************************************************** +* 函数名称: Waveform_Down +* 功能描述: 找出一段波形的波谷值 + dCnt, 波形数据长度 + pCnt, 要查找波谷数 + vlue, 返回的波谷值 +* 返 回 值: true或false +*****************************************************************************************/ +void Waveform_Down(int32_t *Data, uint8_t dCnt, uint8_t pCnt, int32_t *vlue) +{ + uint8_t peak[pCnt]; + for(uint8_t i = 0, j = 0; i < dCnt; i++)//找出峰值地址 + { + if(Data[i] > Data[i + 1] && Data[i + 1] < Data[i + 2]) + { + peak[j++] = i; + } + if(j == pCnt) + break; + } + for(uint8_t i = 0; i < pCnt; i++) + { + vlue[i] = Data[peak[i]]; + } +} +/***************************************************************************************** +* 函数名称: count_most_greater +* 功能描述: 判断数组中的值是否大部分大于 target +* 参 数: arr, + size, + target, +* 返 回 值: true或false +*****************************************************************************************/ +bool count_most_greater(int32_t *arr, uint8_t size, int32_t target) +{ + uint8_t cnt = 0; + for (int i = 0; i < size; i++) { + if (arr[i] < target) + cnt++; + if(cnt > (size - (size / 5))) + return false; + } + return true; +} +/***************************************************************************************** +* 函数名称: count_greater +* 功能描述: 判断数组中的值是否全部大于 target +* 参 数: arr, + size, + target, +* 返 回 值: true或false +*****************************************************************************************/ +bool count_greater(int32_t *arr, uint8_t size, int32_t target) +{ + for (int i = 0; i < size; i++) { + if (arr[i] < target) + return false; + } + return true; +} +/***************************************************************************************** +* 函数名称: count_smaller +* 功能描述: 判断数组中的值是否全部小于 target +* 参 数: arr, + size, + target, +* 返 回 值: true或false +*****************************************************************************************/ +bool count_smaller(int32_t *arr, uint8_t size, int32_t target) +{ + for (int i = 0; i < size; i++) { + if (arr[i] > target) + return false; + } + return true; +} + +/***************************************************************************************** +* 函数名称: CRC_Modbus +* 功能描述: CRC16计算函数 +* 参 数: wBase, 多项式 + Para,校验数据入口 + Data, 校验数据长度入口 +* 返 回 值: crc16校验值 +*****************************************************************************************/ +uint16_t CRC_Modbus(uint16_t wBase, uint8_t *para, uint16_t length) +{ + uint16_t crc = 0xffff; + + uint16_t index,i; + + for(index = 0 ; index < length;index++) { + crc ^= para[index]; + for(i = 0; i < 8; i++) { + if(crc & 1) { + crc >>= 1; + crc ^= wBase; + } + else + crc >>= 1; + } + } + return crc; +} + +/***************************************************************************************** +* 函数名称: CRC_Sum +* 功能描述: 从第二个字节开始,求和取反 +* 参 数: _pbuff,校验数据入口 + _cmdLen,校验数据长度入口 +* 返 回 值: cmd_sum,校验值(一个字节) +*****************************************************************************************/ +uint8_t CRC_Sum(uint8_t *_pbuff, uint16_t _cmdLen) +{ + uint8_t cmd_sum=0; + uint16_t i; + + for(i=1;i<_cmdLen;i++)//从1开始,跳过第一个字节 + { + cmd_sum += _pbuff[i]; + } + cmd_sum = (~cmd_sum); + + return cmd_sum; +} +/***************************************************************************************** +* 函数名称: isAllZero +* 功能描述: 判断一个数组的值是否全部为0 +* 参 数: arr,数组 + size,长度 +* 返 回 值: true或false +*****************************************************************************************/ +bool isAllZero(uint8_t *arr, int size) +{ + for (int i = 0; i < size; i++) { + if (arr[i] != 0) { + return false; // 如果数组中有一个元素不为0,则返回false + } + } + return true; // 遍历完数组后,若所有元素都为0,则返回true +} + +/***************************************************************************************** +* 函数名称: HexToAscii +* 功能描述: 16进制转ASCII码 +* 参 数: HexData,16进制数组 + ASCData,ASCII码 + sLen,数据长度 +* 返 回 值: true或false +*****************************************************************************************/ +void HexToAscii(uint8_t *HexData, char *ASCData, uint8_t sLen) +{ + uint8_t temp; + + for(int i = 0; i < sLen; i++) { + temp = (HexData[i] >> 4) & 0x0f; + if(temp < 10) + temp += '0'; + else + temp = (temp - 10) + 'A'; + + ASCData[i * 2] = temp; + + temp = HexData[i] & 0x0f; + if(temp < 10) + temp += '0'; + else + temp = (temp - 10) + 'A'; + + ASCData[i * 2 + 1] = temp; + } + ASCData[sLen * 2] = '\r'; + ASCData[sLen * 2 + 1] = '\n'; + ASCData[sLen * 2 + 2] = 0; +} + + diff --git a/source/src/SGCP.c b/source/src/SGCP.c new file mode 100644 index 0000000..e0240f8 --- /dev/null +++ b/source/src/SGCP.c @@ -0,0 +1,2227 @@ +#include "SGCP.h" +#include "main.h" +#include "UartDebug.h" +#include "Update.h" +#include "sx127x.h" +#include "Algorithm.h" + +/*烧录时配置项 +IROM1起始地址 0x00 0x20000 +IROM1串口升级地址 0x2A00 0x1D600 +串口升级打开USE_BOOTLOADER和点s文件中的LDR R2, =new_vect_table ;升级时打开 +*/ + +//09 00 01 00 00 00 +uint8_t LocalMAC[6] = {LocalType & 0xFF, (LocalType >> 8) & 0xFF, CommWay, (AddNumber >> 16) & 0xFF, (AddNumber >> 8) & 0xFF, AddNumber & 0xFF}; //本机MAC地址 +uint8_t GatewayMAC[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //网关MAC地址,注册时全为0 +uint8_t LocalDataPack[LocalDataLen]; //本机数据包 + + +SGCP_t SGCP; + +/** + ******************************************************************************* + ** \brief 设备数据信息获取 + ** + ** \param Devtype 设备类型 + ** + ** \param PayLoad 数据体 + ** + ** \retval Len 数据长度 + ******************************************************************************/ +static uint8_t DevGetDataMess(DEVICE_TYPE_M Devtype, uint8_t *PayLoad) +{ + uint8_t Len; + switch(Devtype) + { + case NUL: break; + case FORCE_6D: break; + case OSMOTIC_PRESSURE: break; + case ELASTIC_WAVEGUIDE: break; + case DIELECTRIC_MASS: break; + case _0x0005:break; + case CONT_DEFOR_3D:{ + if(PayLoad == NULL) + memset(&SGCP.DevData.ContDefor3D, 0x00, sizeof(SGCP.DevData.ContDefor3D)); + else + memcpy(&SGCP.DevData.ContDefor3D, &PayLoad[0], sizeof(SGCP.DevData.ContDefor3D)); + DBG_LOG("\tDevice Type:%04X, PitchSkew:%06d, RollSkew:%06d, YawSkew:%06d\r\n", + Devtype, + (SGCP.DevData.ContDefor3D.PitchAngle), + (SGCP.DevData.ContDefor3D.RollAngle), + (SGCP.DevData.ContDefor3D.YawAngle)); + Len = sizeof(SGCP.DevData.ContDefor3D); + break;} + case COMM_UNIT: { + DBG_LOG("\tDevice Type:%04X\r\n",Devtype); + Len = sizeof(SGCP.DevData.CommUnit); + break;} + case FORCE_3D:{ + if(PayLoad == NULL) + memset(&SGCP.DevData.Force3D, 0x00, sizeof(SGCP.DevData.Force3D)); + else + memcpy(&SGCP.DevData.Force3D, &PayLoad[0], sizeof(SGCP.DevData.Force3D)); + DBG_LOG("\tDevice Type:%04X, PitchSkew:%06d, RollSkew:%06d, YawSkew:%06d, Strain1:%09d, Strain2:%09d, Strain3:%09d\r\n", + Devtype, + (SGCP.DevData.Force3D.PitchAngle), + (SGCP.DevData.Force3D.RollAngle), + (SGCP.DevData.Force3D.YawAngle), + (SGCP.DevData.Force3D.Strain1), + (SGCP.DevData.Force3D.Strain2), + (SGCP.DevData.Force3D.Strain3)); + Len = sizeof(SGCP.DevData.Force3D); + break;} + case LASER_TRACING: { + if(PayLoad == NULL) + memset(&SGCP.DevData.LaserTracing, 0x00, sizeof(SGCP.DevData.LaserTracing)); + else + + memcpy(&SGCP.DevData.LaserTracing, &PayLoad[0], sizeof(SGCP.DevData.LaserTracing)); + DBG_LOG("\tBatLevel:%03d, RSSI:%02d, Nsr:%02d\r\n",SGCP.DevData.LaserTracing.MasterDev.BatLevel, SGCP.DevData.LaserTracing.MasterDev.RSSI,SGCP.DevData.LaserTracing.MasterDev.Nsr); + DBG_LOG("\tDevice Type:%04X, PitchSkew:%04d, RollSkew:%04d, YawSkew:%04d\r\n", + Devtype, + (SGCP.DevData.LaserTracing.PitchAngle), + (SGCP.DevData.LaserTracing.RollAngle), + (SGCP.DevData.LaserTracing.YawAngle)); + Len = sizeof(SGCP.DevData.LaserTracing); + break;} + case _0x000A: break; + case _0x000B: break; + case _0x000C: break; + case MULTI_PARAMETER_FUSION: break; + case CRACK_DETECTION: break; + case _0x000F: break; + case ATTITUDE_MONITOR: break; + case LASER_DISPLACE: break; + case REBAR_STRESS: break; + case ANCHOR_ROD_STRESS: break; + case SURFACE_STRESS: break; + case PRESSURE: break; + case MICROWAVE_DISPLACE: break; + } + + return Len; +} +/** + ******************************************************************************* + ** \brief 子设备校准指令 + ** + ** \param [in] Addr 子设备地址 + ** + ** \param [in] PayLoad 数据体 + ** + ** \retval 无 + ******************************************************************************/ +static void ToSDCali(uint8_t Addr) +{ + uint8_t Pack[50]; + uint16_t Crc16; + uint8_t len; + + SubsetFrameHeader SFHeader = (SubsetFrameHeader)Pack; + + SFHeader->Header = 0x7C; + SFHeader->Addr = Addr; + SFHeader->Cmd = MDTOSD_CMD_CALI; + SFHeader->PayloadLen = 0; + + len = sizeof(SubsetFrameHeader_t); + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, len); + Pack[len++] = Crc16 & 0x00ff; + Pack[len++] = (Crc16 >> 8) & 0x00ff; + + SGCP.SDRS485Rx.sCmdMDToSD = (MDTOSD_CMD_M)SFHeader->Cmd; + Uart1SendArray(Pack, len); +} +/** + ******************************************************************************* + ** \brief 子设备读取数据指令 + ** + ** \param [in] Addr 子设备地址 + ** + ** \param [in] PayLoad 数据体 + ** + ** \retval 无 + ******************************************************************************/ +static void ToSDReadData(uint8_t Addr) +{ + uint8_t Pack[50]; + uint16_t Crc16; + uint8_t len; + + SubsetFrameHeader SFHeader = (SubsetFrameHeader)Pack; + + SFHeader->Header = 0x7C; + SFHeader->Addr = Addr; + SFHeader->Cmd = MDTOSD_CMD_READ_DATA; + SFHeader->PayloadLen = 0; + + len = sizeof(SubsetFrameHeader_t); + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, len); + Pack[len++] = Crc16 & 0x00ff; + Pack[len++] = (Crc16 >> 8) & 0x00ff; + + SGCP.SDRS485Rx.sCmdMDToSD = (MDTOSD_CMD_M)SFHeader->Cmd; + Uart1SendArray(Pack, len); +} +/** + ******************************************************************************* + ** \brief 子设备查询指令 + ** + ** \param [in] Addr 子设备485地址 + ** + ** \param [in] PayLoad 数据体 + ** + ** \retval 无 + ******************************************************************************/ +static void ToSDInquire(uint8_t Addr) +{ + uint8_t Pack[50]; + uint16_t Crc16; + uint8_t len; + + SubsetFrameHeader SFHeader = (SubsetFrameHeader)Pack; + + SFHeader->Header = 0x7C; + SFHeader->Addr = Addr; + SFHeader->Cmd = MDTOSD_CMD_INQUIRE; + SFHeader->PayloadLen = 0; + + len = sizeof(SubsetFrameHeader_t); + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, len); + Pack[len++] = Crc16 & 0x00ff; + Pack[len++] = (Crc16 >> 8) & 0x00ff; + + SGCP.SDRS485Rx.sCmdMDToSD = (MDTOSD_CMD_M)SFHeader->Cmd; + Uart1SendArray(Pack, len); +} +/** + ******************************************************************************* + ** \brief 子设备设置采集时间间隔指令 + ** + ** \param [in] Addr 子设备地址 + ** + ** \param [in] CollTime 采集时间间隔 + ** + ** \retval 无 + ******************************************************************************/ +static void ToSDSetColTime(uint8_t Addr, uint16_t CollectInterval) +{ + uint8_t Pack[50]; + uint16_t Crc16; + uint8_t len; + + SubsetFrameHeader SFHeader = (SubsetFrameHeader)Pack; + + SFHeader->Header = 0x7C; + SFHeader->Addr = Addr; + SFHeader->Cmd = MDTOSD_CMD_SET_COL_TIME; + SFHeader->PayloadLen = sizeof(CollectInterval); + + len = sizeof(SubsetFrameHeader_t); + + Pack[len++] = CollectInterval & 0xFF; + Pack[len++] = (CollectInterval >> 8) & 0xFF; + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, len); + Pack[len++] = Crc16 & 0x00ff; + Pack[len++] = (Crc16 >> 8) & 0x00ff; + + SGCP.SDRS485Rx.sCmdMDToSD = (MDTOSD_CMD_M)SFHeader->Cmd; + Uart1SendArray(Pack, len); +} +/** + ******************************************************************************* + ** \brief 子设备时间同步指令 + ** + ** \param [in] Addr 子设备地址 + ** + ** \param [in] PayLoad 数据体 + ** + ** \retval 无 + ******************************************************************************/ +static void ToSDSyncTime(uint8_t Addr, uint32_t TimeStamp) +{ + uint8_t Pack[50]; + uint16_t Crc16; + uint8_t len; + + SubsetFrameHeader SFHeader = (SubsetFrameHeader)Pack; + + SFHeader->Header = 0x7C; + SFHeader->Addr = Addr; + SFHeader->Cmd = MDTOSD_CMD_SYNC_TIME; + SFHeader->PayloadLen = sizeof(TimeStamp); + + len = sizeof(SubsetFrameHeader_t); + + Pack[len++] = TimeStamp & 0xFF; + Pack[len++] = (TimeStamp >> 8) & 0xFF; + Pack[len++] = (TimeStamp >> 16) & 0xFF; + Pack[len++] = (TimeStamp >> 24) & 0xFF; + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, len); + Pack[len++] = Crc16 & 0x00ff; + Pack[len++] = (Crc16 >> 8) & 0x00ff; + + SGCP.SDRS485Rx.sCmdMDToSD = (MDTOSD_CMD_M)SFHeader->Cmd; + Uart1SendArray(Pack, len); +} + +/** + ******************************************************************************* + ** \brief 子设备校准回应 + ** + ** \param [in] Addr 子设备地址 + ** + ** \param [in] Ok_Err 成功失败标志位 + ** + ** \retval 无 + ******************************************************************************/ +static void ToMDCaliRes(uint8_t Addr, bool Ok_Err) +{ + uint8_t Pack[50]; + uint16_t Crc16; + uint8_t len; + + SubsetFrameHeader SFHeader = (SubsetFrameHeader)Pack; + + SFHeader->Header = 0x7C; + SFHeader->Addr = Addr; + SFHeader->Cmd = MDTOSD_CMD_CALI; + SFHeader->PayloadLen = sizeof(Ok_Err); + + len = sizeof(SubsetFrameHeader_t); + + Pack[len++] = Ok_Err; + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, len); + Pack[len++] = Crc16 & 0x00ff; + Pack[len++] = (Crc16 >> 8) & 0x00ff; + + SGCP.SDRS485Rx.sCmdMDToSD = (MDTOSD_CMD_M)SFHeader->Cmd; + LPUart0SendArray(Pack, len); +} +/** + ******************************************************************************* + ** \brief 子设备读取数据指令回应 + ** + ** \param [in] Addr 子设备地址 + ** + ** \param [in] PayLoad 数据体 + ** + ** \retval 无 + ******************************************************************************/ +static void ToMDReadDataRes(uint8_t Addr, uint8_t *PayLoad, uint8_t Len) +{ + uint8_t Pack[50]; + uint16_t Crc16; + uint8_t len; + + SubsetFrameHeader SFHeader = (SubsetFrameHeader)Pack; + + SFHeader->Header = 0x7C; + SFHeader->Addr = Addr; + SFHeader->Cmd = MDTOSD_CMD_READ_DATA; + SFHeader->PayloadLen = Len; + + len = sizeof(SubsetFrameHeader_t); + + for(uint8_t i = 0; i < SFHeader->PayloadLen; i++) + { + Pack[len++] = PayLoad[i]; + } + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, len); + Pack[len++] = Crc16 & 0x00ff; + Pack[len++] = (Crc16 >> 8) & 0x00ff; + + SGCP.SDRS485Rx.sCmdMDToSD = (MDTOSD_CMD_M)SFHeader->Cmd; + LPUart0SendArray(Pack, len); +} +/** + ******************************************************************************* + ** \brief 子设备查询指令回应 + ** + ** \param [in] Addr 子设备485地址 + ** + ** \param [in] PayLoad 数据体 + ** + ** \retval 无 + ******************************************************************************/ +static void ToMDInquireRes(uint8_t Addr) +{ + uint8_t Pack[50]; + uint16_t Crc16; + uint8_t len; + + SubsetFrameHeader SFHeader = (SubsetFrameHeader)Pack; + + SFHeader->Header = 0x7C; + SFHeader->Addr = Addr; + SFHeader->Cmd = MDTOSD_CMD_INQUIRE; + SFHeader->PayloadLen = 6; + + len = sizeof(SubsetFrameHeader_t); + + for(uint8_t i = 0; i < SFHeader->PayloadLen; i++) + { + Pack[len++] = LocalMAC[i]; + } + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, len); + Pack[len++] = Crc16 & 0x00ff; + Pack[len++] = (Crc16 >> 8) & 0x00ff; + + SGCP.SDRS485Rx.sCmdMDToSD = (MDTOSD_CMD_M)SFHeader->Cmd; + LPUart0SendArray(Pack, len); +} +/** + ******************************************************************************* + ** \brief 子设备设置采集时间间隔指令回应 + ** + ** \param [in] Addr 子设备地址 + ** + ** \param [in] Ok_Err 成功失败标志位 + ** + ** \retval 无 + ******************************************************************************/ +static void ToMDSetColTimeRes(uint8_t Addr, bool Ok_Err) +{ + uint8_t Pack[50]; + uint16_t Crc16; + uint8_t len; + + SubsetFrameHeader SFHeader = (SubsetFrameHeader)Pack; + + SFHeader->Header = 0x7C; + SFHeader->Addr = Addr; + SFHeader->Cmd = MDTOSD_CMD_SET_COL_TIME; + SFHeader->PayloadLen = sizeof(Ok_Err); + + len = sizeof(SubsetFrameHeader_t); + + Pack[len++] = Ok_Err; + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, len); + Pack[len++] = Crc16 & 0x00ff; + Pack[len++] = (Crc16 >> 8) & 0x00ff; + + SGCP.SDRS485Rx.sCmdMDToSD = (MDTOSD_CMD_M)SFHeader->Cmd; + LPUart0SendArray(Pack, len); +} +/** + ******************************************************************************* + ** \brief 子设备时间同步指令回应 + ** + ** \param [in] Addr 子设备地址 + ** + ** \param [in] Ok_Err 成功失败标志位 + ** + ** \retval 无 + ******************************************************************************/ +static void ToMDSyncTimeRes(uint8_t Addr, bool Ok_Err) +{ + uint8_t Pack[50]; + uint16_t Crc16; + uint8_t len; + + SubsetFrameHeader SFHeader = (SubsetFrameHeader)Pack; + + SFHeader->Header = 0x7C; + SFHeader->Addr = Addr; + SFHeader->Cmd = MDTOSD_CMD_SYNC_TIME; + SFHeader->PayloadLen = sizeof(Ok_Err); + + len = sizeof(SubsetFrameHeader_t); + + Pack[len++] = Ok_Err; + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, len); + Pack[len++] = Crc16 & 0x00ff; + Pack[len++] = (Crc16 >> 8) & 0x00ff; + + SGCP.SDRS485Rx.sCmdMDToSD = (MDTOSD_CMD_M)SFHeader->Cmd; + LPUart0SendArray(Pack, len); +} + + +/** + ******************************************************************************* + ** \brief 向网关申请注册 + ** + ** \param PayLoad 数据体 + ** + ** \retval 无 + ******************************************************************************/ +static void ToGWDevLogin(void) +{ + uint8_t Pack[512]; + uint16_t Crc16, Len; + + GatewayFrameHeader GFHeader = (GatewayFrameHeader)Pack; + + GFHeader->Header = 0x7B; + memset(&GFHeader->GWAddr[0], 0x00, sizeof(GFHeader->GWAddr)); + memcpy(&GFHeader->MDAddr[0], &LocalMAC[0], sizeof(GFHeader->MDAddr)); + GFHeader->Cmd = GWTOMD_CMD_LOGIN; + GFHeader->PayloadLen = (SGCP.DeviceN * 6 + 1); + + Len = sizeof(GatewayFrameHeader_t); + + Pack[Len++] = SGCP.DeviceN; + for(uint8_t i = 0; i < SGCP.DeviceN; i++) + { + for(uint8_t j = 0; j < 6; j++) + { + Pack[Len++] = SGCP.DeviceMAC[i][j]; + } + } + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, Len); + Pack[Len++] = Crc16 & 0x00ff; + Pack[Len++] = (Crc16 >> 8) & 0x00ff; + + SGCP.GWRS485Rx.sCmdMDToGW = (GWTOMD_CMD_M)GFHeader->Cmd; +#if(SGCP_SELECT == 1 || SGCP_SELECT == 2) + Sx1276LoRaSendBuffer(Pack, Len); +#endif +#if(SGCP_SELECT == 3) + LPUart0SendArray(Pack, Len); +#endif +} +/** + ******************************************************************************* + ** \brief 网关校准指令回应 + ** + ** \param Ok_Err 成功失败标志位 + ** + ** \retval 无 + ******************************************************************************/ +static void ToGWCaliRes(bool Ok_Err) +{ + uint8_t Pack[256]; + uint16_t Crc16; + uint8_t Len; + + GatewayFrameHeader GFHeader = (GatewayFrameHeader)Pack; + + GFHeader->Header = 0x7B; + memcpy(&GFHeader->GWAddr[0], &GatewayMAC[0], sizeof(GFHeader->GWAddr)); + memcpy(&GFHeader->MDAddr[0], &LocalMAC[0], sizeof(GFHeader->MDAddr)); + GFHeader->Cmd = GWTOMD_CMD_CALI; + GFHeader->PayloadLen = sizeof(Ok_Err); + + Len = sizeof(GatewayFrameHeader_t); + + Pack[Len++] = Ok_Err; + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, Len); + Pack[Len++] = Crc16 & 0x00ff; + Pack[Len++] = (Crc16 >> 8) & 0x00ff; + +SGCP.GWRS485Rx.sCmdMDToGW = (GWTOMD_CMD_M)GFHeader->Cmd; +#if(SGCP_SELECT == 1 || SGCP_SELECT == 2) + Sx1276LoRaSendBuffer(Pack, Len); +#endif +#if(SGCP_SELECT == 3) + LPUart0SendArray(Pack, Len); +#endif +} +/** + ******************************************************************************* + ** \brief 网关读取数据指令回应 + ** + ** \param PayLoad 数据体 + ** + ** \retval 无 + ******************************************************************************/ +static void ToGWReadDataRes(uint8_t *PayLoad) +{ + uint8_t Pack[512]; + uint16_t Crc16, Len; + + GatewayFrameHeader GFHeader = (GatewayFrameHeader)Pack; + + GFHeader->Header = 0x7B; + memcpy(&GFHeader->GWAddr[0], &GatewayMAC[0], sizeof(GFHeader->GWAddr)); + memcpy(&GFHeader->MDAddr[0], &LocalMAC[0], sizeof(GFHeader->MDAddr)); + GFHeader->Cmd = GWTOMD_CMD_READ_UPLOAD_SENSOR; + GFHeader->PayloadLen = SGCP.DeviceDataLen; + + Len = sizeof(GatewayFrameHeader_t); + + for(uint8_t i = 0; i < GFHeader->PayloadLen; i++) + { + Pack[Len++] = PayLoad[i]; + } + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, Len); + Pack[Len++] = Crc16 & 0x00ff; + Pack[Len++] = (Crc16 >> 8) & 0x00ff; + +SGCP.GWRS485Rx.sCmdMDToGW = (GWTOMD_CMD_M)GFHeader->Cmd; +#if(SGCP_SELECT == 1 || SGCP_SELECT == 2) + Sx1276LoRaSendBuffer(Pack, Len); +#endif +#if(SGCP_SELECT == 3) + LPUart0SendArray(Pack, Len); +#endif +} + +/** + ******************************************************************************* + ** \brief 网关设置采集时间间隔指令回应 + ** + ** \param Ok_Err 成功失败标志位 + ** + ** \retval 无 + ******************************************************************************/ +static void ToGWSetColTimeRes(bool Ok_Err) +{ + uint8_t Pack[256]; + uint16_t Crc16; + uint8_t Len; + + GatewayFrameHeader GFHeader = (GatewayFrameHeader)Pack; + + GFHeader->Header = 0x7B; + memcpy(&GFHeader->GWAddr[0], &GatewayMAC[0], sizeof(GFHeader->GWAddr)); + memcpy(&GFHeader->MDAddr[0], &LocalMAC[0], sizeof(GFHeader->MDAddr)); + GFHeader->Cmd = GWTOMD_CMD_SET_COL_TIME; + GFHeader->PayloadLen = sizeof(Ok_Err); + + Len = sizeof(GatewayFrameHeader_t); + + Pack[Len++] = Ok_Err; + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, Len); + Pack[Len++] = Crc16 & 0x00ff; + Pack[Len++] = (Crc16 >> 8) & 0x00ff; + +SGCP.GWRS485Rx.sCmdMDToGW = (GWTOMD_CMD_M)GFHeader->Cmd; +#if(SGCP_SELECT == 1 || SGCP_SELECT == 2) + Sx1276LoRaSendBuffer(Pack, Len); +#endif +#if(SGCP_SELECT == 3) + LPUart0SendArray(Pack, Len); +#endif +} + +/** + ******************************************************************************* + ** \brief 网关时间同步指令回应 + ** + ** \param Ok_Err 成功失败标志位 + ** + ** \retval 无 + ******************************************************************************/ +static void ToGWSyncTimeRes(bool Ok_Err) +{ + uint8_t Pack[256]; + uint16_t Crc16; + uint8_t Len; + + GatewayFrameHeader GFHeader = (GatewayFrameHeader)Pack; + + GFHeader->Header = 0x7B; + memcpy(&GFHeader->GWAddr[0], &GatewayMAC[0], sizeof(GFHeader->GWAddr)); + memcpy(&GFHeader->MDAddr[0], &LocalMAC[0], sizeof(GFHeader->MDAddr)); + GFHeader->Cmd = GWTOMD_CMD_SYNC_TIME; + GFHeader->PayloadLen = sizeof(Ok_Err); + + Len = sizeof(GatewayFrameHeader_t); + + Pack[Len++] = Ok_Err; + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, Len); + Pack[Len++] = Crc16 & 0x00ff; + Pack[Len++] = (Crc16 >> 8) & 0x00ff; + +SGCP.GWRS485Rx.sCmdMDToGW = (GWTOMD_CMD_M)GFHeader->Cmd; +#if(SGCP_SELECT == 1 || SGCP_SELECT == 2) + Sx1276LoRaSendBuffer(Pack, Len); +#endif +#if(SGCP_SELECT == 3) + LPUart0SendArray(Pack, Len); +#endif +} +/** + ******************************************************************************* + ** \brief 内部指令修改RS485地址回应 + ** + ** \param PayLoad 数据体 + ** + ** \retval 无 + ******************************************************************************/ +static void Alter485AddrRes(uint8_t *MAC, bool Ok_Err) +{ + uint8_t Pack[50]; + uint16_t Crc16; + uint8_t len; + + InsideFrameHeader IFHeader = (InsideFrameHeader)Pack; + + IFHeader->Header = 0x7D; + memcpy(&IFHeader->MAC[0], &MAC[0], sizeof(IFHeader->MAC)); + IFHeader->Cmd = INSIDE_CMD_ALTER_485ADDR; + IFHeader->PayloadLen = sizeof(Ok_Err); + + len = sizeof(InsideFrameHeader_t); + + Pack[len++] = Ok_Err; + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, len); + Pack[len++] = Crc16 & 0x00ff; + Pack[len++] = (Crc16 >> 8) & 0x00ff; + + LPUart0SendArray(Pack, len); +} +/** + ******************************************************************************* + ** \brief 主设备接收子设备数据处理 + ** + ** \param 无 + ** + ** \retval 无 + ******************************************************************************/ +static void SubsetRevHandler(void) +{ + uint16_t crc16, Check; + uint8_t *PayLoad; + + SubsetFrameHeader SFHeader = (SubsetFrameHeader)SGCP.SubsetBuff; + + crc16 = (SGCP.SubsetBuff[SGCP.SubsetBuffLen - 1] << 8) | SGCP.SubsetBuff[SGCP.SubsetBuffLen - 2]; + Check = CRC_Modbus(CRC16_BASE, SGCP.SubsetBuff, SGCP.SubsetBuffLen - 2); + + if(crc16 != Check){ + DBG_LOG("Subset CRC Err...\r\n"); + return; + } + + + SGCP.SDRS485Rx.rCmdSDToMD = (MDTOSD_CMD_M)SFHeader->Cmd; + PayLoad = &SGCP.SubsetBuff[sizeof(SubsetFrameHeader_t)]; + + switch(SGCP.SDRS485Rx.rCmdSDToMD) { + case MDTOSD_CMD_CALI:{ + SGCP.SubsetCaliOk = PayLoad[0]; + break;} + + case MDTOSD_CMD_READ_DATA:{ + memcpy(&SGCP.DeviceDataBuff[SGCP.DeviceDataLen], PayLoad, SGCP.SDRS485Rx.rPayLen); + SGCP.SubsetReadDataOk = true; + break;} + + case MDTOSD_CMD_INQUIRE:{ + memcpy(&SGCP.DeviceMAC[SGCP.DeviceN], PayLoad, sizeof(SGCP.DeviceMAC[SGCP.DeviceN]));//子设备MAC + SGCP.SubsetMACOk = true; + break;} + + case MDTOSD_CMD_SET_COL_TIME:{ + SGCP.CollTimeSetOk = PayLoad[0]; + break;} + + case MDTOSD_CMD_SYNC_TIME:{ + SGCP.SyncTimeOk = PayLoad[0]; + break;} + } +} +/** + ******************************************************************************* + ** \brief 子设备接收主设备数据处理 + ** + ** \param 无 + ** + ** \retval 无 + ******************************************************************************/ +static void MasRevHandler(void) +{ + uint16_t crc16, Check; + uint8_t *PayLoad; + + SubsetFrameHeader SFHeader = (SubsetFrameHeader)SGCP.SubsetBuff; + + crc16 = (SGCP.SubsetBuff[SGCP.SubsetBuffLen - 1] << 8) | SGCP.SubsetBuff[SGCP.SubsetBuffLen - 2]; + Check = CRC_Modbus(CRC16_BASE, SGCP.SubsetBuff, SGCP.SubsetBuffLen - 2); + + if(crc16 != Check){ + DBG_LOG("Master CRC Err...\r\n"); + return; + } + + if(SFHeader->Addr != App.Para.RS485Addr) + { + if(SFHeader->Addr != 0x00) + { + DBG_LOG("Master RS485Addr Err...\r\n"); + return; + } + else + { + SGCP.BroadCmd = true; + } + } + + SGCP.SDRS485Rx.rCmdSDToMD = (MDTOSD_CMD_M)SFHeader->Cmd; + PayLoad = &SGCP.SubsetBuff[sizeof(SubsetFrameHeader_t)]; + + switch(SGCP.SDRS485Rx.rCmdSDToMD) { + case MDTOSD_CMD_CALI:{ + if(SGCP.MasStatus == MAS_STATUS_IDLE) + { + SGCP.SubsetCaliOk = true; + SGCP.MasStatus = MAS_STATUS_CALI; + } + break;} + + case MDTOSD_CMD_READ_DATA:{ + if(SGCP.BroadCmd == true) + { + SGCP.BroadCmd = false; + return; + } + if(SGCP.MasStatus == MAS_STATUS_IDLE) + { + SGCP.MasStatus = MAS_STATUS_READ_SENSOR; + } + break;} + + case MDTOSD_CMD_INQUIRE:{ + if(SGCP.BroadCmd == true) + { + SGCP.BroadCmd = false; + return; + } + if(SGCP.MasStatus == MAS_STATUS_IDLE) + { + SGCP.MasStatus = MAS_STATUS_DEVICE_INQUIRE; + } + break;} + + case MDTOSD_CMD_SET_COL_TIME:{ + uint32_t temp; + temp = PayLoad[0]; + temp |= (PayLoad[1] << 8); + if(temp < 1 || temp > 7200) + { + DBG_LOG("CollectInterval Err\r\n"); + return; + } + else + { + App.Para.Layout.CollectTime = temp; + SAVE_APP_PARA((uint32_t *)&App.Para); + if(App.Para.Layout.CollectTime >= 30) + RTCInit(30);//定时采集时间重新初始化 + else + RTCInit(App.Para.Layout.CollectTime);//定时采集时间重新初始化 + if(SGCP.MasStatus == MAS_STATUS_IDLE) + { + SGCP.MasStatus = MAS_STATUS_SET_COL_TIME; + } + } + break;} + + case MDTOSD_CMD_SYNC_TIME:{ + uint32_t temp; + temp = PayLoad[0]; + temp |= (PayLoad[1] << 8); + temp |= (PayLoad[2] << 16); + temp |= (PayLoad[3] << 24); + if(temp < 1701173083 || temp > 4102372799) + { + DBG_LOG("TimeStamp Err\r\n"); + return; + } + else + { + App.Para.Layout.TimeStamp = temp; + SAVE_APP_PARA((uint32_t *)&App.Para); + TimeSync(App.Para.Layout.TimeStamp); //设置时间 + if(SGCP.MasStatus == MAS_STATUS_IDLE) + { + SGCP.MasStatus = MAS_STATUS_SYNC_TIME; + } + } + break;} + } +} +/** + ******************************************************************************* + ** \brief 主设备接收网关数据处理 + ** + ** \param 无 + ** + ** \retval 无 + ******************************************************************************/ +static void GWRevHandler(void) +{ + uint16_t crc16,Check; + uint8_t *PayLoad; + uint16_t PayLoadLen; + + GatewayFrameHeader GFHeader = (GatewayFrameHeader)SGCP.GatewayBuff; + + crc16 = (SGCP.GatewayBuff[SGCP.GatewayBuffLen - 1] << 8) | SGCP.GatewayBuff[SGCP.GatewayBuffLen - 2]; + Check = CRC_Modbus(CRC16_BASE, SGCP.GatewayBuff, SGCP.GatewayBuffLen - 2); + + if(crc16 != Check){ + DBG_LOG("Gateway CRC Err...\r\n"); + return; + } + + if(memcmp(GFHeader->MDAddr, LocalMAC, sizeof(GFHeader->MDAddr)) != false) + { + if(isAllZero(GFHeader->MDAddr, sizeof(GFHeader->MDAddr)) != true) + { + DBG_LOG("Gateway Master Device MAC Err...\r\n"); + return; + } + else + { + SGCP.BroadCmd = true; + } + } + + + SGCP.GWRS485Rx.rCmdGWToMD = (GWTOMD_CMD_M)GFHeader->Cmd; + PayLoad = &SGCP.GatewayBuff[sizeof(GatewayFrameHeader_t)]; + LayoutPara LPay = (LayoutPara)PayLoad; + PayLoadLen = GFHeader->PayloadLen; + + switch(SGCP.GWRS485Rx.rCmdGWToMD) { + case GWTOMD_CMD_LOGIN:{ + SGCP.LoginOk = PayLoad[0]; + if(SGCP.LoginOk == true) + { + memcpy(GatewayMAC, GFHeader->GWAddr, sizeof(GatewayMAC)); + } + break;} + + case GWTOMD_CMD_CALI:{ + if(SGCP.LoginOk == true) + { + SGCP.MasterCaliOk = true; + if(SGCP.GWStatus == GW_STATUS_WAIT_UPLOAD) + { + SGCP.UploadOk = true; + SGCP.NextGWStatus = GW_STATUS_CALI; + } + else + SGCP.GWStatus = GW_STATUS_CALI; + } + break;} + + case GWTOMD_CMD_READ_UPLOAD_SENSOR:{ + if(SGCP.LoginOk == true) + { + if(WORK_MODE == 0) + SGCP.GWStatus = GW_STATUS_READ_SENSOR; + else if(WORK_MODE == 1) + { + if(PayLoadLen == 4) + { + App.Para.Layout.TimeStamp = LPay->TimeStamp; + + int8_t TimeDiff;//时间差 + int RTCTimes = TimeTs(); + TimeDiff = App.Para.Layout.TimeStamp - RTCTimes; + if(TimeDiff > 1 || TimeDiff < -1) + { + TimeSync(App.Para.Layout.TimeStamp); //向通讯单元RTC时间寄存器写入时间网关下发的时间 + } + SGCP.UploadOk = true; + SGCP.NextGWStatus = GW_STATUS_IDLE; + } + else if(PayLoadLen == 10) + { + App.Para.Layout.CollectTime = LPay->CollectTime/30; + App.Para.Layout.ReportInterval = LPay->ReportInterval * 2; + App.Para.Layout.ERInterval = LPay->ERInterval * 2; + App.Para.Layout.ERTime = LPay->ERTime * 2; + App.Para.Layout.TimeStamp = LPay->TimeStamp; + + DBG_LOG("The parameters have been updated. CI:%ds, RI:%dmin, EI:%dmin, ET:%dmin\r\n", + LPay->CollectTime, + LPay->ReportInterval, + LPay->ERInterval, + LPay->ERTime); + + int8_t TimeDiff;//时间差 + int RTCTimes = TimeTs(); + TimeDiff = App.Para.Layout.TimeStamp - RTCTimes; + if(TimeDiff > 1 || TimeDiff < -1) + { + TimeSync(App.Para.Layout.TimeStamp); //向通讯单元RTC时间寄存器写入时间网关下发的时间 + } + SGCP.UploadOk = true; + SGCP.NextGWStatus = GW_STATUS_UPLOAD_SENSOR; + } + } + } + break;} + + case GWTOMD_CMD_SET_COL_TIME:{ + if(SGCP.LoginOk == true) + { + uint16_t temp; + temp = PayLoad[0]; + temp |= (PayLoad[1] << 8); + if(temp < 1 || temp > 7200) + { + DBG_LOG("CollectInterval Err\r\n"); + if(SGCP.GWStatus == GW_STATUS_WAIT_UPLOAD) + { + SGCP.UploadOk = true; + SGCP.NextGWStatus = GW_STATUS_IDLE; + } + return; + } + else + { + if(SGCP.GWStatus == GW_STATUS_WAIT_UPLOAD) + { + SGCP.UploadOk = true; + SGCP.NextGWStatus = GW_STATUS_SET_COL_TIME; + } + else + { + SGCP.GWStatus = GW_STATUS_SET_COL_TIME; + } + App.Para.Layout.CollectTime = temp; + SAVE_APP_PARA((uint32_t *)&App.Para); + } + } + break;} + + case GWTOMD_CMD_SYNC_TIME:{ + if(SGCP.LoginOk == true) + { + uint32_t temp; + temp = PayLoad[0]; + temp |= (PayLoad[1] << 8); + temp |= (PayLoad[2] << 16); + temp |= (PayLoad[3] << 24); + if(temp < 1701173083 || temp > 4102372799) + { + DBG_LOG("TimeStamp Err\r\n"); + if(SGCP.GWStatus == GW_STATUS_WAIT_UPLOAD) + { + SGCP.UploadOk = true; + SGCP.NextGWStatus = GW_STATUS_IDLE; + } + return; + } + else + { + if(SGCP.GWStatus == GW_STATUS_WAIT_UPLOAD) + { + SGCP.UploadOk = true; + SGCP.NextGWStatus = GW_STATUS_SYNC_TIME; + } + else + { + SGCP.GWStatus = GW_STATUS_SYNC_TIME; + } + App.Para.Layout.TimeStamp = temp; + SAVE_APP_PARA((uint32_t *)&App.Para); + TimeSync(App.Para.Layout.TimeStamp); //设置时间 + } + } + break;} + + case GWTOMD_CMD_SET_LASER:{ + if(SGCP.LoginOk == true) + { + int8_t temp = PayLoad[0]; + if(temp == 1) + { + LASER1_ON(); + SGCP.LaserOnOff = true; + if(SGCP.GWStatus == GW_STATUS_WAIT_UPLOAD) + { + SGCP.UploadOk = true; + SGCP.NextGWStatus = GW_STATUS_LASER_STARES; + } + else + SGCP.GWStatus = GW_STATUS_LASER_STARES; + } + else if(temp == 0) + { + LASER1_OFF(); + SGCP.LaserOnOff = false; + if(SGCP.GWStatus == GW_STATUS_WAIT_UPLOAD) + { + SGCP.UploadOk = true; + SGCP.NextGWStatus = GW_STATUS_LASER_STARES; + } + else + SGCP.GWStatus = GW_STATUS_LASER_STARES; + } + } + break;} + } + SGCP.Gateway_IRQ_Status = true; +} +/** + ******************************************************************************* + ** \brief 内部指令指令数据接收处理 + ** + ** \param 无 + ** + ** \retval 无 + ******************************************************************************/ +static void InRevHandler(void) +{ + uint16_t crc16,Check; + uint8_t *PayLoad; + + InsideFrameHeader IFHeader = (InsideFrameHeader)SGCP.InsideBuff; + + crc16 = (SGCP.InsideBuff[SGCP.InsideBuffLen - 1] << 8) | SGCP.InsideBuff[SGCP.InsideBuffLen - 2]; + Check = CRC_Modbus(CRC16_BASE, SGCP.InsideBuff, SGCP.InsideBuffLen - 2); + + if(crc16 != Check) + { + DBG_LOG("Inside CRC Err...\r\n"); + return; + } + + if(memcmp(IFHeader->MAC, LocalMAC, sizeof(IFHeader->MAC)) != false) + { + DBG_LOG("Inside MAC Err...\r\n"); + return; + } + + PayLoad = &SGCP.InsideBuff[sizeof(InsideFrameHeader_t)]; + + switch((INSIDE_CMD_M)IFHeader->Cmd) { + case INSIDE_CMD_UPDATE:{ + memcpy(SGCP.InsidePay, PayLoad, SGCP.InsidePayLen); + SGCP.InStatus = IN_STATUS_UPDATE; + break;} + + case INSIDE_CMD_ALTER_485ADDR:{ + uint8_t temp; + temp = PayLoad[0]; + if(temp > 16 || temp < 1) + { + DBG_LOG("RS485Addr Err\r\n"); + return; + } + else + { + App.Para.RS485Addr = temp; + SAVE_APP_PARA((uint32_t *)&App.Para); + if(SGCP.InStatus == IN_STATUS_IDLE) + { + SGCP.InStatus = IN_STATUS_ALTER_485ADDR; + } + } + break;} + } +} +#if (SGCP_SELECT == 0)//本机为单个主设备接多个子设备 +/** + ******************************************************************************* + ** \brief 接收子设备数据状态机 + ** + ** \param 无 + ** + ** \retval 无 + ******************************************************************************/ +void SubRevLoopHandler(void) +{ + switch(SGCP.SubStatus) + { + case SUB_STATUS_IDLE:{ + break;} + + case SUB_STATUS_BROADCAST_CALI:{ + ToSDCali(0x00); + SGCP.SubStatus = SUB_STATUS_IDLE; + break;} + + case SUB_STATUS_READMASTER_DATA:{ + DBG_LOG("<----------- Cache Updating ----------->\r\n"); + memset(SGCP.DeviceDataBuff, NULL, sizeof(SGCP.DeviceDataBuff)); + SGCP.DeviceReadDataOk = false; + SGCP.DeviceDataLen = 0; + SGCP.ReadDataAdd = 0; + #if (USE_VBAT_AD == 1) + SGCP.DevData.MasterDev.BatLevel = VBAT_Percentage; + #else + SGCP.DevData.MasterDev.BatLevel = 0x00; + #endif + #if (SGCP_SELECT == 1 || SGCP_SELECT == 2) + SX1276LoCalcRssiSnr(&SGCP.DevData.MasterDev.RSSI, &SGCP.DevData.MasterDev.Nsr); + #else + SGCP.DevData.MasterDev.RSSI = 0x00; + SGCP.DevData.MasterDev.Nsr = 0x00; + #endif + memcpy(&SGCP.DeviceDataBuff[0], &SGCP.DevData.MasterDev, sizeof(SGCP.DevData.MasterDev)); + + DBG_LOG("Master Device MAC:%02X %02X %02X %02X %02X %02X\r\n", + SGCP.DeviceMAC[SGCP.ReadDataAdd][0],SGCP.DeviceMAC[SGCP.ReadDataAdd][1],SGCP.DeviceMAC[SGCP.ReadDataAdd][2], + SGCP.DeviceMAC[SGCP.ReadDataAdd][3],SGCP.DeviceMAC[SGCP.ReadDataAdd][4],SGCP.DeviceMAC[SGCP.ReadDataAdd][5]); + DBG_LOG("\tBatLevel:%03d, RSSI:%05.2f, Nsr:%05.2f\r\n",SGCP.DevData.MasterDev.BatLevel, SGCP.DevData.MasterDev.RSSI,SGCP.DevData.MasterDev.Nsr); + SGCP.DeviceDataLen = SGCP.DeviceDataLen + sizeof(SGCP.DevData.MasterDev); + if(sizeof(LocalDataPack) != 0x00) + { + memcpy(&SGCP.DeviceDataBuff[SGCP.DeviceDataLen], LocalDataPack, sizeof(LocalDataPack)); + SGCP.DeviceDataLen = SGCP.DeviceDataLen + DevGetDataMess(LocalType, LocalDataPack);; + } + + SGCP.ReadDataAdd++; + SGCP.SubStatus = SUB_STATUS_READSUBSET_DATA; + break;} + + case SUB_STATUS_READSUBSET_DATA:{ + SGCP.SubsetReadDataOk = false; + SGCP.Subset_IRQ_Status = false; + ToSDReadData(SGCP.Dev485Addrs[SGCP.ReadDataAdd]); + SGCP.SD1mSDelayCnt = 100; + SGCP.SubStatus = SUB_STATUS_WAIT_READSUBSET; + break;} + + case SUB_STATUS_WAIT_READSUBSET:{ + if(SGCP.SD1mSDelayCnt <= 0) + { + DBG_LOG("\r\nSub485Addrs:%02X\r\n",SGCP.Dev485Addrs[SGCP.ReadDataAdd]); + DBG_LOG("Subset Device MAC:%02X %02X %02X %02X %02X %02X\r\n", + SGCP.DeviceMAC[SGCP.ReadDataAdd][0],SGCP.DeviceMAC[SGCP.ReadDataAdd][1],SGCP.DeviceMAC[SGCP.ReadDataAdd][2], + SGCP.DeviceMAC[SGCP.ReadDataAdd][3],SGCP.DeviceMAC[SGCP.ReadDataAdd][4],SGCP.DeviceMAC[SGCP.ReadDataAdd][5]); + DBG_LOG("\tDevice Read Data TimeOut!"); + + uint16_t Devtype; + Devtype = (SGCP.DeviceMAC[SGCP.ReadDataAdd][1] << 8) + SGCP.DeviceMAC[SGCP.ReadDataAdd][0]; + SGCP.DeviceDataLen += DevGetDataMess((DEVICE_TYPE_M)Devtype, NULL); + SGCP.ReadDataAdd++; + SGCP.SubStatus = SUB_STATUS_READSUBSET_DATA; + } + if(SGCP.Subset_IRQ_Status == true) + { + SGCP.Subset_IRQ_Status = false; + DBG_LOG("\r\nSub485Addrs:%02X\r\n",SGCP.Dev485Addrs[SGCP.ReadDataAdd]); + DBG_LOG("Subset Device MAC:%02X %02X %02X %02X %02X %02X\r\n", + SGCP.DeviceMAC[SGCP.ReadDataAdd][0],SGCP.DeviceMAC[SGCP.ReadDataAdd][1],SGCP.DeviceMAC[SGCP.ReadDataAdd][2], + SGCP.DeviceMAC[SGCP.ReadDataAdd][3],SGCP.DeviceMAC[SGCP.ReadDataAdd][4],SGCP.DeviceMAC[SGCP.ReadDataAdd][5]); + SubsetRevHandler(); + + uint16_t Devtype; + Devtype = (SGCP.DeviceMAC[SGCP.ReadDataAdd][1] << 8) + SGCP.DeviceMAC[SGCP.ReadDataAdd][0]; + + if(SGCP.SubsetReadDataOk == false) + { + SGCP.DeviceDataLen += DevGetDataMess((DEVICE_TYPE_M)Devtype, NULL); + DBG_LOG("\tDevice Read Data Err!\r\n"); + } + if(SGCP.SubsetReadDataOk == true) + { + SGCP.SubsetReadDataOk = false; + SGCP.DeviceDataLen += DevGetDataMess((DEVICE_TYPE_M)Devtype, &SGCP.DeviceDataBuff[SGCP.DeviceDataLen]); + DBG_LOG("\tDevice Read Data Ok!\r\n"); + } + SGCP.ReadDataAdd++; + SGCP.SubStatus = SUB_STATUS_READSUBSET_DATA; + } + if(SGCP.ReadDataAdd >= SGCP.DeviceN) + { + SGCP.DeviceReadDataOk = true; + memcpy(SGCP.DeviceData, SGCP.DeviceDataBuff, sizeof(SGCP.DeviceData)); + SGCP.SubStatus = SUB_STATUS_IDLE; + DBG_LOG("<----------- Cache Updat End ----------->\r\n"); + } + break;} + + case SUB_STATUS_MASTER_QUERY:{ + DBG_LOG("<----------- Device Scaning ----------->\r\n"); + SGCP.DeviceN = 0; + SGCP.Dev485Addr = 0; + SGCP.DeviceMACOk = false; + SGCP.Subset_IRQ_Status = false; + memset(&SGCP.Dev485Addrs, NULL, sizeof(SGCP.Dev485Addrs)); + memset(&SGCP.DeviceMAC, NULL, sizeof(SGCP.DeviceMAC)); + SGCP.Dev485Addrs[SGCP.DeviceN] = SGCP.Dev485Addr;//主设备485 + memcpy(SGCP.DeviceMAC[SGCP.DeviceN], LocalMAC, sizeof(LocalMAC));//主设备MAC + DBG_LOG("Master Device MAC:%02X %02X %02X %02X %02X %02X\r\n", + SGCP.DeviceMAC[SGCP.DeviceN][0],SGCP.DeviceMAC[SGCP.DeviceN][1],SGCP.DeviceMAC[SGCP.DeviceN][2], + SGCP.DeviceMAC[SGCP.DeviceN][3],SGCP.DeviceMAC[SGCP.DeviceN][4],SGCP.DeviceMAC[SGCP.DeviceN][5]); + SGCP.DeviceN++; + SGCP.Dev485Addr++; + SGCP.SubStatus = SUB_STATUS_SUBSET_QUERY; + break;} + + case SUB_STATUS_SUBSET_QUERY:{ + SGCP.Subset_IRQ_Status = false; + SGCP.SubsetMACOk = false; + ToSDInquire(SGCP.Dev485Addr); + SGCP.SD1mSDelayCnt = 100; + SGCP.SubStatus = SUB_STATUS_WAIT_SUBSET_QUERY; + break;} + + case SUB_STATUS_WAIT_SUBSET_QUERY:{ + if(SGCP.SD1mSDelayCnt <= 0) + { + DBG_LOG("Sub485Addrs:%02X No Device!\r\n",SGCP.Dev485Addr); + SGCP.Dev485Addr++; + SGCP.SubStatus = SUB_STATUS_SUBSET_QUERY; + } + if(SGCP.Subset_IRQ_Status == true) + { + SGCP.Subset_IRQ_Status = false; + SubsetRevHandler(); + + if(SGCP.SubsetMACOk == false) + { + DBG_LOG("Sub485Addrs:%02X Error In Data!",SGCP.Dev485Addr); + } + if(SGCP.SubsetMACOk == true) + { + SGCP.SubsetMACOk = false; + SGCP.Dev485Addrs[SGCP.DeviceN] = SGCP.Dev485Addr; + DBG_LOG("Sub485Addrs:%02X\r\n",SGCP.Dev485Addrs[SGCP.DeviceN]); + DBG_LOG("Subset MAC:%02X %02X %02X %02X %02X %02X\r\n", + SGCP.DeviceMAC[SGCP.DeviceN][0],SGCP.DeviceMAC[SGCP.DeviceN][1],SGCP.DeviceMAC[SGCP.DeviceN][2], + SGCP.DeviceMAC[SGCP.DeviceN][3],SGCP.DeviceMAC[SGCP.DeviceN][4],SGCP.DeviceMAC[SGCP.DeviceN][5]); + SGCP.DeviceN++; + } + SGCP.Dev485Addr++; + SGCP.SubStatus = SUB_STATUS_SUBSET_QUERY; + } + if(SGCP.Dev485Addr >= 16) + { + SGCP.SubStatus = SUB_STATUS_IDLE; + SGCP.DeviceMACOk = true; + DBG_LOG("Device Number:%02d\r\n",SGCP.DeviceN); + DBG_LOG("<----------- Device Scan End ----------->\r\n"); + } + break;} + + case SUB_STATUS_BROADCAST_SET_COLTIME:{ + ToSDSetColTime(0x00, App.Para.Layout.CollectTime); + SGCP.SubStatus = SUB_STATUS_IDLE; + break;} + + case SUB_STATUS_BROADCAST_SYNC_TIME:{ + ToSDSetColTime(0x00, App.Para.Layout.TimeStamp); + SGCP.SubStatus = SUB_STATUS_IDLE; + break;} + } +} + +/** + ******************************************************************************* + ** \brief 接收网关数据状态机 + ** + ** \param 无 + ** + ** \retval 无 + ******************************************************************************/ +void GwRevLoopHandler(void) +{ + switch(SGCP.GWStatus) + { + case GW_STATUS_IDLE:{ + break;} + + case GW_STATUS_WAIT_SUBIDLE:{ + if(SGCP.GW1mSDelayCnt <= 0) + { + DBG_LOG("Subset Be busy!\r\n"); + SGCP.NextSubStatus = SUB_STATUS_IDLE; + SGCP.GWStatus = GW_STATUS_IDLE; + } + if(SGCP.SubStatus == SUB_STATUS_IDLE) + { + SGCP.GW1mSDelayCnt = 0; + SGCP.SubStatus = SGCP.NextSubStatus; + SGCP.NextSubStatus = SUB_STATUS_IDLE; + SGCP.GWStatus = GW_STATUS_IDLE; + } + break;} + + case GW_STATUS_LOGIN:{ + SGCP.LoginOk = false; + SGCP.LoginMess = false; + SGCP.Gateway_IRQ_Status = false; + ToGWDevLogin(); + SGCP.GW1mSDelayCnt = 2000; + SGCP.GWStatus = GW_STATUS_WAIT_LOGIN; + break;} + + case GW_STATUS_WAIT_LOGIN:{ + if(SGCP.GW1mSDelayCnt <= 0) + { + SGCP.LoginMess = true; + DBG_LOG("Login Timeout!\r\n"); + SGCP.GWStatus = GW_STATUS_IDLE; + } + if(SGCP.Gateway_IRQ_Status == true) + { + SGCP.Gateway_IRQ_Status = false; + + if(SGCP.LoginOk == true) + { + DBG_LOG("Login Ok!\r\n"); + } + else if(SGCP.LoginOk == false) + { + DBG_LOG("Login Err!\r\n"); + } + SGCP.LoginMess = true; + SGCP.GWStatus = GW_STATUS_IDLE; + } + break;} + + case GW_STATUS_CALI:{ + PrintfMess(); + if(SGCP.BroadCmd == true) + { + SGCP.GWStatus = GW_STATUS_WAIT_SUBIDLE; + SGCP.NextSubStatus = SUB_STATUS_BROADCAST_CALI; + SGCP.GW1mSDelayCnt = 5000; + SGCP.BroadCmd = false; + DBG_LOG("Broad Cali Ok!\r\n"); + } + else + { + SGCP.GWStatus = GW_STATUS_IDLE; + ToGWCaliRes(SGCP.MasterCaliOk); + DBG_LOG("Alone Cali Ok!\r\n"); + } + SGCP.TimingAcquisition = true;//采集新的传感器数据 + break;} + + case GW_STATUS_READ_SENSOR:{ + PrintfMess(); + ToGWReadDataRes(SGCP.DeviceData); + DBG_LOG("Upload data Ok!\r\n"); + SGCP.TimingAcquisition = true;//采集新的传感器数据 + SGCP.GWStatus = GW_STATUS_WAIT_SUBIDLE; + SGCP.NextSubStatus = SUB_STATUS_READMASTER_DATA; + SGCP.GW1mSDelayCnt = 5000; + break;} + + case GW_STATUS_SET_COL_TIME:{ + PrintfMess(); + if(SGCP.BroadCmd == true) + { + SGCP.BroadCmd = false; + DBG_LOG("Broad CollectInterval Set as %04d\r\n",0x00, App.Para.Layout.CollectTime); + } + else + { + ToGWSetColTimeRes(NULL); + DBG_LOG("Alone CollectInterval Set as %04d\r\n",0x00, App.Para.Layout.CollectTime); + } + SGCP.GWStatus = GW_STATUS_WAIT_SUBIDLE; + SGCP.NextSubStatus = SUB_STATUS_BROADCAST_SET_COLTIME; + SGCP.GW1mSDelayCnt = 5000; + break;} + + case GW_STATUS_SYNC_TIME:{ + PrintfMess(); + if(SGCP.BroadCmd == true) + { + SGCP.BroadCmd = false; + DBG_LOG("Broad CollectInterval Set as %08d\r\n",App.Para.Layout.TimeStamp); + } + + else + { + ToGWSyncTimeRes(true); + DBG_LOG("Alone CollectInterval Set as %08d\r\n",App.Para.Layout.TimeStamp); + } + SGCP.GWStatus = GW_STATUS_WAIT_SUBIDLE; + SGCP.NextSubStatus = SUB_STATUS_BROADCAST_SYNC_TIME; + SGCP.GW1mSDelayCnt = 5000; + break;} + } +} + + + +/* 中断回调函数 */ +/***************************************************************************************** +* 函数名称: LORA_RxCallBack +* 功能描述: Lora数据接收函数 +* 参 数: *rBuff,接收到的字符串 + rlen,接收到的字符串长度 +* 返 回 值: 无 +*****************************************************************************************/ +void LORA_RxCallBack(uint8_t *rBuff, uint8_t rlen) +{ +// if (rlen > 0 && rBuff[0] == 0x7C && memcmp(&rBuff[7],&Comm_DevAddr[0],6) == 0) // 如果接收到了数据,并且设备地址相同则处理接收到的数据 +// { +// //< 处理接收到的数据 +// memcpy(App.UpperBuff, rBuff, rlen); +// App.UpperBuffLen = rlen; +// App.Upper_IRQ_Status = true;//上位机串口中断 +// } +} + +/***************************************************************************************** +* 函数名称: LPUartRx_CallBack +* 功能描述: 低功耗串口数据接收函数 +* 参 数: rData,接收到的字节 +* 返 回 值: 无 +*****************************************************************************************/ +void LPUartRx_CallBack(uint8_t rData) +{ + if(SGCP.LpUart0Delay1mSCnt == 0) { + SGCP.GWRS485Rx.HeaderFrame = false; + } + SGCP.LpUart0Delay1mSCnt = 5; + if(SGCP.GWRS485Rx.HeaderFrame == false) { + if(rData == 0x7B || rData == 0x7D) { + SGCP.GWRS485Rx.HeaderFrame = true; + SGCP.GWRS485Rx.RxLen = 0; + SGCP.GWRS485Rx.rPayLen = 0; + SGCP.InsideBuffLen = 0; + SGCP.InsidePayLen = 0; + SGCP.GWRS485Rx.RxBuff[SGCP.GWRS485Rx.RxLen++] = rData; + } + } + else { + if(SGCP.GWRS485Rx.RxBuff[0] == 0x7B) + { + if(SGCP.GWRS485Rx.RxLen == 14) { + SGCP.GWRS485Rx.rPayLen = rData; + } + if(SGCP.GWRS485Rx.RxLen == 15) { + SGCP.GWRS485Rx.rPayLen |= (rData << 8); + } + if(SGCP.GWRS485Rx.rPayLen > 10) { //大于最大负载长度,认为错误 + SGCP.GWRS485Rx.HeaderFrame = false; + return; + } + + SGCP.GWRS485Rx.RxBuff[SGCP.GWRS485Rx.RxLen++] = rData; + if(SGCP.GWRS485Rx.RxLen >= SGCP.GWRS485Rx.rPayLen + 18) { + SGCP.GWRS485Rx.HeaderFrame = false; + if(SGCP.GWRS485Rx.RxLen > 100) + return; + + memcpy(SGCP.GatewayBuff, SGCP.GWRS485Rx.RxBuff, SGCP.GWRS485Rx.RxLen); + SGCP.GatewayBuffLen = SGCP.GWRS485Rx.RxLen; + if(SGCP.GWRS485Rx.RxBuff[0] == 0x7B) GWRevHandler();//网关数据接收处理 + } + } + if(SGCP.GWRS485Rx.RxBuff[0] == 0x7D) + { + if(SGCP.GWRS485Rx.RxLen == 8) + { + SGCP.InsidePayLen = rData; + } + SGCP.GWRS485Rx.RxBuff[SGCP.GWRS485Rx.RxLen++] = rData; + if(SGCP.GWRS485Rx.RxLen >= SGCP.InsidePayLen + 11) + { + SGCP.GWRS485Rx.HeaderFrame = false; + + memcpy(SGCP.InsideBuff, SGCP.GWRS485Rx.RxBuff, SGCP.GWRS485Rx.RxLen); + SGCP.InsideBuffLen = SGCP.GWRS485Rx.RxLen; + if(SGCP.InsideBuff[0] == 0x7D) InRevHandler();//内部指令 + } + } + } +} + +/***************************************************************************************** +* 函数名称: Uart1Rx_CallBack +* 功能描述: 串口1数据接收函数 +* 参 数: rData,接收到的字节 +* 返 回 值: 无 +*****************************************************************************************/ +void Uart1Rx_CallBack(uint8_t rData) +{ + if(SGCP.Uart1Delay1mSCnt == 0) { + SGCP.SDRS485Rx.HeaderFrame = false; + } + SGCP.Uart1Delay1mSCnt = 5; + if(SGCP.SDRS485Rx.HeaderFrame == false) { + if(rData == 0x7C) { + SGCP.SDRS485Rx.HeaderFrame = true; + SGCP.SDRS485Rx.RxLen = 0; + SGCP.SDRS485Rx.rPayLen = 0; + SGCP.SDRS485Rx.RxBuff[SGCP.SDRS485Rx.RxLen++] = rData; + } + } + else { + if(SGCP.SDRS485Rx.RxLen == 3) { + if(rData > 36) { //大于最大负载长度,认为错误 + SGCP.SDRS485Rx.HeaderFrame = false; + return; + } + SGCP.SDRS485Rx.rPayLen = rData; + } + + SGCP.SDRS485Rx.RxBuff[SGCP.SDRS485Rx.RxLen++] = rData; + if(SGCP.SDRS485Rx.RxLen >= SGCP.SDRS485Rx.rPayLen + 6) { + SGCP.SDRS485Rx.HeaderFrame = false; + if(SGCP.SDRS485Rx.RxLen > 100) + return; + + memcpy(SGCP.SubsetBuff, SGCP.SDRS485Rx.RxBuff, SGCP.SDRS485Rx.RxLen); + SGCP.SubsetBuffLen = SGCP.SDRS485Rx.RxLen; + if(SGCP.SDRS485Rx.RxBuff[0] == 0x7C) SGCP.Subset_IRQ_Status = true;//子设备串口中断 + } + } +} +#endif + +#if (SGCP_SELECT == 1)//本机为单个主设备 +#if (LocalType == LASER_TRACING) +/** + ******************************************************************************* + ** \brief 网关激光状态回应 + ** + ** \param Ok_Err 成功失败标志位 + ** + ** \retval 无 + ******************************************************************************/ +static void ToGWLaserRes(bool Ok_Err) +{ + uint8_t Pack[256]; + uint16_t Crc16; + uint8_t Len; + + GatewayFrameHeader GFHeader = (GatewayFrameHeader)Pack; + + GFHeader->Header = 0x7B; + memcpy(&GFHeader->GWAddr[0], &GatewayMAC[0], sizeof(GFHeader->GWAddr)); + memcpy(&GFHeader->MDAddr[0], &LocalMAC[0], sizeof(GFHeader->MDAddr)); + GFHeader->Cmd = GWTOMD_CMD_SET_LASER; + GFHeader->PayloadLen = sizeof(Ok_Err); + + Len = sizeof(GatewayFrameHeader_t); + + Pack[Len++] = Ok_Err; + + Crc16 = CRC_Modbus(CRC16_BASE, Pack, Len); + Pack[Len++] = Crc16 & 0x00ff; + Pack[Len++] = (Crc16 >> 8) & 0x00ff; + +SGCP.GWRS485Rx.sCmdMDToGW = (GWTOMD_CMD_M)GFHeader->Cmd; +#if(SGCP_SELECT == 1 || SGCP_SELECT == 2) + Sx1276LoRaSendBuffer(Pack, Len); +#endif +#if(SGCP_SELECT == 3) + LPUart0SendArray(Pack, Len); +#endif +} +#endif +/** + ******************************************************************************* + ** \brief 接收网关数据状态机 + ** + ** \param 无 + ** + ** \retval 无 + ******************************************************************************/ +void GwRevLoopHandler(void) +{ + switch(SGCP.GWStatus) + { + case GW_STATUS_IDLE:{ + break;} + + case GW_STATUS_WAIT_SUBIDLE:{ + SGCP.GWStatus = GW_STATUS_IDLE; + break;} + + case GW_STATUS_LOGIN:{ + SGCP.DeviceN = 0; + SGCP.Dev485Addr = 0; + memset(&SGCP.Dev485Addrs, NULL, sizeof(SGCP.Dev485Addrs)); + memset(&SGCP.DeviceMAC, NULL, sizeof(SGCP.DeviceMAC)); + SGCP.Dev485Addrs[SGCP.DeviceN] = SGCP.Dev485Addr;//主设备485 + memcpy(SGCP.DeviceMAC[SGCP.DeviceN], LocalMAC, sizeof(LocalMAC));//主设备MAC + DBG_LOG("Master Device MAC:%02X %02X %02X %02X %02X %02X\r\n", + SGCP.DeviceMAC[SGCP.DeviceN][0],SGCP.DeviceMAC[SGCP.DeviceN][1],SGCP.DeviceMAC[SGCP.DeviceN][2], + SGCP.DeviceMAC[SGCP.DeviceN][3],SGCP.DeviceMAC[SGCP.DeviceN][4],SGCP.DeviceMAC[SGCP.DeviceN][5]); + SGCP.DeviceN++; + SGCP.LoginOk = false; + SGCP.LoginMess = false; + SGCP.Gateway_IRQ_Status = false; + ToGWDevLogin(); + SGCP.GW1mSDelayCnt = 2000; + SGCP.GWStatus = GW_STATUS_WAIT_LOGIN; + break;} + + case GW_STATUS_WAIT_LOGIN:{ + if(SGCP.GW1mSDelayCnt <= 0) + { + SGCP.LoginMess = true; + DBG_LOG("Login Timeout!\r\n"); + SGCP.GWStatus = GW_STATUS_IDLE; + break; + } + if(SGCP.Gateway_IRQ_Status == true) + { + SGCP.Gateway_IRQ_Status = false; + if(SGCP.LoginOk == true) + { + DBG_LOG("Login Ok!\r\n"); + /*注册后传感器需立即更新数据*/ + SGCP.TimingAcquisition = true;//采集新的传感器数据 + } + if(SGCP.LoginOk == false) + { + DBG_LOG("Login Err!\r\n"); + } + SGCP.LoginMess = true; + SGCP.GWStatus = GW_STATUS_IDLE; + } + break;} + + case GW_STATUS_CALI:{ + PrintfMess(); + if(SGCP.BroadCmd == true) + { + SGCP.BroadCmd = false; + DBG_LOG("Broad Cali Ok!\r\n"); + } + else + { + ToGWCaliRes(SGCP.MasterCaliOk); + DBG_LOG("Alone Cali Ok!\r\n"); + } + SGCP.TimingAcquisition = true;//采集新的传感器数据 + SGCP.GWStatus = GW_STATUS_IDLE; + break;} + + case GW_STATUS_READ_SENSOR:{ + PrintfMess(); + + SGCP.DeviceDataLen = 0; + memset(SGCP.DeviceData, NULL, sizeof(SGCP.DeviceData)); + #if (USE_VBAT_AD == 1) + SGCP.DevData.LaserTracing.MasterDev.BatLevel = VBAT_Percentage; + #else + SGCP.DevData.LaserTracing.MasterDev.BatLevel = 0x00; + #endif + #if (SGCP_SELECT == 1 || SGCP_SELECT == 2) + SX1276LoCalcRssiSnr(&SGCP.DevData.LaserTracing.MasterDev.RSSI, &SGCP.DevData.LaserTracing.MasterDev.Nsr);//获取信号强度 + #else + SGCP.DevData.LaserTracing.MasterDev.RSSI = 0x00; + SGCP.DevData.LaserTracing.MasterDev.Nsr = 0x00; + #endif + memcpy(&SGCP.DeviceData[0], &SGCP.DevData.LaserTracing.MasterDev, sizeof(SGCP.DevData.LaserTracing.MasterDev)); + + DBG_LOG("Master Device MAC:%02X %02X %02X %02X %02X %02X\r\n", + SGCP.DeviceMAC[SGCP.ReadDataAdd][0],SGCP.DeviceMAC[SGCP.ReadDataAdd][1],SGCP.DeviceMAC[SGCP.ReadDataAdd][2], + SGCP.DeviceMAC[SGCP.ReadDataAdd][3],SGCP.DeviceMAC[SGCP.ReadDataAdd][4],SGCP.DeviceMAC[SGCP.ReadDataAdd][5]); + DBG_LOG("\tBatLevel:%03d, RSSI:%05.2f, Nsr:%05.2f\r\n",SGCP.DevData.LaserTracing.MasterDev.BatLevel, SGCP.DevData.LaserTracing.MasterDev.RSSI,SGCP.DevData.LaserTracing.MasterDev.Nsr); + memcpy(&SGCP.DeviceData[SGCP.DeviceDataLen], &SGCP.DevData.LaserTracing.MasterDev, sizeof(SGCP.DevData.LaserTracing.MasterDev)); + SGCP.DeviceDataLen += sizeof(SGCP.DevData.LaserTracing.MasterDev); + + if(isAllZero(LocalDataPack, LocalDataLen) == false) + { + memcpy(&SGCP.DeviceData[SGCP.DeviceDataLen], LocalDataPack, sizeof(LocalDataPack)); + SGCP.DeviceDataLen = SGCP.DeviceDataLen + DevGetDataMess(LocalType, LocalDataPack);; + } + ToGWReadDataRes(SGCP.DeviceData); + DBG_LOG("Upload data Ok!\r\n"); + /*上传完数据后传感器需立即更新数据*/ + SGCP.TimingAcquisition = true;//采集新的传感器数据 + SGCP.GWStatus = GW_STATUS_IDLE; + break;} + + case GW_STATUS_SET_COL_TIME:{ + PrintfMess(); + if(SGCP.BroadCmd == true) + { + SGCP.BroadCmd = false; + DBG_LOG("Broad CollectInterval Set as %04d\r\n",0x00, App.Para.Layout.CollectTime); + } + else + { + ToGWSetColTimeRes(true); + DBG_LOG("Alone CollectInterval Set as %04d\r\n",0x00, App.Para.Layout.CollectTime); + } + /*GWRevHandler函数中已经缓存了接收到的采集时间间隔*/ + SGCP.GWStatus = GW_STATUS_IDLE; + break;} + + case GW_STATUS_SYNC_TIME:{ + PrintfMess(); + if(SGCP.BroadCmd == true) + { + SGCP.BroadCmd = false; + DBG_LOG("Broad time synchronization %08d\r\n",App.Para.Layout.TimeStamp); + } + else + { + ToGWSyncTimeRes(true); + DBG_LOG("Alone time synchronization %08d\r\n",App.Para.Layout.TimeStamp); + } + /*GWRevHandler函数中已经同步了接收到的时间戳*/ + SGCP.GWStatus = GW_STATUS_IDLE; + break;} + + case GW_STATUS_UPLOAD_SENSOR:{ + DBG_LOG("Uploading data...\r\n"); + SGCP.DeviceDataLen = 0; + memset(SGCP.DeviceData, NULL, sizeof(SGCP.DeviceData)); + + DBG_LOG("Master Device MAC:%02X %02X %02X %02X %02X %02X\r\n", + SGCP.DeviceMAC[SGCP.ReadDataAdd][0],SGCP.DeviceMAC[SGCP.ReadDataAdd][1],SGCP.DeviceMAC[SGCP.ReadDataAdd][2], + SGCP.DeviceMAC[SGCP.ReadDataAdd][3],SGCP.DeviceMAC[SGCP.ReadDataAdd][4],SGCP.DeviceMAC[SGCP.ReadDataAdd][5]); + + if(isAllZero(LocalDataPack, LocalDataLen) == false) + { + memcpy(&SGCP.DeviceData[SGCP.DeviceDataLen], LocalDataPack, sizeof(LocalDataPack)); + SGCP.DeviceDataLen = DevGetDataMess(LocalType, LocalDataPack); + } + SGCP.UploadOk = false; + SGCP.UploadMess = false; + SGCP.Gateway_IRQ_Status = false; + ToGWReadDataRes(SGCP.DeviceData); + SGCP.GW1mSDelayCnt = 2000; + SGCP.GWStatus = GW_STATUS_WAIT_UPLOAD; + break;} + + case GW_STATUS_WAIT_UPLOAD:{ + if(SGCP.GW1mSDelayCnt <= 0) + { + SGCP.UploadMess = true; + DBG_LOG("\r\nUpload timeout!\r\n"); + SGCP.GWStatus = SGCP.NextGWStatus; + break; + } + if(SGCP.Gateway_IRQ_Status == true) + { + SGCP.Gateway_IRQ_Status = false; + if(SGCP.UploadOk == true) + { + DBG_LOG("\r\nUpload data ok!\r\n"); + /*上传完数据后传感器需立即更新数据*/ + SGCP.TimingAcquisition = true;//采集新的传感器数据 + } + else if(SGCP.UploadOk == false) + { + DBG_LOG("\r\nUpload data err!\r\n"); + } + SGCP.UploadMess = true; + SGCP.GWStatus = SGCP.NextGWStatus; + } + break;} + + case GW_STATUS_LASER_STARES:{ + PrintfMess(); + if(SGCP.LaserOnOff == true) + { + ToGWLaserRes(SGCP.LaserOnOff); + DBG_LOG("The laser has been activated!\r\n"); + } + else if(SGCP.LaserOnOff == false) + { + ToGWLaserRes(SGCP.LaserOnOff); + DBG_LOG("The laser has been turned off!\r\n"); + } + SGCP.GWStatus = GW_STATUS_IDLE; + break;} + } +} + +/* 中断回调函数 */ +/***************************************************************************************** +* 函数名称: LORA_RxCallBack +* 功能描述: Lora数据接收函数 +* 参 数: *rBuff,接收到的字符串 + rlen,接收到的字符串长度 +* 返 回 值: 无 +*****************************************************************************************/ +void LORA_RxCallBack(uint8_t *rBuff, uint8_t rlen) +{ + if (rlen > 0 && rBuff[0] == 0x7B && memcmp(&rBuff[7],&LocalMAC[0],6) == 0) // 如果接收到了数据,并且设备地址相同则处理接收到的数据 + { + //< 处理接收到的数据 + memcpy(SGCP.GatewayBuff, rBuff, rlen); + SGCP.GatewayBuffLen = rlen; + GWRevHandler();//网关数据接收处理 + } +} + +/***************************************************************************************** +* 函数名称: LPUartRx_CallBack +* 功能描述: 低功耗串口数据接收函数 +* 参 数: rData,接收到的字节 +* 返 回 值: 无 +*****************************************************************************************/ +void LPUartRx_CallBack(uint8_t rData) +{ + if(SGCP.LpUart0Delay1mSCnt == 0) { + SGCP.GWRS485Rx.HeaderFrame = false; + } + SGCP.LpUart0Delay1mSCnt = 5; + if(SGCP.GWRS485Rx.HeaderFrame == false) { + if(rData == 0x7B || rData == 0x7D) { + SGCP.GWRS485Rx.HeaderFrame = true; + SGCP.GWRS485Rx.RxLen = 0; + SGCP.GWRS485Rx.rPayLen = 0; + SGCP.InsideBuffLen = 0; + SGCP.InsidePayLen = 0; + SGCP.GWRS485Rx.RxBuff[SGCP.GWRS485Rx.RxLen++] = rData; + } + } + else { + if(SGCP.GWRS485Rx.RxBuff[0] == 0x7B) + { + if(SGCP.GWRS485Rx.RxLen == 14) { + SGCP.GWRS485Rx.rPayLen = rData; + } + if(SGCP.GWRS485Rx.RxLen == 15) { + SGCP.GWRS485Rx.rPayLen |= (rData << 8); + } + if(SGCP.GWRS485Rx.rPayLen > 10) { //大于最大负载长度,认为错误 + SGCP.GWRS485Rx.HeaderFrame = false; + return; + } + + SGCP.GWRS485Rx.RxBuff[SGCP.GWRS485Rx.RxLen++] = rData; + if(SGCP.GWRS485Rx.RxLen >= SGCP.GWRS485Rx.rPayLen + 18) { + SGCP.GWRS485Rx.HeaderFrame = false; + if(SGCP.GWRS485Rx.RxLen > 100) + return; + + memcpy(SGCP.GatewayBuff, SGCP.GWRS485Rx.RxBuff, SGCP.GWRS485Rx.RxLen); + SGCP.GatewayBuffLen = SGCP.GWRS485Rx.RxLen; + if(SGCP.GWRS485Rx.RxBuff[0] == 0x7B) GWRevHandler();//网关数据接收处理 + } + } + if(SGCP.GWRS485Rx.RxBuff[0] == 0x7D) + { + if(SGCP.GWRS485Rx.RxLen == 8) + { + SGCP.InsidePayLen = rData; + } + SGCP.GWRS485Rx.RxBuff[SGCP.GWRS485Rx.RxLen++] = rData; + if(SGCP.GWRS485Rx.RxLen >= SGCP.InsidePayLen + 11) + { + SGCP.GWRS485Rx.HeaderFrame = false; + + memcpy(SGCP.InsideBuff, SGCP.GWRS485Rx.RxBuff, SGCP.GWRS485Rx.RxLen); + SGCP.InsideBuffLen = SGCP.GWRS485Rx.RxLen; + if(SGCP.GWRS485Rx.RxBuff[0] == 0x7D) InRevHandler();//内部指令 + } + } + } +} + +/***************************************************************************************** +* 函数名称: Uart1Rx_CallBack +* 功能描述: 串口1数据接收函数 +* 参 数: rData,接收到的字节 +* 返 回 值: 无 +*****************************************************************************************/ +void Uart1Rx_CallBack(uint8_t rData) +{ +// if(SGCP.Uart1Delay1mSCnt == 0) { +// SGCP.SDRS485Rx.HeaderFrame = false; +// } +// SGCP.Uart1Delay1mSCnt = 5; +// if(SGCP.SDRS485Rx.HeaderFrame == false) { +// if(rData == 0x7C) { +// SGCP.SDRS485Rx.HeaderFrame = true; +// SGCP.SDRS485Rx.RxLen = 0; +// SGCP.SDRS485Rx.rPayLen = 0; +// SGCP.SDRS485Rx.RxBuff[SGCP.SDRS485Rx.RxLen++] = rData; +// } +// } +// else { +// if(SGCP.SDRS485Rx.RxLen == 3) { +// if(rData > 36) { //大于最大负载长度,认为错误 +// SGCP.SDRS485Rx.HeaderFrame = false; +// return; +// } +// SGCP.SDRS485Rx.rPayLen = rData; +// } +// +// SGCP.SDRS485Rx.RxBuff[SGCP.SDRS485Rx.RxLen++] = rData; +// if(SGCP.SDRS485Rx.RxLen >= SGCP.SDRS485Rx.rPayLen + 6) { +// SGCP.SDRS485Rx.HeaderFrame = false; +// if(SGCP.SDRS485Rx.RxLen > 100) +// return; + +// memcpy(SGCP.SubsetBuff, SGCP.SDRS485Rx.RxBuff, SGCP.SDRS485Rx.RxLen); +// SGCP.SubsetBuffLen = SGCP.SDRS485Rx.RxLen; +// if(SGCP.SDRS485Rx.RxBuff[0] == 0x7C) SGCP.Subset_IRQ_Status = true;//子设备串口中断 +// } +// } +} +#endif + +#if (SGCP_SELECT == 2)//本机为单个子设备 +/** + ******************************************************************************* + ** \brief 接收主设备数据状态机 + ** + ** \param 无 + ** + ** \retval 无 + ******************************************************************************/ +void MasRevLoopHandler(void) +{ + switch(SGCP.MasStatus) + { + case MAS_STATUS_IDLE:{ + break;} + + case MAS_STATUS_CALI:{ + PrintfMess(); + if(SGCP.BroadCmd == true) + { + SGCP.BroadCmd = false; + DBG_LOG("Broad Cail!\r\n"); + } + else + { + ToMDCaliRes(App.Para.Layout.RS485Addr, SGCP.SubsetCaliOk); + DBG_LOG("Alone Cail!\r\n"); + } + SGCP.TimingAcquisition = true;//采集新的传感器数据 + SGCP.MasStatus = MAS_STATUS_IDLE; + break;} + + case MAS_STATUS_READ_SENSOR:{ + PrintfMess(); + + SGCP.DeviceDataLen = 0; + memset(SGCP.DeviceData, NULL, sizeof(SGCP.DeviceData)); + DBG_LOG("Sub485Addr:%02X\r\n",App.Para.Layout.RS485Addr); + + if(sizeof(LocalDataPack) != 0x00) + { + memcpy(&SGCP.DeviceData[SGCP.DeviceDataLen], LocalDataPack, sizeof(LocalDataPack)); + SGCP.DeviceDataLen = SGCP.DeviceDataLen + DevGetDataMess(LocalType, LocalDataPack);; + } + + ToMDReadDataRes(App.Para.Layout.RS485Addr, SGCP.DeviceData, SGCP.DeviceDataLen); + DBG_LOG("Upload Sensor Data Ok!\r\n"); + SGCP.TimingAcquisition = true;//采集新的传感器数据 + SGCP.MasStatus = MAS_STATUS_IDLE; + break;} + + case MAS_STATUS_DEVICE_INQUIRE:{ + PrintfMess(); + ToMDInquireRes(App.Para.Layout.RS485Addr); + DBG_LOG("Device Inquire!\r\n"); + SGCP.MasStatus = MAS_STATUS_IDLE; + break;} + + case MAS_STATUS_SET_COL_TIME:{ + PrintfMess(); + if(SGCP.BroadCmd == true) + { + SGCP.BroadCmd = false; + DBG_LOG("Broad Set Col Time!\r\n"); + } + else + { + + ToMDSetColTimeRes(App.Para.Layout.RS485Addr, true); + DBG_LOG("Alone Set Col Time!\r\n"); + } + SGCP.MasStatus = MAS_STATUS_IDLE; + break;} + + case MAS_STATUS_SYNC_TIME:{ + PrintfMess(); + if(SGCP.BroadCmd == true) + { + SGCP.BroadCmd = false; + DBG_LOG("Broad Sync Time!\r\n"); + } + else + { + ToMDSyncTimeRes(App.Para.Layout.RS485Addr, true); + DBG_LOG("Alone Sync Time!\r\n"); + } + SGCP.MasStatus = MAS_STATUS_IDLE; + break;} + } +} +/* 中断回调函数 */ +/***************************************************************************************** +* 函数名称: LORA_RxCallBack +* 功能描述: Lora数据接收函数 +* 参 数: *rBuff,接收到的字符串 + rlen,接收到的字符串长度 +* 返 回 值: 无 +*****************************************************************************************/ +void LORA_RxCallBack(uint8_t *rBuff, uint8_t rlen) +{ +// if (rlen > 0 && rBuff[0] == 0x7C && memcmp(&rBuff[7],&Comm_DevAddr[0],6) == 0) // 如果接收到了数据,并且设备地址相同则处理接收到的数据 +// { +// //< 处理接收到的数据 +// memcpy(App.UpperBuff, rBuff, rlen); +// App.UpperBuffLen = rlen; +// App.Upper_IRQ_Status = true;//上位机串口中断 +// } +} + +/***************************************************************************************** +* 函数名称: LPUartRx_CallBack +* 功能描述: 低功耗串口数据接收函数 +* 参 数: rData,接收到的字节 +* 返 回 值: 无 +*****************************************************************************************/ +void LPUartRx_CallBack(uint8_t rData) +{ + if(SGCP.LpUart0Delay1mSCnt == 0) { + SGCP.SDRS485Rx.HeaderFrame = false; + } + SGCP.LpUart0Delay1mSCnt = 5; + if(SGCP.SDRS485Rx.HeaderFrame == false) { + if(rData == 0x7C || rData == 0x7D) { + SGCP.SDRS485Rx.HeaderFrame = true; + SGCP.SDRS485Rx.RxLen = 0; + SGCP.SDRS485Rx.rPayLen = 0; + SGCP.InsideBuffLen = 0; + SGCP.InsidePayLen = 0; + SGCP.SDRS485Rx.RxBuff[SGCP.SDRS485Rx.RxLen++] = rData; + } + } + else { + if(SGCP.SDRS485Rx.RxBuff[0] == 0x7C) + { + if(SGCP.SDRS485Rx.RxLen == 3) { + if(rData > 36) { //大于最大负载长度,认为错误 + SGCP.SDRS485Rx.HeaderFrame = false; + return; + } + SGCP.SDRS485Rx.rPayLen = rData; + } + + SGCP.SDRS485Rx.RxBuff[SGCP.SDRS485Rx.RxLen++] = rData; + if(SGCP.SDRS485Rx.RxLen >= SGCP.SDRS485Rx.rPayLen + 6) { + SGCP.SDRS485Rx.HeaderFrame = false; + if(SGCP.SDRS485Rx.RxLen > 100) + return; + + memcpy(SGCP.SubsetBuff, SGCP.SDRS485Rx.RxBuff, SGCP.SDRS485Rx.RxLen); + SGCP.SubsetBuffLen = SGCP.SDRS485Rx.RxLen; + if(SGCP.SDRS485Rx.RxBuff[0] == 0x7C) MasRevHandler();//子设备串口中断 + } + } + if(SGCP.SDRS485Rx.RxBuff[0] == 0x7D) + { + if(SGCP.SDRS485Rx.RxLen == 8) + { + SGCP.InsidePayLen = rData; + } + SGCP.SDRS485Rx.RxBuff[SGCP.SDRS485Rx.RxLen++] = rData; + if(SGCP.SDRS485Rx.RxLen >= SGCP.InsidePayLen + 11) + { + SGCP.SDRS485Rx.HeaderFrame = false; + + memcpy(SGCP.InsideBuff, SGCP.SDRS485Rx.RxBuff, SGCP.SDRS485Rx.RxLen); + SGCP.InsideBuffLen = SGCP.SDRS485Rx.RxLen; + if(SGCP.SDRS485Rx.RxBuff[0] == 0x7D) InRevHandler();//内部指令 + } + } + } +} +/***************************************************************************************** +* 函数名称: Uart1Rx_CallBack +* 功能描述: 串口1数据接收函数 +* 参 数: rData,接收到的字节 +* 返 回 值: 无 +*****************************************************************************************/ +void Uart1Rx_CallBack(uint8_t rData) +{ +// if(SGCP.Uart1Delay1mSCnt == 0) { +// SGCP.SDRS485Rx.HeaderFrame = false; +// } +// SGCP.Uart1Delay1mSCnt = 5; +// if(SGCP.SDRS485Rx.HeaderFrame == false) { +// if(rData == 0x7C) { +// SGCP.SDRS485Rx.HeaderFrame = true; +// SGCP.SDRS485Rx.RxLen = 0; +// SGCP.SDRS485Rx.rPayLen = 0; +// SGCP.SDRS485Rx.RxBuff[SGCP.SDRS485Rx.RxLen++] = rData; +// } +// } +// else { +// if(SGCP.SDRS485Rx.RxLen == 3) { +// if(rData > 36) { //大于最大负载长度,认为错误 +// SGCP.SDRS485Rx.HeaderFrame = false; +// return; +// } +// SGCP.SDRS485Rx.rPayLen = rData; +// } +// +// SGCP.SDRS485Rx.RxBuff[SGCP.SDRS485Rx.RxLen++] = rData; +// if(SGCP.SDRS485Rx.RxLen >= SGCP.SDRS485Rx.rPayLen + 6) { +// SGCP.SDRS485Rx.HeaderFrame = false; +// if(SGCP.SDRS485Rx.RxLen > 100) +// return; + +// memcpy(SGCP.SubsetBuff, SGCP.SDRS485Rx.RxBuff, SGCP.SDRS485Rx.RxLen); +// SGCP.SubsetBuffLen = SGCP.SDRS485Rx.RxLen; +// if(SGCP.SDRS485Rx.RxBuff[0] == 0x7C) SGCP.Subset_IRQ_Status = true;//子设备串口中断 +// } +// } +} + +#endif + +/** + ******************************************************************************* + ** \brief 内部指令数据状态机 + ** + ** \param 无 + ** + ** \retval 无 + ******************************************************************************/ +void InRevLoopHandler(void) +{ + switch(SGCP.InStatus) + { + case IN_STATUS_IDLE:{ + break;} + + case IN_STATUS_ALTER_485ADDR:{ + PrintfMess(); + Alter485AddrRes(LocalMAC, true); + DBG_LOG("Alter RS485Addr:%X\r\n", App.Para.RS485Addr); + SGCP.InStatus = IN_STATUS_IDLE; + break;} + + case IN_STATUS_UPDATE:{ + Update(SGCP.InsidePay);//固件更新. + memset(SGCP.InsidePay, NULL, sizeof(SGCP.InsidePay)); + SGCP.InStatus = IN_STATUS_IDLE; + break;} + } +} +/***************************************************************************************** +* 函数名称: SGCP1mSRoutine +* 功能描述: SGCP时基循环处理函数 +* 参 数: 无 +* 返 回 值: 无 +*****************************************************************************************/ +void SGCP1mSRoutine(void) +{ + if(SGCP.LpUart0Delay1mSCnt > 0) + SGCP.LpUart0Delay1mSCnt--; + if(SGCP.LoraDelay1mSCnt > 0) + SGCP.LoraDelay1mSCnt--; + if(SGCP.Uart1Delay1mSCnt > 0) + SGCP.Uart1Delay1mSCnt--; + if(SGCP.SD1mSDelayCnt > 0) + SGCP.SD1mSDelayCnt--; + if(SGCP.GW1mSDelayCnt > 0) + SGCP.GW1mSDelayCnt--; + if(SGCP.In1mSDelayCnt > 0) + SGCP.In1mSDelayCnt--; +} + + diff --git a/source/src/Update.c b/source/src/Update.c new file mode 100644 index 0000000..ec791e3 --- /dev/null +++ b/source/src/Update.c @@ -0,0 +1,48 @@ +#include "Update.h" +#include "UartDebug.h" + +static BootPara_t BLPara; + +/***************************************************************************************** +* 函数名称: Update +* 功能描述: 固件升级,此函数在解析到升级指令是调用 +* 参 数: PayLoad 协议负载,需去除帧头等信息,只传负载数据 +* 返 回 值: 无 +*****************************************************************************************/ +void Update(uint8_t *PayLoad) +{ + UpDataRequset_t Req; + + memcpy(&Req, PayLoad, sizeof(UpDataRequset_t)); + BLPara.AppSize = Req.AppSize; + BLPara.Crc32Check = Req.AppCrc32; + BLPara.PackageCnt = Req.PackageNum; + BLPara.AppFlag = 0; + BLPara.UpdateFlag = APP_UPDATE_FLAG; + + U_DBG_LOG("Receive upgrade command:\r\n"); + U_DBG_LOG("PackageNum: %d\r\n", BLPara.PackageCnt); + U_DBG_LOG("AppSize: %d\r\n", BLPara.AppSize); + U_DBG_LOG("AppCrc32: 0x%08x\r\n", BLPara.Crc32Check); + U_DBG_LOG("System Reset!\r\n"); + + SAVE_BOOT_PARA((uint32_t *)&BLPara); + U_DELAY_MS(200); + U_SYSTEM_TESET(); +} + +/***************************************************************************************** +* 函数名称: UpdateInit +* 功能描述: 升级参数初始化,需要在程序启动,外设初试完后调用 +* 参 数: 无 +* 返 回 值: 无 +*****************************************************************************************/ +void UpdateInit(void) +{ + READ_BOOT_PARA((uint32_t *)&BLPara); + if(BLPara.AppFlag != APP_START_FLAG) { + BLPara.AppFlag = APP_START_FLAG; + SAVE_BOOT_PARA((uint32_t *)&BLPara); + } +} + diff --git a/source/src/bsp.c b/source/src/bsp.c new file mode 100644 index 0000000..a01992c --- /dev/null +++ b/source/src/bsp.c @@ -0,0 +1,937 @@ +#include +#include +#include "sysctrl.h" +#include "gpio.h" +#include "flash.h" +#include "bsp.h" +#include "lpuart.h" +#include "uart.h" +#include "lpm.h" +#include "lptim.h" +#include "spi.h" +#include "reset.h" +#include "wdt.h" +#include "rtc.h" +#include "i2c.h" +#include "bgr.h" +#include "adc.h" +#include "UartDebug.h" + +#include "lsm6dsl_app.h" +#include "mmc5983.h" +#include "sx127x.h" + +extern void LPUartRx_CallBack(uint8_t Rx); +extern void Uart1Rx_CallBack(uint8_t Rx); +extern void DebugUartIRQ(uint8_t Data); +extern void SysTick_CallBack(void); +extern void RtcIRQHander(void); +extern void LPTimer0IRQHander(void); +extern void LORA_RxCallBack(uint8_t *rBuff, uint8_t rlen); + +static __IO uint32_t SysTickCnt = 0; +static volatile uint32_t u32AdcRestult; + +static void SystemClkDivInit(void)//系统时钟分频设置 +{ + //时钟分频设置 + Sysctrl_SetHCLKDiv(SysctrlHclkDiv1); + Sysctrl_SetPCLKDiv(SysctrlPclkDiv1); +} +static void SystemClkInit(en_sysctrl_rch_freq_t enRchFreq)//时钟初始化 +{ + ///< RCH时钟不同频率的切换,需要先将时钟切换到RCL + Sysctrl_SetRCLTrim(SysctrlRclFreq38400); + Sysctrl_SetRCLStableTime(SysctrlRclStableCycle64); + Sysctrl_ClkSourceEnable(SysctrlClkRCL, TRUE); + + /*内部高速时钟初始化 24MHZ*/ + /*Sysctrl_SetRCHTrim(enRchFreq); + Sysctrl_ClkSourceEnable(SysctrlClkRCH, TRUE); + //< HCLK不超过24M:此处设置FLASH读等待周期为0 cycle + Flash_WaitCycle(FlashWaitCycle0); + + Sysctrl_SysClkSwitch(SysctrlClkRCH);//系统时钟源选择 + */ + + /*内部高速时钟初始化 48MHZ*/ + stc_sysctrl_pll_cfg_t stcPLLCfg; + + ///< 加载目标频率的RCH的TRIM值 + Sysctrl_SetRCHTrim(SysctrlRchFreq4MHz); + ///< 使能RCH + Sysctrl_ClkSourceEnable(SysctrlClkRCH, TRUE); + + stcPLLCfg.enInFreq = SysctrlPllInFreq4_6MHz; //RCH 4MHz + stcPLLCfg.enOutFreq = SysctrlPllOutFreq36_48MHz; //PLL 输出 + stcPLLCfg.enPllClkSrc = SysctrlPllRch; //输入时钟源选择RCH + stcPLLCfg.enPllMul = SysctrlPllMul12; //4MHz x 12 = 48MHz + Sysctrl_SetPLLFreq(&stcPLLCfg); + + ///< 当使用的时钟源HCLK大于24M:设置FLASH 读等待周期为1 cycle(默认值也为1 cycle) + Flash_WaitCycle(FlashWaitCycle1); + + ///< 使能PLL + Sysctrl_ClkSourceEnable(SysctrlClkPLL, TRUE); + ///< 时钟切换到PLL + Sysctrl_SysClkSwitch(SysctrlClkPLL); + + /*外部低速晶振初始化 32.768KHz*/ +/* Sysctrl_XTLDriverCfg(SysctrlXtlAmp3, SysctrlXtalDriver3); + Sysctrl_SetXTLStableTime(SysctrlXtlStableCycle16384); + Sysctrl_ClkSourceEnable(SysctrlClkXTL, TRUE); +*/ +} +static void SystemRCLInit(void) +{ + Sysctrl_SetRCLTrim(SysctrlRclFreq38400); ///< 配置RCL时钟为38400kHz + Sysctrl_SetRCLStableTime(SysctrlRclStableCycle256); + Sysctrl_ClkSourceEnable(SysctrlClkRCL, TRUE); ///< 使能RCL时钟 +} + +static void Uart0Init(void) +{ + stc_gpio_cfg_t stcGpioCfg; + stc_uart_cfg_t stcCfg; + DDL_ZERO_STRUCT(stcGpioCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); + + /// 0x99 || RtcInitStruct.rtcTime.u8Month > 0x12) { + RtcInitStruct.rtcTime.u8Second = 0x30; + RtcInitStruct.rtcTime.u8Minute = 0x38; + RtcInitStruct.rtcTime.u8Hour = 0x08; + RtcInitStruct.rtcTime.u8Day = 0x02; + RtcInitStruct.rtcTime.u8DayOfWeek = 0x06; + RtcInitStruct.rtcTime.u8Month = 0x09; + RtcInitStruct.rtcTime.u8Year = 0x23; + } + RtcInitStruct.rtcCompen = RtcCompenEnable; + RtcInitStruct.rtcCompValue = 0; //补偿值 根据实际情况进行补偿 + Rtc_Init(&RtcInitStruct); + Rtc_AlmIeCmd(TRUE); //使能闹钟中断 + EnableNvic(RTC_IRQn, IrqLevel3, TRUE); //使能RTC中断向量 + Rtc_Cmd(TRUE); //使能RTC开始计数 + Rtc_StartWait(); //启动RTC计数,如果要立即切换到低功耗,需要执行此函数 +} +/****************************************************************************** +* 函数名称: LPTimer0Init +* 功能描述: 低功耗定时器0初始化 +* 参 数: sTime 定时中断秒时间 +* 返 回 值: 无 + ******************************************************************************/ +void LPTimer0Init(uint16_t _100ms) +{ + Lptim_Cmd(M0P_LPTIMER0, FALSE); + + stc_lptim_cfg_t stcLptCfg; + DDL_ZERO_STRUCT(stcLptCfg); + + ///< 使能LPTIM0 外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralLpTim0, TRUE); + + stcLptCfg.enPrs = LptimPrsDiv256; + stcLptCfg.enGate = LptimGateLow; + stcLptCfg.enGatep = LptimGatePLow; + stcLptCfg.enTcksel = LptimRcl; + stcLptCfg.enTogen = LptimTogEnLow; + stcLptCfg.enCt = LptimTimerFun; //警示器功能 + stcLptCfg.enMd = LptimMode1; //工作模式为模式1:无自动重装载16位计数器/定时器 + stcLptCfg.u16Arr = 0x10000 - (_100ms * 13); //预装载寄存器值 + Lptim_Init(M0P_LPTIMER0, &stcLptCfg); + + Lptim_ClrItStatus(M0P_LPTIMER0); //清除中断标志位 + Lptim_ConfIt(M0P_LPTIMER0, TRUE); //允许LPTIMER中断 + EnableNvic(LPTIM_0_1_IRQn, IrqLevel3, TRUE); + + Lptim_Cmd(M0P_LPTIMER0, TRUE); +} +void LPTimer0_ON(uint16_t _100ms) +{ + LPTimer0Init(_100ms); +} +void LPTimer0_OFF(void) +{ + EnableNvic(LPTIM_0_1_IRQn, IrqLevel3, FALSE); + Lptim_Cmd(M0P_LPTIMER0, FALSE); +} +static void GPIOInit(void) +{ + stc_gpio_cfg_t GpioInitStruct; + + DDL_ZERO_STRUCT(GpioInitStruct); + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); + + //未使用或引出的脚设为输入上拉 + GpioInitStruct.enDir = GpioDirIn; + GpioInitStruct.enPu = GpioPuEnable; + + Gpio_Init(GpioPortA, GpioPin0, &GpioInitStruct); + Gpio_Init(GpioPortA, GpioPin1, &GpioInitStruct); + Gpio_Init(GpioPortA, GpioPin2, &GpioInitStruct); + Gpio_Init(GpioPortA, GpioPin5, &GpioInitStruct); + Gpio_Init(GpioPortA, GpioPin6, &GpioInitStruct); + Gpio_Init(GpioPortA, GpioPin7, &GpioInitStruct); + Gpio_Init(GpioPortA, GpioPin8, &GpioInitStruct); + + Gpio_Init(GpioPortB, GpioPin2, &GpioInitStruct); + Gpio_Init(GpioPortB, GpioPin8, &GpioInitStruct); + Gpio_Init(GpioPortB, GpioPin9, &GpioInitStruct); + Gpio_Init(GpioPortB, GpioPin15, &GpioInitStruct); + + Gpio_Init(GpioPortF, GpioPin6, &GpioInitStruct); + //end + + /********************************** GPIO输出 ****************************************/ + GpioInitStruct.enDir = GpioDirOut; ///< 端口方向配置->输出 + GpioInitStruct.enDrv = GpioDrvH; ///< 端口驱动能力配置->高驱动能力 + GpioInitStruct.enPu = GpioPuDisable; ///< 端口上下拉配置->无 + GpioInitStruct.enPd = GpioPdDisable; + GpioInitStruct.enOD = GpioOdDisable; ///< 端口开漏输出配置->开漏输出关闭 + GpioInitStruct.enCtrlMode = GpioAHB; ///< 端口输入/输出值寄存器总线控制模式配置->AHB + GpioInitStruct.bOutputVal = false; ///< 端口默认输出配置->低电平 + //< RS485控制引脚 + Gpio_Init(RS485_CTRL_PORTx,RS485_CTRL_PINx,&GpioInitStruct); + //< 激光控制引脚 + Gpio_Init(LASER1_ON_OFF_PORTx,LASER1_ON_OFF_PINx,&GpioInitStruct); + Gpio_Init(LASER2_ON_OFF_PORTx,LASER2_ON_OFF_PINx,&GpioInitStruct); + Gpio_Init(LASER3_ON_OFF_PORTx,LASER3_ON_OFF_PINx,&GpioInitStruct); + + GpioInitStruct.bOutputVal = true; ///< 端口默认输出配置->高电平 + //< LORA --> RST + Gpio_Init(LORA_RST_PORTx,LORA_RST_PINx,&GpioInitStruct); + //< LED_State + Gpio_Init(LED_STATE_PORTx,LED_STATE_PINx,&GpioInitStruct); + + /********************************** GPIO输入 ****************************************/ + GpioInitStruct.enDir = GpioDirIn; ///< 端口方向配置->输入 + GpioInitStruct.enPu = GpioPuDisable; ///< 端口上下拉配置->无 + GpioInitStruct.enPd = GpioPdDisable; + GpioInitStruct.enOD = GpioOdDisable; + + //< LORA --> DIO0 + Gpio_Init(LORA_DIO0_PORTx,LORA_DIO0_PINx,&GpioInitStruct); + //< LORA --> DIO0 + Gpio_Init(LORA_DIO1_PORTx,LORA_DIO1_PINx,&GpioInitStruct); + //< ACC_INT1 + Gpio_Init(LSM6DSLTR_INT1_PORTx,LSM6DSLTR_INT1_PINx,&GpioInitStruct); + //< ACC_INT2 + Gpio_Init(LSM6DSLTR_INT2_PORTx,LSM6DSLTR_INT2_PINx,&GpioInitStruct); + //< MMC_INT + Gpio_Init(MMC5983MA_INT_PORTx,MMC5983MA_INT_PINx,&GpioInitStruct); + GlobalIntEnable(); +} +void GlobalIntEnable(void)//全局中断使能 +{ + EnableNvic(PORTB_IRQn, IrqLevel3, TRUE); + EnableNvic(PORTC_E_IRQn, IrqLevel3, TRUE); +} +void GlobalIntDisable(void)//全局中断失能 +{ + EnableNvic(PORTB_IRQn, IrqLevel3, FALSE); + EnableNvic(PORTC_E_IRQn, IrqLevel3, FALSE); +} +void LORAIntEnable(void)//LORA中断使能 +{ + Gpio_EnableIrq(LORA_DIO0_PORTx, LORA_DIO0_PINx, GpioIrqRising);//LORA_DIO0 + Gpio_EnableIrq(LORA_DIO1_PORTx, LORA_DIO1_PINx, GpioIrqRising);//LORA_DIO1 +} +void LORAIntDisable(void)//LORA中断失能 +{ + Gpio_DisableIrq(LORA_DIO0_PORTx, LORA_DIO0_PINx, GpioIrqRising); + Gpio_DisableIrq(LORA_DIO1_PORTx, LORA_DIO1_PINx, GpioIrqRising); +} +void ACCandMMCIntEnable(void)//加速度和地磁中断使能 +{ + Gpio_EnableIrq(LSM6DSLTR_INT1_PORTx, LSM6DSLTR_INT1_PINx, GpioIrqRising);//ACC_Int1 + Gpio_EnableIrq(LSM6DSLTR_INT2_PORTx, LSM6DSLTR_INT2_PINx, GpioIrqRising);//ACC_Int2 + Gpio_EnableIrq(MMC5983MA_INT_PORTx, MMC5983MA_INT_PINx, GpioIrqRising);//MMC_Int +} +void ACCandMMCIntDisable(void)//加速度和地磁中断失能 +{ + Gpio_DisableIrq(LSM6DSLTR_INT1_PORTx, LSM6DSLTR_INT1_PINx, GpioIrqRising);//ACC_Int1 + Gpio_DisableIrq(LSM6DSLTR_INT2_PORTx, LSM6DSLTR_INT2_PINx, GpioIrqRising);//ACC_Int2 + Gpio_DisableIrq(MMC5983MA_INT_PORTx, MMC5983MA_INT_PINx, GpioIrqRising);//MMC_Int +} + +static void SPI0Init(void) +{ + stc_gpio_cfg_t GpioInitStruct; + stc_spi_cfg_t SpiInitStruct; + + DDL_ZERO_STRUCT(GpioInitStruct); + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); + + /************************** SPI0配置:主机-->LORA *******************************/ + GpioInitStruct.enDir = GpioDirOut; + + Gpio_Init(SPI0_NSS_PORTx,SPI0_NSS_PINx,&GpioInitStruct); + Gpio_SetAfMode(SPI0_NSS_PORTx,SPI0_NSS_PINx,SPI0_NSS_AF); //配置SPI0_NSS + + Gpio_Init(SPI0_SCK_PORTx,SPI0_SCK_PINx,&GpioInitStruct); + Gpio_SetAfMode(SPI0_SCK_PORTx,SPI0_SCK_PINx,SPI0_SCK_AF); //配置SPI0_SCK + + Gpio_Init(SPI0_MOSI_PORTx,SPI0_MOSI_PINx,&GpioInitStruct); + Gpio_SetAfMode(SPI0_MOSI_PORTx,SPI0_MOSI_PINx,SPI0_MOSI_AF); //配置SPI0_MOSI + + GpioInitStruct.enDir = GpioDirIn; ///< 端口方向配置->输入 + + Gpio_Init(SPI0_MISO_PORTx,SPI0_MISO_PINx,&GpioInitStruct); + Gpio_SetAfMode(SPI0_MISO_PORTx, SPI0_MISO_PINx,SPI0_MISO_AF); //配置SPI0_MISO + + Sysctrl_SetPeripheralGate(SysctrlPeripheralSpi0,TRUE); ///< 打开SPI0外设时钟 + Reset_RstPeripheral0(ResetMskSpi0); ///<复位模块 + + //SPI0模块配置:主机 + SpiInitStruct.enSpiMode = SpiMskMaster; //配置位主机模式 + SpiInitStruct.enPclkDiv = SpiClkMskDiv4; //波特率:PCLK/4 + SpiInitStruct.enCPHA = SpiMskCphasecond; //第二边沿采样 + SpiInitStruct.enCPOL = SpiMskcpolhigh; //极性为高 + Spi_Init(M0P_SPI0, &SpiInitStruct); +} + +static void SPI1Init(void) +{ + stc_gpio_cfg_t GpioInitStruct; + stc_spi_cfg_t SpiInitStruct; + + DDL_ZERO_STRUCT(GpioInitStruct); + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); + + /************************** SPI1配置:主机-->LORA *******************************/ + GpioInitStruct.enDir = GpioDirOut; + + Gpio_Init(SPI1_NSS_PORTx,SPI1_NSS_PINx,&GpioInitStruct); + Gpio_SetAfMode(SPI1_NSS_PORTx,SPI1_NSS_PINx,SPI1_NSS_AF); //配置SPI1_NSS + + Gpio_Init(SPI1_SCK_PORTx,SPI1_SCK_PINx,&GpioInitStruct); + Gpio_SetAfMode(SPI1_SCK_PORTx,SPI1_SCK_PINx,SPI1_SCK_AF); //配置SPI1_SCK + + Gpio_Init(SPI1_MOSI_PORTx,SPI1_MOSI_PINx,&GpioInitStruct); + Gpio_SetAfMode(SPI1_MOSI_PORTx,SPI1_MOSI_PINx,SPI1_MOSI_AF); //配置SPI1_MOSI + + GpioInitStruct.enDir = GpioDirIn; ///< 端口方向配置->输入 + + Gpio_Init(SPI1_MISO_PORTx,SPI1_MISO_PINx,&GpioInitStruct); + Gpio_SetAfMode(SPI1_MISO_PORTx, SPI1_MISO_PINx,SPI1_MISO_AF); //配置SPI1_MISO + + Sysctrl_SetPeripheralGate(SysctrlPeripheralSpi1,TRUE); ///< 打开SPI0外设时钟 + Reset_RstPeripheral0(ResetMskSpi1); ///<复位模块 + + //SPI1模块配置:主机 + SpiInitStruct.enSpiMode = SpiMskMaster; //配置位主机模式 + SpiInitStruct.enPclkDiv = SpiClkMskDiv2; //波特率:PCLK/2 + SpiInitStruct.enCPHA = SpiMskCphasecond; //第二边沿采样 + SpiInitStruct.enCPOL = SpiMskcpolhigh; //极性为高 + Spi_Init(M0P_SPI1, &SpiInitStruct); +} + +uint8_t Spi0SendReceive(uint8_t sData) +{ + return Spi_RWByte(M0P_SPI0, sData); +} + +uint8_t Spi1SendReceive(uint8_t sData) +{ + return Spi_RWByte(M0P_SPI1, sData); +} +static void I2C0Init(void) +{ + stc_gpio_cfg_t stcGpioCfg; + stc_i2c_cfg_t stcI2cCfg; + + DDL_ZERO_STRUCT(stcI2cCfg); + DDL_ZERO_STRUCT(stcGpioCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); //开启GPIO时钟门控 + + stcGpioCfg.enDir = GpioDirOut; ///< 端口方向配置->输出 + stcGpioCfg.enOD = GpioOdEnable; ///< 开漏输出 + stcGpioCfg.enPu = GpioPuEnable; ///< 端口上拉配置->使能 + stcGpioCfg.enPd = GpioPdDisable; ///< 端口下拉配置->禁止 + stcGpioCfg.bOutputVal = TRUE; + + Gpio_Init(I2C0_SCL_PORTx, I2C0_SCL_PINx, &stcGpioCfg); ///< 端口初始化 + Gpio_SetAfMode(I2C0_SCL_PORTx, I2C0_SCL_PINx, I2C0_SCL_AF); + + Gpio_Init(I2C0_SDA_PORTx, I2C0_SDA_PINx, &stcGpioCfg); + Gpio_SetAfMode(I2C0_SDA_PORTx, I2C0_SDA_PINx, I2C0_SDA_AF); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralI2c0,TRUE); ///< 开启I2C0时钟门控 + + stcI2cCfg.u32Pclk = Sysctrl_GetPClkFreq(); ///< 获取PCLK时钟 + stcI2cCfg.u32Baud = 400000; ///< 1MHz + stcI2cCfg.enMode = I2cMasterMode; ///< 主机模式 + stcI2cCfg.u8SlaveAddr = 0xD5; ///< 从地址,主模式无效 + stcI2cCfg.bGc = FALSE; ///< 广播地址应答使能关闭 + I2C_Init(M0P_I2C0, &stcI2cCfg); ///< 模块初始化 +} + +static void I2C1Init(void) +{ + stc_gpio_cfg_t stcGpioCfg; + stc_i2c_cfg_t stcI2cCfg; + + DDL_ZERO_STRUCT(stcI2cCfg); + DDL_ZERO_STRUCT(stcGpioCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); //开启GPIO时钟门控 + + stcGpioCfg.enDir = GpioDirOut; ///< 端口方向配置->输出 + stcGpioCfg.enOD = GpioOdEnable; ///< 开漏输出 + stcGpioCfg.enPu = GpioPuEnable; ///< 端口上拉配置->使能 + stcGpioCfg.enPd = GpioPdDisable; ///< 端口下拉配置->禁止 + stcGpioCfg.bOutputVal = TRUE; + + Gpio_Init(I2C1_SCL_PORTx, I2C1_SCL_PINx, &stcGpioCfg); ///< 端口初始化 + Gpio_SetAfMode(I2C1_SCL_PORTx, I2C1_SCL_PINx, I2C1_SCL_AF); + + Gpio_Init(I2C1_SDA_PORTx, I2C1_SDA_PINx, &stcGpioCfg); + Gpio_SetAfMode(I2C1_SDA_PORTx, I2C1_SDA_PINx, I2C1_SDA_AF); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralI2c1,TRUE); ///< 开启I2C1时钟门控 + + stcI2cCfg.u32Pclk = Sysctrl_GetPClkFreq(); ///< 获取PCLK时钟 + stcI2cCfg.u32Baud = 400000; ///< 1MHz + stcI2cCfg.enMode = I2cMasterMode; ///< 主机模式 + stcI2cCfg.u8SlaveAddr = 0xD5; ///< 从地址,主模式无效 + stcI2cCfg.bGc = FALSE; ///< 广播地址应答使能关闭 + I2C_Init(M0P_I2C1, &stcI2cCfg); ///< 模块初始化 +} + + +static void WdtInit(void) +{ +#if (USE_WDT == 1) + ///< 开启WDT外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralWdt,TRUE); + ///< WDT 初始化 + Wdt_Init(WdtResetEn, WdtT52s4); + Wdt_Start(); +#endif +} + +void FlashWrite(uint32_t Addr, uint32_t *wData, int wLen) +{ + while(Ok != Flash_SectorErase(Addr)); + for(int i = 0; i < wLen; i++) { + Flash_WriteWord(Addr + i * 4, wData[i]); + } +} + +void FlashRead(uint32_t Addr, uint32_t *rData, int rLen) +{ + uint32_t u32Addr = Addr; + for(int i = 0; i < rLen; i++) { + rData[i] = *((volatile uint32_t*)(u32Addr + i * 4)); + } +} +void FeedDog(void) +{ +#if (USE_WDT == 1) + Wdt_Feed(); +#endif +} +static uint8_t BCDToDec(uint8_t bcd) +{ + return ((bcd >> 4)& 0x0f) * 10 + (bcd & 0x0f); +} + +static uint8_t DecToBCD(uint8_t Dec) +{ + return (Dec / 10) << 4 | (Dec % 10); +} + +void TimeGet(struct tm *cTime) +{ + stc_rtc_time_t RtcDateTime; + + Rtc_ReadDateTime(&RtcDateTime); + cTime->tm_year = BCDToDec(RtcDateTime.u8Year) + 100; + cTime->tm_mon = BCDToDec(RtcDateTime.u8Month) - 1; + cTime->tm_mday = BCDToDec(RtcDateTime.u8Day); + cTime->tm_hour = BCDToDec(RtcDateTime.u8Hour) + 8; + cTime->tm_min = BCDToDec(RtcDateTime.u8Minute); + cTime->tm_sec = BCDToDec(RtcDateTime.u8Second); + cTime->tm_isdst = 0; +} + +uint32_t TimeTs(void) +{ + struct tm cTime; + + TimeGet(&cTime); + time_t cTimet = mktime(&cTime); + return cTimet; +} + +void TimeShow(uint32_t dwStamp) +{ + struct tm *stime; + stime = localtime(&dwStamp); + DBG_LOG("%d/",stime->tm_year + 1900); + DBG_LOG("%d/",stime->tm_mon + 1); + DBG_LOG("%d ",stime->tm_mday); + DBG_LOG("%d:",stime->tm_hour); + DBG_LOG("%d:",stime->tm_min); + DBG_LOG("%d\r\n",stime->tm_sec); +} + +void TimeSync(time_t ts) +{ + struct tm *td; + stc_rtc_time_t RtcDateTime; + + td = localtime(&ts); + + RtcDateTime.u8Year = DecToBCD(td->tm_year - 100); + RtcDateTime.u8Month = DecToBCD(td->tm_mon + 1); + RtcDateTime.u8Day = DecToBCD(td->tm_mday); + RtcDateTime.u8DayOfWeek = DecToBCD(td->tm_wday); + RtcDateTime.u8Hour = DecToBCD(td->tm_hour); + RtcDateTime.u8Minute = DecToBCD(td->tm_min); + RtcDateTime.u8Second = DecToBCD(td->tm_sec); + + Rtc_SetTime(&RtcDateTime); +} + +void PrintfMess(void) +{ + DBG_LOG("\r\n"); + uint32_t CT = TimeTs(); + TimeShow(CT); +#if(USE_LED == 1) + LED_ON(); +#endif +#if(USE_VBAT_AD == 1) + DBG_LOG("VBAT_Percentage:%d\r\n",VBAT_Percentage); +#endif +} +void DBGUartSendByte(uint8_t sData) +{ + Uart_SendDataPoll(M0P_UART0, sData); +} + +void LPUart0SendArray(uint8_t *sData, uint8_t sLen) +{ + RS485_CTRL_TX(); + for(int i = 0; i < sLen; i++) { + LPUart_SendData(M0P_LPUART0, sData[i]); + } + RS485_CTRL_RX(); +} + +uint32_t GetSysTick(void) +{ + return SysTickCnt; +} +void delay_us(uint32_t uS)//24MHz一个nop延时0.5us,12MHz延时1us +{ + uS *= 2; + while(uS--) + { + __NOP(); + } +} +void delay_ms(uint32_t mS) +{ + volatile uint32_t cTick, mTick; + + cTick = GetSysTick(); + while(1){ + mTick = GetSysTick(); + if(mTick - cTick >= mS) + break; + } +} + +void SysTick_IRQHandler(void) +{ + SysTickCnt++; + SysTick_CallBack(); +} + +void PortA_IRQHandler(void) +{ + +} +void PortB_IRQHandler(void) +{ + //LORA DIO0 + if(TRUE == Gpio_GetIrqStatus(LORA_DIO0_PORTx, LORA_DIO0_PINx)) { + Gpio_ClearIrq(LORA_DIO0_PORTx, LORA_DIO0_PINx); + Sx1276LoRaLoopHandler(); //lora + } + //LORA DIO1 + if(TRUE == Gpio_GetIrqStatus(LORA_DIO1_PORTx, LORA_DIO1_PINx)) { + Gpio_ClearIrq(LORA_DIO1_PORTx, LORA_DIO1_PINx); + } +} + +void PortC_IRQHandler(void) +{ + //加速度INT1 + if(TRUE == Gpio_GetIrqStatus(LSM6DSLTR_INT1_PORTx, LSM6DSLTR_INT1_PINx)) { + Gpio_ClearIrq(LSM6DSLTR_INT1_PORTx, LSM6DSLTR_INT1_PINx); + Lsm6dsInt1CallBack(); + } + + //地磁INT + if(TRUE == Gpio_GetIrqStatus(MMC5983MA_INT_PORTx, MMC5983MA_INT_PINx)) { + Gpio_ClearIrq(MMC5983MA_INT_PORTx, MMC5983MA_INT_PINx); + MMC5983IntCallBack(); + } +} +///CTRL &= ~SysTick_CTRL_ENABLE_Msk; + + //< LORA + Sx1276LoRaSleep();//Lora睡眠 + LORAIntDisable();//关闭LORA中断 + + ACCandMMCIntDisable();//关闭加速度和地磁中断 + +#if (USE_VBAT_AD == 1)//< AD + AD_OFF(); + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdcBgr, TRUE); + Sysctrl_ClkSourceEnable(SysctrlClkPLL,FALSE); + Bgr_BgrDisable(); ///< 关闭BGR + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdcBgr, FALSE); + Adc_SGL_Stop();//关闭单次采样 +#endif + +#if (USE_SPI0 == 1) + Sysctrl_SetPeripheralGate(SysctrlPeripheralSpi0,FALSE);//关闭SPI0外设时钟 +#endif +#if (USE_UART0 == 1) + EnableNvic(UART0_2_IRQn, IrqLevel3, false); + Sysctrl_SetPeripheralGate(SysctrlPeripheralUart0,FALSE); //关闭UART0时钟 +#endif + + DeepSleepGPIOCfg(); + Lpm_GotoDeepSleep(FALSE); +} + +void WakeUpInit(void) +{ + SystemClkDivInit(); + SystemClkInit(SysctrlRchFreq24MHz); + GPIOInit(); + +#if (USE_VBAT_AD == 1)//< AD + AD_ON(); + AdcInit(); +#endif +#if (USE_UART0 == 1) + Uart0Init(); +#endif +#if (USE_SPI0 == 1) + SPI0Init(); +#endif +#if (USE_WDT == 1)//< WDT + WdtInit(); +#endif + + LORAIntEnable();//开启LORA中断 + Sx1276LoRaWakeup();//LORA唤醒 + ACCandMMCIntEnable();//开启加速度和地磁中断 + + SysTick_Config(SystemCoreClock/1000); +} + +void SystemReset(void) +{ + NVIC_SystemReset(); +} + +void BspInit(void) +{ + SystemClkDivInit(); + SystemClkInit(SysctrlRchFreq24MHz); + GPIOInit(); + +#if (USE_VBAT_AD == 1)//< AD + AD_ON(); + AdcInit(); +#endif +#if (USE_UART0 == 1)//< DEBUG + Uart0Init(); +#endif +#if (USE_RTC == 1)//< RTC + RTCInit(30); +#endif +#if (USE_WDT == 1)//< WDT + WdtInit(); +#endif +#if (USE_SPI0 == 1) + SPI0Init(); +#endif +#if (USE_SPI1 == 1) + SPI1Init(); +#endif +#if (USE_LPUART0 == 1)//< LPUART0 + LpUart0Init(); +#endif +#if(USE_I2C0 == 1) + I2C0Init(); +#endif +#if(USE_I2C1 == 1) + I2C1Init(); +#endif + + SysTick_Config(SystemCoreClock/1000); + while(Ok != Flash_Init(6, TRUE)); +} \ No newline at end of file diff --git a/source/src/main.c b/source/src/main.c new file mode 100644 index 0000000..3475a40 --- /dev/null +++ b/source/src/main.c @@ -0,0 +1,571 @@ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include +#include "main.h" +#include "UartDebug.h" +#include "bsp.h" +#include "Algorithm.h" +#include "SGCP.h" +#include "Update.h" +#include "sx127x.h" +#include "lsm6dsl_app.h" +#include "mmc5983.h" + + +#define SOFTWARE_VERSION 11 //杞欢鐗堟湰 +#define HARDWARE_VERSION 11 //纭欢鐗堟湰 + +AppDetect_t App; + +extern uint8_t LocalMAC[6]; //鏈満MAC鍦板潃 +extern uint8_t GatewayMAC[6]; //缃戝叧MAC鍦板潃锛屾敞鍐屾椂鍏ㄤ负0 +extern uint8_t LocalDataPack[sizeof(SGCP.DevData.LaserTracing)]; //鏈満鏁版嵁鍖 //鏈満鏁版嵁鍖 + +void Lsm6dDataProcessCallBack(float *Acc, float *Gy) +{ + memcpy(App.Sensor.acce, Acc, 12); + memcpy(App.Sensor.gy, Gy, 12); + //DBG_LOG("acc_X:%07.1f, acc_Y:%07.1f, acc_Z:%07.1f\r\n", App.Sensor.acce[X], App.Sensor.acce[Y],App.Sensor.acce[Z]); + //DBG_LOG("gy_X:%07.1f, gy_Y:%07.1f, gy_Z:%07.1f\r\n", App.Sensor.gy[X], App.Sensor.gy[Y],App.Sensor.gy[Z]); + App.AccRead_EndFlag = true; +} + +void MmcDataProcessCallBack(float *Mag) +{ + memcpy(App.Sensor.mag, Mag, 12); + //DBG_LOG("mag_X:%07.1f, mag_Y:%07.1f, mag_Z:%07.1f\r\n", App.Sensor.mag[X], App.Sensor.mag[Y],App.Sensor.mag[Z]); + App.MagRead_EndFlag = true; +} + +static void AppInit(void) +{ + memset(&App, 0x00, sizeof(App)); + READ_APP_PARA((uint32_t *)&App.Para); + +#if(USE_BOOTLOADER == 1) + UpdateInit(); + + if(App.Para.FactoryFlag != 0x00) + { + App.Para.FactoryFlag = 0x00; + /*鏍″噯鍙傛暟鍒濆鍖*/ + App.Para.CaliPara.PitchZero = 0; + App.Para.CaliPara.RollZero = 0; + App.Para.CaliPara.YawZero = 0; + SAVE_APP_PARA((uint32_t *)&App.Para); + } +#endif + + if(App.Para.RS485Addr > 16 || App.Para.RS485Addr < 1){ + App.Para.RS485Addr = 1; + } + if(App.Para.Layout.CollectTime > 240 || App.Para.Layout.CollectTime < 1) { + App.Para.Layout.CollectTime = 10; + } + if(App.Para.Layout.ReportInterval > 1440 || App.Para.Layout.ReportInterval < 10) { + App.Para.Layout.ReportInterval = 40; + } + if(App.Para.Layout.ERInterval > 10 || App.Para.Layout.ERInterval < 2) { + App.Para.Layout.ERInterval = 4; + } + if(App.Para.Layout.ERTime > 240 || App.Para.Layout.ERTime < 20) { + App.Para.Layout.ERTime = 40; + } + + DBG_LOG("\r\n\r\n"); + DBG_LOG("****************************************************\r\n"); + DBG_LOG("** **\r\n"); + DBG_LOG("** LaserTracing **\r\n"); + DBG_LOG("** SoftWare V:%d.%d **\r\n", SOFTWARE_VERSION / 10, SOFTWARE_VERSION % 10); + DBG_LOG("** HardWare V:%d.%d **\r\n", HARDWARE_VERSION / 10, HARDWARE_VERSION % 10); + DBG_LOG("** Compile: %s %s **\r\n", __DATE__, __TIME__); + DBG_LOG("** **\r\n"); + DBG_LOG("****************************************************\r\n\r\n"); + DBG_LOG("RS485Addr: %02X\r\n",App.Para.RS485Addr); + DBG_LOG("LocalMAC: %02X %02X %02X %02X %02X %02X\r\n",LocalMAC[0], LocalMAC[1], LocalMAC[2], LocalMAC[3], LocalMAC[4], LocalMAC[5]); + DBG_LOG("CollectTime: %ds\r\n\r\n",(App.Para.Layout.CollectTime*30)); + + LORAIntEnable(); + Sx1276LoRaInit(LORA_RxCallBack); //< LORA鑺墖鍒濆鍖 + FeedDog(); + + Lsm6dslInit(); + MMC5983Init(); + MMC5983Stop(); + Lsm6dsStop(); + ACCandMMCIntEnable(); + + LPTimer0_OFF(); + + uint32_t seed = 0;//< 闅忔満鏁板垵濮嬪寲 + seed = seed + LocalMAC[2]; + seed = (seed << 8) + LocalMAC[3]; + seed = (seed << 8) + LocalMAC[4]; + seed = (seed << 8) + LocalMAC[5]; + srand(seed); + App.Nonce = rand(); + + SGCP.LoginOk = false; + SGCP.LoginMess = false; + SGCP.LaserOnOff = false; + SGCP.MasterCaliOk = true; + SGCP.DeviceReadDataOk = false; + SGCP.TimingAcquisition = false; + + App.Login2Min30SCount = 0; + App.Login30MinCount = 0; + App.RepeLoginCount = 0; + App.LoginFlag = false; + App.Login_RTC = false; + App.Login_LPTimer0 = true; + //LPTimer0_ON((App.Nonce % 1200) + 300);//瀹氭椂30s+闅忔満2鍒嗛挓锛屾渶灏忛棿闅100ms + LPTimer0_ON(50); + DBG_LOG("Login LPTimer0 Open\r\n"); + + App.Upload45S10SCount = 0; + App.UploadFlag = false; + App.Upload_LPTimer0 = false; + + App.Coll_N = 0; + App.Repor_N = 0; + App.ERInterval_N = 0; + App.ERTime_N = 0; + App.ERFlag = false; + + App.MagRead_EndFlag = false; + App.AccRead_EndFlag = false; + App.UpdateOk = false; + App.CaliFlag = false; + App.LaserFlag = false; + + App.Status = APP_STATUS_ON; + App.TD1mSDelayCnt = (App.Nonce % 2000) + 2000; +} + +static void ReadDataLoopHandler(void) +{ + switch (App.RDStatus) + { + case READDATA_STATUS_IDLE:{ + break;} + + case READDATA_STATUS_UPDAING:{ + DBG_LOG("<------------ Sensor Data Updaing ------------> \r\n"); + App.UpdateOk = false; + Lsm6dsStart(); + MMC5983Start(); + App.ReadData1mSDelayCnt = 2000; + App.RDStatus = READDATA_STATUS_WAIT_UPDAING; + break;} + + case READDATA_STATUS_WAIT_UPDAING:{ + if(App.ReadData1mSDelayCnt <= 0){ + if(App.AccRead_EndFlag == false) + DBG_LOG("Lsm6dsl Get Data TimeOut...\r\n"); + if(App.MagRead_EndFlag == false) + DBG_LOG("MMC5983 Get Data TimeOut...\r\n"); + App.RDStatus = READDATA_STATUS_DATA_HANDLE; + } + else if(App.MagRead_EndFlag == true + && App.AccRead_EndFlag == true){ + App.RDStatus = READDATA_STATUS_DATA_HANDLE; + } + break;} + + case READDATA_STATUS_DATA_HANDLE:{ + if(App.MagRead_EndFlag == false || App.AccRead_EndFlag == false){ + DBG_LOG("<------------ Sensor Data Upda End ------------> \r\n"); + App.RDStatus = READDATA_STATUS_IDLE; + App.UpdateOk = false; + break; + } + App.MagRead_EndFlag = false; + App.AccRead_EndFlag = false; + + IMU_Update(0, App.Sensor.acce, App.Sensor.mag, &App.AHRSData.Rad, &App.AHRSData.Deg); + App.ConvertedData.Pitch = (int16_t)(App.AHRSData.Deg.pitch * 10); + App.ConvertedData.Roll = (int16_t)(App.AHRSData.Deg.roll * 10); + App.ConvertedData.Yaw = (int16_t)(App.AHRSData.Deg.yaw * 10); + DBG_LOG("PitchAngle:%06.1f, RollAngle:%06.1f, YawAngle:%06.1f\r\n",App.AHRSData.Deg.pitch, App.AHRSData.Deg.roll, App.AHRSData.Deg.yaw); + + if(SGCP.MasterCaliOk == true) + { + SGCP.MasterCaliOk = false; + App.CaliFlag = true; + App.Para.CaliPara.PitchZero = App.ConvertedData.Pitch; + App.Para.CaliPara.RollZero = App.ConvertedData.Roll; + App.Para.CaliPara.YawZero = App.ConvertedData.Yaw; +// App.Para.CaliPara.PitchZero = 0; +// App.Para.CaliPara.RollZero = 0; +// App.Para.CaliPara.YawZero = 0; + SAVE_APP_PARA((uint32_t *)&App.Para); + } + if(App.CaliFlag == true && App.ERFlag == false) + { + int16_t PitchDiff,RollDiff; + PitchDiff = App.ConvertedData.Pitch - App.Para.CaliPara.PitchZero; + RollDiff = App.ConvertedData.Roll - App.Para.CaliPara.RollZero; + if((PitchDiff > ERINTERVAL_VPT) || (RollDiff > ERINTERVAL_VPT)) + { + //瑙﹀彂绱фヤ笂鎶 + App.ERFlag = true; + DBG_LOG("PitchDiff=%04d, PitchDiff=%04d\r\n", PitchDiff,RollDiff); + DBG_LOG("Start emergency reporting!\r\n"); + DBG_LOG("ERInterval: %dMin, ERTime: %dMin\r\n", App.Para.Layout.ERInterval/2, App.Para.Layout.ERTime/2); + } + } + + SGCP.DevData.LaserTracing.PitchAngle = App.ConvertedData.Pitch; + SGCP.DevData.LaserTracing.RollAngle = App.ConvertedData.Roll; + SGCP.DevData.LaserTracing.YawAngle = App.ConvertedData.Yaw; + +#if (USE_VBAT_AD == 1) + SGCP.DevData.LaserTracing.MasterDev.BatLevel = VBAT_Percentage; +#else + SGCP.DevData.LaserTracing.MasterDev.BatLevel = 0x00; +#endif +#if (SGCP_SELECT == 1 || SGCP_SELECT == 2) + SX1276LoCalcRssiSnr(&SGCP.DevData.LaserTracing.MasterDev.RSSI, &SGCP.DevData.LaserTracing.MasterDev.Nsr);//鑾峰彇淇″彿寮哄害 +#else + SGCP.DevData.LaserTracing.MasterDev.RSSI = 0x00; + SGCP.DevData.LaserTracing.MasterDev.Nsr = 0x00; +#endif + + memcpy(LocalDataPack, &SGCP.DevData.LaserTracing, sizeof(LocalDataPack)); + DBG_LOG("<------------ Sensor Data Upda End ------------> \r\n"); + //App.RDStatus = READDATA_STATUS_UPDAING;//鎸佺画宸ヤ綔 + App.RDStatus = READDATA_STATUS_IDLE; + App.UpdateOk = true; + break;} + } +} + +static void AppLoopHandler(void) +{ + switch(App.Status) { + case APP_STATUS_IDLE:{ + break;} + + case APP_STATUS_SLEEP:{ + DBG_LOG("Sleep...\r\n\n\n"); + FeedDog(); + EnterDeepSleep(); + FeedDog(); + + WakeUpInit(); + App.Status = APP_STATUS_ON; + break;} + + case APP_STATUS_ON:{ + if(App.TD1mSDelayCnt <= 0){ + App.TD1mSDelayCnt = 1000;//鍞ら啋鍚庡緟鏈烘椂闂 + App.Status = APP_STATUS_ACTION; + } + break;} + + case APP_STATUS_OFF:{ + LED_OFF(); + App.Status = APP_STATUS_SLEEP; + DBG_LOG("Power Off...\r\n"); + break;} + + case APP_STATUS_ACTION:{ + if(SGCP.InStatus != IN_STATUS_IDLE){ + break; + } + else if(SGCP.LoginOk == false && App.LoginFlag == true && SGCP.GWStatus == GW_STATUS_IDLE)//璁惧娉ㄥ唽 + { + PrintfMess(); + App.LoginFlag = false; + LPTimer0_OFF();//鍏抽棴浣庡姛鑰楀畾鏃跺櫒 + SGCP.GWStatus = GW_STATUS_LOGIN;//娉ㄥ唽 + App.Status = APP_STATUS_WAIT_LOGIN; + } + else if(SGCP.TimingAcquisition == true && App.RDStatus == READDATA_STATUS_IDLE)//璁惧鏁版嵁鑾峰彇 + { + PrintfMess(); + SGCP.TimingAcquisition = false; + App.RDStatus = READDATA_STATUS_UPDAING; + App.Status = APP_STATUS_ACTION; + App.TD1mSDelayCnt = 1000; + } + else if(SGCP.LoginOk == true && App.UploadFlag == true && SGCP.GWStatus == GW_STATUS_IDLE && App.UpdateOk == true) + { + PrintfMess(); + App.UploadFlag = false; + LPTimer0_OFF();//鍏抽棴浣庡姛鑰楀畾鏃跺櫒 + SGCP.GWStatus = GW_STATUS_UPLOAD_SENSOR;//涓婁紶 + App.Status = APP_STATUS_WAIT_UPLOAD; + } + else if(App.RDStatus == READDATA_STATUS_IDLE + && SGCP.GWStatus == GW_STATUS_IDLE + && SGCP.InStatus == IN_STATUS_IDLE + && SGCP.TimingAcquisition == false + && App.TD1mSDelayCnt == 0 + && App.ReadData1mSDelayCnt == 0 + && SGCP.LaserOnOff == false + && App.TestTimeCnt == 0) + { + //App.Status = APP_STATUS_ACTION;//鎸佺画宸ヤ綔 + App.Status = APP_STATUS_OFF; + } + else if(App.LaserFlag == true) + { + App.LaserFlag = false; + App.TestTimeCnt = 3000; + LASER1_ON(); + } + break;} + + case APP_STATUS_WAIT_LOGIN:{ + if(SGCP.LoginMess == true) + { + if(SGCP.LoginOk == false) + { + App.Login2Min30SCount++; + if(App.Login2Min30SCount >= 3) + { + PrintfMess(); + DBG_LOG("Number of registration failures:%d\r\n",App.Login2Min30SCount); + DBG_LOG("Login RTC Open\r\n"); + App.Login2Min30SCount = 0; + App.Login30MinCount = 0; + App.Login_RTC = true;//鍚姩30鍒嗘敞鍐屽畾鏃跺櫒 + } + else + { + PrintfMess(); + App.Login_LPTimer0 = true; + LPTimer0_ON((App.Nonce % 1200) + 300);//瀹氭椂30s+闅忔満2鍒嗛挓锛屾渶灏忛棿闅100ms + //LPTimer0_ON(100);//瀹氭椂10s + DBG_LOG("Number of registration failures:%d\r\n",App.Login2Min30SCount); + DBG_LOG("Login LPTimer0 Open\r\n"); + } + } + else if(SGCP.LoginOk == true) + { + App.Login2Min30SCount = 0; + App.Login30MinCount = 0; + App.Upload45S10SCount = 0; + App.UploadFlag = true; + App.RDStatus = READDATA_STATUS_UPDAING; + } + SGCP.LoginMess = false; + App.TD1mSDelayCnt = 1000; + App.Status = APP_STATUS_ACTION; + } + break;} + + case APP_STATUS_WAIT_UPLOAD:{ + if(SGCP.UploadMess == true) + { + if(SGCP.UploadOk == false) + { + App.Upload45S10SCount++; + if((App.Upload45S10SCount%3) == 0) + { + PrintfMess(); + DBG_LOG("Number of failed uploads:%d\r\n",App.Upload45S10SCount); + if(App.Upload45S10SCount >= 9) + { + DBG_LOG("Resend registration information.\r\n"); + SGCP.LoginOk = false; + App.LoginFlag = true; + } + } + else + { + PrintfMess(); + App.Upload_LPTimer0 = true; + LPTimer0_ON((App.Nonce % 100) + 45);//闅忔満寤舵椂100~10000ms+45绉掑悗閲嶆柊鍙戦 + //LPTimer0_ON(100);//瀹氭椂10s + DBG_LOG("Number of failed uploads:%d\r\n",App.Upload45S10SCount); + DBG_LOG("Upload LPTimer0 Open\r\n"); + } + } + else if(SGCP.UploadOk == true) + { + App.Upload45S10SCount = 0; + } + SGCP.UploadMess = false; + App.TD1mSDelayCnt = 1000; + App.Status = APP_STATUS_ACTION; + } + break;} + } +} + +static void App1mSRoutine(void) +{ + if(App.TD1mSDelayCnt > 0) + App.TD1mSDelayCnt--; + if(App.ReadData1mSDelayCnt > 0) + App.ReadData1mSDelayCnt--; + App.FeedDogDlyCnt++; + if(App.TestTimeCnt > 0) + { + App.TestTimeCnt--; + if(App.TestTimeCnt <= 0) + { + LASER1_OFF(); + } + } +} + +void FeedDogHandler(void) +{ + if(App.FeedDogDlyCnt >= 200) { + FeedDog(); + App.FeedDogDlyCnt = 0; + } +} + +void SystemResetHandler(void) +{ + //绯荤粺瀹氭椂閲嶅惎 + if(App.SysResetTimeCnt > SYSTEM_TIMING_LOGIN) { + delay_ms(5); + SystemReset(); + while(1); + } +} + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + BspInit(); + delay_ms(3000);//涓婄數寤舵椂锛岀瓑寰呬粠璁惧鍚姩 + AppInit(); + + while (1) { +#if(USE_VBAT_AD == 1) + ADCLoopHandler(); +#endif +#if(USE_WDT == 1) + FeedDogHandler(); +#endif +#if(USE_DEBUG == 1) + DebugLoopHandler(); +#endif + Lsm6dslLoopHandler(); + MMC5983LoopHandler(); + ReadDataLoopHandler(); + GwRevLoopHandler(); + InRevLoopHandler(); + AppLoopHandler(); + } +} +/******************************************************************************* + * 涓柇鍥炶皟鍑芥暟 + ******************************************************************************/ +void SysTick_CallBack(void) +{ + App1mSRoutine(); + SGCP1mSRoutine(); + Debug1mSRoutine(); + Lsm6dsl1mSRoutine(); + MMC59831mSRoutine(); +} + +void RtcIRQHander(void) +{ + //SGCP.TimingAcquisition = true; //30S鏇存柊涓娆℃暟鎹 +#if USE_LORA_CH == 0 + App.Tcnt++;//涓鍒嗛挓寮鍚縺鍏3绉 + if(App.Tcnt >= 2) + { + App.Tcnt = 0; + App.LaserFlag = true; + } +#endif + if(SGCP.LoginOk == true) + { + App.RepeLoginCount++; + if(App.RepeLoginCount >= SYSTEM_TIMING_LOGIN){ + DBG_LOG("24h Repetition Login\r\n"); + App.RepeLoginCount = 0; + SGCP.LoginOk = false;//24h閲嶅娉ㄥ唽 + App.Login2Min30SCount = 0; + App.Login30MinCount = 0; + App.Login_RTC = false;//鍏抽棴30鍒嗘敞鍐屽畾鏃跺櫒 + + LPTimer0_ON((App.Nonce % 1200) + 300);//瀹氭椂30s+闅忔満2鍒嗛挓锛屾渶灏忛棿闅100ms + DBG_LOG("Login LPTimer0 Open\r\n"); + } + + App.Coll_N++; + if(App.Coll_N >= App.Para.Layout.CollectTime) + { + App.Coll_N = 0; + SGCP.TimingAcquisition = true; //瀹氭椂鏇存柊鏁版嵁 + } + + if(App.ERFlag == true) + { + App.ERInterval_N++; + App.ERTime_N++; + if(App.ERInterval_N >= App.Para.Layout.ERInterval) + { + App.ERInterval_N = 0; + App.UploadFlag = true; + } + if(App.ERTime_N >= App.Para.Layout.ERTime) + { + App.ERTime_N = 0; + App.ERFlag = false; + SGCP.MasterCaliOk = true;//绱фヤ笂鎶ユ椂闂寸粨鏉燂紝閲嶆柊鏍″噯鍙傛暟 + } + } + else{ + App.Repor_N++; + if(App.Repor_N >= App.Para.Layout.ReportInterval) + { + App.Repor_N = 0; + App.UploadFlag = true; + } + } + } + + if(App.Login_RTC == true) + { + App.Login30MinCount++; + if(App.Login30MinCount >= ERR_TIMING_LOGIN)//30鍒嗛挓閲嶇疆娉ㄥ唽閿欒淇℃伅 + { + PrintfMess(); + App.Login30MinCount = 0; + App.Login_RTC = false;//鍏抽棴30鍒嗘敞鍐屽畾鏃跺櫒 + DBG_LOG("Login RTC Close\r\n"); + + App.Login_LPTimer0 = true; + LPTimer0_ON((App.Nonce % 1200) + 300);//瀹氭椂30s+闅忔満2鍒嗛挓锛屾渶灏忛棿闅100ms + //LPTimer0_ON(100);//瀹氭椂10s + DBG_LOG("Login LPTimer0 Open\r\n"); + } + } +} +void LPTimer0IRQHander(void) +{ + if(App.Login_LPTimer0 == true) + { + App.Login_LPTimer0 = false; + App.LoginFlag = true; + } + if(App.Upload_LPTimer0 == true) + { + App.Upload_LPTimer0 = false; + App.UploadFlag = true; + } +} + + +