From 1dac28a7c9c5c215609a11599df692f7e79c58bb Mon Sep 17 00:00:00 2001 From: qitas Date: Sat, 3 Jul 2021 14:55:52 +0800 Subject: [PATCH] add --- .gitignore | 6 + README.md | 13 +- index.json | 63 +- .../api_uart_protocol/api_uart_protocol.c | 268 + .../api_uart_protocol/api_uart_protocol.h | 76 + project/custom/bsp_charge/bsp_batterymanage.c | 135 + project/custom/bsp_charge/bsp_batterymanage.h | 69 + project/custom/bsp_check/bsp_check_dev.c | 18 + project/custom/bsp_check/bsp_check_dev.h | 27 + project/custom/bsp_hw_mcu/bsp_adc.c | 145 + project/custom/bsp_hw_mcu/bsp_adc.h | 34 + project/custom/bsp_hw_mcu/bsp_clk.c | 41 + project/custom/bsp_hw_mcu/bsp_clk.h | 33 + project/custom/bsp_hw_mcu/bsp_exti.c | 20 + project/custom/bsp_hw_mcu/bsp_exti.h | 33 + project/custom/bsp_hw_mcu/bsp_gpio.c | 39 + project/custom/bsp_hw_mcu/bsp_gpio.h | 32 + project/custom/bsp_hw_mcu/bsp_iwdg.c | 54 + project/custom/bsp_hw_mcu/bsp_iwdg.h | 33 + project/custom/bsp_hw_mcu/bsp_mcu_id.c | 57 + project/custom/bsp_hw_mcu/bsp_mcu_id.h | 44 + project/custom/bsp_hw_mcu/bsp_mcu_include.h | 36 + project/custom/bsp_hw_mcu/bsp_usart.c | 191 + project/custom/bsp_hw_mcu/bsp_usart.h | 41 + project/custom/cfg_board/cfg_board.h | 32 + .../cfg_board/cfg_board_shared_pwr_bank.h | 29 + project/custom/config.h | 69 + project/custom/hc32fxxx.h | 27 + project/custom/lock/app_lock.c | 79 + project/custom/lock/app_lock.h | 35 + .../api_shared_pwr_handler.c | 23 + .../api_shared_pwr_handler.h | 42 + project/custom/syspower/app_lowpower.c | 19 + project/custom/syspower/app_syspower.c | 61 + project/custom/syspower/app_syspower.h | 42 + project/custom/systick/api_sys_timer.c | 51 + project/custom/systick/api_sys_timer.h | 28 + project/custom/typedef.h | 47 + project/driver/inc/adc.h | 386 + project/driver/inc/adt.h | 787 ++ project/driver/inc/bt.h | 231 + project/driver/inc/clk.h | 291 + project/driver/inc/crc.h | 111 + project/driver/inc/ddl.h | 204 + project/driver/inc/flash.h | 140 + project/driver/inc/gpio.h | 902 ++ project/driver/inc/i2c.h | 158 + project/driver/inc/interrupts_hc32f003.h | 83 + project/driver/inc/lpm.h | 167 + project/driver/inc/lvd.h | 205 + project/driver/inc/pca.h | 285 + project/driver/inc/reset.h | 154 + project/driver/inc/spi.h | 185 + project/driver/inc/trim.h | 182 + project/driver/inc/uart.h | 263 + project/driver/inc/vc.h | 299 + project/driver/inc/wdt.h | 128 + project/driver/src/adc.c | 719 ++ project/driver/src/adt.c | 1854 ++++ project/driver/src/bt.c | 564 + project/driver/src/clk.c | 779 ++ project/driver/src/crc.c | 257 + project/driver/src/ddl.c | 306 + project/driver/src/flash.c | 596 ++ project/driver/src/gpio.c | 530 + project/driver/src/i2c.c | 525 + project/driver/src/interrupts_hc32f003.c | 359 + project/driver/src/lpm.c | 134 + project/driver/src/lvd.c | 316 + project/driver/src/pca.c | 755 ++ project/driver/src/reset.c | 204 + project/driver/src/spi.c | 275 + project/driver/src/trim.c | 352 + project/driver/src/uart.c | 741 ++ project/driver/src/vc.c | 683 ++ project/driver/src/wdt.c | 187 + .../EWARM/flashloader/FlashHC32F003.flash | 10 + .../handler/EWARM/flashloader/HC32F003.board | 8 + project/handler/EWARM/hc32f003.icf | 29 + project/handler/EWARM/startup_hc32f003.s | 353 + project/handler/EWARM/template.ewd | 3265 ++++++ project/handler/EWARM/template.ewp | 2213 ++++ project/handler/EWARM/template.eww | 10 + project/handler/MDK/JLinkSettings.ini | 35 + project/handler/MDK/startup_hc32f003.s | 294 + project/handler/MDK/template.uvoptx | 567 + project/handler/MDK/template.uvprojx | 533 + project/handler/source/ddl_device.h | 76 + project/handler/source/main.c | 115 + project/mcu/EWARM/HDSC_HC32F003.svd | 9170 +++++++++++++++++ .../config/flashloader/FlashHC32F003.flash | 10 + .../config/flashloader/FlashHC32F003.mac | 23 + .../EWARM/config/flashloader/HC32F003.board | 8 + project/mcu/EWARM/config/reset.mac | 8 + project/mcu/MDK/HDSC_HC32F003.SFR | Bin 0 -> 261255 bytes project/mcu/MDK/config/Flash_HC32F003.FLM | Bin 0 -> 16960 bytes project/mcu/common/HC32F003.h | 3334 ++++++ project/mcu/common/base_types.h | 154 + project/mcu/common/system_hc32f003.c | 98 + project/mcu/common/system_hc32f003.h | 102 + src/gcc_template/src/main.c | 20 +- 101 files changed, 37772 insertions(+), 52 deletions(-) create mode 100644 project/custom/api_uart_protocol/api_uart_protocol.c create mode 100644 project/custom/api_uart_protocol/api_uart_protocol.h create mode 100644 project/custom/bsp_charge/bsp_batterymanage.c create mode 100644 project/custom/bsp_charge/bsp_batterymanage.h create mode 100644 project/custom/bsp_check/bsp_check_dev.c create mode 100644 project/custom/bsp_check/bsp_check_dev.h create mode 100644 project/custom/bsp_hw_mcu/bsp_adc.c create mode 100644 project/custom/bsp_hw_mcu/bsp_adc.h create mode 100644 project/custom/bsp_hw_mcu/bsp_clk.c create mode 100644 project/custom/bsp_hw_mcu/bsp_clk.h create mode 100644 project/custom/bsp_hw_mcu/bsp_exti.c create mode 100644 project/custom/bsp_hw_mcu/bsp_exti.h create mode 100644 project/custom/bsp_hw_mcu/bsp_gpio.c create mode 100644 project/custom/bsp_hw_mcu/bsp_gpio.h create mode 100644 project/custom/bsp_hw_mcu/bsp_iwdg.c create mode 100644 project/custom/bsp_hw_mcu/bsp_iwdg.h create mode 100644 project/custom/bsp_hw_mcu/bsp_mcu_id.c create mode 100644 project/custom/bsp_hw_mcu/bsp_mcu_id.h create mode 100644 project/custom/bsp_hw_mcu/bsp_mcu_include.h create mode 100644 project/custom/bsp_hw_mcu/bsp_usart.c create mode 100644 project/custom/bsp_hw_mcu/bsp_usart.h create mode 100644 project/custom/cfg_board/cfg_board.h create mode 100644 project/custom/cfg_board/cfg_board_shared_pwr_bank.h create mode 100644 project/custom/config.h create mode 100644 project/custom/hc32fxxx.h create mode 100644 project/custom/lock/app_lock.c create mode 100644 project/custom/lock/app_lock.h create mode 100644 project/custom/shared_power_handler/api_shared_pwr_handler.c create mode 100644 project/custom/shared_power_handler/api_shared_pwr_handler.h create mode 100644 project/custom/syspower/app_lowpower.c create mode 100644 project/custom/syspower/app_syspower.c create mode 100644 project/custom/syspower/app_syspower.h create mode 100644 project/custom/systick/api_sys_timer.c create mode 100644 project/custom/systick/api_sys_timer.h create mode 100644 project/custom/typedef.h create mode 100644 project/driver/inc/adc.h create mode 100644 project/driver/inc/adt.h create mode 100644 project/driver/inc/bt.h create mode 100644 project/driver/inc/clk.h create mode 100644 project/driver/inc/crc.h create mode 100644 project/driver/inc/ddl.h create mode 100644 project/driver/inc/flash.h create mode 100644 project/driver/inc/gpio.h create mode 100644 project/driver/inc/i2c.h create mode 100644 project/driver/inc/interrupts_hc32f003.h create mode 100644 project/driver/inc/lpm.h create mode 100644 project/driver/inc/lvd.h create mode 100644 project/driver/inc/pca.h create mode 100644 project/driver/inc/reset.h create mode 100644 project/driver/inc/spi.h create mode 100644 project/driver/inc/trim.h create mode 100644 project/driver/inc/uart.h create mode 100644 project/driver/inc/vc.h create mode 100644 project/driver/inc/wdt.h create mode 100644 project/driver/src/adc.c create mode 100644 project/driver/src/adt.c create mode 100644 project/driver/src/bt.c create mode 100644 project/driver/src/clk.c create mode 100644 project/driver/src/crc.c create mode 100644 project/driver/src/ddl.c create mode 100644 project/driver/src/flash.c create mode 100644 project/driver/src/gpio.c create mode 100644 project/driver/src/i2c.c create mode 100644 project/driver/src/interrupts_hc32f003.c create mode 100644 project/driver/src/lpm.c create mode 100644 project/driver/src/lvd.c create mode 100644 project/driver/src/pca.c create mode 100644 project/driver/src/reset.c create mode 100644 project/driver/src/spi.c create mode 100644 project/driver/src/trim.c create mode 100644 project/driver/src/uart.c create mode 100644 project/driver/src/vc.c create mode 100644 project/driver/src/wdt.c create mode 100644 project/handler/EWARM/flashloader/FlashHC32F003.flash create mode 100644 project/handler/EWARM/flashloader/HC32F003.board create mode 100644 project/handler/EWARM/hc32f003.icf create mode 100644 project/handler/EWARM/startup_hc32f003.s create mode 100644 project/handler/EWARM/template.ewd create mode 100644 project/handler/EWARM/template.ewp create mode 100644 project/handler/EWARM/template.eww create mode 100644 project/handler/MDK/JLinkSettings.ini create mode 100644 project/handler/MDK/startup_hc32f003.s create mode 100644 project/handler/MDK/template.uvoptx create mode 100644 project/handler/MDK/template.uvprojx create mode 100644 project/handler/source/ddl_device.h create mode 100644 project/handler/source/main.c create mode 100644 project/mcu/EWARM/HDSC_HC32F003.svd create mode 100644 project/mcu/EWARM/config/flashloader/FlashHC32F003.flash create mode 100644 project/mcu/EWARM/config/flashloader/FlashHC32F003.mac create mode 100644 project/mcu/EWARM/config/flashloader/HC32F003.board create mode 100644 project/mcu/EWARM/config/reset.mac create mode 100644 project/mcu/MDK/HDSC_HC32F003.SFR create mode 100644 project/mcu/MDK/config/Flash_HC32F003.FLM create mode 100644 project/mcu/common/HC32F003.h create mode 100644 project/mcu/common/base_types.h create mode 100644 project/mcu/common/system_hc32f003.c create mode 100644 project/mcu/common/system_hc32f003.h diff --git a/.gitignore b/.gitignore index 84cf0f7..bd5a920 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,9 @@ *.out *.o ~$* +output +RTE +*uvguix* +*.scvd +settings +*.tmp diff --git a/README.md b/README.md index ae0a97f..a51d09e 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ [![Build Status](https://github.com/SoCXin/HC32F005/workflows/src/badge.svg)](https://github.com/SoCXin/HC32F005/actions/workflows/src.yml) * [hdsc](https://www.hdsc.com.cn/):[Cortex-M0](https://github.com/SoCXin/Cortex) -* [Level](https://github.com/SoCXin/Level) :32MHz * 0.95DMIPS/MHz +* [L2R2](https://github.com/SoCXin/Level) :32 MHz x 0.94 DMIPS/MHz, [2.46 CoreMark/MHz](https://www.eembc.org/coremark/scores.php) ## [简介](https://github.com/SoCXin/HC32F005/wiki) -[HC32F005](https://github.com/SoCXin/HC32F005) 为Low Pin宽电压工作范围的MCU,12位1Msps采样SARADC内置运放 +[HC32F005](https://github.com/SoCXin/HC32F005) 为小封装高性价比MCU,12位1Msps采样SARADC,内置运放 [![sites](docs/HC32F005.png)](https://www.hdsc.com.cn/Category83-1433) @@ -22,19 +22,22 @@ ### [资源收录](https://github.com/SoCXin) -* [参考文档](docs/) * [参考资源](src/) +* [参考文档](docs/) * [参考工程](project/) + ### [选型建议](https://github.com/SoCXin) [HC32F003](https://github.com/SoCXin/HC32F005),[HC32F005](https://github.com/SoCXin/HC32F005),[HC32L110](https://github.com/SoCXin/HC32L110) 规格类似,HC32L110 拥有 RTC 外设 * TSSOP20 -* SOP20 * QFN20 * QFN24 -[![sites](docs/test.png)](https://www.hdsc.com.cn/Category83-1433) + [![sites](docs/test.jpg)](https://www.hdsc.com.cn/Category83-1433) +[![sites](docs/test.png)](https://www.hdsc.com.cn/Category83-1433) + + ### [探索芯世界 www.SoC.xin](http://www.SoC.Xin) diff --git a/index.json b/index.json index d02b51e..8a9b78f 100644 --- a/index.json +++ b/index.json @@ -1,41 +1,37 @@ { - "name":"HC32F005", - "series":["HC32F005C6PA","HC32F005C6PB","HC32F003C4PB"], "type":"MCU", - "Core":"Cortex-M0", - "Freq":"32MHz", - "description":"hdsc Cortex-M0 MCU", - "peripheral": ["ADC","IIC","UART","SPI","LDO","PWM"], - "package":["QFN20","SOP20","TSSOP20"], - "SRAM":4, - "Flash":32, - "DATA":128, - "UART": { - "num": 2, - "FIFO": 16, - "ISO7816": 1, - "more":["BUAD","LIN","IrDA"] - }, - "ADC": { + "name":"HC32F005", + "title": "HDSC MCU HC32F005", + "description":"HDSC Cortex-M0 HC32F005 MCU", + "version":"1.0.0", + "Core": { "num": 1, - "channel": 8, - "resolution": 12, - "rate": 2400 + "type":"Cortex-M0", + "Freq": 32, + "DMIPS": 100, + "CoreMark": 160 }, - "TIM": { - "resolution":[16,16,16], - "rate": 1024 + "manufacturer": { + "vendor":"WCH", + "homepage": "https://www.hdsc.com.cn/Category83-1433" }, + "repository": { + "type": "git", + "url": "https://github.com/SoCXin/HC32F005.git" + }, + "series":["HC32F005C6PA","HC32F005C6PB","HC32F003C4PB"], + "package":["QFN24","QFN20","SOP20","TSSOP20"], + "peripheral": ["TIM","ADC","USB","UART","SPI","LDO","PWM"], + "price":[4,8], "PWR": { "VDD": [2800,5000], "Ivdd": 3.5, "LDO": [5000,3300], "rate": 1024 }, - "PWM": { - "num": 2, - "resolution": 8, - "rate": 256 + "EMC": { + "EFT": 2000, + "ESD": 4000 }, "upload": { "ISP": true, @@ -43,8 +39,13 @@ "SWD": true, "speed": 115200 }, - "vendor":"nuvoton", - "url":"http://www.SoC.xin/HC32F005", - "repo":"https://github.com/SoCXin/HC32F005", - "version":"1.0.0" + "keywords": [ + "dev-platform", + "ARM", + "Cortex-M", + "HDSC", + "HC32F005", + "DAC","SDIO","CAN","I2C","RTC","SPI", + "3.6V","1.8V" + ] } diff --git a/project/custom/api_uart_protocol/api_uart_protocol.c b/project/custom/api_uart_protocol/api_uart_protocol.c new file mode 100644 index 0000000..ac97418 --- /dev/null +++ b/project/custom/api_uart_protocol/api_uart_protocol.c @@ -0,0 +1,268 @@ +//=========================================================================================================================== +//=========================================================================================================================== +//±¾ÎļþʵÏÖÉ豸¼ì²⹦ÄÜ +//´´½¨Õߣºsteve +//´´½¨ÈÕÆڣº2018-06- 04 +//´´½¨°汾£ºversion-1.0 +//Ð޸ÄÈÕÆڣº +//Ð޸ÄÄÚÈݣº +//Ð޸İ汾£º +//=========================================================================================================================== +#include "config.h" + +comm_msg_t handler_msg; +u8 pedestalNo[MCU_ID_LEN_MAX]; +static void api_send_cmd_to_handler_ack(u8 adr, u8 ack); +//printf redefined +void api_comm_parm_init(void) +{ + memset((char *)&handler_msg, 0, sizeof(comm_msg_t)); + handler_msg.write.max_len = COMM_BUF_LEN; + handler_msg.read.max_len = COMM_BUF_LEN; + handler_msg.dev_en = 1; + Get_ChipID(); +} + +void uart_protocol_process(u8 *buf, u8 len) +{//aa 55 10 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 + sh_printf("uart_protocol_process:%d\n",buf[0]); + if(buf[0] == CMD_PEDESTAL_GET_BAT_INFO) + {//aa 55 10 01 ID1 ... ID12 µçÁ¿ ÉÏËøÇé¿ö checksum + sh_printf("GET_BAT_INFO:%d\n",buf[1]); + if(buf[1] == E_GET_BAT_INFO) + { + handler_msg.bat_report_notify = E_HAND_GET_INFO; + batt_discharge_ctl(TRUE); + }else if(buf[1] == E_BAT_RETURN_OK) + { + batt_discharge_ctl(FALSE); + }else if(buf[1] == E_BAT_RENT_OK) + { + batt_discharge_ctl(TRUE); + } + handler_msg.read.end_flag = 1; + }else if(buf[0] == CMD_RETURN_GET_BAT_INFO) + {//aa 55 10 01 ID1 ... ID12 µçÁ¿ ÉÏËøÇé¿ö checksum + handler_msg.read.end_flag = 1; + handler_msg.bat_report_notify = E_HAND_RETRUN_INFO; + }else if(buf[0] == CMD_GET_PEDESTAL_ID) + { + u8 i = 0; + for(; i< 12; i++) + { + pedestalNo[i] = buf[1+i]; + } + handler_msg.read.end_flag = 1; + }else if(buf[0] == CMD_PC_PEDESTAL_ID) + { + api_send_pedestal_id(); + handler_msg.read.end_flag = 1; + return; + }else if(buf[0] == CMD_HD_ACK){ + if(buf[1] == HD_ACK) + { + handler_msg.read.end_flag = 1; + }else{ + handler_msg.read.end_flag = 0xff; + } + return; + } + + api_send_cmd_to_handler_ack(CMD_HD_ACK, HD_ACK); +} +static void api_comm_handle_pack_prc(u8 dat) +{ + static u16 head = 0; + static u8 data_len; + static u8 get_len = 0; + static u8 step = 0; + static u8 get_buf[128]; + static u8 checksum = 0; + //head = buf[0]; + //os_printf("RX:%02x ",buf[0]); + //for(cnt = 1; cnt < len; cnt++) + { + //os_printf("%02x ",buf[cnt]); + if(step == 0) + { + head <<= 8; + head |= dat; + if(head == SYNC_HEAD) + { + step = 1; + data_len = 0; + get_len = 0; + checksum = 0; + head = 0; + } + }else if(step == 1) + { + data_len = dat; + step++; + checksum += dat; + }else if(step == 2) + { + get_buf[get_len] = dat; + checksum += dat; + get_len++; + if(get_len == (data_len-1)) + { + step = 3; + } + }else if(step == 3) + { + if(checksum == dat) + { + uart_protocol_process(get_buf, data_len-1); + step = 0; + sh_printf("HD ok\r\n"); + }else{ + sh_printf("HD err\r\n"); + api_send_cmd_to_handler_ack(CMD_HD_ACK, HD_NACK); + //os_printf("check failed:%d,%d,%d\n",checksum,buf[cnt],cnt); + } + step = 0; + head = 0; + } + } +} + +static void handle_parse_analysis(comm_msg_t *msg) +{ + //if(msg->dev_en == 0)return; + //if(msg->read.end_flag) + //if(msg->read.get_len != msg->read.que_len) + { + u8 get_byte; + u16 get_cnt = 0; + + msg->read.end_flag = 0; + if(msg->read.get_len == msg->read.que_len)return; + while(1) + { + get_byte = msg->read.que_buf[msg->read.get_len]; + msg->read.get_buf[get_cnt] = get_byte; + sh_printf("%02x ",get_byte); + api_comm_handle_pack_prc(get_byte); + + msg->read.get_len++; + get_cnt++; + if(get_cnt >= sizeof(msg->read.get_buf))get_cnt = 0; + if(msg->read.get_len >= msg->read.max_len)msg->read.get_len = 0; + if(msg->read.get_len == msg->read.que_len)break; + } + sh_printf("\r\n"); + } +} +void api_uart_protocol_task(void)//protocol +{ + handle_parse_analysis(&handler_msg); +} +u8 api_uart_handler_send_cmd (u8 * cmd, u8 len, u8 ack, u32 waittime) +{ + comm_pack_t *w_pack = (comm_pack_t *)&handler_msg.write; + comm_pack_t *r_pack = (comm_pack_t *)&handler_msg.read; + //sprintf(w_pack->que_buf, "%s\r\n", cmd); + handle_parse_analysis(&handler_msg); + r_pack->end_flag = 0; + r_pack->get_len = r_pack->que_len = 0; + bsp_uart_tx_string(w_pack->que_buf, len); + if(ack != HD_ACK)//??????? + { + return 1; + } + + w_pack->time_out = waittime; + while(w_pack->time_out) + { + r_pack->end_flag = 0; + while ((!r_pack->end_flag) && w_pack->time_out) + { + handle_parse_analysis(&handler_msg); + } + //memcpy(r_pack->get_buf, r_pack->que_buf, r_pack->que_len); + //r_pack->get_buf[r_pack->que_len] = '\0'; + sh_printf("end_flag:%d\n",r_pack->end_flag); + if(r_pack->end_flag == 1) + { + return 1; + } + else if(r_pack->end_flag == 0xff) + { + return 0; + } + + } + return 0; +} +u8 api_handler_send_cmd(char *cmd, u8 len) +{ + u8 fail = 4; + + while(fail--) + { + if(api_uart_handler_send_cmd((u8 *)cmd, len, HD_ACK, 100)) + { + sh_printf("HD send success\r\n"); + return 1; + } + } + sh_printf("HD send fail\r\n"); + return 0; +} +static void api_send_cmd_to_handler_ack(u8 adr, u8 ack) +{ + u8 Chksum; + u8 cmd_buf[6]; + //if(wifi_msg.wift_work_sta == E_WIFI_DISCONNECT)return; + cmd_buf[0] = SYNC_HEAD>>8; + cmd_buf[1] = SYNC_HEAD&0xff; + cmd_buf[2] = 1 + 2; + cmd_buf[3] = adr; + Chksum = (u8)(1 + 2); + Chksum += adr; + cmd_buf[4] = ack; + Chksum += ack; + cmd_buf[5] = Chksum; + bsp_uart_tx_string(cmd_buf, 6); +} +u8 api_send_cmd_to_handler(u8 adr,u8 *str,u8 len) +{ + u8 i; + u8 Chksum; + u8 *cmd_buf; + if(!handler_msg.dev_en)return 0; + cmd_buf = handler_msg.write.que_buf; + cmd_buf[0] = SYNC_HEAD>>8; + cmd_buf[1] = SYNC_HEAD&0xff; + cmd_buf[2] = len + 2; + cmd_buf[3] = adr; + Chksum = (u8)(len + 2); + Chksum += adr; + for(i=0;i max)max = Bat.ADBuffer[i]; + if(Bat.ADBuffer[i] < min)min = Bat.ADBuffer[i]; + } + return((max-min) < BAT_STABLE_VALUE); +} + +void bsp_bat_manage_task(void) +{// 50ms loop + if(Bat.ADCnt >= BAT_SAMPLE_LEN) + { + u32 bat_conv_value; + u16 bat_ave_value; + u8 i; + Bat.ADCnt = 0; + /* Calculate AD value average */ + bat_conv_value = 0; + for(i = 0; i < BAT_SAMPLE_LEN; i++) + { + bat_conv_value += Bat.ADBuffer[i]; + //sh_printf("%d,",Bat.ADBuffer[i]); + } + if(bsp_bat_stable_chk() == 0) + { + batt_printf("batt err\n"); + return; + } + //batt_printf(", tol :%d\r\n",bat_conv_value); + bat_ave_value = bat_conv_value/BAT_SAMPLE_LEN; + + Bat.bat_level = VBAT_AD_CALC_VAL(bat_ave_value); + if(abs(Bat.bat_level - Bat.bak_bat_level) > 50) + { + Bat.bak_bat_level = Bat.bat_level; + batt_printf("batt err2\n"); + return; + } + Bat.bak_bat_level = Bat.bat_level; + if(Bat.bat_level < LPWR_OFF_VBAT_VAL)Bat.bat_level = LPWR_OFF_VBAT_VAL; + if(Bat.bat_level > BAT_VOL_FULL_VAL)Bat.bat_level = BAT_VOL_FULL_VAL; + Bat.PCT = (u8)((Bat.bat_level - LPWR_OFF_VBAT_VAL)*100/(BAT_VOL_FULL_VAL-LPWR_OFF_VBAT_VAL)); + if(Bat.PCT > 100)Bat.PCT=100; + //batt_printf("BATT AD:%d,%d\r\n",Bat.bat_level,Bat.PCT); + if(Bat.WorkState == BAT_IDLE) + { + Bat.WorkState = BAT_NORMAL; + api_send_handler_sta(E_HAND_INIT_INFO);////·¢Æð¹黹 + } + if((Bat.bat_level <= LPWR_OFF_VBAT_VAL)) + { + //µç³صçѹ³¬¹ý½çÏޣ¬ÐèҪ¹رյçԴ±£»¤µç³Ø + Bat.ShutTimer = BAT_SHUT_TIMER; + if(Bat.WorkState != BAT_ERR) + { + //if(bsp_bat_stable_chk() != 0) + { + Bat.WorkState = BAT_ERR; + BattErrProcess(Bat.bat_level); + } + } + }else + { + //µç³ØÕý³£¹¤×÷ + if(Bat.WorkState != BAT_NORMAL) + { + if((Bat.bat_level > LOWBAT_VOL_RECOVER_VAL)) + { + + { + if(Bat.ShutTimer) + { + Bat.ShutTimer--; + if(Bat.ShutTimer == 0) + {//Õý³£¹¤×÷´¦Àí + Bat.WorkState = BAT_NORMAL; + BattNormalProcess(); + } + } + } + } + } + } + }else + { + Bat.ADBuffer[Bat.ADCnt]= bsp_adc_get_val(BATT_ADC_CHAN); + Bat.ADCnt++; + } +} + +void BattErrProcess(u16 BatVal) +{ + batt_printf("BattErrProcess:%d\r\n",BatVal); + batt_discharge_ctl(FALSE); +} + +void BattNormalProcess(void) +{ + batt_printf("BattNormalProcess\r\n"); +} +void batt_charging_ctl(boolean_t onf) +{//³äµç + Gpio_SetIO(0, 3, onf); +} +void batt_discharge_ctl(boolean_t onf) +{//·ŵç + Gpio_SetIO(2, 5, onf); +} +#endif +/********************************************************* + File End +*********************************************************/ diff --git a/project/custom/bsp_charge/bsp_batterymanage.h b/project/custom/bsp_charge/bsp_batterymanage.h new file mode 100644 index 0000000..1dd16fe --- /dev/null +++ b/project/custom/bsp_charge/bsp_batterymanage.h @@ -0,0 +1,69 @@ +//=========================================================================================================================== +//±¾ÎļþʵÏֵç³عÜÀíµĹ¦ÄÜ +//´´½¨Õߣºsteve +//´´½¨ÈÕÆڣº2011-02- 27 +//´´½¨°汾£ºversion-1.0 +//Ð޸ÄÈÕÆڣº +//Ð޸ÄÄÚÈݣº +//Ð޸İ汾£º +//=========================================================================================================================== +#ifndef _BATTERY_MANAGE_H +#define _BATTERY_MANAGE_H +#include +#ifdef __cplusplus +extern "C" { +#endif +#define BAT_SAMPLE_LEN 16// 800ms +//#define BATT_RELEASE +#ifdef BATT_RELEASE +#define batt_printf(format...) ((void)0) +#else +#define batt_printf(format...) sh_printf(##format) +#endif +#define VBAT_AD_CALC_VAL(vbat) (u32)(200 * MCU_AD_REF_V * 10 * vbat)/(4095) //220kÉÏÀ­£¬220KÏÂÀ­ + +#define VoltageCalcToAd(v) (u16)(v*4095/MCU_AD_REF_V)/*°ѵçѹֵ¼ÆËãת»»³É12λµÄÊýֵ*/ +#define BAT_STABLE_VALUE VoltageCalcToAd(0.1) + +#define BAT_VOL_FULL_VAL ((u16)4200) +#define LPWR_OFF_VBAT_VAL ((u16)2900) +#define LPWR_WARNING_VBAT_VAL ((u16)3200) +#define LOWBAT_VOL_RECOVER_VAL ((u16)3200) + +#define BAT_SHUT_TIMER 3// BAT_SAMPLE_LEN* BAT_SHUT_TIMER >2.1s + +typedef enum { + BAT_IDLE = 0, + BAT_NORMAL, + BAT_ERR, +}BAT_State; +#define BAT_CHK_TIMER 50 +typedef struct +{ + u32 CheckTimer; + u16 ADBuffer[BAT_SAMPLE_LEN]; + u16 ShutTimer; + u16 bat_level; + u16 bak_bat_level; + u8 PCT;//percentage + u8 ADCnt; + BAT_State WorkState; +}BatStruct; + +extern BatStruct Bat; + +void bsp_batmanage_parm_init(void); +void bsp_bat_manage_task(void); +void BattErrProcess(u16 BatVal); +void BattNormalProcess(void); +void batt_charging_ctl(boolean_t onf); +void batt_discharge_ctl(boolean_t onf); +#ifdef __cplusplus +} +#endif +#endif//_BATTERY_MANAGE_H + +/********************************************************* + File End +*********************************************************/ + diff --git a/project/custom/bsp_check/bsp_check_dev.c b/project/custom/bsp_check/bsp_check_dev.c new file mode 100644 index 0000000..e541257 --- /dev/null +++ b/project/custom/bsp_check/bsp_check_dev.c @@ -0,0 +1,18 @@ +//=========================================================================================================================== +//=========================================================================================================================== +//±¾ÎļþʵÏÖÉ豸¼ì²⹦ÄÜ +//´´½¨Õߣºsteve +//´´½¨ÈÕÆڣº2018-06- 04 +//´´½¨°汾£ºversion-1.0 +//Ð޸ÄÈÕÆڣº +//Ð޸ÄÄÚÈݣº +//Ð޸İ汾£º +//=========================================================================================================================== +#include "config.h" +void api_check_task(void) +{ + +} +/********************************************************* + File End +*********************************************************/ diff --git a/project/custom/bsp_check/bsp_check_dev.h b/project/custom/bsp_check/bsp_check_dev.h new file mode 100644 index 0000000..4bbd541 --- /dev/null +++ b/project/custom/bsp_check/bsp_check_dev.h @@ -0,0 +1,27 @@ +//=========================================================================================================================== +//±¾ÎļþʵÏÖÉ豸¼ì²⹦ÄÜ +//´´½¨Õߣºsteve +//´´½¨ÈÕÆڣº2018-06- 04 +//´´½¨°汾£ºversion-1.0 +//Ð޸ÄÈÕÆڣº +//Ð޸ÄÄÚÈݣº +//Ð޸İ汾£º +//=========================================================================================================================== +#ifndef _CHECK_DEV_H +#define _CHECK_DEV_H + + +#ifdef __cplusplus +extern "C" { +#endif + +void api_check_task(void); +#ifdef __cplusplus +} +#endif +#endif//_BATTERY_MANAGE_H + +/********************************************************* + File End +*********************************************************/ + diff --git a/project/custom/bsp_hw_mcu/bsp_adc.c b/project/custom/bsp_hw_mcu/bsp_adc.c new file mode 100644 index 0000000..584bfd0 --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_adc.c @@ -0,0 +1,145 @@ +/** + ****************************************************************************** + * Îļþ: bsp_adc.c + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: ADC ģ¿éÖмä¼þ£¬ADC ³õʼ»¯£¬Æô¶¯µȹ¦ÄÜ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "config.h" +static uint8_t u8Channel; +static uint16_t u16ScanResult[8]; +static uint8_t ad_conv_finish = 0; +void AdcContIrqCallback(void) +{ + //Öжϱê־λÅжϺÍÇåÁ㣬ÒÑÔڿ⺯ÊýÖд¦ÀíAdc_IRQHandler(); + + for (u8Channel = 0; u8Channel < 8; u8Channel++) + { + Adc_GetScanResult(u8Channel, &u16ScanResult[u8Channel]); + } + ad_conv_finish = 1; + // Adc_ClrContIrqState(); +} +void AdcRegIrqCallback(void) +{ + // Öжϱê־λÅжϺÍÇåÁ㣬ÒÑÔڿ⺯ÊýÖд¦ÀíAdc_IRQHandler(); + + + // Adc_ClrRegIrqState(); +} + +void AdcHhtIrqCallback(void) +{ + // Öжϱê־λÅжϺÍÇåÁ㣬ÒÑÔڿ⺯ÊýÖд¦ÀíAdc_IRQHandler(); + + // Adc_ClrHhtIrqState(); +} + +void AdcLltIrqCallback(void) +{ + // Öжϱê־λÅжϺÍÇåÁ㣬ÒÑÔڿ⺯ÊýÖд¦ÀíAdc_IRQHandler(); + + + // Adc_ClrLltIrqState(); +} + +/** + * ÃèÊö: ³õʼ»¯ËùÓÐÓõ½µÄADC + * ²ÎÊý: ÎÞ + * ·µ»Ø: ÎÞ + */ +void bsp_adc_cfg(void) +{ + stc_adc_cfg_t stcAdcCfg; + stc_adc_scan_cfg_t stcAdcScanCfg; + stc_adc_irq_t stcAdcIrq; + stc_adc_irq_calbakfn_pt_t stcAdcIrqCalbaks; + + DDL_ZERO_STRUCT(stcAdcCfg); + DDL_ZERO_STRUCT(stcAdcScanCfg); + DDL_ZERO_STRUCT(stcAdcIrq); + DDL_ZERO_STRUCT(stcAdcIrqCalbaks); + + //Clk_SwitchTo(ClkRCL); + //Clk_SetRCHFreq(ClkFreq24Mhz); + //Clk_SwitchTo(ClkRCH); + + Clk_SetPeripheralGate(ClkPeripheralGpio, TRUE); //GPIO ÍâÉèʱÖÓʹÄÜ + + + if (Ok != Clk_SetPeripheralGate(ClkPeripheralAdcBgr, TRUE)) //ADCBGR ÍâÉèʱÖÓʹÄÜ + { + return; + } + //³õʼ»¯ÍⲿGPIO P03ΪÊä³ö¡¢ÉÏÀ­¡¢¿ª©£¬ + Gpio_InitIOExt(2, 4, GpioDirIn, TRUE, FALSE, TRUE, FALSE); + Gpio_InitIOExt(2, 6, GpioDirIn, TRUE, FALSE, TRUE, FALSE); + Gpio_SetAnalog(2, 4, TRUE);//AIN0 + Gpio_SetAnalog(2, 6, TRUE);//AIN1 + //Gpio_SetAnalog(3, 4, TRUE);//AIN4 + + + Adc_Enable(); + M0P_BGR->CR_f.BGR_EN = 0x1u; //BGR±ØÐëʹÄÜ + M0P_BGR->CR_f.TS_EN = 0x0u; //ÄÚÖÃζȴ«¸ÐÆ÷£¬ÊÓʹÓÃÐèÇó + delay100us(1); + + stcAdcCfg.enAdcOpMode = AdcScanMode; //ɨÃè²ÉÑùģʽ + stcAdcCfg.enAdcClkSel = AdcClkSysTDiv1; //PCLK + stcAdcCfg.enAdcSampTimeSel = AdcSampTime8Clk; //8¸ö²ÉÑùʱÖÓ + stcAdcCfg.enAdcRefVolSel = RefVolSelInBgr2p5; //²ο¼µçѹ:Äڲ¿2.5V(avdd>3V,SPS<=200kHz) + //stcAdcCfg.enAdcRefVolSel = RefVolSelAVDD; //²ο¼µçѹ:AVDD + //stcAdcCfg.bAdcInBufEn = FALSE; //µçѹ¸úËæÆ÷Èç¹ûʹÄܣ¬SPS²ÉÑùËÙÂÊ <=200K + stcAdcCfg.bAdcInBufEn = TRUE; //µçѹ¸úËæÆ÷Èç¹ûʹÄܣ¬SPS²ÉÑùËÙÂÊ <=200K + + stcAdcCfg.enAdcTrig0Sel = AdcTrigDisable; //ADCת»»×Զ¯´¥·¢ÉèÖà + stcAdcCfg.enAdcTrig1Sel = AdcTrigDisable; + Adc_Init(&stcAdcCfg); + + stcAdcIrq.bAdcIrq = TRUE; //ת»»Íê³ÉÖжϺ¯ÊýÈë¿ÚÅäÖÃʹÄÜ + stcAdcIrq.bAdcRegCmp = FALSE; + stcAdcIrq.bAdcHhtCmp = FALSE; + stcAdcIrq.bAdcLltCmp = FALSE; + stcAdcIrqCalbaks.pfnAdcContIrq = AdcContIrqCallback; //ת»»Íê³ÉÖжÏÈë¿ں¯Êý + stcAdcIrqCalbaks.pfnAdcRegIrq = AdcRegIrqCallback; + stcAdcIrqCalbaks.pfnAdcHhtIrq = AdcHhtIrqCallback; + stcAdcIrqCalbaks.pfnAdcLltIrq = AdcLltIrqCallback; + Adc_ConfigIrq(&stcAdcIrq, &stcAdcIrqCalbaks); //ת»»ÖжÏÈë¿ں¯ÊýÅäÖà + Adc_EnableIrq(); //ÖжÏʹÄÜ + Adc_CmpCfg(&stcAdcIrq); //½á¹û±ȽÏÖжÏʹÄÜ/½ûֹÅäÖà + + stcAdcScanCfg.u8AdcScanModeCh = ADC_SCAN_CH0_EN + | ADC_SCAN_CH1_EN; + //| ADC_SCAN_CH4_EN; + + stcAdcScanCfg.u8AdcSampCnt = 0x1; //Á¬ÐøɨÃèת»»´ÎÊý£¬±£³ÖͨµÀµı¶Êý£¬6ͨµÀ = 0x5+1(1±¶)£¬»òÕß11+1(2±¶)¡­¡­ + Adc_ConfigScanMode(&stcAdcCfg, &stcAdcScanCfg); + Adc_Start(); +} +/** + * ÃèÊö: ADC + * ²ÎÊý: ÎÞ + * ·µ»Ø: ÎÞ + */ +u16 bsp_adc_get_val(u8 ch) +{ + u16 get_ad; + if(ad_conv_finish) + { + ad_conv_finish = 0; + Adc_Start(); + } + __disable_irq(); + get_ad = u16ScanResult[ch]; + __enable_irq(); + return get_ad; +} +/************************************************************************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_adc.h b/project/custom/bsp_hw_mcu/bsp_adc.h new file mode 100644 index 0000000..cbd4d0a --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_adc.h @@ -0,0 +1,34 @@ +/** + ****************************************************************************** + * Îļþ: bsp_adc.h + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: ADC Öмä¼þͷÎļþ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* ·Àֹµݹé°üº¬¸ÃͷÎļþ ------------------------------------------------------*/ +#ifndef __BSP_ADC_H +#define __BSP_ADC_H + +#ifdef __cplusplus + extern "C" { +#endif + +#define ADC_VOLAGE_TO_VALUE_CAL(volage) ((u16)((volage/MCU_AD_REF_V)*4096)) +#define ADC_VALUE_TO_VOLAGE_CAL(value) (value*MCU_AD_REF_V)/4096 +void bsp_adc_cfg(void); +u16 bsp_adc_get_val(u8 ch); +#ifdef __cplusplus +} +#endif + + +#endif /* __DRV_ADC_H */ + +/************************************************************************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_clk.c b/project/custom/bsp_hw_mcu/bsp_clk.c new file mode 100644 index 0000000..9e90923 --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_clk.c @@ -0,0 +1,41 @@ +/** + ****************************************************************************** + * Îļþ: drv_iwdg.c + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: IWDG Öмä¼þ£¬³õʼ»¯ IWDG + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "config.h" + +/** + * ÃèÊö: ³õʼ»¯ IWDG£¬ÉèÖà IWDG Ԥ·ÖƵºÍÖØÔØֵ + * ²ÎÊý: iwdg_prescaler: IWDG Ԥ·ÖƵ + * time_out_ms: IWDG ³¬ʱʱ¼䣬µ¥λΪºÁÃë + * ·µ»Ø: ÎÞ + */ +void bsp_clk_cfg(void) +{ + u32 u32Val; + stc_clk_systickcfg_t stcCfg; + //RCH 24MHz + Clk_SwitchTo(ClkRCL); + Clk_SetRCHFreq(MCU_CLK_SEL); + Clk_SwitchTo(ClkRCH); + u32Val = Clk_GetHClkFreq(); + DDL_ZERO_STRUCT(stcCfg); + stcCfg.enClk = ClkRCH; //hclk/8 + stcCfg.u32LoadVal = (SystemCoreClock/1000); //1ms + Clk_SysTickConfig(&stcCfg); + SysTick_Config(stcCfg.u32LoadVal); + +} + +/*************************************************************************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_clk.h b/project/custom/bsp_hw_mcu/bsp_clk.h new file mode 100644 index 0000000..1e082c1 --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_clk.h @@ -0,0 +1,33 @@ +/** + ****************************************************************************** + * Îļþ: bsp_iwdg.h + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: IWDG Öмä¼þͷÎļþ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* ·Àֹµݹé°üº¬¸ÃͷÎļþ ------------------------------------------------------*/ +#ifndef __BSP_CLK_H__ +#define __BSP_CLK_H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ + +void bsp_clk_cfg(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __BSP_CLK_H__ */ + +/****************************** ************************** *****************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_exti.c b/project/custom/bsp_hw_mcu/bsp_exti.c new file mode 100644 index 0000000..4972bcc --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_exti.c @@ -0,0 +1,20 @@ +/** + ****************************************************************************** + * Îļþ: bsp_exti.c + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: EXTI Öмä¼þ£¬ÅäÖà EXTI + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "config.h" + + + +/*************************************************************************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_exti.h b/project/custom/bsp_hw_mcu/bsp_exti.h new file mode 100644 index 0000000..b42d33d --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_exti.h @@ -0,0 +1,33 @@ +/** + ****************************************************************************** + * Îļþ: bsp_exti.h + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: ÍⲿÖжÏ(EXTI)Öмä¼þͷÎļþ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* ·Àֹµݹé°üº¬¸ÃͷÎļþ ------------------------------------------------------*/ +#ifndef __BSP_EXTI_H__ +#define __BSP_EXTI_H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ + + + +#ifdef __cplusplus +} +#endif + +#endif /* __BSP_EXTI_H__ */ + +/*************************************************************************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_gpio.c b/project/custom/bsp_hw_mcu/bsp_gpio.c new file mode 100644 index 0000000..dc3163b --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_gpio.c @@ -0,0 +1,39 @@ +/** + ****************************************************************************** + * Îļþ: bsp_gpio.c + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: GPIO ģ¿éÖмä¼þ²㣬³õʼ»¯¸÷¸ö¹¦ÄÜģ¿éÓõ½µÄ GPIO£¬Èç LED£¬´®¿ڵÈ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "config.h" +void bsp_gpio_38kout_init(void) +{ + M0P_GPIO->P23_SEL_f.SEL = 7; +} +void bsp_gpio_cfg(void) +{ +#if MCU_OUT_38K_PWM_EN + bsp_gpio_38kout_init(); +#endif + //GPIOÊä³ö + //³õʼ»¯ÍⲿGPIO P03ΪÊä³ö¡¢ÉÏÀ­¡¢ÍÆÍìÊä³ö£¬P03¶˿ڳäµç¿ØÖÆ + Gpio_InitIOExt(0, 3, GpioDirOut, TRUE, FALSE, FALSE, FALSE); + //³õʼ»¯ÍⲿGPIO P25ΪÊä³ö¡¢ÉÏÀ­¡¢ÍÆÍìÊä³ö£¬P23¶˿ڳäµçICµÄKEY¿ØÖÆ + Gpio_InitIOExt(2, 5, GpioDirOut, TRUE, FALSE, FALSE, FALSE); + batt_charging_ctl(TRUE); + batt_discharge_ctl(FALSE); + //Gpio_InitIOExt(2, 4, GpioDirOut, TRUE, FALSE, FALSE, FALSE); +} + + + + +/*************************************************************************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_gpio.h b/project/custom/bsp_hw_mcu/bsp_gpio.h new file mode 100644 index 0000000..211042c --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_gpio.h @@ -0,0 +1,32 @@ +/** + ****************************************************************************** + * Îļþ: bsp_gpio.h + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: GPIO Öмä¼þͷÎļþ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* ·Àֹµݹé°üº¬¸ÃͷÎļþ ------------------------------------------------------*/ +#ifndef __BSP_GPIO_H__ +#define __BSP_GPIO_H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +void bsp_gpio_cfg(void); +#ifdef __cplusplus +} +#endif + + +#endif /* __DRV_GPIO_H */ + +/*************************************************************************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_iwdg.c b/project/custom/bsp_hw_mcu/bsp_iwdg.c new file mode 100644 index 0000000..64856a5 --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_iwdg.c @@ -0,0 +1,54 @@ +/** + ****************************************************************************** + * Îļþ: drv_iwdg.c + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: IWDG Öмä¼þ£¬³õʼ»¯ IWDG + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "config.h" +static void WdtCallback(void) +{ + // comment following to demonstrate the hardware watchdog reset +} +/** + * ÃèÊö: ³õʼ»¯ IWDG£¬ÉèÖà IWDG Ԥ·ÖƵºÍÖØÔØֵ + * ²ÎÊý: iwdg_prescaler: IWDG Ԥ·ÖƵ + * time_out_ms: IWDG ³¬ʱʱ¼䣬µ¥λΪºÁÃë + * ·µ»Ø: ÎÞ + */ +void bsp_iwdg_cfg(void) +{ + stc_wdt_config_t stcWdt_Config; + stc_lpm_config_t stcLpmCfg; + + DDL_ZERO_STRUCT(stcWdt_Config); + DDL_ZERO_STRUCT(stcLpmCfg); + + stcLpmCfg.enSLEEPDEEP = SlpDpDisable;//SlpDpEnable; + stcLpmCfg.enSLEEPONEXIT = SlpExtEnable; + + + stcWdt_Config.u8LoadValue = 0x0b;//3.2s + stcWdt_Config.enResetEnable = WINT_EN;//WRESET_EN;//// + stcWdt_Config.pfnWdtIrqCb = WdtCallback; + + Clk_SetPeripheralGate(ClkPeripheralWdt,TRUE);// + Wdt_Init(&stcWdt_Config); + + Wdt_Start(); +#if 0 + while(1 == Gpio_GetIO(3,3));//??:??????????????,?????? + Lpm_Config(&stcLpmCfg); + Lpm_GotoLpmMode(); +#endif +} + +/*************************************************************************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_iwdg.h b/project/custom/bsp_hw_mcu/bsp_iwdg.h new file mode 100644 index 0000000..d438df1 --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_iwdg.h @@ -0,0 +1,33 @@ +/** + ****************************************************************************** + * Îļþ: bsp_iwdg.h + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: IWDG Öмä¼þͷÎļþ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* ·Àֹµݹé°üº¬¸ÃͷÎļþ ------------------------------------------------------*/ +#ifndef __BSP_IWDG_H__ +#define __BSP_IWDG_H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ + +void bsp_iwdg_cfg(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __BSP_IWDG_H__ */ + +/****************************** ************************** *****************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_mcu_id.c b/project/custom/bsp_hw_mcu/bsp_mcu_id.c new file mode 100644 index 0000000..ee17ac7 --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_mcu_id.c @@ -0,0 +1,57 @@ +/** + ****************************************************************************** + * Îļþ: bsp_mcu_id.c + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: ʱÖÓ (RCC) ģ¿éÖмä¼þ²㣬ʵÏָ÷¸ö¹¦ÄÜģ¿éµÄʱÖӳõʼ»¯¹¤×÷ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "config.h" +uint32_t idAddr[]={ + 0x00100e74,/*HC32F0ΨһIDÆðʼµØַ*/ + 0x1FFFF7E8,/*STM32F1ΨһIDÆðʼµØַ*/ + 0x1FFF7A10,/*STM32F2ΨһIDÆðʼµØַ*/ + 0x1FFFF7AC,/*STM32F3ΨһIDÆðʼµØַ*/ + 0x1FFF7A10,/*STM32F4ΨһIDÆðʼµØַ*/ + 0x1FF0F420,/*STM32F7ΨһIDÆðʼµØַ*/ + 0x1FF80050,/*STM32L0ΨһIDÆðʼµØַ*/ + 0x1FF80050,/*STM32L1ΨһIDÆðʼµØַ*/ + 0x1FFF7590,/*STM32L4ΨһIDÆðʼµØַ*/ + 0x1FF0F420 +}; /*STM32H7ΨһIDÆðʼµØַ*/ +/*»ñȡMCUµÄΨһID*/ +void GetSTM32MCUID(uint32_t *id,MCUTypedef type) +{ + if(id!=NULL) + { + id[0]=*(uint32_t*)(idAddr[type]); + id[1]=*(uint32_t*)(idAddr[type]+4); + id[2]=*(uint32_t*)(idAddr[type]+8); + } +} +/* + * º¯ÊýÃû£ºGet_ChipID + * ÃèÊö £º»ñȡоƬID + * ÊäÈë £ºÎÞ + * Êä³ö £ºÎÞ ffff0d5214130000007171b9 + */ +void Get_ChipID(void) +{ + u32 CpuID[3]; + u8 i; + GetSTM32MCUID(CpuID, HC32F0); + memcpy(shared.handler.No, &CpuID[0], sizeof(shared.handler.No)); + for(i=0; i< 3; i++) + { + sh_printf("%08x",CpuID[i]); + } + sh_printf("\r\n"); +} +/*************************************************************************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_mcu_id.h b/project/custom/bsp_hw_mcu/bsp_mcu_id.h new file mode 100644 index 0000000..78365d8 --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_mcu_id.h @@ -0,0 +1,44 @@ +/** + ****************************************************************************** + * Îļþ: bsp_mcu_id.h + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: ͷÎļþ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* ·Àֹµݹé°üº¬¸ÃͷÎļþ ------------------------------------------------------*/ +#ifndef __BSP_MCU_ID_H__ +#define __BSP_MCU_ID_H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/*¶¨ÒåSTM32 MCUµÄÀàÐÍ*/ +typedef enum { + HC32F0, + STM32F1, + STM32F2, + STM32F3, + STM32F4, + STM32F7, + STM32L0, + STM32L1, + STM32L4, + STM32H7, +}MCUTypedef; +extern void Get_ChipID(void); +#ifdef __cplusplus +} +#endif + + +#endif /* __BSP_MCU_ID_H__ */ + +/*************************************************************************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_mcu_include.h b/project/custom/bsp_hw_mcu/bsp_mcu_include.h new file mode 100644 index 0000000..7f42aef --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_mcu_include.h @@ -0,0 +1,36 @@ +/** + ****************************************************************************** + * Îļþ: drv_usart.h + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: ´®¿ÚÖмä¼þͷÎļþ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* ·Àֹµݹé°üº¬¸ÃͷÎļþ ------------------------------------------------------*/ +#ifndef __BSP_MCU_INCLUDE_H +#define __BSP_MCU_INCLUDE_H +#include "bsp_adc.h" +#include "bsp_exti.h" +#include "bsp_gpio.h" +#include "bsp_iwdg.h" +#include "bsp_usart.h" +#include "bsp_clk.h" +#include "bsp_mcu_id.h" +#ifdef __cplusplus + extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + + +#endif /* __BSP_MCU_INCLUDE_H */ + +/*************************************************************************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_usart.c b/project/custom/bsp_hw_mcu/bsp_usart.c new file mode 100644 index 0000000..cc9fa2c --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_usart.c @@ -0,0 +1,191 @@ +/** + ****************************************************************************** + * Îļþ: bsp_usart.c + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: ´®¿ÚÖмä¼þ£¬ÅäÖô®¿Ú + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "config.h" + +void RxIntCallback(void) +{ + u8 rx = M0P_UART0->SBUF; + //u8 rx = M0P_UART1->SBUF; + handler_msg.read.que_buf[handler_msg.read.que_len] = rx; + handler_msg.read.que_len++; + if(handler_msg.read.que_len >= handler_msg.read.max_len) + { + handler_msg.read.que_len = 0; + } + if(rx == 0xff) + { + handler_msg.read.end_flag = 1; + } + +} +void ErrIntCallback(void) +{ + +} +/** + * ÃèÊö: Ï򴮿ڷ¢ËÍһ¸ö×ַû + * ²ÎÊý: ch: ½«Ҫ·¢Ë͵Ä×ַû + * ·µ»Ø: ÎÞ + */ +void bsp_usart_send_byte(uint8_t ch) +{ + Uart_SendData(UARTCH0,ch); +} + +void bsp_uart_tx_string(u8 *buf, u8 len) +{ + while(len--) + { + bsp_usart_send_byte(*buf++); + } +} +void bsp_usart0_cfg(void) +{ + uint16_t timer=0; + uint32_t pclk=0; + stc_uart_config_t stcConfig; + stc_uart_irq_cb_t stcUartIrqCb; + stc_uart_multimode_t stcMulti; + stc_uart_baud_config_t stcBaud; + stc_bt_config_t stcBtConfig; + + + DDL_ZERO_STRUCT(stcUartIrqCb); + DDL_ZERO_STRUCT(stcMulti); + DDL_ZERO_STRUCT(stcBaud); + DDL_ZERO_STRUCT(stcBtConfig); + //p14 uart0-tx p15 uart0-rx + Gpio_InitIOExt(1,4,GpioDirOut,TRUE,FALSE,TRUE,FALSE); + Gpio_InitIOExt(1,5,GpioDirOut,TRUE,FALSE,TRUE,FALSE); + //Gpio_InitIOExt(1,4,GpioDirOut,TRUE,FALSE,FALSE,FALSE); + //Gpio_InitIOExt(1,5,GpioDirOut,TRUE,FALSE,FALSE,FALSE); + //ͨµÀ¶˿ÚÅäÖà + Gpio_SetFunc_UART0TX_P14(); + Gpio_SetFunc_UART0RX_P15(); + + //ÍâÉèʱÖÓʹÄÜ + Clk_SetPeripheralGate(ClkPeripheralBt,TRUE);//ģʽ0/2¿ÉÒԲ»ʹÄÜ + Clk_SetPeripheralGate(ClkPeripheralUart0,TRUE); + + stcUartIrqCb.pfnRxIrqCb = RxIntCallback; + stcUartIrqCb.pfnTxIrqCb = NULL; + stcUartIrqCb.pfnRxErrIrqCb = ErrIntCallback; + stcConfig.pstcIrqCb = &stcUartIrqCb; + stcConfig.bTouchNvic = TRUE; + + + stcConfig.enRunMode = UartMode1;//²âÊÔÏ¸ü¸Ĵ˴¦À´ת»»4ÖÖģʽ²âÊÔ + + + stcMulti.enMulti_mode = UartNormal;//²âÊÔÏ¸ü¸Ĵ˴¦À´ת»»¶àÖ÷»úģʽ£¬mode2/3²ÅÓжàÖ÷»úģʽ + + stcConfig.pstcMultiMode = &stcMulti; + + stcBaud.bDbaud = 0u;//˫±¶²¨ÌØÂʹ¦ÄÜ + stcBaud.u32Baud = MCU_UART_BAUD;//¸üв¨ÌØÂÊλÖà + stcBaud.u8Mode = UartMode1; //¼ÆË㲨ÌØÂÊÐèҪģʽ²ÎÊý + pclk = Clk_GetPClkFreq(); + timer=Uart_SetBaudRate(UARTCH0,pclk,&stcBaud); + + stcBtConfig.enMD = BtMode2; + stcBtConfig.enCT = BtTimer; + Bt_Init(TIM0, &stcBtConfig);//µ÷ÓÃbasetimer1ÉèÖú¯Êý²úÉú²¨ÌØÂÊ + Bt_ARRSet(TIM0,timer); + Bt_Cnt16Set(TIM0,timer); + Bt_Run(TIM0); + + Uart_Init(UARTCH0, &stcConfig); + Uart_EnableIrq(UARTCH0,UartRxIrq); + Uart_ClrStatus(UARTCH0,UartRxFull); + Uart_EnableFunc(UARTCH0,UartRx); +} +void bsp_usart1_cfg(void) +{ + uint16_t timer=0; + uint32_t pclk=0; + stc_uart_config_t stcConfig; + stc_uart_irq_cb_t stcUartIrqCb; + stc_uart_multimode_t stcMulti; + stc_uart_baud_config_t stcBaud; + stc_bt_config_t stcBtConfig; + + + DDL_ZERO_STRUCT(stcUartIrqCb); + DDL_ZERO_STRUCT(stcMulti); + DDL_ZERO_STRUCT(stcBaud); + DDL_ZERO_STRUCT(stcBtConfig); + //p32 uart1-tx p33 uart1-rx + Gpio_InitIOExt(3,2,GpioDirOut,TRUE,FALSE,FALSE,FALSE); + Gpio_InitIOExt(3,3,GpioDirOut,TRUE,FALSE,FALSE,FALSE); + + //ͨµÀ¶˿ÚÅäÖà + Gpio_SetFunc_UART1TX_P32(); + Gpio_SetFunc_UART1RX_P33(); + + //ÍâÉèʱÖÓʹÄÜ + Clk_SetPeripheralGate(ClkPeripheralBt,TRUE);//ģʽ0/2¿ÉÒԲ»ʹÄÜ + Clk_SetPeripheralGate(ClkPeripheralUart1,TRUE); + + + + stcUartIrqCb.pfnRxIrqCb = RxIntCallback; + stcUartIrqCb.pfnTxIrqCb = NULL; + stcUartIrqCb.pfnRxErrIrqCb = ErrIntCallback; + stcConfig.pstcIrqCb = &stcUartIrqCb; + stcConfig.bTouchNvic = TRUE; + + + stcConfig.enRunMode = UartMode1;//²âÊÔÏ¸ü¸Ĵ˴¦À´ת»»4ÖÖģʽ²âÊÔ + + + stcMulti.enMulti_mode = UartNormal;//²âÊÔÏ¸ü¸Ĵ˴¦À´ת»»¶àÖ÷»úģʽ£¬mode2/3²ÅÓжàÖ÷»úģʽ + + stcConfig.pstcMultiMode = &stcMulti; + + stcBaud.bDbaud = 0u;//˫±¶²¨ÌØÂʹ¦ÄÜ + stcBaud.u32Baud = MCU_UART_BAUD;//¸üв¨ÌØÂÊλÖà //4m + stcBaud.u8Mode = UartMode1; //¼ÆË㲨ÌØÂÊÐèҪģʽ²ÎÊý + pclk = Clk_GetPClkFreq(); + timer=Uart_SetBaudRate(UARTCH1,pclk,&stcBaud); + + stcBtConfig.enMD = BtMode2; + stcBtConfig.enCT = BtTimer; + Bt_Init(TIM1, &stcBtConfig);//µ÷ÓÃbasetimer1ÉèÖú¯Êý²úÉú²¨ÌØÂÊ + Bt_ARRSet(TIM1,timer); + Bt_Cnt16Set(TIM1,timer); + Bt_Run(TIM1); + + Uart_Init(UARTCH1, &stcConfig); + //Uart_EnableIrq(UARTCH1,UartRxIrq); + Uart_DisableIrq(UARTCH1,UartRxIrq); + //Uart_ClrStatus(UARTCH1,UartRxFull); + //Uart_EnableFunc(UARTCH1,UartRx); +} +/** + * ÃèÊö: ³õʼ»¯´®¿Ú + * ²ÎÊý: ÎÞ + * ·µ»Ø: ÎÞ + */ +void bsp_usart_cfg(void) +{ + bsp_usart0_cfg(); +#ifdef SH_DEBUG + bsp_usart1_cfg(); +#endif + sh_printf("bsp_usart_cfg\r\n"); +} + +/*************************************************************************************/ diff --git a/project/custom/bsp_hw_mcu/bsp_usart.h b/project/custom/bsp_hw_mcu/bsp_usart.h new file mode 100644 index 0000000..8656a49 --- /dev/null +++ b/project/custom/bsp_hw_mcu/bsp_usart.h @@ -0,0 +1,41 @@ +/** + ****************************************************************************** + * Îļþ: bsp_usart.h + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: ´®¿ÚÖмä¼þͷÎļþ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* ·Àֹµݹé°üº¬¸ÃͷÎļþ ------------------------------------------------------*/ +#ifndef __BSP_USART_H__ +#define __DRV_USART_H + +#ifdef __cplusplus + extern "C" { +#endif + +#define T1_PORT (3) +#define T1_PIN (3) + +/* Includes ------------------------------------------------------------------*/ + +void bsp_usart_cfg(void); +void bsp_usart_send_byte(uint8_t ch); +uint16_t bsp_usart_receive_char(void); +void bsp_uart_tx_string(u8 *buf, u8 len); + + +#ifdef __cplusplus +} +#endif + + +#endif /* __DRV_USART_H */ + +/*************************************************************************************/ diff --git a/project/custom/cfg_board/cfg_board.h b/project/custom/cfg_board/cfg_board.h new file mode 100644 index 0000000..1a631bf --- /dev/null +++ b/project/custom/cfg_board/cfg_board.h @@ -0,0 +1,32 @@ +/** + ****************************************************************************** + * Îļþ: app_board.h + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: ¿ª·¢°åÏà¹ØÅäÖà + ****************************************************************************** + * + * °æȨËùÓÐ (C), steve + * + * + ****************************************************************************** + */ + +/* ·Àֹµݹé°üº¬¸ÃͷÎļþ ------------------------------------------------------*/ +#ifndef __CFG_BOARD_H__ +#define __CFG_BOARD_H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "cfg_board_shared_pwr_bank.h" + +#ifdef __cplusplus +} +#endif + +#endif /* __CFG_BOARD_H__ */ + +/*************************************************************************************/ diff --git a/project/custom/cfg_board/cfg_board_shared_pwr_bank.h b/project/custom/cfg_board/cfg_board_shared_pwr_bank.h new file mode 100644 index 0000000..0c37e35 --- /dev/null +++ b/project/custom/cfg_board/cfg_board_shared_pwr_bank.h @@ -0,0 +1,29 @@ +/** + ****************************************************************************** + * Îļþ:app_board_haier.h + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: º£¶ûɨµػúÏà¹ØÅäÖà + ****************************************************************************** + * + * °æȨËùÓÐ (C), steve + * + * + ****************************************************************************** + */ + +/* ·Àֹµݹé°üº¬¸ÃͷÎļþ ------------------------------------------------------*/ +#ifndef __CFG_BOARD_PWR_BANK_H__ +#define __CFG_BOARD_PWR_BANK_H__ + +#ifdef __cplusplus + extern "C" { +#endif +#define BATT_ADC_CHAN 1 +#ifdef __cplusplus +} +#endif + +#endif /* __CFG_BOARD_PWR_BANK_H__ */ + +/*************************************************************************************/ diff --git a/project/custom/config.h b/project/custom/config.h new file mode 100644 index 0000000..78f82a9 --- /dev/null +++ b/project/custom/config.h @@ -0,0 +1,69 @@ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __CONFIG_H_ +#define __CONFIG_H_ + +#ifdef __cplusplus + extern "C" { +#endif +/* +********************************************************************************************************* +* ±ê׼¿â +********************************************************************************************************* +*/ +#include +#include +#include +#include +#include + +/* +********************************************************************************************************* +* OS +********************************************************************************************************* +*/ + +/* +********************************************************************************************************* +* ÆäËü¿â +********************************************************************************************************* +*/ +#include "hc32fxxx.h" +#include "typedef.h" +#include "./cfg_board/cfg_board.h" +#include "./systick/api_sys_timer.h" +#include "./api_uart_protocol/api_uart_protocol.h" +#include "./bsp_hw_mcu/bsp_mcu_include.h" +#include "./shared_power_handler/api_shared_pwr_handler.h" +#include "./lock/app_lock.h" +#include "./bsp_charge/bsp_batterymanage.h" +/* +********************************************************************************************************* +* º궨Òå +********************************************************************************************************* +*/ + + +#define SH_DEBUG +#ifdef SH_DEBUG +#define sh_printf printf +#else +#define sh_printf(...) +#endif + +#define CHK_BATT_EN 1 +#define MCU_OUT_38K_PWM_EN 0 +#define MCU_CLK_SEL ClkFreq4Mhz +#define MCU_UART_BAUD 9600 //4MHZ MAX 9600 +#define MCU_AD_REF_V 2.5 +/* +********************************************************************************************************* +* APP / BSP +********************************************************************************************************* +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* __CONFIG_H_ */ diff --git a/project/custom/hc32fxxx.h b/project/custom/hc32fxxx.h new file mode 100644 index 0000000..bac6da4 --- /dev/null +++ b/project/custom/hc32fxxx.h @@ -0,0 +1,27 @@ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __HC32FXXX_H_ +#define __HC32FXXX_H_ + +#ifdef __cplusplus + extern "C" { +#endif +#include "ddl.h" +#include "uart.h" +#include "bt.h" +#include "lpm.h" +#include "gpio.h" +#include "wdt.h" +#include "clk.h" +#include "adc.h" +/* +********************************************************************************************************* +* APP / BSP +********************************************************************************************************* +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* __HC32FXXX_H_ */ diff --git a/project/custom/lock/app_lock.c b/project/custom/lock/app_lock.c new file mode 100644 index 0000000..700e387 --- /dev/null +++ b/project/custom/lock/app_lock.c @@ -0,0 +1,79 @@ +/** + ****************************************************************************** + * Îļþ: app_syspower.c + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: ϵͳµçԴÖмä¼þ£¬ʵÏÖϵͳµçԴ¿ØÖÆAPI + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "config.h" + +void api_lock_handler_init(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + /*Configure GPIO pin Output Level */ + GPIO_WriteBit(GPIOB, GPIO_Pin_9|GPIO_Pin_8|GPIO_Pin_7|GPIO_Pin_6|GPIO_Pin_5, Bit_RESET); + /* Configure pins */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9|GPIO_Pin_8|GPIO_Pin_7|GPIO_Pin_6|GPIO_Pin_5; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; + GPIO_Init(GPIOB, &GPIO_InitStructure); + + /*Configure GPIO pin Output Level */ + GPIO_WriteBit(GPIOC, GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15, Bit_RESET); + /* Configure pins */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; + GPIO_Init(GPIOC, &GPIO_InitStructure); + +} + +void api_lock_handler_ctl(u8 index, u8 onf) +{ + if(index == 0) + { + if(onf == 0) + { + GPIO_WriteBit(GPIOC, GPIO_Pin_15, Bit_RESET); + }else{ + GPIO_WriteBit(GPIOC, GPIO_Pin_15, Bit_SET); + } + }else if(index == 1) + { + if(onf == 0) + { + GPIO_WriteBit(GPIOC, GPIO_Pin_14, Bit_RESET); + }else{ + GPIO_WriteBit(GPIOC, GPIO_Pin_14, Bit_SET); + } + }else if(index == 2) + { + if(onf == 0) + { + GPIO_WriteBit(GPIOC, GPIO_Pin_13, Bit_RESET); + }else{ + GPIO_WriteBit(GPIOC, GPIO_Pin_13, Bit_SET); + } + }else if(index == 3) + { + if(onf == 0) + { + GPIO_WriteBit(GPIOB, GPIO_Pin_9, Bit_RESET); + }else{ + GPIO_WriteBit(GPIOB, GPIO_Pin_9, Bit_SET); + } + } +} +/*************************************************************************************/ diff --git a/project/custom/lock/app_lock.h b/project/custom/lock/app_lock.h new file mode 100644 index 0000000..866f2f8 --- /dev/null +++ b/project/custom/lock/app_lock.h @@ -0,0 +1,35 @@ +/** + ****************************************************************************** + * Îļþ: app_syspower.h + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: ϵͳµçԴÖмä¼þͷÎļþ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* ·Àֹµݹé°üº¬¸ÃͷÎļþ ------------------------------------------------------*/ +#ifndef __APP_LOCK_H +#define __APP_LOCK_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +void api_lock_handler_init(void); + +void api_lock_handler_ctl(u8 index, u8 onf); + +#ifdef __cplusplus +} +#endif + + +#endif /* __APP_LOCK_H */ + +/*************************************************************************************/ diff --git a/project/custom/shared_power_handler/api_shared_pwr_handler.c b/project/custom/shared_power_handler/api_shared_pwr_handler.c new file mode 100644 index 0000000..b8fc94d --- /dev/null +++ b/project/custom/shared_power_handler/api_shared_pwr_handler.c @@ -0,0 +1,23 @@ +//=========================================================================================================================== +//±¾ÎļþʵÏֵç³عÜÀíµĹ¦ÄÜ +//´´½¨Õߣºsteve +//´´½¨ÈÕÆڣº2014-05-10 +//´´½¨°汾£ºversion-1.0 +//Ð޸ÄÈÕÆڣº +//Ð޸ÄÄÚÈݣº +//Ð޸İ汾£º +//=========================================================================================================================== +#include "config.h" +stSharedDevInfo shared; +void api_shared_hand_msg_task(void) +{ + if(handler_msg.bat_report_notify) + { + sh_printf("bat_report_notify:%d\n",handler_msg.bat_report_notify); + api_send_handler_sta(handler_msg.bat_report_notify); + handler_msg.bat_report_notify = 0; + } +} +/********************************************************* + File End +*********************************************************/ diff --git a/project/custom/shared_power_handler/api_shared_pwr_handler.h b/project/custom/shared_power_handler/api_shared_pwr_handler.h new file mode 100644 index 0000000..7123f34 --- /dev/null +++ b/project/custom/shared_power_handler/api_shared_pwr_handler.h @@ -0,0 +1,42 @@ +//=========================================================================================================================== +//±¾ÎļþʵÏֵç³عÜÀíµĹ¦ÄÜ +//´´½¨Õߣºsteve +//´´½¨ÈÕÆڣº2011-02- 27 +//´´½¨°汾£ºversion-1.0 +//Ð޸ÄÈÕÆڣº +//Ð޸ÄÄÚÈݣº +//Ð޸İ汾£º +//=========================================================================================================================== +#ifndef _API_SHARED_PWR_HANDLER_H +#define _API_SHARED_PWR_HANDLER_H +#include +#ifdef __cplusplus +extern "C" { +#endif +enum{ + E_HAND_IDLE = 0, + E_HAND_INIT_INFO, //µÚһ´βéѯÐÅϢ + E_HAND_RETRUN_INFO, //¹黹²éѯÐÅϢ + E_HAND_GET_INFO = 0xff, //µ××ù²éѯÐÅϢ +}; +#define MCU_ID_LEN_MAX 12 +typedef struct{ + u8 No[MCU_ID_LEN_MAX]; + u8 status; //0:Òѽ裬1:´æÔÚ 2:¹黹 + u8 bat_level; + u8 locked; +}stHandlerPwr; +typedef struct{ + stHandlerPwr handler; +}stSharedDevInfo; +extern stSharedDevInfo shared; +void api_shared_hand_msg_task(void); +#ifdef __cplusplus +} +#endif +#endif//_API_SHARED_PWR_HANDLER_H + +/********************************************************* + File End +*********************************************************/ + diff --git a/project/custom/syspower/app_lowpower.c b/project/custom/syspower/app_lowpower.c new file mode 100644 index 0000000..d579dbf --- /dev/null +++ b/project/custom/syspower/app_lowpower.c @@ -0,0 +1,19 @@ +/** + ****************************************************************************** + * Îļþ: app_lowpower.c + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: µ͹¦ºÄÖмä¼þ£¬ʵÏÖϵͳ µ͹¦ºÄ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "custom.h" + + +/*************************************************************************************/ diff --git a/project/custom/syspower/app_syspower.c b/project/custom/syspower/app_syspower.c new file mode 100644 index 0000000..ce5049e --- /dev/null +++ b/project/custom/syspower/app_syspower.c @@ -0,0 +1,61 @@ +/** + ****************************************************************************** + * Îļþ: app_syspower.c + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: ϵͳµçԴÖмä¼þ£¬ʵÏÖϵͳµçԴ¿ØÖÆAPI + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "custom.h" + +/** + * ÃèÊö: µçԴ¿ØÖƳõʼ»¯ + * ²ÎÊý: ÎÞ + * ·µ»Ø: ÎÞ + */ +void drv_syspower_init(void) +{ + app_syspower_ctl(POWER_OFF); +} +/** + * ÃèÊö: µçԴ¿ª¹ؿØÖÆ + * ²ÎÊý: onf: µçԴ¿ª¹Ø״̬ + * ·µ»Ø: ÎÞ + */ +void app_syspower_ctl(POWER_CTL_t onf) +{ + if(onf == POWER_ON) + { + app_syspower_on(); + }else + { + app_syspower_off(); + } +} +/** + * ÃèÊö: µçԴ¿ª¿ØÖÆ + * ²ÎÊý: + * ·µ»Ø: ÎÞ + */ +void app_syspower_on(void) +{ + +} +/** + * ÃèÊö: µçԴ¹ؿØÖÆ + * ²ÎÊý: + * ·µ»Ø: ÎÞ + */ +void app_syspower_off(void) +{ + +} + +/*************************************************************************************/ diff --git a/project/custom/syspower/app_syspower.h b/project/custom/syspower/app_syspower.h new file mode 100644 index 0000000..8d2c685 --- /dev/null +++ b/project/custom/syspower/app_syspower.h @@ -0,0 +1,42 @@ +/** + ****************************************************************************** + * Îļþ: app_syspower.h + * ×÷Õß: steve + * °汾: V1.0.0 + * ÃèÊö: ϵͳµçԴÖмä¼þͷÎļþ + ****************************************************************************** + * + * °æȨËùÓÐ (C): steve + * + * + ****************************************************************************** + */ + +/* ·Àֹµݹé°üº¬¸ÃͷÎļþ ------------------------------------------------------*/ +#ifndef __APP_SYSPOWER_H +#define __APP_SYSPOWER_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +typedef enum +{ + POWER_OFF = 0, + POWER_ON, +}POWER_CTL_t; + +void drv_syspower_init(void); +void app_syspower_ctl(POWER_CTL_t onf); +void app_syspower_on(void); +void app_syspower_off(void); + +#ifdef __cplusplus +} +#endif + + +#endif /* __APP_SYSPOWER_H */ + +/*************************************************************************************/ diff --git a/project/custom/systick/api_sys_timer.c b/project/custom/systick/api_sys_timer.c new file mode 100644 index 0000000..a9bef24 --- /dev/null +++ b/project/custom/systick/api_sys_timer.c @@ -0,0 +1,51 @@ +//=========================================================================================================================== +//=========================================================================================================================== +//±¾ÎļþʵÏÖÉ豸¼ì²⹦ÄÜ +//´´½¨Õߣºsteve +//´´½¨ÈÕÆڣº2018-06- 04 +//´´½¨°汾£ºversion-1.0 +//Ð޸ÄÈÕÆڣº +//Ð޸ÄÄÚÈݣº +//Ð޸İ汾£º +//=========================================================================================================================== +#include "config.h" +u16 systick_timer; +u8 base_10ms_cnt; +u8 base_10ms_flag; +/** + * @brief SYSTICK callback. + * @retval None + */ +void SysTick_Handler(void) +{ + /* NOTE : This function Should not be modified, when the callback is needed, + the HAL_SYSTICK_Callback could be implemented in the user file + */ + systick_timer++; + base_10ms_cnt++; + if(base_10ms_cnt > 10) + { + base_10ms_cnt = 0; + base_10ms_flag = 1; + } + if(handler_msg.write.time_out)handler_msg.write.time_out--; +} +void api_sys_timer_task(void) +{ + static u16 systick_10ms = 0; + + if(base_10ms_flag == 0)return; + base_10ms_flag = 0; + systick_10ms++; + if((systick_10ms % 5) == 0) + {//50ms + bsp_bat_manage_task(); + } + if((systick_10ms % 50) == 0) + {//500ms + systick_10ms = 0; + } +} +/********************************************************* + File End +*********************************************************/ diff --git a/project/custom/systick/api_sys_timer.h b/project/custom/systick/api_sys_timer.h new file mode 100644 index 0000000..88ca713 --- /dev/null +++ b/project/custom/systick/api_sys_timer.h @@ -0,0 +1,28 @@ +//=========================================================================================================================== +//±¾ÎļþʵÏÖÉ豸¼ì²⹦ÄÜ +//´´½¨Õߣºsteve +//´´½¨ÈÕÆڣº2018-06- 04 +//´´½¨°汾£ºversion-1.0 +//Ð޸ÄÈÕÆڣº +//Ð޸ÄÄÚÈݣº +//Ð޸İ汾£º +//=========================================================================================================================== +#ifndef __API_SYS_TIMER_H__ +#define __API_SYS_TIMER_H__ + + +#ifdef __cplusplus +extern "C" { +#endif + +void api_sys_timer_task(void); + +#ifdef __cplusplus +} +#endif +#endif//__API_SYS_TIMER_H__ + +/********************************************************* + File End +*********************************************************/ + diff --git a/project/custom/typedef.h b/project/custom/typedef.h new file mode 100644 index 0000000..f7ab961 --- /dev/null +++ b/project/custom/typedef.h @@ -0,0 +1,47 @@ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __TYPEDEF_H_ +#define __TYPEDEF_H_ + +#ifdef __cplusplus + extern "C" { +#endif +#include "stdint.h" +/*!< STM32F10x Standard Peripheral Library old types (maintained for legacy purpose) */ +typedef int32_t s32; +typedef int16_t s16; +typedef int8_t s8; + +typedef const int32_t sc32; /*!< Read Only */ +typedef const int16_t sc16; /*!< Read Only */ +typedef const int8_t sc8; /*!< Read Only */ + +typedef int32_t vs32; +typedef int16_t vs16; +typedef int8_t vs8; + +typedef int32_t vsc32; /*!< Read Only */ +typedef int16_t vsc16; /*!< Read Only */ +typedef int8_t vsc8; /*!< Read Only */ + +typedef uint32_t u32; +typedef uint16_t u16; +typedef uint8_t u8; + +typedef const uint32_t uc32; /*!< Read Only */ +typedef const uint16_t uc16; /*!< Read Only */ +typedef const uint8_t uc8; /*!< Read Only */ + +typedef uint32_t vu32; +typedef uint16_t vu16; +typedef uint8_t vu8; + +typedef uint32_t vuc32; /*!< Read Only */ +typedef uint16_t vuc16; /*!< Read Only */ +typedef uint8_t vuc8; /*!< Read Only */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CONFIG_H_ */ diff --git a/project/driver/inc/adc.h b/project/driver/inc/adc.h new file mode 100644 index 0000000..f738bf5 --- /dev/null +++ b/project/driver/inc/adc.h @@ -0,0 +1,386 @@ +/****************************************************************************** +* 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" +#include "interrupts_hc32f003.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_op_mode +{ + AdcNormalMode = 0, /*!< 单输入通道单次采样模式 */ + AdcContMode = 1, /*!< 单输入通道连续采样模式 */ + AdcScanMode = 2, /*!< 多输入通道扫描采样模式*/ + +} en_adc_op_mode_t; + +/** + ****************************************************************************** + ** \brief ADC时钟选择 + *****************************************************************************/ +typedef enum en_adc_clk_sel +{ + AdcClkSysTDiv1 = 0, /*!< PCLK */ + AdcClkSysTDiv2 = 1, /*!< 1/2 PCLK */ + AdcClkSysTDiv4 = 2, /*!< 1/4 PCLK */ + AdcClkSysTDiv8 = 3, /*!< 1/8 PCLK */ + +} en_adc_clk_sel_t; + +/** + ****************************************************************************** + ** \brief ADC参考电压 + *****************************************************************************/ +typedef enum en_adc_ref_vol_sel +{ + RefVolSelInBgr1p5 = 0, /*!<内部参考电压1.5V(SPS<=200kHz)*/ + RefVolSelInBgr2p5 = 1, /*!<内部参考电压2.5V(avdd>3V,SPS<=200kHz)*/ + RefVolSelExtern1 = 2, /*!<外部输入(max avdd) P3.6*/ + RefVolSelAVDD = 3, /*! 38.5k + ///< RCH -> hclk/8 + ///< XTH -> XTH + boolean_t bNoRef; ///< 使用系统时钟 + ///< TRUE : 使用系统时钟HCLK + ///< FALSE : 使用enClk + uint32_t u32LoadVal; ///< 计数周期值 +}stc_clk_systickcfg_t; + +/** + ******************************************************************************* + ** \brief 时钟初始化配置 + ******************************************************************************/ +typedef struct +{ + en_clk_source_t enClkSrc; ///< 时钟源选择 + en_clk_div_t enHClkDiv; ///< 系统时钟分频系数 + en_clk_div_t enPClkDiv; ///< 外设时钟分频系数 +}stc_clk_config_t; + +/****************************************************************************** + * Global variable declarations ('extern', definition in C source) + ******************************************************************************/ + +/****************************************************************************** + * Global function prototypes (definition in C source) + ******************************************************************************/ +///< 时钟初始化 / 去初始化 +en_result_t Clk_Init(stc_clk_config_t *pstcCfg); +en_result_t Clk_DeInit(void); + +///< 时钟基本功能设置 +en_result_t Clk_Enable(en_clk_source_t enSource, boolean_t bFlag); +en_result_t Clk_SetSource(en_clk_source_t enSource); +boolean_t Clk_GetClkRdy(en_clk_source_t enSource); +en_result_t Clk_SetXTH_StableTime(en_clk_cycle_t enCycle); +en_result_t Clk_SetRCL_StableTime(en_clk_cycle_t enCycle); + +///< 时钟源切换 +en_result_t Clk_SwitchTo(en_clk_source_t enSource); + +///< 时钟频率设定 +en_result_t Clk_SetRCHFreq(en_clk_freq_t enVal); +en_result_t Clk_SetRCLFreq(en_clk_freq_t enVal); + +///< 时钟分频设置 +en_result_t Clk_SetHClkDiv(uint8_t u8Div); +en_result_t Clk_SetPClkDiv(uint8_t u8Div); + +///< 获取时钟频率 +uint32_t Clk_GetHClkFreq(void); +uint32_t Clk_GetPClkFreq(void); + +///< 时钟外设门控开关 +en_result_t Clk_SetPeripheralGate(en_clk_peripheral_gate_t enPeripheral, + boolean_t bFlag); +boolean_t Clk_GetPeripheralGate(en_clk_peripheral_gate_t enPeripheral); + + +///< 时钟功能开关 +en_result_t Clk_SetFunc(en_clk_func_t enFunc, boolean_t bFlag); + +///< systick 配置 +en_result_t Clk_SysTickConfig(stc_clk_systickcfg_t *pstcCfg); +en_result_t Clk_DebugClk(en_clk_debug_t enPeri, boolean_t bFlag); + +//Systick SKEW 获取 +boolean_t Clk_SysTickSkewGet(void); +//Systick CALIB 获取 +uint32_t Clk_SysTickStcalibGet(void); +//@} // ClkGroup + +#ifdef __cplusplus +#endif + + +#endif /* __CLK_H__ */ +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/project/driver/inc/crc.h b/project/driver/inc/crc.h new file mode 100644 index 0000000..b122acd --- /dev/null +++ b/project/driver/inc/crc.h @@ -0,0 +1,111 @@ +/****************************************************************************** +* 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 crc.h + ** + ** CRC 数据结构及API声明. + ** + ** - 2016-05-04 LuX V1.0. + ** + ******************************************************************************/ + +#ifndef __CRC_H__ +#define __CRC_H__ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "ddl.h" + +/* C binding of definitions if building with C++ compiler */ +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + ****************************************************************************** + ** \defgroup CrcGroup Cyclic Redundancy Check (CRC) + ** + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Global type definitions + ******************************************************************************/ + + +/****************************************************************************** + * Global definitions + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions ('extern') + ******************************************************************************/ + +/****************************************************************************** + * Global function prototypes (definition in C source) + ******************************************************************************/ +//CRC16 编码值获取 +uint16_t CRC16_Get8(uint8_t* pu8Data, uint32_t u32Len); +uint16_t CRC16_Get16(uint16_t* pu16Data, uint32_t u32Len); +uint16_t CRC16_Get32(uint32_t* pu32Data, uint32_t u32Len); +//CRC16 校验 +en_result_t CRC16_Check8(uint8_t* pu8Data, uint32_t u32Len, uint16_t u16CRC); +en_result_t CRC16_Check16(uint16_t* pu16Data, uint32_t u32Len, uint16_t u16CRC); +en_result_t CRC16_Check32(uint32_t* pu32Data, uint32_t u32Len, uint16_t u16CRC); + +//@} // CRC Group + +#ifdef __cplusplus +} +#endif + +#endif /* __CRC_H__ */ +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/project/driver/inc/ddl.h b/project/driver/inc/ddl.h new file mode 100644 index 0000000..7b94fd1 --- /dev/null +++ b/project/driver/inc/ddl.h @@ -0,0 +1,204 @@ +/******************************************************************************* +* 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 ddl.h + ** + ** DDL common define. + ** @link SampleGroup Some description @endlink + ** + ** - 2017-04-29 1.0 Ronnie First version. + ** + ******************************************************************************/ + +#ifndef __DDL_H__ +#define __DDL_H__ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "base_types.h" +#include "hc32f003.h" +#include "system_hc32f003.h" +#include "clk.h" +#include "gpio.h" + +/* C binding of definitions if building with C++ compiler */ +#ifdef __cplusplus +extern "C" +{ +#endif + +/******************************************************************************/ +/* Global pre-processor symbols/macros ('#define') */ +/* Macro for initializing local structures to zero */ +/******************************************************************************/ +#define DDL_ZERO_STRUCT(x) ddl_memclr((uint8_t*)&(x), (uint32_t)(sizeof(x))) + +#define DEC2BCD(x) ((((x)/10)<<4) + ((x)%10)) +#define BCD2DEC(x) ((((x)>>4)*10) + ((x)&0x0F)) + +#define setBit(addr,offset,flag) { if( (flag) > 0u){\ + *((volatile uint32_t *)(addr)) |= ((1UL)<<(offset));\ + }else{\ + *((volatile uint32_t *)(addr)) &= (~(1UL<<(offset)));\ + }\ + } + +#define getBit(addr,offset) ((((*((volatile uint32_t *)(addr))) >> (offset)) & 1u)>0?1u:0) + +/** + ****************************************************************************** + ** Global Device Series List + ******************************************************************************/ +#define DDL_DEVICE_SERIES_HC32F003 (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! + +/** + ****************************************************************************** + ** \brief IRQ name definition for all type MCUs + ******************************************************************************/ + + #define PORT0_IRQHandler(void) IRQ000_Handler(void) + #define PORT1_IRQHandler(void) IRQ001_Handler(void) + #define PORT2_IRQHandler(void) IRQ002_Handler(void) + #define PORT3_IRQHandler(void) IRQ003_Handler(void) +// IRQ004_Handler(void) +// IRQ005_Handler(void) + #define UART0_IRQHandler(void) IRQ006_Handler(void) + #define UART1_IRQHandler(void) IRQ007_Handler(void) +// IRQ009_Handler(void) + #define SPI_IRQHandler(void) IRQ010_Handler(void) +// IRQ011_Handler(void) + #define I2C_IRQHandler(void) IRQ012_Handler(void) +// IRQ013_Handler(void) + #define TIM0_IRQHandler(void) IRQ014_Handler(void) + #define TIM1_IRQHandler(void) IRQ015_Handler(void) + #define TIM2_IRQHandler(void) IRQ016_Handler(void) + #define TIM4_IRQHandler(void) IRQ018_Handler(void) + #define TIM5_IRQHandler(void) IRQ019_Handler(void) + #define TIM6_IRQHandler(void) IRQ020_Handler(void) + #define PCA_IRQHandler(void) IRQ021_Handler(void) + #define WDT_IRQHandler(void) IRQ022_Handler(void) + #define ADC_IRQHandler(void) IRQ024_Handler(void) +// IRQ025_Handler(void) + #define VC0_IRQHandler(void) IRQ026_Handler(void) + #define VC1_IRQHandler(void) IRQ027_Handler(void) + #define LVD_IRQHandler(void) IRQ028_Handler(void) +// IRQ029_Handler(void) + #define EF_RAM_IRQHandler(void) IRQ030_Handler(void) + #define CLKTRIM_IRQHandler(void) IRQ031_Handler(void) + +/******************************************************************************/ +/* 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. + ******************************************************************************/ +extern void DDL_WAIT_LOOP_HOOK(void); + +void Debug_UartInit(void); + +void delay1ms(uint32_t u32Cnt); +void delay100us(uint32_t u32Cnt); +#ifdef __cplusplus +} +#endif + +#endif /* __DDL_H__ */ + +/******************************************************************************/ +/* EOF (not truncated) */ +/******************************************************************************/ + diff --git a/project/driver/inc/flash.h b/project/driver/inc/flash.h new file mode 100644 index 0000000..218ddc2 --- /dev/null +++ b/project/driver/inc/flash.h @@ -0,0 +1,140 @@ +/************************************************************************************* +* 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 flash.h + ** + ** FLASH 数据结构及API声明. + ** + ** - 2017-05-02 LuX V1.0 + ** + ******************************************************************************/ + +#ifndef __FLASH_H__ +#define __FLASH_H__ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "ddl.h" + +/* C binding of definitions if building with C++ compiler */ +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + ****************************************************************************** + ** \defgroup FlashGroup Flash Controller (Flash) + ** + ** + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Global type definitions + ******************************************************************************/ +/** + ****************************************************************************** + ** \brief Flash中断类型重定义 + *****************************************************************************/ +typedef enum en_flash_int_type +{ + flash_int0 = 0u, ///<擦写保护报警中断 + flash_int1 = 1u, ///<擦写PC地址报警中断 +} en_flash_int_type_t; + + +/** + ****************************************************************************** + ** \brief Redefinition of FLASH register structure + ******************************************************************************/ + + +/****************************************************************************** + * Global definitions + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions ('extern') + ******************************************************************************/ + +/****************************************************************************** + * Global function prototypes (definition in C source) + ******************************************************************************/ +//中断相关函数 +//中断标志获取 +boolean_t Flash_GetIntFlag(en_flash_int_type_t enFlashIntType); +//中断标志清除 +en_result_t Flash_ClearIntFlag(en_flash_int_type_t enFlashIntType); +//中断使能/禁止 +en_result_t Flash_EnableIrq(en_flash_int_type_t enFlashIntType); +en_result_t Flash_DisableIrq(en_flash_int_type_t enFlashIntType); + +/* Flash 初始化配置 */ +en_result_t Flash_Init(func_ptr_t pfnFlashCb, uint8_t u8FreqCfg); + +/* Flash 字节/半字/字写 */ +en_result_t Flash_WriteByte(uint32_t u32Addr, uint8_t u8Data); +en_result_t Flash_WriteHalfWord(uint32_t u32Addr, uint16_t u16Data); +en_result_t Flash_WriteWord(uint32_t u32Addr, uint32_t u32Data); + +/* Flash 页/全片擦除 */ +en_result_t Flash_SectorErase(uint32_t u32SectorAddr); +en_result_t Flash_ChipErase(void); + + + +//@} // FlashGroup + +#ifdef __cplusplus +} +#endif + +#endif /* __FLASH_H__ */ +/******************************************************************************/ +/* EOF (not truncated) */ +/******************************************************************************/ diff --git a/project/driver/inc/gpio.h b/project/driver/inc/gpio.h new file mode 100644 index 0000000..d2bb844 --- /dev/null +++ b/project/driver/inc/gpio.h @@ -0,0 +1,902 @@ +/******************************************************************************* +* 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 gpio.h + ** + ** GPIO driver + ** @link GPIO Group Some description @endlink + ** + ** - 2017-05-04 + ** + ******************************************************************************/ + +#ifndef __GPIO_H__ +#define __GPIO_H__ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "ddl.h" +#include "interrupts_hc32f003.h" + +/* C binding of definitions if building with C++ compiler */ +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + ******************************************************************************* + ** \defgroup GpioGroup General Purpose I/O (GPIO) + ** + ** + ******************************************************************************/ +//@{ +#define GPIO_GPSZ (0x40u) + +/******************************************************************************* + * Global type definitions + ******************************************************************************/ + +/** + ******************************************************************************* + ** \brief GPIO输入输出方向 + ******************************************************************************/ +typedef enum en_gpio_dir +{ + GpioDirOut, ///< GPIO 输出 + GpioDirIn, ///< GPIO 输入 +}en_gpio_dir_t; + + +/** + ******************************************************************************* + ** \brief GPIO中断触发方式 + ******************************************************************************/ +typedef enum en_gpio_irqtype +{ + GpioIrqHigh = 1 << 0, ///< GPIO高电平触发 + GpioIrqLow = 1 << 1, ///< GPIO低电平触发 + GpioIrqRising = 1 << 2, ///< GPIO上升沿触发 + GpioIrqFalling = 1 << 3, ///< GPIO下降沿触发 +}en_gpio_irqtype_t; + +/** + ******************************************************************************* + ** \brief GPIO附加功能 + ******************************************************************************/ +typedef enum en_gpio_ctrlext +{ + GpioCtrlIESEL, ///< >0: deep sleep + ///< =0: active sleep + GpioCtrlIRPOL, ///< >0: reverse output + ///< =0: normal output + GpioCtrlHclkEn, ///< >0: output enable + ///< =0 output disable + GpioCtrlPclkEn, ///< >0: output enable + ///< =0 output disable + GpioCtrlHclkSel, ///< div value + GpioCtrlPclkSel, ///< div value +}en_gpio_ctrlext_t; + +/** + ******************************************************************************* + ** \brief GPIO SSN 信号源枚举 + ******************************************************************************/ +typedef enum en_gpio_ctrl1src +{ + GpioCtrl1SrcP35 = 0x1, ///< P35 + GpioCtrl1SrcP36 = 0x2, ///< P36 + GpioCtrl1SrcP01 = 0x3, ///< P01 + GpioCtrl1SrcP02 = 0x4, ///< P02 + GpioCtrl1SrcP03 = 0x5, ///< P03 + GpioCtrl1SrcP15 = 0x6, ///< P15 + GpioCtrl1SrcP14 = 0x7, ///< P14 + GpioCtrl1SrcP23 = 0x8, ///< P23 + GpioCtrl1SrcP24 = 0x9, ///< P24 + GpioCtrl1SrcP25 = 0xA, ///< P25 + GpioCtrl1SrcP26 = 0xB, ///< P26 + GpioCtrl1SrcP27 = 0xC, ///< P27 + GpioCtrl1SrcP31 = 0xD, ///< P31 + GpioCtrl1SrcP32 = 0xE, ///< P32 + GpioCtrl1SrcP33 = 0xF, ///< P33 + +}en_gpio_ctrl1src_t; + + +/** + ******************************************************************************* + ** \brief GPIO PCA 捕获通道x信号来源选择 + ******************************************************************************/ +typedef enum en_gpio_target +{ + GpioSignalCAP4, ///< CAP4 + GpioSignalCAP3, ///< CAP3 + GpioSignalCAP2, ///< CAP2 + GpioSignalCAP1, ///< CAP1 + GpioSignalCAP0, ///< CAP0 + GpioSignalTm6A, ///< Tm6A + GpioSignalTm5A, ///< Tm5A + GpioSignalTm4A, ///< Tm4A + GpioSignalTm6B, ///< Tm6B + GpioSignalTm5B, ///< Tm5B + GpioSignalTm4B, ///< Tm4B + GpioSignalTm2, ///< Tm2 + GpioSignalTm1, ///< Tm1 + GpioSignalTm0, ///< Tm0 +}en_gpio_target_t; + +/** + ******************************************************************************* + ** \brief GPIO Timer信号来源选择 + ******************************************************************************/ +typedef enum en_gpio_timex_in +{ + GpioTMxIn = 0, ///< TMx + GpioPcaCapxIn = 0, ///< PcaCapx + GpioUart0RxdIn = 1, ///< Uart0Rxd + GpioUart1RxdIn = 2, ///< Uart1Rxd + GpioUart2RxdIn = 3, ///< Uart2Rxd +}en_gpio_timex_in_t; + + +/******************************************************************************* + * Global definitions + ******************************************************************************/ + +///< GPIO 模拟功能选择 +en_result_t Gpio_SetAnalog(uint8_t u8Port, uint8_t u8Pin, boolean_t bFlag); + +///< GPIO IO功能初始化 +en_result_t Gpio_InitIO(uint8_t u8Port, uint8_t u8Pin, + en_gpio_dir_t enDir); + +en_result_t Gpio_InitIOExt(uint8_t u8Port, uint8_t u8Pin, + en_gpio_dir_t enDir, + boolean_t bPullup, + boolean_t bPulldown, + boolean_t bOdr, + boolean_t bDrive); + +///< GPIO IO输出输入电平 +void Gpio_SetIO(uint8_t u8Port, uint8_t u8Pin,boolean_t bVal); +boolean_t Gpio_GetIO(uint8_t u8Port, uint8_t u8Pin); + +///< GPIO 中断控制使能 +en_result_t Gpio_EnableIrq(uint8_t u8Port, + uint8_t u8Pin, + en_gpio_irqtype_t enType); + +en_result_t Gpio_DisableIrq(uint8_t u8Port, + uint8_t u8Pin, + en_gpio_irqtype_t enType); + +boolean_t Gpio_GetIrqStat(uint8_t u8Port,uint8_t u8Pin); +en_result_t Gpio_ClearIrq(uint8_t u8Port,uint8_t u8Pin); + +///< GPIO 附加功能函数 +en_result_t Gpio_SetCtrlExt(en_gpio_ctrlext_t enFunc, uint8_t u8val); +en_result_t Gpio_SetSsnSel(en_gpio_ctrl1src_t enSrc); +en_result_t Gpio_SetExtClkSel(en_gpio_ctrl1src_t enSrc); +en_result_t Gpio_SetSignalSource(en_gpio_target_t enTarget, en_gpio_timex_in_t enType); + +/* + GPIO PIN功能配置设置宏定义 +*/ +#define Gpio_SetFunc_UART0_RXD_P01() do{\ + M0P_GPIO->P0ADS_f.P01 = 0;\ + M0P_GPIO->P01_SEL_f.SEL = 1;\ + M0P_GPIO->P0DIR_f.P01 = 1;\ + }while(0); + +#define Gpio_SetFunc_I2C_SDA_P01() do{\ + M0P_GPIO->P0ADS_f.P01 = 0;\ + M0P_GPIO->P01_SEL_f.SEL = 2;\ + M0P_GPIO->P0DIR_f.P01 = 0;\ + }while(0); + +#define Gpio_SetFunc_UART1_TXD_P01() do{\ + M0P_GPIO->P0ADS_f.P01 = 0;\ + M0P_GPIO->P01_SEL_f.SEL = 3;\ + M0P_GPIO->P0DIR_f.P01 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM0_TOG_P01() do{\ + M0P_GPIO->P0ADS_f.P01 = 0;\ + M0P_GPIO->P01_SEL_f.SEL = 4;\ + M0P_GPIO->P0DIR_f.P01 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM5_CHB_P01() do{\ + M0P_GPIO->P0ADS_f.P01 = 0;\ + M0P_GPIO->P01_SEL_f.SEL = 5;\ + M0P_GPIO->P0DIR_f.P01 = 0;\ + }while(0); + +#define Gpio_SetFunc_SPI_SCK_P01() do{\ + M0P_GPIO->P0ADS_f.P01 = 0;\ + M0P_GPIO->P01_SEL_f.SEL = 6;\ + M0P_GPIO->P0DIR_f.P01 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM2_EXT_P01() do{\ + M0P_GPIO->P0ADS_f.P01 = 0;\ + M0P_GPIO->P01_SEL_f.SEL = 7;\ + M0P_GPIO->P0DIR_f.P01 = 1;\ + }while(0); + +#define Gpio_SetFunc_UART0_TXD_P02() do{\ + M0P_GPIO->P0ADS_f.P02 = 0;\ + M0P_GPIO->P02_SEL_f.SEL = 1;\ + M0P_GPIO->P0DIR_f.P02 = 0;\ + }while(0); + +#define Gpio_SetFunc_I2C_SCL_P02() do{\ + M0P_GPIO->P0ADS_f.P02 = 0;\ + M0P_GPIO->P02_SEL_f.SEL = 2;\ + M0P_GPIO->P0DIR_f.P02 = 0;\ + }while(0); + +#define Gpio_SetFunc_UART1_RXD_P02() do{\ + M0P_GPIO->P0ADS_f.P02 = 0;\ + M0P_GPIO->P02_SEL_f.SEL = 3;\ + M0P_GPIO->P0DIR_f.P02 = 0;\ + }while(0); + +#define Gpio_SetFunc_TM0_TOGN_P02() do{\ + M0P_GPIO->P0ADS_f.P02 = 0;\ + M0P_GPIO->P02_SEL_f.SEL = 4;\ + M0P_GPIO->P0DIR_f.P02 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM6_CHA_P02() do{\ + M0P_GPIO->P0ADS_f.P02 = 0;\ + M0P_GPIO->P02_SEL_f.SEL = 5;\ + M0P_GPIO->P0DIR_f.P02 = 0;\ + }while(0); + +#define Gpio_SetFunc_SPI_CS_P02() do{\ + M0P_GPIO->P0ADS_f.P02 = 0;\ + M0P_GPIO->P02_SEL_f.SEL = 6;\ + M0P_GPIO->P0DIR_f.P02 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM2_GATE_P02() do{\ + M0P_GPIO->P0ADS_f.P02 = 0;\ + M0P_GPIO->P02_SEL_f.SEL = 7;\ + M0P_GPIO->P0DIR_f.P02 = 1;\ + }while(0); + +#define Gpio_SetFunc_PCA_CH3_P03(x) do{\ + M0P_GPIO->P0ADS_f.P03 = 0;\ + M0P_GPIO->P03_SEL_f.SEL = 1;\ + M0P_GPIO->P0DIR_f.P03 = (x);\ + }while(0); + +#define Gpio_SetFunc_SPI_CS_P03() do{\ + M0P_GPIO->P0ADS_f.P03 = 0;\ + M0P_GPIO->P03_SEL_f.SEL = 2;\ + M0P_GPIO->P0DIR_f.P03 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM6_CHB_P03() do{\ + M0P_GPIO->P0ADS_f.P03 = 0;\ + M0P_GPIO->P03_SEL_f.SEL = 3;\ + M0P_GPIO->P0DIR_f.P03 = 0;\ + }while(0); + +#define Gpio_SetFunc_LPTIM_EXT_P03() do{\ + M0P_GPIO->P0ADS_f.P03 = 0;\ + M0P_GPIO->P03_SEL_f.SEL = 4;\ + M0P_GPIO->P0DIR_f.P03 = 1;\ + }while(0); + +#define Gpio_SetFunc_PCA_ECI_P03() do{\ + M0P_GPIO->P0ADS_f.P03 = 0;\ + M0P_GPIO->P03_SEL_f.SEL = 6;\ + M0P_GPIO->P0DIR_f.P03 = 0;\ + }while(0); + +#define Gpio_SetFunc_VC0_OUT_P03() do{\ + M0P_GPIO->P0ADS_f.P03 = 0;\ + M0P_GPIO->P03_SEL_f.SEL = 7;\ + M0P_GPIO->P0DIR_f.P03 = 0;\ + }while(0); + +#define Gpio_SetFunc_I2C_SCL_P14() do{\ + M0P_GPIO->P1ADS_f.P14 = 0;\ + M0P_GPIO->P14_SEL_f.SEL = 1;\ + M0P_GPIO->P1DIR_f.P14 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM2_TOGN_P14() do{\ + M0P_GPIO->P1ADS_f.P14 = 0;\ + M0P_GPIO->P14_SEL_f.SEL = 2;\ + M0P_GPIO->P1DIR_f.P14 = 0;\ + }while(0); + +#define Gpio_SetFunc_PCA_ECI_P14() do{\ + M0P_GPIO->P1ADS_f.P14 = 0;\ + M0P_GPIO->P14_SEL_f.SEL = 3;\ + M0P_GPIO->P1DIR_f.P14 = 0;\ + }while(0); + +#define Gpio_SetFunc_ADC_RDY_P14() do{\ + M0P_GPIO->P1ADS_f.P14 = 0;\ + M0P_GPIO->P14_SEL_f.SEL = 4;\ + M0P_GPIO->P1DIR_f.P14 = 0;\ + }while(0); + +#define Gpio_SetFunc_SPICS_P14() do{\ + M0P_GPIO->P1ADS_f.P14 = 0;\ + M0P_GPIO->P14_SEL_f.SEL = 5;\ + M0P_GPIO->P1DIR_f.P14 = 0;\ + }while(0); + +#define Gpio_SetFunc_UART0TX_P14() do{\ + M0P_GPIO->P1ADS_f.P14 = 0;\ + M0P_GPIO->P14_SEL_f.SEL = 6;\ + M0P_GPIO->P1DIR_f.P14 = 0;\ + }while(0); + +#define Gpio_SetFunc_I2CDAT_P15() do{\ + M0P_GPIO->P1ADS_f.P15 = 0;\ + M0P_GPIO->P15_SEL_f.SEL = 1;\ + M0P_GPIO->P1DIR_f.P15 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM2_TOG_P15() do{\ + M0P_GPIO->P1ADS_f.P15 = 0;\ + M0P_GPIO->P15_SEL_f.SEL = 2;\ + M0P_GPIO->P1DIR_f.P15 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM4_CHB_P15() do{\ + M0P_GPIO->P1ADS_f.P15 = 0;\ + M0P_GPIO->P15_SEL_f.SEL = 3;\ + M0P_GPIO->P1DIR_f.P15 = 0;\ + }while(0); + +#define Gpio_SetFunc_LPTIM_GATE_P15() do{\ + M0P_GPIO->P1ADS_f.P15 = 0;\ + M0P_GPIO->P15_SEL_f.SEL = 4;\ + M0P_GPIO->P1DIR_f.P15 = 1;\ + }while(0); + +#define Gpio_SetFunc_SPICLK_P15() do{\ + M0P_GPIO->P1ADS_f.P15 = 0;\ + M0P_GPIO->P15_SEL_f.SEL = 5;\ + M0P_GPIO->P1DIR_f.P15 = 0;\ + }while(0); + +#define Gpio_SetFunc_UART0RX_P15() do{\ + M0P_GPIO->P1ADS_f.P15 = 0;\ + M0P_GPIO->P15_SEL_f.SEL = 6;\ + M0P_GPIO->P1DIR_f.P15 = 1;\ + }while(0); + +#define Gpio_SetFunc_LVDOUT_P15() do{\ + M0P_GPIO->P1ADS_f.P15 = 0;\ + M0P_GPIO->P15_SEL_f.SEL = 7;\ + M0P_GPIO->P1DIR_f.P15 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM6_CHA_P23() do{\ + M0P_GPIO->P2ADS_f.P23 = 0;\ + M0P_GPIO->P23_SEL_f.SEL = 1;\ + M0P_GPIO->P2DIR_f.P23 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM4_CHB_P23() do{\ + M0P_GPIO->P2ADS_f.P23 = 0;\ + M0P_GPIO->P23_SEL_f.SEL = 2;\ + M0P_GPIO->P2DIR_f.P23 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM4_CHA_P23() do{\ + M0P_GPIO->P2ADS_f.P23 = 0;\ + M0P_GPIO->P23_SEL_f.SEL = 3;\ + M0P_GPIO->P2DIR_f.P23 = 0;\ + }while(0); + +#define Gpio_SetFunc_PAC_CH0_P23() do{\ + M0P_GPIO->P2ADS_f.P23 = 0;\ + M0P_GPIO->P23_SEL_f.SEL = 4;\ + M0P_GPIO->P2DIR_f.P23 = 1;\ + }while(0); + +#define Gpio_SetFunc_SPIMISO_P23() do{\ + M0P_GPIO->P2ADS_f.P23 = 0;\ + M0P_GPIO->P23_SEL_f.SEL = 5;\ + M0P_GPIO->P2DIR_f.P23 = 1;\ + }while(0); + +#define Gpio_SetFunc_UART1TX_P23() do{\ + M0P_GPIO->P2ADS_f.P23 = 0;\ + M0P_GPIO->P23_SEL_f.SEL = 6;\ + M0P_GPIO->P2DIR_f.P23 = 0;\ + }while(0); + +#define Gpio_SetFunc_IROUT_P23(x) do{\ + M0P_GPIO->P2ADS_f.P23 = 0;\ + M0P_GPIO->P23_SEL_f.SEL = 7;\ + M0P_GPIO->P2DIR_f.P23 = 0;\ + M0P_GPIO->CTRL1_f.IR_POL = (x);\ + }while(0); + +#define Gpio_SetFunc_TIM4_CHB_P24() do{\ + M0P_GPIO->P2ADS_f.P24 = 0;\ + M0P_GPIO->P24_SEL_f.SEL = 1;\ + M0P_GPIO->P2DIR_f.P24 = 0;\ + M0P_GPIO->CTRL1_f.HCLK_EN = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM5_CHB_P24() do{\ + M0P_GPIO->P2ADS_f.P24 = 0;\ + M0P_GPIO->P24_SEL_f.SEL = 2;\ + M0P_GPIO->P2DIR_f.P24 = 0;\ + M0P_GPIO->CTRL1_f.HCLK_EN = 0;\ + }while(0); + +#define Gpio_SetFunc_HCLKOUT_P24() do{\ + M0P_GPIO->P2ADS_f.P24 = 0;\ + M0P_GPIO->P24_SEL_f.SEL = 3;\ + M0P_GPIO->P2DIR_f.P24 = 0;\ + M0P_GPIO->CTRL1_f.HCLK_EN = 1;\ + }while(0); + +#define Gpio_SetFunc_PCA_CH1_P24(x) do{\ + M0P_GPIO->P2ADS_f.P24 = 0;\ + M0P_GPIO->P24_SEL_f.SEL = 4;\ + M0P_GPIO->P2DIR_f.P24 = (x);\ + M0P_GPIO->CTRL1_f.HCLK_EN = 0;\ + }while(0); + +#define Gpio_SetFunc_SPIMOSI_P24() do{\ + M0P_GPIO->P2ADS_f.P24 = 0;\ + M0P_GPIO->P24_SEL_f.SEL = 5;\ + M0P_GPIO->P2DIR_f.P24 = 0;\ + M0P_GPIO->CTRL1_f.HCLK_EN = 0;\ + }while(0); + +#define Gpio_SetFunc_UART1RX_P24() do{\ + M0P_GPIO->P2ADS_f.P24 = 0;\ + M0P_GPIO->P24_SEL_f.SEL = 6;\ + M0P_GPIO->P2DIR_f.P24 = 1;\ + M0P_GPIO->CTRL1_f.HCLK_EN = 0;\ + }while(0); + +#define Gpio_SetFunc_VC1_OUT_P24() do{\ + M0P_GPIO->P2ADS_f.P24 = 0;\ + M0P_GPIO->P24_SEL_f.SEL = 7;\ + M0P_GPIO->P2DIR_f.P24 = 0;\ + M0P_GPIO->CTRL1_f.HCLK_EN = 0;\ + }while(0); + +#define Gpio_SetFunc_SPICLK_P25() do{\ + M0P_GPIO->P2ADS_f.P25 = 0;\ + M0P_GPIO->P25_SEL_f.SEL = 1;\ + M0P_GPIO->P2DIR_f.P25 = 0;\ + }while(0); + +#define Gpio_SetFunc_PCA_CH0_P25(x) do{\ + M0P_GPIO->P2ADS_f.P25 = 0;\ + M0P_GPIO->P25_SEL_f.SEL = 2;\ + M0P_GPIO->P2DIR_f.P25 = (x);\ + }while(0); + +#define Gpio_SetFunc_TIM5_CHA_P25() do{\ + M0P_GPIO->P2ADS_f.P25 = 0;\ + M0P_GPIO->P25_SEL_f.SEL = 3;\ + M0P_GPIO->P2DIR_f.P25 = 0;\ + }while(0); + +#define Gpio_SetFunc_LVDOUT_P25() do{\ + M0P_GPIO->P2ADS_f.P25 = 0;\ + M0P_GPIO->P25_SEL_f.SEL = 4;\ + M0P_GPIO->P2DIR_f.P25 = 0;\ + }while(0); + +#define Gpio_SetFunc_UART2RX_P25() do{\ + M0P_GPIO->P2ADS_f.P25 = 0;\ + M0P_GPIO->P25_SEL_f.SEL = 5;\ + M0P_GPIO->P2DIR_f.P25 = 1;\ + }while(0); + +#define Gpio_SetFunc_I2CDAT_P25() do{\ + M0P_GPIO->P2ADS_f.P25 = 0;\ + M0P_GPIO->P25_SEL_f.SEL = 6;\ + M0P_GPIO->P2DIR_f.P25 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM1_GATE_P25() do{\ + M0P_GPIO->P2ADS_f.P25 = 0;\ + M0P_GPIO->P25_SEL_f.SEL = 7;\ + M0P_GPIO->P2DIR_f.P25 = 1;\ + }while(0); + +#define Gpio_SetFunc_SPIMOSI_P26() do{\ + M0P_GPIO->P2ADS_f.P26 = 0;\ + M0P_GPIO->P26_SEL_f.SEL = 1;\ + M0P_GPIO->P2DIR_f.P26 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM4_CHA_P26() do{\ + M0P_GPIO->P2ADS_f.P26 = 0;\ + M0P_GPIO->P26_SEL_f.SEL = 2;\ + M0P_GPIO->P2DIR_f.P26 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM5_CHB_P26() do{\ + M0P_GPIO->P2ADS_f.P26 = 0;\ + M0P_GPIO->P26_SEL_f.SEL = 3;\ + M0P_GPIO->P2DIR_f.P26 = 0;\ + }while(0); + +#define Gpio_SetFunc_PCA_CH2_P26(x) do{\ + M0P_GPIO->P2ADS_f.P26 = 0;\ + M0P_GPIO->P26_SEL_f.SEL = 4;\ + M0P_GPIO->P2DIR_f.P26 = (x);\ + }while(0); + +#define Gpio_SetFunc_UART2TX_P26() do{\ + M0P_GPIO->P2ADS_f.P26 = 0;\ + M0P_GPIO->P26_SEL_f.SEL = 5;\ + M0P_GPIO->P2DIR_f.P26 = 0;\ + }while(0); + +#define Gpio_SetFunc_I2CCLK_P26() do{\ + M0P_GPIO->P2ADS_f.P26 = 0;\ + M0P_GPIO->P26_SEL_f.SEL = 6;\ + M0P_GPIO->P2DIR_f.P26 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM1_EXT_P26() do{\ + M0P_GPIO->P2ADS_f.P26 = 0;\ + M0P_GPIO->P26_SEL_f.SEL = 7;\ + M0P_GPIO->P2DIR_f.P26 = 1;\ + }while(0); + +#define Gpio_SetFunc_SPIMISO_P27() do{\ + M0P_GPIO->P2ADS_f.P27 = 0;\ + M0P_GPIO->P27_SEL_f.SEL = 1;\ + M0P_GPIO->P2DIR_f.P27 = 1;\ + }while(0); + +#define Gpio_SetFunc_TIM5_CHA_P27() do{\ + M0P_GPIO->P2ADS_f.P27 = 0;\ + M0P_GPIO->P27_SEL_f.SEL = 2;\ + M0P_GPIO->P2DIR_f.P27 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM6_CHA_P27() do{\ + M0P_GPIO->P2ADS_f.P27 = 0;\ + M0P_GPIO->P27_SEL_f.SEL = 3;\ + M0P_GPIO->P2DIR_f.P27 = 0;\ + }while(0); + +#define Gpio_SetFunc_PCA_CH3_P27(x) do{\ + M0P_GPIO->P2ADS_f.P27 = 0;\ + M0P_GPIO->P27_SEL_f.SEL = 4;\ + M0P_GPIO->P2DIR_f.P27 = (x);\ + }while(0); + +#define Gpio_SetFunc_UART0RX_P27() do{\ + M0P_GPIO->P2ADS_f.P27 = 0;\ + M0P_GPIO->P27_SEL_f.SEL = 5;\ + M0P_GPIO->P2DIR_f.P27 = 1;\ + }while(0); + +#define Gpio_SetFunc_RCH_OUT_P27() do{\ + M0P_GPIO->P2ADS_f.P27 = 0;\ + M0P_GPIO->P27_SEL_f.SEL = 6;\ + M0P_GPIO->P2DIR_f.P27 = 0;\ + }while(0); + +#define Gpio_SetFunc_XTH_OUT_P27() do{\ + M0P_GPIO->P2ADS_f.P27 = 0;\ + M0P_GPIO->P27_SEL_f.SEL = 7;\ + M0P_GPIO->P2DIR_f.P27 = 0;\ + }while(0); + +#define Gpio_SetFunc_PCAECI_P31() do{\ + M0P_GPIO->P3ADS_f.P31 = 0;\ + M0P_GPIO->P31_SEL_f.SEL = 2;\ + M0P_GPIO->P3DIR_f.P31 = 0;\ + M0P_GPIO->CTRL1_f.PCLK_EN = 0;\ + M0P_GPIO->CTRL1_f.HCLK_EN = 0;\ + }while(0); + +#define Gpio_SetFunc_PCLKOUT_P31() do{\ + M0P_GPIO->P3ADS_f.P31 = 0;\ + M0P_GPIO->P31_SEL_f.SEL = 3;\ + M0P_GPIO->P3DIR_f.P31 = 0;\ + M0P_GPIO->CTRL1_f.PCLK_EN = 1;\ + M0P_GPIO->CTRL1_f.HCLK_EN = 0;\ + }while(0); + +#define Gpio_SetFunc_VC0_OUT_P31() do{\ + M0P_GPIO->P3ADS_f.P31 = 0;\ + M0P_GPIO->P31_SEL_f.SEL = 4;\ + M0P_GPIO->P3DIR_f.P31 = 0;\ + M0P_GPIO->CTRL1_f.PCLK_EN = 0;\ + M0P_GPIO->CTRL1_f.HCLK_EN = 0;\ + }while(0); + +#define Gpio_SetFunc_UART0TX_P31() do{\ + M0P_GPIO->P3ADS_f.P31 = 0;\ + M0P_GPIO->P31_SEL_f.SEL = 5;\ + M0P_GPIO->P3DIR_f.P31 = 0;\ + M0P_GPIO->CTRL1_f.PCLK_EN = 0;\ + M0P_GPIO->CTRL1_f.HCLK_EN = 0;\ + }while(0); + +#define Gpio_SetFunc_RCL_OUT_P31() do{\ + M0P_GPIO->P3ADS_f.P31 = 0;\ + M0P_GPIO->P31_SEL_f.SEL = 6;\ + M0P_GPIO->P3DIR_f.P31 = 0;\ + M0P_GPIO->CTRL1_f.PCLK_EN = 0;\ + M0P_GPIO->CTRL1_f.HCLK_EN = 0;\ + }while(0); + +#define Gpio_SetFunc_HCLKOUT_P31() do{\ + M0P_GPIO->P3ADS_f.P31 = 0;\ + M0P_GPIO->P31_SEL_f.SEL = 7;\ + M0P_GPIO->P3DIR_f.P31 = 0;\ + M0P_GPIO->CTRL1_f.PCLK_EN = 0;\ + M0P_GPIO->CTRL1_f.HCLK_EN = 1;\ + }while(0); + + +#define Gpio_SetFunc_PCA_CH2_P32(x) do{\ + M0P_GPIO->P3ADS_f.P32 = 0;\ + M0P_GPIO->P32_SEL_f.SEL = 2;\ + M0P_GPIO->P3DIR_f.P32 = (x);\ + }while(0); + +#define Gpio_SetFunc_TIM6_CHB_P32() do{\ + M0P_GPIO->P3ADS_f.P32 = 0;\ + M0P_GPIO->P32_SEL_f.SEL = 3;\ + M0P_GPIO->P3DIR_f.P32 = 0;\ + }while(0); + +#define Gpio_SetFunc_VC1_OUT_P32() do{\ + M0P_GPIO->P3ADS_f.P32 = 0;\ + M0P_GPIO->P32_SEL_f.SEL = 4;\ + M0P_GPIO->P3DIR_f.P32 = 0;\ + }while(0); + +#define Gpio_SetFunc_UART1TX_P32() do{\ + M0P_GPIO->P3ADS_f.P32 = 0;\ + M0P_GPIO->P32_SEL_f.SEL = 5;\ + M0P_GPIO->P3DIR_f.P32 = 0;\ + }while(0); + +#define Gpio_SetFunc_PCA_CH4_P32(x) do{\ + M0P_GPIO->P3ADS_f.P32 = 0;\ + M0P_GPIO->P32_SEL_f.SEL = 6;\ + M0P_GPIO->P3DIR_f.P32 = (x);\ + }while(0); + +#define Gpio_SetFunc_UART2RX_P33() do{\ + M0P_GPIO->P3ADS_f.P33 = 0;\ + M0P_GPIO->P33_SEL_f.SEL = 1;\ + M0P_GPIO->P3DIR_f.P33 = 1;\ + }while(0); + +#define Gpio_SetFunc_PCA_CH1_P33(x) do{\ + M0P_GPIO->P3ADS_f.P33 = 0;\ + M0P_GPIO->P33_SEL_f.SEL = 2;\ + M0P_GPIO->P3DIR_f.P33 = (x);\ + }while(0); + +#define Gpio_SetFunc_TIM5_CHB_P33() do{\ + M0P_GPIO->P3ADS_f.P33 = 0;\ + M0P_GPIO->P33_SEL_f.SEL = 3;\ + M0P_GPIO->P3DIR_f.P33 = 0;\ + }while(0); + +#define Gpio_SetFunc_PCAECI_P33() do{\ + M0P_GPIO->P3ADS_f.P33 = 0;\ + M0P_GPIO->P33_SEL_f.SEL = 4;\ + M0P_GPIO->P3DIR_f.P33 = 0;\ + }while(0); + +#define Gpio_SetFunc_UART1RX_P33() do{\ + M0P_GPIO->P3ADS_f.P33 = 0;\ + M0P_GPIO->P33_SEL_f.SEL = 5;\ + M0P_GPIO->P3DIR_f.P33 = 1;\ + }while(0); + + +#define Gpio_SetFunc_TIM1_TOGN_P33() do{\ + M0P_GPIO->P3ADS_f.P33 = 0;\ + M0P_GPIO->P33_SEL_f.SEL = 7;\ + M0P_GPIO->P3DIR_f.P33 = 0;\ + }while(0); + +#define Gpio_SetFunc_PCA_CH0_P34(x) do{\ + M0P_GPIO->P3ADS_f.P34 = 0;\ + M0P_GPIO->P34_SEL_f.SEL = 1;\ + M0P_GPIO->P3DIR_f.P34 = (x);\ + }while(0); + +#define Gpio_SetFunc_UART2TX_P34() do{\ + M0P_GPIO->P3ADS_f.P34 = 0;\ + M0P_GPIO->P34_SEL_f.SEL = 2;\ + M0P_GPIO->P3DIR_f.P34 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM5_CHA_P34() do{\ + M0P_GPIO->P3ADS_f.P34 = 0;\ + M0P_GPIO->P34_SEL_f.SEL = 3;\ + M0P_GPIO->P3DIR_f.P34 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM0_EXT_P34() do{\ + M0P_GPIO->P3ADS_f.P34 = 0;\ + M0P_GPIO->P34_SEL_f.SEL = 4;\ + M0P_GPIO->P3DIR_f.P34 = 1;\ + }while(0); + +#define Gpio_SetFunc_TIM4_CHA_P34() do{\ + M0P_GPIO->P3ADS_f.P34 = 0;\ + M0P_GPIO->P34_SEL_f.SEL = 5;\ + M0P_GPIO->P3DIR_f.P34 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM1_TOG_P34() do{\ + M0P_GPIO->P3ADS_f.P34 = 0;\ + M0P_GPIO->P34_SEL_f.SEL = 7;\ + M0P_GPIO->P3DIR_f.P34 = 0;\ + }while(0); + +#define Gpio_SetFunc_UART1TX_P35() do{\ + M0P_GPIO->P3ADS_f.P35 = 0;\ + M0P_GPIO->P35_SEL_f.SEL = 1;\ + M0P_GPIO->P3DIR_f.P35 = 0;\ + }while(0); + +#define Gpio_SetFunc_TIM6_CHB_P35() do{\ + M0P_GPIO->P3ADS_f.P35 = 0;\ + M0P_GPIO->P35_SEL_f.SEL = 2;\ + M0P_GPIO->P3DIR_f.P35 = 0;\ + }while(0); + +#define Gpio_SetFunc_UART0TX_P35() do{\ + M0P_GPIO->P3ADS_f.P35 = 0;\ + M0P_GPIO->P35_SEL_f.SEL = 3;\ + M0P_GPIO->P3DIR_f.P35 = 0;\ + M0P_GPIO->P3PU_f.P35 = 1;\ + }while(0); + +#define Gpio_SetFunc_TIM0_GATE_P35() do{\ + M0P_GPIO->P3ADS_f.P35 = 0;\ + M0P_GPIO->P35_SEL_f.SEL = 4;\ + M0P_GPIO->P3DIR_f.P35 = 1;\ + }while(0); + +#define Gpio_SetFunc_TIM4_CHB_P35() do{\ + M0P_GPIO->P3ADS_f.P35 = 0;\ + M0P_GPIO->P35_SEL_f.SEL = 5;\ + M0P_GPIO->P3DIR_f.P35 = 0;\ + }while(0); + +#define Gpio_SetFunc_SPIMISO_P35() do{\ + M0P_GPIO->P3ADS_f.P35 = 0;\ + M0P_GPIO->P35_SEL_f.SEL = 6;\ + M0P_GPIO->P3DIR_f.P35 = 1;\ + }while(0); + +#define Gpio_SetFunc_I2CDAT_P35() do{\ + M0P_GPIO->P3ADS_f.P35 = 0;\ + M0P_GPIO->P35_SEL_f.SEL = 7;\ + M0P_GPIO->P3DIR_f.P35 = 0;\ + }while(0); + +#define Gpio_SetFunc_UART1RX_P36() do{\ + M0P_GPIO->P3ADS_f.P36 = 0;\ + M0P_GPIO->P36_SEL_f.SEL = 1;\ + M0P_GPIO->P3DIR_f.P36 = 1;\ + M0P_GPIO->P3PD_f.P36 = 1;\ + }while(0); + +#define Gpio_SetFunc_TIM6_CHA_P36() do{\ + M0P_GPIO->P3ADS_f.P36 = 0;\ + M0P_GPIO->P36_SEL_f.SEL = 2;\ + M0P_GPIO->P3DIR_f.P36 = 0;\ + }while(0); + +#define Gpio_SetFunc_UART0RX_P36() do{\ + M0P_GPIO->P3ADS_f.P36 = 0;\ + M0P_GPIO->P36_SEL_f.SEL = 3;\ + M0P_GPIO->P3DIR_f.P36 = 1;\ + }while(0); + +#define Gpio_SetFunc_PCA_CH4_P36(x) do{\ + M0P_GPIO->P3ADS_f.P36 = 0;\ + M0P_GPIO->P36_SEL_f.SEL = 4;\ + M0P_GPIO->P3DIR_f.P36 = (x);\ + }while(0); + +#define Gpio_SetFunc_TIM4_CHA_P36() do{\ + M0P_GPIO->P3ADS_f.P36 = 0;\ + M0P_GPIO->P36_SEL_f.SEL = 5;\ + M0P_GPIO->P3DIR_f.P36 = 0;\ + }while(0); + +#define Gpio_SetFunc_SPIMOSI_P36() do{\ + M0P_GPIO->P3ADS_f.P36 = 0;\ + M0P_GPIO->P36_SEL_f.SEL = 6;\ + M0P_GPIO->P3DIR_f.P36 = 0;\ + }while(0); + +#define Gpio_SetFunc_I2CCLK_P36() do{\ + M0P_GPIO->P3ADS_f.P36 = 0;\ + M0P_GPIO->P36_SEL_f.SEL = 7;\ + M0P_GPIO->P3DIR_f.P36 = 0;\ + }while(0); + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions ('extern') + ******************************************************************************/ + +/****************************************************************************** + Global function prototypes (definition in C source) +*******************************************************************************/ + + +//@} // GpioGroup + +#ifdef __cplusplus +} +#endif + +#endif /* __GPIO_H__ */ +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/project/driver/inc/i2c.h b/project/driver/inc/i2c.h new file mode 100644 index 0000000..f367a12 --- /dev/null +++ b/project/driver/inc/i2c.h @@ -0,0 +1,158 @@ +/****************************************************************************** +* 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 i2c.h + ** + ** Headerfile for I2C functions + ** + ** + ** History: + ** - 2017-06-13 CJ First Version + ** + *****************************************************************************/ + +#ifndef __I2C_H__ +#define __I2C_H__ + +#include "ddl.h" +#include "interrupts_hc32f003.h" + +/** + ******************************************************************************* + ** \defgroup I2cGroup Inter-Integrated Circuit (I2C) + ** + ** + ******************************************************************************/ +//@{ + +/******************************************************************************/ +/* Global pre-processor symbols/macros ('#define') */ +/******************************************************************************/ + +/****************************************************************************** + * Global type definitions + ******************************************************************************/ +/** + ****************************************************************************** + ** \brief I2C功能配置 + *****************************************************************************/ +typedef enum en_i2c_func +{ + I2cMode_En = 0, ///IFR_f.REG_INTF) + { + if (NULL != stcAdcIrqCalbaks.pfnAdcRegIrq) + { + stcAdcIrqCalbaks.pfnAdcRegIrq(); + } + M0P_ADC->ICLR_f.REG_INTC = 0u; + } + + if (TRUE == M0P_ADC->IFR_f.HHT_INTF) + { + if (NULL != stcAdcIrqCalbaks.pfnAdcHhtIrq) + { + stcAdcIrqCalbaks.pfnAdcHhtIrq(); + } + M0P_ADC->ICLR_f.HHT_INTC = 0u; + } + + if (TRUE == M0P_ADC->IFR_f.LLT_INTF) + { + if (NULL != stcAdcIrqCalbaks.pfnAdcLltIrq) + { + stcAdcIrqCalbaks.pfnAdcLltIrq(); + } + M0P_ADC->ICLR_f.LLT_INTC = 0u; + } + + if (TRUE == M0P_ADC->IFR_f.CONT_INTF) + { + if (NULL != stcAdcIrqCalbaks.pfnAdcContIrq) + { + stcAdcIrqCalbaks.pfnAdcContIrq(); + } + M0P_ADC->ICLR_f.CONT_INTC = 0u; + } +} + +/** + * \brief + * 配置ADC中断 + * + * \param [in] pstcAdcIrqCfg ADC中断配置指针 + * \param [in] pstcAdcIrqCalbaks ADC中断回调函数指针 + * + * \retval 无 + */ +void Adc_ConfigIrq(stc_adc_irq_t* pstcAdcIrqCfg, + stc_adc_irq_calbakfn_pt_t* pstcAdcIrqCalbaks) +{ + if (TRUE == pstcAdcIrqCfg->bAdcIrq) + { + if (NULL != pstcAdcIrqCalbaks->pfnAdcContIrq) + { + stcAdcIrqCalbaks.pfnAdcContIrq = pstcAdcIrqCalbaks->pfnAdcContIrq; + } + } + + if (TRUE == pstcAdcIrqCfg->bAdcRegCmp) + { + if (NULL != pstcAdcIrqCalbaks->pfnAdcRegIrq) + { + stcAdcIrqCalbaks.pfnAdcRegIrq = pstcAdcIrqCalbaks->pfnAdcRegIrq; + } + } + + if (TRUE == pstcAdcIrqCfg->bAdcHhtCmp) + { + if (NULL != pstcAdcIrqCalbaks->pfnAdcHhtIrq) + { + stcAdcIrqCalbaks.pfnAdcHhtIrq = pstcAdcIrqCalbaks->pfnAdcHhtIrq; + } + } + + if (TRUE == pstcAdcIrqCfg->bAdcLltCmp) + { + if (NULL != pstcAdcIrqCalbaks->pfnAdcLltIrq) + { + stcAdcIrqCalbaks.pfnAdcLltIrq = pstcAdcIrqCalbaks->pfnAdcLltIrq; + } + } +} + +/** + * \brief + * 获取ADC中断状态 + * + * \param [in] pstcAdcIrqState ADC中断状态指针 + * + * \retval 无 + */ +void Adc_GetIrqState(stc_adc_irq_t* pstcAdcIrqState) +{ + pstcAdcIrqState->bAdcIrq = M0P_ADC->IFR_f.CONT_INTF; + pstcAdcIrqState->bAdcRegCmp = M0P_ADC->IFR_f.REG_INTF; + pstcAdcIrqState->bAdcHhtCmp = M0P_ADC->IFR_f.HHT_INTF; + pstcAdcIrqState->bAdcLltCmp = M0P_ADC->IFR_f.LLT_INTF; +} + +/** + * \brief + * 清除ADC CONT中断状态 + * + * \param 无 + * + * \retval 无 + */ +void Adc_ClrContIrqState(void) +{ + M0P_ADC->ICLR = ~(1<<3); +} + +/** + * \brief + * 清除ADC REG中断状态 + * + * \param 无 + * + * \retval 无 + */ +void Adc_ClrRegIrqState(void) +{ + M0P_ADC->ICLR = ~(1<<2); +} + +/** + * \brief + * 清除ADC HHT中断状态 + * + * \param 无 + * + * \retval 无 + */ +void Adc_ClrHhtIrqState(void) +{ + M0P_ADC->ICLR = ~(1<<1); +} + +/** + * \brief + * 清除ADC LLT中断状态 + * + * \param 无 + * + * \retval 无 + */ +void Adc_ClrIrqLltState(void) +{ + M0P_ADC->ICLR = ~1; +} + + +/** + * \brief + * ADC中断使能 + * + * \param 无 + * + * \retval 无 + */ +void Adc_EnableIrq(void) +{ + M0P_ADC->CR0_f.IE = 1u; +} + +/** + * \brief + * ADC比较使能 + * + * \param [in] pstcAdcIrqCfg ADC比较配置 + * + * \retval 无 + */ +void Adc_CmpCfg(stc_adc_irq_t* pstcAdcIrqCfg) +{ + if (TRUE == pstcAdcIrqCfg->bAdcRegCmp) + { + M0P_ADC->CR1_f.REGCMP = 1u; + } + else + { + M0P_ADC->CR1_f.REGCMP = 0u; + } + + if (TRUE == pstcAdcIrqCfg->bAdcHhtCmp) + { + M0P_ADC->CR1_f.HTCMP = 1u; + } + else + { + M0P_ADC->CR1_f.HTCMP = 0u; + } + + if (TRUE == pstcAdcIrqCfg->bAdcLltCmp) + { + M0P_ADC->CR1_f.LTCMP = 1u; + } + else + { + M0P_ADC->CR1_f.LTCMP = 0u; + } + + AdcEnableNvic(ADC_IRQn); +} + +/** + * \brief + * ADC中断除能 + * + * \param 无 + * + * \retval 无 + */ +void Adc_DisableIrq(void) +{ + uint32_t u32Cr1; + + M0P_ADC->CR0_f.IE = 0u; + + u32Cr1 = M0P_ADC->CR1 | (1<<15); // must write 1 to bit 15 to avoid clear ADC_result_acc + u32Cr1 &= ~((1u<<12)|(1u<<13)|(1u<<14)); + M0P_ADC->CR1 = u32Cr1; + AdcDisableNvic(ADC_IRQn); +} + +/** + * \brief + * ADC初始化 + * + * \param [in] pstcAdcConfig ADC配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adc_Init(stc_adc_cfg_t* pstcAdcConfig) +{ + if (NULL == pstcAdcConfig) + { + return ErrorInvalidParameter; + } + + M0P_ADC->CR0_f.CLKSEL = pstcAdcConfig->enAdcClkSel; + M0P_ADC->CR0_f.SAM = pstcAdcConfig->enAdcSampTimeSel; + M0P_ADC->CR0_f.SREF = pstcAdcConfig->enAdcRefVolSel; + M0P_ADC->CR0_f.BUFEN = pstcAdcConfig->bAdcInBufEn; + M0P_ADC->HT_f.HT = pstcAdcConfig->u32AdcRegHighThd; + M0P_ADC->LT_f.LT = pstcAdcConfig->u32AdcRegLowThd; + M0P_ADC->CR1_f.TRIGS0 = pstcAdcConfig->enAdcTrig0Sel; + M0P_ADC->CR1_f.TRIGS1 = pstcAdcConfig->enAdcTrig1Sel; + M0P_ADC->CR0_f.IE = 0u; + M0P_ADC->CR1_f.REGCMP = 0u; + M0P_ADC->CR1_f.HTCMP = 0u; + M0P_ADC->CR1_f.LTCMP = 0u; + + return Ok; +} + +/** + * \brief + * ADC Deinit + * + * \param 无 + * + * \retval 无 + */ +void Adc_DeInit(void) +{ + AdcDisableNvic(ADC_IRQn); + + M0P_ADC->CR0_f.ADCEN = 0u; + + M0P_ADC->CR0_f.IE = 0u; + M0P_ADC->CR1_f.REGCMP = 0u; + M0P_ADC->CR1_f.HTCMP = 0u; + M0P_ADC->CR1_f.LTCMP = 0u; + M0P_ADC->ICLR_f.CONT_INTC = 0u; + M0P_ADC->ICLR_f.REG_INTC = 0u; + M0P_ADC->ICLR_f.HHT_INTC = 0u; + M0P_ADC->ICLR_f.LLT_INTC = 0u; + + M0P_ADC->CR0_f.CLKSEL = 0u; + M0P_ADC->CR0_f.SAM = 0x2u; + M0P_ADC->CR0_f.SREF = 0x3u; + M0P_ADC->CR0_f.SEL = 0xFu; + M0P_ADC->CR0_f.BUFEN = 0u; + M0P_ADC->HT_f.HT = 0xFFFu; + M0P_ADC->LT_f.LT = 0u; + M0P_ADC->CR1_f.TRIGS0 = 0u; + M0P_ADC->CR1_f.TRIGS1 = 0u; +} + +/** + * \brief + * ADC转换开始 + * + * \param 无 + * + * \retval 无 + */ + +void Adc_Start(void) +{ + M0P_ADC->ICLR_f.CONT_INTC = 0u; + M0P_ADC->CR0_f.STATERST = 1u; + M0P_ADC->CR0_f.START = 1u; +} + +/** + * \brief + * ADC转换停止 + * + * \param 无 + * + * \retval 无 + */ +void Adc_Stop(void) +{ + M0P_ADC->CR0_f.START = 0u; +} + +/** + * \brief + * ADC使能 + * + * \param 无 + * + * \retval 无 + */ +void Adc_Enable(void) +{ + M0P_ADC->CR0_f.ADCEN = 1u; +} + +/** + * \brief + * ADC除能 + * + * \param 无 + * + * \retval 无 + */ +void Adc_Disable(void) +{ + M0P_ADC->CR0_f.ADCEN = 0u; +} + +/** + * \brief + * 配置普通转换模式 + * + * \param [in] pstcAdcConfig ADC配置指针 + * \param [in] pstcAdcNormCfg 普通转换模式配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adc_ConfigNormMode(stc_adc_cfg_t* pstcAdcConfig, stc_adc_norm_cfg_t* pstcAdcNormCfg) +{ + if ((NULL == pstcAdcNormCfg) || (NULL == pstcAdcConfig)) + { + return ErrorInvalidParameter; + } + + pstcAdcConfig->enAdcOpMode = AdcNormalMode; + M0P_ADC->CR1_f.CT = 0u; + M0P_ADC->CR0_f.SEL = pstcAdcNormCfg->enAdcNormModeCh; + M0P_ADC->CR1_f.RACC_EN = pstcAdcNormCfg->bAdcResultAccEn; + + return Ok; +} + +/** + * \brief + * 配置连续转换模式 + * + * \param [in] pstcAdcConfig ADC配置指针 + * \param [in] pstcAdcNormCfg 连续转换模式配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adc_ConfigContMode(stc_adc_cfg_t* pstcAdcConfig, stc_adc_cont_cfg_t* pstcAdcContCfg) +{ + if ((NULL == pstcAdcContCfg) || (NULL == pstcAdcConfig)) + { + return ErrorInvalidParameter; + } + + pstcAdcConfig->enAdcOpMode = AdcContMode; + M0P_ADC->CR1_f.CT = 1u; + M0P_ADC->CR0_f.SEL = pstcAdcContCfg->enAdcContModeCh; + M0P_ADC->CR1_f.RACC_EN = pstcAdcContCfg->bAdcResultAccEn; + if (pstcAdcContCfg->bAdcResultAccEn) + { + M0P_ADC->CR1_f.RACC_CLR = 1u; + } + M0P_ADC->CR2 = 1<enAdcContModeCh; + M0P_ADC->CR2_f.ADCCNT = pstcAdcContCfg->u8AdcSampCnt; + + return Ok; +} + +/** + * \brief + * 配置扫描转换模式 + * + * \param [in] pstcAdcConfig ADC配置指针 + * \param [in] pstcAdcNormCfg 扫描转换模式配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adc_ConfigScanMode(stc_adc_cfg_t* pstcAdcConfig, stc_adc_scan_cfg_t* pstcAdcScanCfg) +{ + if ((NULL == pstcAdcScanCfg) || (NULL == pstcAdcConfig)) + { + return ErrorInvalidParameter; + } + + pstcAdcConfig->enAdcOpMode = AdcScanMode; + M0P_ADC->CR1_f.CT = 1u; + M0P_ADC->CR2 = pstcAdcScanCfg->u8AdcScanModeCh; + M0P_ADC->CR2_f.ADCCNT = pstcAdcScanCfg->u8AdcSampCnt; + + return Ok; +} + +/** + * \brief + * 查询ADC转换状态 + * + * \param none + * + * \retval boolean_t TRUE: ADC转换中 + * \retval boolean_t FALSE: ADC转换完成 + */ +boolean_t Adc_PollBusyState(void) +{ + return M0P_ADC->CR0_f.START; +} + +/** + * \brief + * 获取采样值 + * + * \param [out] pu16AdcResult 采样值指针 + * + * \retval en_result_t Ok: 成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adc_GetResult(uint16_t* pu16AdcResult) +{ + if (NULL == pu16AdcResult) + { + return ErrorInvalidParameter; + } + + *pu16AdcResult = M0P_ADC->RESULT_f.RESULT; + + return Ok; +} + +/** + * \brief + * 获取累加采样值 + * + * \param [out] pu32AdcAccResult 累加采样值指针 + * + * \retval en_result_t Ok: 成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adc_GetAccResult(uint32_t* pu32AdcAccResult) +{ + if (NULL == pu32AdcAccResult) + { + return ErrorInvalidParameter; + } + + *pu32AdcAccResult = M0P_ADC->RESULT_ACC_f.RESULT_ACC; + + return Ok; +} + +/** + * \brief + * 清零累加采样值 + * + * \param 无 + * + * \retval 无 + */ +void Adc_ClrAccResult(void) +{ + M0P_ADC->CR1_f.RACC_CLR = 0u; +} + +/** + * \brief + * 获取扫描采样模式下指定通道的采样值 + * + * \param [in] u8Channel 通道号 + * \param [out] pu16AdcResult 采样值指针 + * + * \retval en_result_t Ok: 成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adc_GetScanResult(uint8_t u8Channel, uint16_t* pu16AdcResult) +{ + if (NULL == pu16AdcResult) + { + return ErrorInvalidParameter; + } + + switch (u8Channel) + { + case AdcExInputCH0: + *pu16AdcResult = M0P_ADC->RESULT0_f.RESULT0; + break; + case AdcExInputCH1: + *pu16AdcResult = M0P_ADC->RESULT1_f.RESULT1; + break; + case AdcExInputCH2: + *pu16AdcResult = M0P_ADC->RESULT2_f.RESULT2; + break; + case AdcExInputCH3: + *pu16AdcResult = M0P_ADC->RESULT3_f.RESULT3; + break; + case AdcExInputCH4: + *pu16AdcResult = M0P_ADC->RESULT4_f.RESULT4; + break; + case AdcExInputCH5: + *pu16AdcResult = M0P_ADC->RESULT5_f.RESULT5; + break; + case AdcExInputCH6: + *pu16AdcResult = M0P_ADC->RESULT6_f.RESULT6; + break; + case AdcExInputCH7: + *pu16AdcResult = M0P_ADC->RESULT7_f.RESULT7; + break; + default: + return ErrorInvalidParameter; + } + return Ok; +} +/** + * \brief + * 获取ch8的采样值 + * \param [out] pu16AdcResult 采样值指针 + * + * \retval en_result_t Ok: 成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adc_GetCH8Result(uint16_t* pu16AdcResult) +{ + if (NULL == pu16AdcResult) + { + return ErrorInvalidParameter; + } + *pu16AdcResult = M0P_ADC->RESULT8_f.RESULT8; + return Ok; +} + +/** + * \brief + * 设置ADC参考电压 + * + * \param [in] enAdcRefVolSel ADC参考电压 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adc_SetVref(en_adc_ref_vol_sel_t enAdcRefVolSel) +{ + if (enAdcRefVolSel > RefVolSelAVDD) + { + return ErrorInvalidParameter; + } + + M0P_ADC->CR0_f.SREF = enAdcRefVolSel; + return Ok; +} + +//@} // AdcGroup + + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/project/driver/src/adt.c b/project/driver/src/adt.c new file mode 100644 index 0000000..7f40834 --- /dev/null +++ b/project/driver/src/adt.c @@ -0,0 +1,1854 @@ +/****************************************************************************** +* 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 + ** + ** - 2017-07-16 LiuHL First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adt.h" + +/** + ****************************************************************************** + ** \addtogroup AdtGroup + ******************************************************************************/ +//@{ + +/****************************************************************************** + * 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') + ******************************************************************************/ +static func_ptr_t pfnAdtIrqCbk[3][16]; + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + *****************************************************************************/ + +/** + * \brief + * 使能NVIC中ADT中断 + * + * \param [in] enIrqn 中断号 + * + * \retval 无 + */ +static void AdtEnableNvic(IRQn_Type enIrqn) +{ + NVIC_ClearPendingIRQ(enIrqn); + NVIC_EnableIRQ(enIrqn); + NVIC_SetPriority(enIrqn, DDL_IRQ_LEVEL_DEFAULT); +} + +/** + * \brief + * 除能NVIC中ADT中断 + * + * \param [in] enIrqn 中断号 + * + * \retval 无 + */ +static void AdtDisableNvic(IRQn_Type enIrqn) +{ + NVIC_ClearPendingIRQ(enIrqn); + NVIC_DisableIRQ(enIrqn); + NVIC_SetPriority(enIrqn, DDL_IRQ_LEVEL_DEFAULT); +} + +/** + * \brief + * ADC中断服务程序 + * + * \param [in] u8Param 未使用 + * + * \retval 无 + */ +void Adt_IRQHandler(uint8_t u8Param) +{ + uint8_t u8Adt = u8Param - 4; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*u8Adt); + + if (TRUE == pstcM0PAdt->IFR_f.CMAF) + { + if (NULL != pfnAdtIrqCbk[u8Adt][AdtCMAIrq]) + { + pfnAdtIrqCbk[u8Adt][AdtCMAIrq](); + } + pstcM0PAdt->ICLR = ~(1<IFR_f.CMBF) + { + if (NULL != pfnAdtIrqCbk[u8Adt][AdtCMBIrq]) + { + pfnAdtIrqCbk[u8Adt][AdtCMBIrq](); + } + pstcM0PAdt->ICLR = ~(1<IFR_f.CMCF) + { + if (NULL != pfnAdtIrqCbk[u8Adt][AdtCMCIrq]) + { + pfnAdtIrqCbk[u8Adt][AdtCMCIrq](); + } + pstcM0PAdt->ICLR = ~(1<IFR_f.CMDF) + { + if (NULL != pfnAdtIrqCbk[u8Adt][AdtCMDIrq]) + { + pfnAdtIrqCbk[u8Adt][AdtCMDIrq](); + } + pstcM0PAdt->ICLR = ~(1<IFR_f.OVFF) + { + if (NULL != pfnAdtIrqCbk[u8Adt][AdtOVFIrq]) + { + pfnAdtIrqCbk[u8Adt][AdtOVFIrq](); + } + pstcM0PAdt->ICLR = ~(1<IFR_f.UDFF) + { + if (NULL != pfnAdtIrqCbk[u8Adt][AdtUDFIrq]) + { + pfnAdtIrqCbk[u8Adt][AdtUDFIrq](); + } + pstcM0PAdt->ICLR = ~(1<IFR_f.DTEF) + { + if (NULL != pfnAdtIrqCbk[u8Adt][AdtDTEIrq]) + { + pfnAdtIrqCbk[u8Adt][AdtDTEIrq](); + } + pstcM0PAdt->ICLR = ~(1<ICONR; + if (bEn) + { + u32Val |= 1u<ICONR = u32Val; + return Ok; +} + +/** + * \brief + * 获取中断标志 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtIrq 中断类型 + * \param [in] pbFlag 中断标志指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_GetIrqFlag(en_adt_unit_t enAdtUnit, + en_adt_irq_type_t enAdtIrq, + boolean_t* pbFlag) +{ + uint32_t u32Val; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + u32Val = pstcM0PAdt->IFR; + *pbFlag = (u32Val>>enAdtIrq) & 0x1; + + return Ok; +} + +/** + * \brief + * 清除中断标志 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtIrq 中断类型 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ClearIrqFlag(en_adt_unit_t enAdtUnit, + en_adt_irq_type_t enAdtIrq) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->ICLR = ~(1u<HCUPR; + pstcM0PAdt->HCUPR = u32Val | (1u<HCUPR = 0; + return Ok; +} + + +/** + * \brief + * 配置硬件递减事件 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtHwCntDwn 硬件递减事件 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ConfigHwCntDwn(en_adt_unit_t enAdtUnit, en_adt_hw_cnt_t enAdtHwCntDwn) +{ + uint32_t u32Val; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if ((AdTIM6 < enAdtUnit) || (AdtHwCntMax <= enAdtHwCntDwn)) + { + return ErrorInvalidParameter; + } + + u32Val = pstcM0PAdt->HCDOR; + pstcM0PAdt->HCDOR = u32Val | (1u<HCDOR = 0; + return Ok; +} + +/** + * \brief + * 配置硬件启动事件 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtHwStart 硬件启动事件 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ConfigHwStart(en_adt_unit_t enAdtUnit, en_adt_hw_trig_t enAdtHwStart) +{ + uint32_t u32Val; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if ((AdTIM6 < enAdtUnit) || (AdtHwTrigEnd <= enAdtHwStart)) + { + return ErrorInvalidParameter; + } + u32Val = pstcM0PAdt->HSTAR; + pstcM0PAdt->HSTAR = u32Val | (1u<HSTAR = 0; + return Ok; +} + +/** + * \brief + * 使能硬件启动 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_EnableHwStart(en_adt_unit_t enAdtUnit) +{ + uint32_t u32Val; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + u32Val = pstcM0PAdt->HSTAR; + pstcM0PAdt->HSTAR = u32Val | (1u<<31); + return Ok; +} + +/** + * \brief + * 除能硬件启动 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_DisableHwStart(en_adt_unit_t enAdtUnit) +{ + uint32_t u32Val; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + u32Val = pstcM0PAdt->HSTAR; + pstcM0PAdt->HSTAR = u32Val & 0x7FFFFFFF; + return Ok; +} + +/** + * \brief + * 配置硬件停止事件 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtHwStop 硬件停止事件 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ConfigHwStop(en_adt_unit_t enAdtUnit, en_adt_hw_trig_t enAdtHwStop) +{ + uint32_t u32Val; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if ((AdTIM6 < enAdtUnit) || (AdtHwTrigEnd <= enAdtHwStop)) + { + return ErrorInvalidParameter; + } + u32Val = pstcM0PAdt->HSTPR; + pstcM0PAdt->HSTPR = u32Val | (1u<HSTPR = 0; + return Ok; +} + +/** + * \brief + * 使能硬件停止 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_EnableHwStop(en_adt_unit_t enAdtUnit) +{ + uint32_t u32Val; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + u32Val = pstcM0PAdt->HSTPR; + pstcM0PAdt->HSTPR = u32Val | (1u<<31); + return Ok; +} + +/** + * \brief + * 除能硬件停止 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_DisableHwStop(en_adt_unit_t enAdtUnit) +{ + uint32_t u32Val; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + u32Val = pstcM0PAdt->HSTPR; + pstcM0PAdt->HSTPR = u32Val & 0x7FFFFFFF; + return Ok; +} + +/** + * \brief + * 配置硬件清零事件 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtHwClear 硬件清零事件 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ConfigHwClear(en_adt_unit_t enAdtUnit, en_adt_hw_trig_t enAdtHwClear) +{ + uint32_t u32Val; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if ((AdTIM6 < enAdtUnit) || (AdtHwTrigEnd <= enAdtHwClear)) + { + return ErrorInvalidParameter; + } + u32Val = pstcM0PAdt->HCELR & (1u<<31); + pstcM0PAdt->HCELR = u32Val | (1u<HCELR = 0; + return Ok; +} + +/** + * \brief + * 使能硬件清零 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_EnableHwClear(en_adt_unit_t enAdtUnit) +{ + uint32_t u32Val; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + u32Val = pstcM0PAdt->HCELR; + pstcM0PAdt->HCELR = u32Val | (1u<<31); + return Ok; +} + +/** + * \brief + * 除能硬件清零 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_DisableHwClear(en_adt_unit_t enAdtUnit) +{ + uint32_t u32Val; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + u32Val = pstcM0PAdt->HCELR; + pstcM0PAdt->HCELR = u32Val & 0x7FFFFFFF; + return Ok; +} + +/** + * \brief + * 配置硬件捕获A事件 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtHwCaptureA 硬件捕获A事件选择 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ConfigHwCaptureA(en_adt_unit_t enAdtUnit, en_adt_hw_trig_t enAdtHwCaptureA) +{ + uint32_t u32Val; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if ((AdTIM6 < enAdtUnit) || (AdtHwTrigEnd <= enAdtHwCaptureA)) + { + return ErrorInvalidParameter; + } + + u32Val = pstcM0PAdt->HCPAR; + pstcM0PAdt->HCPAR = u32Val | (1u<PCONR_f.CAPCA = 1; + return Ok; +} + +/** + * \brief + * 清除硬件捕获A事件 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ClearHwCaptureA(en_adt_unit_t enAdtUnit) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->HCPAR = 0; + return Ok; +} + +/** + * \brief + * 配置硬件捕获B事件 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtHwCaptureB 硬件捕获B事件选择 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ConfigHwCaptureB(en_adt_unit_t enAdtUnit, en_adt_hw_trig_t enAdtHwCaptureB) +{ + uint32_t u32Val; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if ((AdTIM6 < enAdtUnit) || (AdtHwTrigEnd <= enAdtHwCaptureB)) + { + return ErrorInvalidParameter; + } + + u32Val = pstcM0PAdt->HCPBR; + pstcM0PAdt->HCPBR = u32Val | (1u<PCONR_f.CAPCB = 1; + return Ok; +} + +/** + * \brief + * 清除硬件捕获B事件 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ClearHwCaptureB(en_adt_unit_t enAdtUnit) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->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 |= 0x1; + } + if (pstcAdtSwSyncStart->bAdTim5) + { + u32Val |= 0x2; + } + if (pstcAdtSwSyncStart->bAdTim6) + { + u32Val |= 0x4; + } + + M0P_ADT0->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 |= 0x1; + } + if (pstcAdtSwSyncStop->bAdTim5) + { + u32Val |= 0x2; + } + if (pstcAdtSwSyncStop->bAdTim6) + { + u32Val |= 0x4; + } + + M0P_ADT0->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 |= 0x1; + } + if (pstcAdtSwSyncClear->bAdTim5) + { + u32Val |= 0x2; + } + if (pstcAdtSwSyncClear->bAdTim6) + { + u32Val |= 0x4; + } + + M0P_ADT0->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_ADT0->SSTAR & 0x1) + { + pstcAdtSwSyncState->bAdTim4 = TRUE; + } + else + { + pstcAdtSwSyncState->bAdTim4 = FALSE; + } + if (M0P_ADT0->SSTAR & 0x2) + { + pstcAdtSwSyncState->bAdTim5 = TRUE; + } + else + { + pstcAdtSwSyncState->bAdTim5 = FALSE; + } + if (M0P_ADT0->SSTAR & 0x4) + { + 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_AosTrigConfig(stc_adt_aos_trig_cfg_t* pstcAdtAosTrigCfg) +{ + if (NULL == pstcAdtAosTrigCfg) + { + return ErrorInvalidParameter; + } + + M0P_ADT0->ITRIG_f.IAOS0S = pstcAdtAosTrigCfg->enAos0TrigSrc; + M0P_ADT0->ITRIG_f.IAOS1S = pstcAdtAosTrigCfg->enAos1TrigSrc; + M0P_ADT0->ITRIG_f.IAOS2S = pstcAdtAosTrigCfg->enAos2TrigSrc; + M0P_ADT0->ITRIG_f.IAOS3S = pstcAdtAosTrigCfg->enAos3TrigSrc; + return Ok; +} + +/** + * \brief + * 中断触发配置 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] pstcAdtIrqTrigCfg 触发配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_IrqTrigConfig(en_adt_unit_t enAdtUnit, + stc_adt_irq_trig_cfg_t* pstcAdtIrqTrigCfg) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if ((AdTIM6 < enAdtUnit) || (NULL == pstcAdtIrqTrigCfg)) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->CR_f.UDFE = pstcAdtIrqTrigCfg->bAdtUnderFlowTrigEn; + pstcM0PAdt->CR_f.OVFE = pstcAdtIrqTrigCfg->bAdtOverFlowTrigEn; + pstcM0PAdt->CR_f.CMDE = pstcAdtIrqTrigCfg->bAdtCntMatchDTrigEn; + pstcM0PAdt->CR_f.CMCE = pstcAdtIrqTrigCfg->bAdtCntMatchCTrigEn; + pstcM0PAdt->CR_f.CMBE = pstcAdtIrqTrigCfg->bAdtCntMatchBTrigEn; + pstcM0PAdt->CR_f.CMAE = pstcAdtIrqTrigCfg->bAdtCntMatchATrigEn; + return Ok; +} + +/** + * \brief + * 端口触发配置 + * + * \param [in] enAdtTrigPort 触发端口 + * \param [in] pstcAdtPortTrigCfg 触发配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_PortTrigConfig(en_adt_trig_port_t enAdtTrigPort, + stc_adt_port_trig_cfg_t* pstcAdtPortTrigCfg) +{ + if (NULL == pstcAdtPortTrigCfg) + { + return ErrorInvalidParameter; + } + + switch (enAdtTrigPort) + { + case AdtTrigA: + M0P_ADT0->TTRIG_f.TRIGAS = pstcAdtPortTrigCfg->enTrigSrc; + M0P_ADT0->FCONR_f.NOFIENTA = pstcAdtPortTrigCfg->bFltEn; + M0P_ADT0->FCONR_f.NOFICKTA = pstcAdtPortTrigCfg->enFltClk; + break; + + case AdtTrigB: + M0P_ADT0->TTRIG_f.TRIGBS = pstcAdtPortTrigCfg->enTrigSrc; + M0P_ADT0->FCONR_f.NOFIENTB = pstcAdtPortTrigCfg->bFltEn; + M0P_ADT0->FCONR_f.NOFICKTB = pstcAdtPortTrigCfg->enFltClk; + break; + + case AdtTrigC: + M0P_ADT0->TTRIG_f.TRIGCS = pstcAdtPortTrigCfg->enTrigSrc; + M0P_ADT0->FCONR_f.NOFIENTC = pstcAdtPortTrigCfg->bFltEn; + M0P_ADT0->FCONR_f.NOFICKTC = pstcAdtPortTrigCfg->enFltClk; + break; + + case AdtTrigD: + M0P_ADT0->TTRIG_f.TRIGDS = pstcAdtPortTrigCfg->enTrigSrc; + M0P_ADT0->FCONR_f.NOFIENTD = pstcAdtPortTrigCfg->bFltEn; + M0P_ADT0->FCONR_f.NOFICKTD = pstcAdtPortTrigCfg->enFltClk; + break; + + default: + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + * \brief + * CHxX端口配置 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtCHxXPort TIMxX端口 + * \param [in] pstcAdtCHxXCfg TIMxX端口配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_CHxXPortConfig(en_adt_unit_t enAdtUnit, + en_adt_CHxX_port_t enAdtCHxXPort, + stc_adt_CHxX_port_cfg_t* pstcAdtCHxXCfg) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if ((AdTIM6 < enAdtUnit) || (NULL == pstcAdtCHxXCfg)) + { + return ErrorInvalidParameter; + } + + switch (enAdtCHxXPort) + { + case AdtCHxA: + pstcM0PAdt->PCONR_f.CAPCA = pstcAdtCHxXCfg->enCap; + pstcM0PAdt->PCONR_f.STACA = pstcAdtCHxXCfg->enStaOut; + pstcM0PAdt->PCONR_f.STPCA = pstcAdtCHxXCfg->enStpOut; + pstcM0PAdt->PCONR_f.STASTPSA = pstcAdtCHxXCfg->enStaStp; + pstcM0PAdt->PCONR_f.CMPCA = pstcAdtCHxXCfg->enCmpc; + pstcM0PAdt->PCONR_f.PERCA = pstcAdtCHxXCfg->enPerc; + pstcM0PAdt->PCONR_f.OUTENA = pstcAdtCHxXCfg->bOutEn; + pstcM0PAdt->PCONR_f.DISSELA = pstcAdtCHxXCfg->enDisSel; + pstcM0PAdt->PCONR_f.DISVALA = pstcAdtCHxXCfg->enDisVal; + pstcM0PAdt->FCONR_f.NOFIENGA = pstcAdtCHxXCfg->bFltEn; + pstcM0PAdt->FCONR_f.NOFICKGA = pstcAdtCHxXCfg->enFltClk; + break; + + case AdtCHxB: + pstcM0PAdt->PCONR_f.CAPCB = pstcAdtCHxXCfg->enCap; + pstcM0PAdt->PCONR_f.STACB = pstcAdtCHxXCfg->enStaOut; + pstcM0PAdt->PCONR_f.STPCB = pstcAdtCHxXCfg->enStpOut; + pstcM0PAdt->PCONR_f.STASTPSB = pstcAdtCHxXCfg->enStaStp; + pstcM0PAdt->PCONR_f.CMPCB = pstcAdtCHxXCfg->enCmpc; + pstcM0PAdt->PCONR_f.PERCB = pstcAdtCHxXCfg->enPerc; + pstcM0PAdt->PCONR_f.OUTENB = pstcAdtCHxXCfg->bOutEn; + pstcM0PAdt->PCONR_f.DISSELB = pstcAdtCHxXCfg->enDisSel; + pstcM0PAdt->PCONR_f.DISVALB = pstcAdtCHxXCfg->enDisVal; + pstcM0PAdt->FCONR_f.NOFIENGB = pstcAdtCHxXCfg->bFltEn; + pstcM0PAdt->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_ADT0->PTBKP; + u32Val &= ~(1u<PTBKP = u32Val | (pstcAdtBrkPtCfg->enPol<PTBKS; + M0P_ADT0->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 <= 15; i++) + { + if (TRUE == pstcAdtDisable3->stcBrkPtCfg[i].bPortEn) + { + Adt_EnableBrakePort(i, &pstcAdtDisable3->stcBrkPtCfg[i]); + } + } + + M0P_ADT0->AOSSR_f.BFILTEN = pstcAdtDisable3->bFltEn; + M0P_ADT0->AOSSR_f.BFILTS = pstcAdtDisable3->enFltClk; + M0P_ADT0->AOSSR_f.SOFTBK = pstcAdtDisable3->bSwBrk; + + return Ok; +} + +/** + * \brief + * 获取端口刹车标志 + * + * \param none + * + * \retval TRUE or FALSE + */ +boolean_t Adt_GetPortBrakeFlag(void) +{ + return M0P_ADT0->AOSSR_f.FBRAKE; +} + +/** + * \brief + * 清除端口刹车标志 + * + * \param none + * + * \retval none + */ +void Adt_ClearPortBrakeFlag(void) +{ + M0P_ADT0->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_ADT0->AOSSR_f.SMH2 = pstcAdtDisable1->bTim6OutSH; + M0P_ADT0->AOSSR_f.SMH1 = pstcAdtDisable1->bTim5OutSH; + M0P_ADT0->AOSSR_f.SMH0 = pstcAdtDisable1->bTim4OutSH; + M0P_ADT0->AOSSR_f.SML2 = pstcAdtDisable1->bTim6OutSL; + M0P_ADT0->AOSSR_f.SML1 = pstcAdtDisable1->bTim5OutSL; + M0P_ADT0->AOSSR_f.SML0 = pstcAdtDisable1->bTim4OutSL; + + return Ok; +} + +/** + * \brief + * 获取同高同低刹车标志 + * + * \param none + * + * \retval TRUE or FALSE + */ +boolean_t Adt_GetSameBrakeFlag(void) +{ + return M0P_ADT0->AOSSR_f.FSAME; +} + +/** + * \brief + * 清除同高同低刹车标志 + * + * \param none + * + * \retval none + */ +void Adt_ClearSameBrakeFlag(void) +{ + M0P_ADT0->AOSCL_f.FSAME = 0; +} + +/** + * \brief + * PWM展频配置 + * + * \param [in] pstcAdtPwmDitherCfg PWM展频配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_PwmDitherConfig(stc_adt_pwm_dither_cfg_t* pstcAdtPwmDitherCfg) +{ + if (NULL == pstcAdtPwmDitherCfg) + { + return ErrorInvalidParameter; + } + + M0P_ADT0->CR_f.DITENS = pstcAdtPwmDitherCfg->enAdtPDType; + M0P_ADT0->CR_f.DITENB = pstcAdtPwmDitherCfg->bTimxBPDEn; + M0P_ADT0->CR_f.DITENA = pstcAdtPwmDitherCfg->bTimxAPDEn; + return Ok; +} + +/** + * \brief + * ADT初始化 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] pstcAdtBaseCntCfg 计数配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_Init(en_adt_unit_t enAdtUnit, stc_adt_basecnt_cfg_t* pstcAdtBaseCntCfg) +{ + int32_t i; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if ((AdTIM6 < enAdtUnit) || (NULL == pstcAdtBaseCntCfg)) + { + return ErrorInvalidParameter; + } + + if (AdtTriangleModeB < pstcAdtBaseCntCfg->enCntMode) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->GCONR_f.MODE = pstcAdtBaseCntCfg->enCntMode; + pstcM0PAdt->GCONR_f.DIR = pstcAdtBaseCntCfg->enCntDir; + pstcM0PAdt->GCONR_f.CKDIV = pstcAdtBaseCntCfg->enCntClkDiv; + + for (i = 0; i < 16; i++) + { + pfnAdtIrqCbk[enAdtUnit][i] = NULL; + } + + AdtEnableNvic((IRQn_Type)((int32_t)TIM4_IRQn + (int32_t)enAdtUnit)); + + return Ok; +} + +/** + * \brief + * ADT Deinit + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_DeInit(en_adt_unit_t enAdtUnit) +{ + int32_t i; + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->GCONR_f.START = 0; + + AdtDisableNvic((IRQn_Type)((int32_t)TIM4_IRQn + (int32_t)enAdtUnit)); + + for (i = 0; i < 16; i++) + { + pfnAdtIrqCbk[enAdtUnit][i] = NULL; + } + + return Ok; +} + +/** + * \brief + * 开始计数 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_StartCount(en_adt_unit_t enAdtUnit) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->GCONR_f.START = 1; + + return Ok; +} + +/** + * \brief + * 停止计数 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_StopCount(en_adt_unit_t enAdtUnit) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->GCONR_f.START = 0; + + return Ok; +} + +/** + * \brief + * 设置计数值 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] u16Value 计数值 + * + * \retval en_result_t Ok: 配置成功 + * ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_SetCount(en_adt_unit_t enAdtUnit, uint16_t u16Value) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->CNTER_f.CNT = u16Value; + return Ok; +} + +/** + * \brief + * 清除计数值 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] u16Value 计数值 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ClearCount(en_adt_unit_t enAdtUnit) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->CNTER_f.CNT = 0; + return Ok; +} + +/** + * \brief + * 获取计数状态 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] pstcAdtCntState 计数状态指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_GetCntState(en_adt_unit_t enAdtUnit, stc_adt_cntstate_cfg_t* pstcAdtCntState) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if ((AdTIM6 < enAdtUnit) || (NULL == pstcAdtCntState)) + { + return ErrorInvalidParameter; + } + + pstcAdtCntState->u16Counter = pstcM0PAdt->CNTER_f.CNT; + pstcAdtCntState->enCntDir = pstcM0PAdt->STFLR_f.DIRF; + pstcAdtCntState->u8ValidPeriod = pstcM0PAdt->STFLR_f.VPERNUM; + pstcAdtCntState->bDTEF = pstcM0PAdt->STFLR_f.DTEF; + pstcAdtCntState->bUDFF = pstcM0PAdt->STFLR_f.UDFF; + pstcAdtCntState->bOVFF = pstcM0PAdt->STFLR_f.OVFF; + pstcAdtCntState->bCMDF = pstcM0PAdt->STFLR_f.CMDF; + pstcAdtCntState->bCMCF = pstcM0PAdt->STFLR_f.CMCF; + pstcAdtCntState->bCMBF = pstcM0PAdt->STFLR_f.CMBF; + pstcAdtCntState->bCMAF = pstcM0PAdt->STFLR_f.CMAF; + + return Ok; +} + +/** + * \brief + * 配置计数周期 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] u16Period 计数周期值 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_SetPeriod(en_adt_unit_t enAdtUnit, uint16_t u16Period) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->PERAR = u16Period; + + return Ok; +} + +/** + * \brief + * 配置计数周期缓冲 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] u16PeriodBuf 计数周期缓冲值 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_SetPeriodBuf(en_adt_unit_t enAdtUnit, uint16_t u16PeriodBuf) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->PERBR = u16PeriodBuf; + pstcM0PAdt->BCONR_f.BENP = 1u; + + return Ok; +} + +/** + * \brief + * 清除计数周期缓冲 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ClearPeriodBuf(en_adt_unit_t enAdtUnit) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->BCONR_f.BENP = 0; + pstcM0PAdt->PERBR = 0; + + return Ok; +} + +/** + * \brief + * 配置有效计数周期 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] pstcAdtValidPerCfg 有效计数周期配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_SetValidPeriod(en_adt_unit_t enAdtUnit, + stc_adt_validper_cfg_t* pstcAdtValidPerCfg) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if ((AdTIM6 < enAdtUnit) || (NULL == pstcAdtValidPerCfg)) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->VPERR_f.PCNTS = pstcAdtValidPerCfg->enValidCnt; + pstcM0PAdt->VPERR_f.PCNTE = pstcAdtValidPerCfg->enValidCdt; + pstcM0PAdt->VPERR_f.GEPERID = pstcAdtValidPerCfg->bPeriodD; + pstcM0PAdt->VPERR_f.GEPERIC = pstcAdtValidPerCfg->bPeriodC; + pstcM0PAdt->VPERR_f.GEPERIB = pstcAdtValidPerCfg->bPeriodB; + pstcM0PAdt->VPERR_f.GEPERIA = pstcAdtValidPerCfg->bPeriodA; + + return Ok; +} + +/** + * \brief + * 配置比较输出计数基准值 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtCompare 比较基准 + * \param [in] u16Compare 比较基准值 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_SetCompareValue(en_adt_unit_t enAdtUnit, + en_adt_compare_t enAdtCompare, + uint16_t u16Compare) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + if (AdtCompareA == enAdtCompare) + { + pstcM0PAdt->GCMAR = u16Compare; + } + else if (AdtCompareB == enAdtCompare) + { + pstcM0PAdt->GCMBR = u16Compare; + } + else if (AdtCompareC == enAdtCompare) + { + pstcM0PAdt->GCMCR = u16Compare; + } + else if (AdtCompareD == enAdtCompare) + { + pstcM0PAdt->GCMDR = u16Compare; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + * \brief + * 配置通用比较值/捕获值缓存传送 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtCHxXPort TIMxX端口 + * \param [in] bCompareBufEn 通用比较值缓存传送使能 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_EnableValueBuf(en_adt_unit_t enAdtUnit, + en_adt_CHxX_port_t enAdtCHxXPort, + boolean_t bCompareBufEn) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + if (AdtCHxA == enAdtCHxXPort) + { + pstcM0PAdt->BCONR_f.BENA = bCompareBufEn; + } + else if (AdtCHxB == enAdtCHxXPort) + { + pstcM0PAdt->BCONR_f.BENB = bCompareBufEn; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + * \brief + * 清除比较输出计数值/捕获值缓存 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtCHxXPort TIMxX端口 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ClearValueBuf(en_adt_unit_t enAdtUnit, + en_adt_CHxX_port_t enAdtCHxXPort) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + if (AdtCHxA == enAdtCHxXPort) + { + pstcM0PAdt->GCMCR = 0; + pstcM0PAdt->BCONR_f.BENA = 0; + } + else if (AdtCHxB == enAdtCHxXPort) + { + pstcM0PAdt->GCMDR = 0; + pstcM0PAdt->BCONR_f.BENB = 0; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + * \brief + * 获取捕获值 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtCHxXPort TIMxX端口 + * \param [in] pu16Capture 捕获值指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_GetCaptureValue(en_adt_unit_t enAdtUnit, + en_adt_CHxX_port_t enAdtCHxXPort, + uint16_t* pu16Capture) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + if (AdtCHxA == enAdtCHxXPort) + { + *pu16Capture = pstcM0PAdt->GCMAR_f.GCMA; + } + else if (AdtCHxB == enAdtCHxXPort) + { + *pu16Capture = pstcM0PAdt->GCMBR_f.GCMB; + } + else + { + return ErrorInvalidParameter; + } + return Ok; +} + +/** + * \brief + * 获取捕获缓存值 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] enAdtCHxXPort TIMxX端口 + * \param [in] pu16CaptureBuf 捕获缓存值指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_GetCaptureBuf(en_adt_unit_t enAdtUnit, + en_adt_CHxX_port_t enAdtCHxXPort, + uint16_t* pu16CaptureBuf) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + if (AdtCHxA == enAdtCHxXPort) + { + *pu16CaptureBuf = pstcM0PAdt->GCMCR_f.GCMC; + } + else if (AdtCHxB == enAdtCHxXPort) + { + *pu16CaptureBuf = pstcM0PAdt->GCMDR_f.GCMD; + } + else + { + return ErrorInvalidParameter; + } + return Ok; +} + +/** + * \brief + * 设置死区时间上基准值 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] u16Value 死区时间上基准值 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_SetDTUA(en_adt_unit_t enAdtUnit, + uint16_t u16Value) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->DTUAR = u16Value; + + + return Ok; +} + +/** + * \brief + * 设置死区时间下基准值 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] u16Value 死区时间下基准值 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_SetDTDA(en_adt_unit_t enAdtUnit, + uint16_t u16Value) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->DTDAR = u16Value; + + + return Ok; +} + +/** + * \brief + * 配置死区时间功能 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] bDTEn 死区功能使能 + * \param [in] bEqual DTDAR的值和DTUAR的值自动相等 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ConfigDT(en_adt_unit_t enAdtUnit, + boolean_t bDTEn, + boolean_t bEqual) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if (AdTIM6 < enAdtUnit) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->DCONR_f.DTCEN = bDTEn; + pstcM0PAdt->DCONR_f.SEPA = bEqual; + + return Ok; +} + +/** + * \brief + * Z相输入屏蔽设置 + * + * \param [in] enAdtUnit ADV Timer通道选择(TIM4、TIM5、TIM6) + * \param [in] pstcAdtZMaskCfg 计数配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Adt_ConfigZMask(en_adt_unit_t enAdtUnit, stc_adt_zmask_cfg_t* pstcAdtZMaskCfg) +{ + volatile M0P_ADT_TypeDef *pstcM0PAdt = (M0P_ADT_TypeDef *)((uint32_t)M0P_ADT0+0x400*enAdtUnit); + + if ((AdTIM6 < enAdtUnit) || (NULL == pstcAdtZMaskCfg)) + { + return ErrorInvalidParameter; + } + + pstcM0PAdt->GCONR_f.ZMSK = pstcAdtZMaskCfg->enZMaskCycle; + pstcM0PAdt->GCONR_f.ZMSKPOS = pstcAdtZMaskCfg->bFltPosCntMaksEn; + pstcM0PAdt->GCONR_f.ZMSKREV = pstcAdtZMaskCfg->bFltRevCntMaksEn; + + return Ok; +} + +//@} // AdtGroup + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/project/driver/src/bt.c b/project/driver/src/bt.c new file mode 100644 index 0000000..091400a --- /dev/null +++ b/project/driver/src/bt.c @@ -0,0 +1,564 @@ +/****************************************************************************** +*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 bt.c + ** + ** Common API of base timer. + ** @link btGroup Some description @endlink + ** + ** - 2017-05-16 + ** + ******************************************************************************/ + +/******************************************************************************* + * 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') + ******************************************************************************/ +static func_ptr_t pfnTim0Callback = NULL; +static func_ptr_t pfnTim1Callback = NULL; +static func_ptr_t pfnTim2Callback = NULL; +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +/** + ***************************************************************************** + ** \brief Base Timer 中断标志获取 + ** + ** + ** \param [in] enUnit Timer通道选择(TIM0、TIM1、TIM2) + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +boolean_t Bt_GetIntFlag(en_bt_unit_t enUnit) +{ + boolean_t bRetVal = FALSE; + + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enUnit) + { + case TIM0: + bRetVal = M0P_BT0->IFR_f.TF ? TRUE : FALSE; + break; + case TIM1: + bRetVal = M0P_BT1->IFR_f.TF ? TRUE : FALSE; + break; + case TIM2: + bRetVal = M0P_BT2->IFR_f.TF ? TRUE : FALSE; + break; + default: + bRetVal = FALSE; + break; + } + + return bRetVal; +} + +/** + ***************************************************************************** + ** \brief Base Timer 中断标志清除 + ** + ** + ** \param [in] enUnit Timer通道选择(TIM0、TIM1、TIM2) + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_ClearIntFlag(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enUnit) + { + case TIM0: + M0P_BT0->ICLR_f.TFC = FALSE; + break; + case TIM1: + M0P_BT1->ICLR_f.TFC = FALSE;; + break; + case TIM2: + M0P_BT2->ICLR_f.TFC = FALSE;; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 中断使能 + ** + ** + ** \param [in] enUnit Timer通道选择(TIM0、TIM1、TIM2) + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_EnableIrq (en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enUnit) + { + case TIM0: + M0P_BT0->CR_f.IE = TRUE; + break; + case TIM1: + M0P_BT1->CR_f.IE = TRUE; + break; + case TIM2: + M0P_BT2->CR_f.IE = TRUE; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 中断禁止 + ** + ** + ** \param [in] enUnit Timer通道选择(TIM0、TIM1、TIM2) + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_DisableIrq(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enUnit) + { + case TIM0: + M0P_BT0->CR_f.IE = FALSE; + break; + case TIM1: + M0P_BT1->CR_f.IE = FALSE; + break; + case TIM2: + M0P_BT2->CR_f.IE = FALSE; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 中断服务函数 + ** + ** + ** \param [in] u8Param Timer通道选择(0 - TIM0、1 - TIM1、2 - TIM2) + ** + ** \retval NULL + *****************************************************************************/ +void Tim_IRQHandler(uint8_t u8Param) +{ + switch (u8Param) + { + case 0: + pfnTim0Callback(); + break; + case 1: + pfnTim1Callback(); + break; + case 2: + pfnTim2Callback(); + break; + default: + ; + break; + } +} + + + +/** + ***************************************************************************** + ** \brief Base Timer 初始化配置 + ** + ** + ** \param [in] enUnit Timer通道选择(TIM0、TIM1、TIM2) + ** \param [in] pstcConfig 初始化配置结构体指针 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Init(en_bt_unit_t enUnit, stc_bt_config_t* pstcConfig) +{ + en_result_t enResult = Ok; + + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enUnit) + { + case TIM0: + { + M0P_BT0->CR_f.GATE_P = pstcConfig->enGateP; + M0P_BT0->CR_f.GATE = pstcConfig->enGate; + M0P_BT0->CR_f.PRS = pstcConfig->enPRS; + M0P_BT0->CR_f.TOG_EN = pstcConfig->enTog; + M0P_BT0->CR_f.CT = pstcConfig->enCT; + M0P_BT0->CR_f.MD = pstcConfig->enMD; + + pfnTim0Callback = pstcConfig->pfnTim0Cb; + } + break; + case TIM1: + { + M0P_BT1->CR_f.GATE_P = pstcConfig->enGateP; + M0P_BT1->CR_f.GATE = pstcConfig->enGate; + M0P_BT1->CR_f.PRS = pstcConfig->enPRS; + M0P_BT1->CR_f.TOG_EN = pstcConfig->enTog; + M0P_BT1->CR_f.CT = pstcConfig->enCT; + M0P_BT1->CR_f.MD = pstcConfig->enMD; + + pfnTim1Callback = pstcConfig->pfnTim1Cb; + } + break; + case TIM2: + { + M0P_BT2->CR_f.GATE_P = pstcConfig->enGateP; + M0P_BT2->CR_f.GATE = pstcConfig->enGate; + M0P_BT2->CR_f.PRS = pstcConfig->enPRS; + M0P_BT2->CR_f.TOG_EN = pstcConfig->enTog; + M0P_BT2->CR_f.CT = pstcConfig->enCT; + M0P_BT2->CR_f.MD = pstcConfig->enMD; + + pfnTim2Callback = pstcConfig->pfnTim2Cb; + } + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 启动运行 + ** + ** + ** \param [in] enUnit Timer通道选择(TIM0、TIM1、TIM2) + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Run(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enUnit) + { + case TIM0: + M0P_BT0->CR_f.TR = TRUE; + break; + case TIM1: + M0P_BT1->CR_f.TR = TRUE; + break; + case TIM2: + M0P_BT2->CR_f.TR = TRUE; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 停止运行 + ** + ** + ** \param [in] enUnit Timer通道选择(TIM0、TIM1、TIM2) + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Stop(en_bt_unit_t enUnit) +{ + en_result_t enResult = Ok; + + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enUnit) + { + case TIM0: + M0P_BT0->CR_f.TR = FALSE; + break; + case TIM1: + M0P_BT1->CR_f.TR = FALSE; + break; + case TIM2: + M0P_BT2->CR_f.TR = FALSE; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 重载值设置 + ** + ** + ** \param [in] enUnit Timer通道选择(TIM0、TIM1、TIM2) + ** \param [in] u16Data 16bits重载值 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_ARRSet(en_bt_unit_t enUnit, uint16_t u16Data) +{ + en_result_t enResult = Ok; + + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enUnit) + { + case TIM0: + M0P_BT0->ARR_f.ARR = u16Data; + break; + case TIM1: + M0P_BT1->ARR_f.ARR = u16Data; + break; + case TIM2: + M0P_BT2->ARR_f.ARR = u16Data; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 16位计数器初值设置 + ** + ** + ** \param [in] enUnit Timer通道选择(TIM0、TIM1、TIM2) + ** \param [in] u16Data 16位初值 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Cnt16Set(en_bt_unit_t enUnit, uint16_t u16Data) +{ + en_result_t enResult = Ok; + + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enUnit) + { + case TIM0: + M0P_BT0->CNT_f.CNT = u16Data; + break; + case TIM1: + M0P_BT1->CNT_f.CNT = u16Data; + break; + case TIM2: + M0P_BT2->CNT_f.CNT = u16Data; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 16位计数值获取 + ** + ** + ** \param [in] enUnit Timer通道选择(TIM0、TIM1、TIM2) + ** + ** \retval 16bits计数值 + *****************************************************************************/ +uint16_t Bt_Cnt16Get(en_bt_unit_t enUnit) +{ + uint16_t u16CntData = 0; + + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enUnit) + { + case TIM0: + u16CntData = M0P_BT0->CNT_f.CNT; + break; + case TIM1: + u16CntData = M0P_BT1->CNT_f.CNT; + break; + case TIM2: + u16CntData = M0P_BT2->CNT_f.CNT; + break; + default: + u16CntData = 0; + break; + } + + return u16CntData; +} + +/** + ***************************************************************************** + ** \brief Base Timer 32位计数器初值设置 + ** + ** + ** \param [in] enUnit Timer通道选择(TIM0、TIM1、TIM2) + ** \param [in] u32Data 32位初值 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Cnt32Set(en_bt_unit_t enUnit, uint32_t u32Data) +{ + en_result_t enResult = Ok; + + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enUnit) + { + case TIM0: + M0P_BT0->CNT32_f.CNT32 = u32Data; + break; + case TIM1: + M0P_BT1->CNT32_f.CNT32 = u32Data; + break; + case TIM2: + M0P_BT2->CNT32_f.CNT32 = u32Data; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 32位计数值获取 + ** + ** + ** \param [in] enUnit Timer通道选择(TIM0、TIM1、TIM2) + ** + ** \retval 32bits计数值 + *****************************************************************************/ +uint32_t Bt_Cnt32Get(en_bt_unit_t enUnit) +{ + uint32_t u32CntData = 0; + + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enUnit) + { + case TIM0: + u32CntData = M0P_BT0->CNT32_f.CNT32; + break; + case TIM1: + u32CntData = M0P_BT1->CNT32_f.CNT32; + break; + case TIM2: + u32CntData = M0P_BT2->CNT32_f.CNT32; + break; + default: + u32CntData = 0; + break; + } + + return u32CntData; +} + +//@} // BtGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/project/driver/src/clk.c b/project/driver/src/clk.c new file mode 100644 index 0000000..6cee4d1 --- /dev/null +++ b/project/driver/src/clk.c @@ -0,0 +1,779 @@ +/****************************************************************************** +*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 clk.c + ** + ** Common API of clk. + ** @link clkGroup Some description @endlink + ** + ** - 2017-05-04 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "clk.h" + +/** + ******************************************************************************* + ** \addtogroup ClkGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define CLK_TIMEOUT (1000000u) + +#define IS_VALID_SRC(x) ( ClkRCH == (x)||\ + ClkXTH == (x)||\ + ClkRCL == (x)) + + +#define IS_VALID_FUNC(x) ( ClkFuncWkupRCH == (x)||\ + ClkFuncXTHEn == (x)||\ + ClkFuncFaultEn == (x)||\ + ClkFuncRtcLPWEn == (x)||\ + ClkFuncLockUpEn == (x)||\ + ClkFuncRstPinIOEn == (x)||\ + ClkFuncSwdPinIOEn == (x) ) + +#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_38_4K_VAL (*((volatile uint16_t*) (0x00100C20ul))) +#define RCL_CR_TRIM_32_8K_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 时钟解锁 + ** + ** \retval + ******************************************************************************/ +static void ClkUnlock(void) +{ + M0P_CLOCK->SYSCTRL2 = 0x5A5A; + M0P_CLOCK->SYSCTRL2 = 0xA5A5; +} + +/** + ******************************************************************************* + ** \brief 时钟SYSCTRL0寄存器空写 + ** + ** \retval + ******************************************************************************/ +static void ClkWriteDummy(void) +{ + M0P_CLOCK->SYSCTRL0_f.RESERVED11 = 0x0; +} + +/** + ******************************************************************************* + ** \brief 时钟功能设定 + ** \param [in] enFunc 功能枚举类型 + ** \param [in] bFlag 开关 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_SetFunc(en_clk_func_t enFunc, boolean_t bFlag) +{ + en_result_t enRet = Ok; + + ClkUnlock(); + bFlag = !!bFlag; + + switch (enFunc) + { + case ClkFuncWkupRCH: + M0P_CLOCK->SYSCTRL0_f.WAKEUP_BYRCH = bFlag; + break; + case ClkFuncXTHEn: + M0P_CLOCK->SYSCTRL1_f.EXTH_EN = bFlag; + break; + case ClkFuncFaultEn: + M0P_CLOCK->SYSCTRL1_f.CLOCK_FT_EN = bFlag; + break; + case ClkFuncLockUpEn: + M0P_CLOCK->SYSCTRL1_f.LOCK_EN = bFlag; + break; + case ClkFuncRstPinIOEn: + M0P_CLOCK->SYSCTRL1_f.RES_UIO = bFlag; + break; + case ClkFuncSwdPinIOEn: + M0P_CLOCK->SYSCTRL1_f.SWD_UIO = bFlag; + break; + default: + ClkWriteDummy(); + enRet = ErrorInvalidParameter; + break; + } + + return enRet; +} + + +/** + ******************************************************************************* + ** \brief 时钟源切换 + ** \param [in] enSource 新时钟源 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_SwitchTo(en_clk_source_t enSource) +{ + en_clk_source_t ClkOld; + en_clk_source_t ClkNew = enSource; + + + ClkOld = (en_clk_source_t)M0P_CLOCK->SYSCTRL0_f.CLK_SW4_SEL; + //set wait + switch (ClkNew) + { + case ClkRCH: + break; + case ClkXTH: + Clk_SetXTH_StableTime(ClkCycle16384); + break; + case ClkRCL: + Clk_SetRCL_StableTime(ClkCycle256); + break; + default: + return ErrorInvalidParameter; + } + + //如果当前时钟或目标时钟有一个大于24MHz,则开启FLASH读等待周期 + //add flash wait + M0P_FLASH->BYPASS = 0x5A5A; + M0P_FLASH->BYPASS = 0xA5A5; + if (((ClkXTH == ClkNew) || (ClkXTH == ClkOld)) && (CLK_XTH_VAL > (24 * 1000 * 1000))) + { + M0P_FLASH->CR_f.WAIT = TRUE; + } + + Clk_Enable(ClkNew, TRUE); + + while (FALSE == Clk_GetClkRdy(ClkNew)) + { + ; + } + + //switch + Clk_SetSource(ClkNew); + + //close old + Clk_Enable(ClkOld, FALSE); + + //如果当前时钟非外部高速(即不大于24MHz)则不增加读等待周期 + if(ClkXTH != ClkNew) + { + M0P_FLASH->CR_f.WAIT = FALSE; + } + + SystemCoreClockUpdate(); + + return Ok; + +} + + +/** + ******************************************************************************* + ** \brief 获得系统时钟(HCLK)频率值 + ** \param [in] + ** \retval uint32_t HCLK频率值 + ** + ******************************************************************************/ +uint32_t Clk_GetHClkFreq(void) +{ + uint32_t u32Val = 0; + uint16_t u16TrimVal22_12 = 0; + const uint8_t u8hcr_tbl[] = { 4, 8, 16, 24 }; + const uint32_t u32lcr_tbl[] = { 32768, 38400 }; + + en_clk_source_t enSrc; + + //1. get current input source + enSrc = (en_clk_source_t)M0P_CLOCK->SYSCTRL0_f.CLK_SW4_SEL; + + switch (enSrc) + { + case ClkRCH: + u32Val = u8hcr_tbl[(M0P_CLOCK->RCH_CR_f.TRIM&0x600U)>>9u]; + u32Val *= 1000u * 1000u; + if(24000000u == u32Val) + { + u16TrimVal22_12 = RCH_CR_TRIM_22_12M_VAL; + if(u16TrimVal22_12 == M0P_CLOCK->RCH_CR_f.TRIM) + { + u32Val = 22120000u; + } + } + break; + case ClkRCL: + u32Val = u32lcr_tbl[(M0P_CLOCK->RCL_CR_f.TRIM&0x200U)>>9u]; + break; + case ClkXTH: + u32Val = CLK_XTH_VAL; + break; + default: + u32Val = 0u; + break; + } + + u32Val = u32Val >> M0P_CLOCK->SYSCTRL0_f.HCLK_PRS; + + return u32Val; +} + +/** + ******************************************************************************* + ** \brief 获得外设时钟(PCLK)频率值 + ** \param [in] + ** \retval uint32_t PCLK频率值 + ** + ******************************************************************************/ +uint32_t Clk_GetPClkFreq(void) +{ + uint32_t u32Val = 0; + + u32Val = Clk_GetHClkFreq(); + u32Val = u32Val >> M0P_CLOCK->SYSCTRL0_f.PCLK_PRS; + + return u32Val; +} + + +/** + ******************************************************************************* + ** \brief 时钟初始化函数 + ** \param [in] pstcCfg 初始化配置参数 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_Init(stc_clk_config_t *pstcCfg) +{ + ASSERT(NULL != pstcCfg); + ASSERT(pstcCfg->enHClkDiv <= ClkDiv128); + ASSERT(pstcCfg->enPClkDiv <= ClkDiv8); + + Clk_SwitchTo(pstcCfg->enClkSrc); + Clk_SetHClkDiv(pstcCfg->enHClkDiv); + Clk_SetPClkDiv(pstcCfg->enPClkDiv); + + return Ok; +} + + +/** + ******************************************************************************* + ** \brief 时钟去初始化函数 + ** \param [in] + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_DeInit(void) +{ + //set clock to HCR 4Mhz + Clk_SetRCHFreq(ClkFreq4Mhz); + Clk_SwitchTo(ClkRCH); + Clk_SetHClkDiv(ClkDiv1); + Clk_SetPClkDiv(ClkDiv1); + return Ok; +} + + +/** + ******************************************************************************* + ** \brief 时钟源设定 + ** \note 需配合其他操作,生效设定 + ** \param [in] enSource 目标时钟源 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_SetSource(en_clk_source_t enSource) +{ + en_result_t enRet = Ok; + + ClkUnlock(); + + switch (enSource) + { + case ClkRCH: + case ClkRCL: + case ClkXTH: + M0P_CLOCK->SYSCTRL0_f.CLK_SW4_SEL = enSource; + break; + default: + ClkWriteDummy(); + enRet = ErrorInvalidParameter; + break; + } + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 获得时钟源稳定标志 + ** \param [in] enSource 目标时钟源 + ** \retval TRUE 稳定 + ** FALSE 未稳定 + ******************************************************************************/ +boolean_t Clk_GetClkRdy(en_clk_source_t enSource) +{ + boolean_t bFlag = FALSE; + + switch (enSource) + { + case ClkRCH: + bFlag = M0P_CLOCK->RCH_CR_f.STABLE; + break; + case ClkXTH: + bFlag = M0P_CLOCK->XTH_CR_f.STABLE; + break; + case ClkRCL: + bFlag = M0P_CLOCK->RCL_CR_f.STABLE; + break; + default: + break; + } + return bFlag; +} + + +/** + ******************************************************************************* + ** \brief 内部高速时钟频率设定 + ** \param [in] enVal 设定的频率值 + ** \retval Ok 设定成功 + ** 其他 设定失败或时钟未稳定 + ******************************************************************************/ +en_result_t Clk_SetRCHFreq(en_clk_freq_t enVal) +{ + en_result_t enRet = Ok; + + switch (enVal) + { + case ClkFreq4Mhz: + M0P_CLOCK->RCH_CR_f.TRIM = RCH_CR_TRIM_4M_VAL; + break; + case ClkFreq8Mhz: + M0P_CLOCK->RCH_CR_f.TRIM = RCH_CR_TRIM_8M_VAL; + break; + case ClkFreq16Mhz: + M0P_CLOCK->RCH_CR_f.TRIM = RCH_CR_TRIM_16M_VAL; + break; + case ClkFreq22_12Mhz: + M0P_CLOCK->RCH_CR_f.TRIM = RCH_CR_TRIM_22_12M_VAL; + break; + case ClkFreq24Mhz: + M0P_CLOCK->RCH_CR_f.TRIM = RCH_CR_TRIM_24M_VAL; + break; + default: + enRet = ErrorInvalidParameter; + break; + } + + return enRet; +} + + +/** + ******************************************************************************* + ** \brief 内部低速时钟频率设定 + ** \param [in] enVal 设定的频率值 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_SetRCLFreq(en_clk_freq_t enVal) +{ + en_result_t enRet = Ok; + + switch (enVal) + { + case ClkFreq32768: + M0P_CLOCK->RCL_CR_f.TRIM = RCL_CR_TRIM_32_8K_VAL; + break; + case ClkFreq38_4K: + M0P_CLOCK->RCL_CR_f.TRIM = RCL_CR_TRIM_38_4K_VAL; + break; + default: + enRet = ErrorInvalidParameter; + break; + } + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 系统时钟(HCLK)分频设定 + ** \param [in] u8Div 分频设定值 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_SetHClkDiv(uint8_t u8Div) +{ + switch (u8Div) + { + case ClkDiv1: + case ClkDiv2: + case ClkDiv4: + case ClkDiv8: + case ClkDiv16: + case ClkDiv32: + case ClkDiv64: + case ClkDiv128: + ClkUnlock(); + u8Div = Log2(u8Div); + M0P_CLOCK->SYSCTRL0_f.HCLK_PRS = u8Div; + break; + default: + return ErrorInvalidParameter; + } + + return Ok; +} + + +/** + ******************************************************************************* + ** \brief 外设时钟(PCLK)分频设定 + ** \param [in] u8Div 分频设定值 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_SetPClkDiv(uint8_t u8Div) +{ + + switch (u8Div) + { + case ClkDiv1: + case ClkDiv2: + case ClkDiv4: + case ClkDiv8: + ClkUnlock(); + u8Div = Log2(u8Div); + M0P_CLOCK->SYSCTRL0_f.PCLK_PRS = u8Div; + break; + default: + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + ******************************************************************************* + ** \brief 外部高速时钟稳定时间设定 + ** \param [in] enCycle 稳定时钟周期值 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_SetXTH_StableTime(en_clk_cycle_t enCycle) +{ + en_result_t enRet = Ok; + + switch (enCycle) + { + case ClkCycle256: + M0P_CLOCK->XTH_CR_f.STARTUP = 0u; + break; + case ClkCycle1024: + M0P_CLOCK->XTH_CR_f.STARTUP = 1u; + break; + case ClkCycle4096: + M0P_CLOCK->XTH_CR_f.STARTUP = 2u; + break; + case ClkCycle16384: + M0P_CLOCK->XTH_CR_f.STARTUP = 3u; + break; + default: + enRet = ErrorInvalidParameter; + break; + } + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 内部低速时钟稳定时间设定 + ** \param [in] enCycle 稳定时钟周期值 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_SetRCL_StableTime(en_clk_cycle_t enCycle) +{ + en_result_t enRet = Ok; + + switch (enCycle) + { + case ClkCycle4: + M0P_CLOCK->RCL_CR_f.STARTUP = 0u; + break; + case ClkCycle16: + M0P_CLOCK->RCL_CR_f.STARTUP = 1u; + break; + case ClkCycle64: + M0P_CLOCK->RCL_CR_f.STARTUP = 2u; + break; + case ClkCycle256: + M0P_CLOCK->RCL_CR_f.STARTUP = 3u; + break; + default: + enRet = ErrorInvalidParameter; + break; + } + + return enRet; +} + + +/** + * \brief Clk_Enable + * enable/disalbe to a paticular clock + * \param [in] enSource clock source + * \param [in] u8Flag TRUE: enable + * FALSE: disable + * \retval en_result_t Ok: operation done. + * ErrorInvalidParameter: invalid source type + */ + +/** + ******************************************************************************* + ** \brief 时钟使能 + ** \param [in] enSource 目标时钟源 + ** \param [in] bFlag 使能开关 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_Enable(en_clk_source_t enSource, boolean_t bFlag) +{ + en_result_t enRet = Ok; + + ClkUnlock(); + //force to 0/1 + bFlag = !!bFlag; + + switch (enSource) + { + + case ClkRCL: + M0P_CLOCK->SYSCTRL0_f.RCL_EN = bFlag; + break; + + case ClkXTH: + M0P_GPIO->P0ADS_f.P01 = bFlag; + M0P_GPIO->P0ADS_f.P02 = bFlag; + M0P_CLOCK->XTH_CR_f.DRIVER = 0xF; + M0P_CLOCK->SYSCTRL0_f.XTH_EN = bFlag; + break; + + case ClkRCH: + M0P_CLOCK->SYSCTRL0_f.RCH_EN = bFlag; + break; + + default: + ClkWriteDummy(); + enRet = ErrorInvalidParameter; + break; + } + + return enRet; +} + + +/** + ******************************************************************************* + ** \brief 设置外设时钟门控开关 + ** \param [in] enPeripheral 目标外设 + ** \param [in] bFlag 使能开关 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_SetPeripheralGate(en_clk_peripheral_gate_t enPeripheral, + boolean_t bFlag) +{ + en_result_t enRet = Ok; + + bFlag = !!bFlag; + setBit(&M0P_CLOCK->PERI_CLKEN, enPeripheral, bFlag); + return enRet; +} + + +/** + ******************************************************************************* + ** \brief 获得外设时钟门控开关状态 + ** \param [in] enPeripheral 目标外设 + ** \retval TRUE 开 + ** FALSE 关 + ******************************************************************************/ +boolean_t Clk_GetPeripheralGate(en_clk_peripheral_gate_t enPeripheral) +{ + return getBit(&M0P_CLOCK->PERI_CLKEN, enPeripheral); +} + +/** + ******************************************************************************* + ** \brief 设定Systick配置 + ** \param [in] pstcCfg systick配置参数 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_SysTickConfig(stc_clk_systickcfg_t *pstcCfg) +{ + if (NULL == pstcCfg) + { + return ErrorInvalidParameter; + } + + M0P_CLOCK->PERI_CLKEN_f.TICK = 1; + switch (pstcCfg->enClk) + { + case ClkRCH: + M0P_CLOCK->SYSTICK_CR_f.CLK_SEL = 0x2; + break; + case ClkRCL: + M0P_CLOCK->SYSTICK_CR_f.CLK_SEL = 0x1; + break; + case ClkXTH: + M0P_CLOCK->SYSTICK_CR_f.CLK_SEL = 0x3; + break; + default: + return ErrorInvalidParameter; + } + + M0P_CLOCK->SYSTICK_CR_f.NOREF = pstcCfg->bNoRef; + + SysTick->LOAD = (uint32_t)(pstcCfg->u32LoadVal - 1UL); /* set reload register */ + NVIC_SetPriority(SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_ENABLE_Msk; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief Systick SKEW 获取 + ** \param [in] NULL + ** \retval SKEW值 (TRUE or FALSE) + ******************************************************************************/ +boolean_t Clk_SysTickSkewGet(void) +{ + return (boolean_t)M0P_CLOCK->SYSTICK_CR_f.SKEW; +} + +/** + ******************************************************************************* + ** \brief Systick CALIB 获取 + ** \param [in] NULL + ** \retval CALIB值 (10ms校准值) + ******************************************************************************/ +uint32_t Clk_SysTickStcalibGet(void) +{ + return (uint32_t)M0P_CLOCK->SYSTICK_CR_f.STCALIB; +} + +/** + ******************************************************************************* + ** \brief 设定时钟外设调试开关 + ** \param [in] enPeri 目标外设 + ** \param [in] bFlag 状态开关 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Clk_DebugClk(en_clk_debug_t enPeri, boolean_t bFlag) +{ + switch (enPeri) + { + case ClkDBGTim0: + case ClkDBGTim1: + case ClkDBGTim2: + case ClkDBGLpTim: + case ClkDBGTim4: + case ClkDBGTim5: + case ClkDBGTim6: + case ClkDBGTPca: + case ClkDBGTWdt: + case ClkDBGTRtc: + case ClkDBGTTick: + setBit(&M0P_CLOCK->DEBUG_ACTIVE, 1 << enPeri, bFlag); + break; + default: + return ErrorInvalidParameter; + } + return Ok; +} + +//@} // ClkGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/project/driver/src/crc.c b/project/driver/src/crc.c new file mode 100644 index 0000000..d11da3e --- /dev/null +++ b/project/driver/src/crc.c @@ -0,0 +1,257 @@ +/****************************************************************************** +*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 编码(字节填充方式) + ** + ** 该函数主要用于生成CRC16编码. + ** + ** \param [in] pu8Data 待编码数据指针(字节方式输入) + ** \param [in] u32Len 待编码数据长度(字节数) + ** + ** \retval CRC16 CRC16编码值. + *****************************************************************************/ +uint16_t CRC16_Get8(uint8_t* pu8Data, uint32_t u32Len) +{ + uint32_t u32Index; + + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA_f))) = pu8Data[u32Index]; + } + + return (M0P_CRC->RESULT_f.RESULT); +} + +/** + ***************************************************************************** + ** \brief CRC16 编码(半字填充方式) + ** + ** 该函数主要用于生成CRC16编码. + ** + ** \param [in] pu16Data 待编码数据指针(半字方式输入) + ** \param [in] u32Len 待编码数据长度(半字数) + ** + ** \retval CRC16 CRC16编码值. + *****************************************************************************/ +uint16_t CRC16_Get16(uint16_t* pu16Data, uint32_t u32Len) +{ + uint32_t u32Index; + + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA_f))) = pu16Data[u32Index]; + } + + return (M0P_CRC->RESULT_f.RESULT); +} + +/** + ***************************************************************************** + ** \brief CRC16 编码(字填充方式) + ** + ** 该函数主要用于生成CRC16编码. + ** + ** \param [in] pu32Data 待编码数据指针(字方式输入) + ** \param [in] u32Len 待编码数据长度(字数) + ** + ** \retval CRC16 CRC16编码值. + *****************************************************************************/ +uint16_t CRC16_Get32(uint32_t* pu32Data, uint32_t u32Len) +{ + uint32_t u32Index; + + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA_f.DATA = pu32Data[u32Index]; + } + + return (M0P_CRC->RESULT_f.RESULT); +} + +/** + ***************************************************************************** + ** \brief CRC16 校验(字节填充方式) + ** + ** 该函数主要用于对数据及CRC16值进行校验. + ** + ** \param [in] pu8Data 待校验数据指针(字节方式输入) + ** \param [in] u32Len 待校验数据长度(字节数) + ** \param [in] u16CRC 待校验CRC16值 + ** + ** \retval Ok CRC校验正确 + ** \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; + + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA_f))) = pu8Data[u32Index]; + } + + *((volatile uint16_t*)(&(M0P_CRC->DATA_f))) = u16CRC; + + enResult = M0P_CRC->RESULT_f.FLAG ? Ok : Error; + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief CRC16 校验(半字填充方式) + ** + ** 该函数主要用于对数据及CRC16值进行校验. + ** + ** \param [in] pu16Data 待校验数据指针(半字方式输入) + ** \param [in] u32Len 待校验数据长度(半字数) + ** \param [in] u16CRC 待校验CRC16值 + ** + ** \retval Ok CRC校验正确 + ** \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; + + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA_f))) = pu16Data[u32Index]; + } + + *((volatile uint16_t*)(&(M0P_CRC->DATA_f))) = u16CRC; + + enResult = M0P_CRC->RESULT_f.FLAG ? Ok : Error; + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief CRC16 校验(字填充方式) + ** + ** 该函数主要用于对数据及CRC16值进行校验. + ** + ** \param [in] pu32Data 待校验数据指针(字方式输入) + ** \param [in] u32Len 待校验数据长度(字数) + ** \param [in] u16CRC 待校验CRC16值 + ** + ** \retval Ok CRC校验正确 + ** \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; + + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA_f))) = pu32Data[u32Index]; + } + + *((volatile uint16_t*)(&(M0P_CRC->DATA_f))) = u16CRC; + + enResult = M0P_CRC->RESULT_f.FLAG ? Ok : Error; + + return (enResult); +} + + +//@} // CrcGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/project/driver/src/ddl.c b/project/driver/src/ddl.c new file mode 100644 index 0000000..c1dfc3a --- /dev/null +++ b/project/driver/src/ddl.c @@ -0,0 +1,306 @@ +/******************************************************************************* +* 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 ddl.c + ** + ** Common API of DDL. + ** @link ddlGroup Some description @endlink + ** + ** - 2017-05-04 + ** + ******************************************************************************/ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "config.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 Hook function, which is called in polling loops + *****************************************************************************/ +void DDL_WAIT_LOOP_HOOK(void) +{ + // Place code for triggering Watchdog counters here, if needed +} + +/** + ***************************************************************************** + ** \brief debug printf function. + *****************************************************************************/ +void Debug_UartInit(void) +{ +#if 0//def SH_DEBUG + uint32_t u32Pclk1 = 0; + volatile uint32_t u32ReloadVal = 0; + M0P_GPIO->P1ADS_f.P14 = 0; + M0P_GPIO->P14_SEL_f.SEL = 3; + M0P_GPIO->P1DIR_f.P14 = 0; + + u32Pclk1 = Clk_GetPClkFreq(); + u32ReloadVal = 65536 - u32Pclk1 * 2 / 115200 / 32; + + M0P_BT0->CR_f.CT = 0; + M0P_BT0->CR_f.MD = 1; + M0P_BT0->CR_f.TOG_EN = 1; + M0P_BT0->ARR = u32ReloadVal; + M0P_BT0->CNT = u32ReloadVal; + M0P_BT0->CR_f.TR = 1; + + M0P_UART0->SCON_f.DBAUD = 1; + M0P_UART0->SCON_f.SM01 = 1; + +#endif +} + +void Debug_Output(uint8_t u8Data) +{ +#if 0 + M0P_UART0->SCON_f.REN = 0; + M0P_UART0->SBUF = u8Data; + + while (TRUE != M0P_UART0->ISR_f.TI) + { + ; + } + M0P_UART0->ICR_f.TICLR = 0; +#else + Uart_SendData(UARTCH1,u8Data); +#endif +} + +//#ifdef __DEBUG +///** +// ****************************************************************************** +// ** \brief Re-target putchar function +// ******************************************************************************/ +//int fputc(int ch, FILE *f) +//{ + +// if (((uint8_t)ch) == '\n') +// { +// Debug_Output('\r'); +// } +// Debug_Output(ch); + +// return ch; +//} +//#endif + + + +extern void Debug_UartInit(void); +extern void Debug_Output(uint8_t u8Data); + +#if defined (__CC_ARM) //KEIL +#pragma import(__use_no_semihosting) +void _sys_exit(int x) +{ + x = x; +} +struct __FILE +{ + int handle; + /* Whatever you require here. If the only file you are using is */ + /* standard output using printf() for debugging, no file handling */ +/* is required. */ +}; +/* FILE is typedef?d in stdio.h. */ +FILE __stdout; + +#endif + +#ifdef __DEBUG +/** + ****************************************************************************** + ** \brief Re-target putchar function + ******************************************************************************/ +int fputc(int ch, FILE *f) +{ + + if (((uint8_t)ch) == '\n') + { + Debug_Output('\r'); + } + Debug_Output(ch); + + return ch; +} +#endif + +void _ttywrch(int c) +{ +} + + +int __backspace(void) +{ + return 0; +} + + + +/** + * \brief delay1ms + * delay approximately 1ms. + * \param [in] u32Cnt + * \retval void + */ +void delay1ms(uint32_t u32Cnt) +{ + uint32_t u32end; + while(u32Cnt-- > 0) + { + SysTick->VAL = 0; + + u32end = 0x1000000 - SystemCoreClock/1000; + while(SysTick->VAL > u32end) + { + ; + } + } +} + +/** + * \brief delay100us + * delay approximately 100us. + * \param [in] u32Cnt + * \retval void + */ +void delay100us(uint32_t u32Cnt) +{ + uint32_t u32end; + while(u32Cnt-- > 0) + { + SysTick->VAL = 0; + + u32end = 0x1000000 - SystemCoreClock/10000; + while(SysTick->VAL > u32end) + { + ; + } + } +} + +//@} // DDL Functions + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/project/driver/src/flash.c b/project/driver/src/flash.c new file mode 100644 index 0000000..ea8effc --- /dev/null +++ b/project/driver/src/flash.c @@ -0,0 +1,596 @@ +/****************************************************************************** +*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 flash.c + ** + ** Common API of flash. + ** @link flashGroup Some description @endlink + ** + ** - 2017-05-16 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "flash.h" +/** + ******************************************************************************* + ** \addtogroup FlashGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define FLASH_END_ADDR (0x00003FFFu) +#define FLASH_BYPASS() M0P_FLASH->BYPASS_f.BYSEQ = 0x5A5A;\ + M0P_FLASH->BYPASS_f.BYSEQ = 0xA5A5; +#define FLASH_IE_TRUE (0x03) +#define FLASH_IE_FALSE (0x00) +/******************************************************************************* + * 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 LOCK + ** + ** Flash 加解锁数据类型重定义 + ******************************************************************************/ +typedef enum en_flash_lock +{ + LockAll = 0x0000u, ///<全片加锁 + UnlockAll = 0xFFFFu, ///<全片解锁 +} en_flash_lock_t; + +/** + ****************************************************************************** + ** \brief FLASH 编程时间参数配置 + ** + ** FLASH编程时间参数配置数据类型重定义 (4MHz) + ******************************************************************************/ +typedef enum en_flash_prgtimer +{ + Tnvs = 32u, + Tpgs = 23u, + Tprog = 27u, + Tserase = 18000u, + Tmerase = 140000u, + Tprcv = 24u, + Tsrcv = 240u, + Tmrcv = 1000u, +} en_flash_prgtimer_t; + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ +static func_ptr_t pfnFlashCallback = NULL; + +/******************************************************************************* + * 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; + + switch (enFlashIntType) + { + case flash_int0: + bRetVal = M0P_FLASH->IFR_f.IF0 ? TRUE : FALSE; + break; + case flash_int1: + bRetVal = M0P_FLASH->IFR_f.IF1 ? TRUE : FALSE; + break; + default: + bRetVal = FALSE; + break; + } + + 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; + + switch (enFlashIntType) + { + case flash_int0: + FLASH_BYPASS(); + M0P_FLASH->ICLR_f.ICLR0 = FALSE; + enResult = Ok; + break; + case flash_int1: + FLASH_BYPASS(); + M0P_FLASH->ICLR_f.ICLR1 = FALSE; + enResult = Ok; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Flash中断服务函数 + ** + ** + ** \param [in] u8Param == 0 + ** + *****************************************************************************/ +void EfRam_IRQHandler(uint8_t u8Param) +{ + pfnFlashCallback(); +} + +/** + ***************************************************************************** + ** \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; + + switch (enFlashIntType) + { + case flash_int0: + FLASH_BYPASS(); + M0P_FLASH->CR_f.IE |= 0x01; + enResult = Ok; + break; + case flash_int1: + FLASH_BYPASS(); + M0P_FLASH->CR_f.IE |= 0x02; + enResult = Ok; + break; + default: + enResult = Error; + break; + } + + 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; + + switch (enFlashIntType) + { + case flash_int0: + FLASH_BYPASS(); + M0P_FLASH->CR_f.IE &= ~0x02u; + enResult = Ok; + break; + case flash_int1: + FLASH_BYPASS(); + M0P_FLASH->CR_f.IE &= ~0x01u; + enResult = Ok; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief FLASH 中断服务程序及编程时间配置 + ** + ** 该函数用于配置中断服务函数并根据系统时钟配置FLASH编程时间相关寄存器. + ** + ** \param [in] pfnFlashCb Flash中断服务回调函数[void function(void)] + ** \param [in] u8FreqCfg 时钟频率配置: + ** 0 - (0,4]MHz; + ** 1 - (4,8]MHz; + ** 2 - (8,16]MHz; + ** 3 - (16,32]MHz(该配置会打开读FLASH等待周期); + ** other - 无效值 + ** + ** \retval Ok 操作成功. + ** \retval ErrorInvalidParameter 参数无效. + ** + *****************************************************************************/ +en_result_t Flash_Init(func_ptr_t pfnFlashCb, uint8_t u8FreqCfg) +{ + en_result_t enResult = Ok; + + if (u8FreqCfg > 3) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + //flash时间参数寄存器配置 + FLASH_BYPASS(); + M0P_FLASH->TNVS_f.TNVS = Tnvs << u8FreqCfg; + FLASH_BYPASS(); + M0P_FLASH->TPGS_f.TPGS = Tpgs << u8FreqCfg; + FLASH_BYPASS(); + M0P_FLASH->TPROG_f.TPROG = Tprog << u8FreqCfg; + FLASH_BYPASS(); + M0P_FLASH->TSERASE_f.TSERASE = Tserase << u8FreqCfg; + FLASH_BYPASS(); + M0P_FLASH->TMERASE_f.TMERASE = Tmerase << u8FreqCfg; + FLASH_BYPASS(); + M0P_FLASH->TPRCV_f.TPRCV = Tprcv << u8FreqCfg; + FLASH_BYPASS(); + M0P_FLASH->TSRCV_f.TSRCV = Tsrcv << u8FreqCfg; + FLASH_BYPASS(); + M0P_FLASH->TMRCV_f.TMRCV = Tmrcv << u8FreqCfg; + + //开启读FLASH等待周期 + if (3 == u8FreqCfg) + { + FLASH_BYPASS(); + M0P_FLASH->CR_f.WAIT = TRUE; + } + else + { + FLASH_BYPASS(); + M0P_FLASH->CR_f.WAIT = FALSE; + } + + pfnFlashCallback = pfnFlashCb; + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 字节写 + ** + ** 用于向FLASH写入1字节数据. + ** + ** \param [in] u32Addr Flash地址 + ** \param [in] u8Data 1字节数据 + ** + ** \retval Ok 写入成功. + ** \retval ErrorInvalidParameter FLASH地址无效 + *****************************************************************************/ +en_result_t Flash_WriteByte(uint32_t u32Addr, uint8_t u8Data) +{ + en_result_t enResult = Ok; + + if (FLASH_END_ADDR < u32Addr) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + //unlock flash + FLASH_BYPASS(); + M0P_FLASH->SLOCK_f.SLOCK = UnlockAll; + + //busy? + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + ; + } + + //set OP + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = Program; + + //write data + *((volatile uint8_t*)u32Addr) = u8Data; + + //busy? + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + ; + } + + //lock flash + FLASH_BYPASS(); + M0P_FLASH->SLOCK_f.SLOCK = LockAll; + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 半字写 + ** + ** 用于向FLASH写入半字(2字节)数据. + ** + ** \param [in] u32Addr Flash地址 + ** \param [in] u16Data 半字(2字节)数据 + ** + ** \retval Ok 写入成功. + ** \retval ErrorInvalidParameter FLASH地址无效 + *****************************************************************************/ +en_result_t Flash_WriteHalfWord(uint32_t u32Addr, uint16_t u16Data) +{ + en_result_t enResult = Ok; + + if ((FLASH_END_ADDR < u32Addr) || (u32Addr % 2)) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + //unlock flash + FLASH_BYPASS(); + M0P_FLASH->SLOCK_f.SLOCK = UnlockAll; + + //busy? + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + ; + } + + //set OP + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = Program; + + //write data + *((volatile uint16_t*)u32Addr) = u16Data; + + //busy? + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + ; + } + + //lock flash + FLASH_BYPASS(); + M0P_FLASH->SLOCK_f.SLOCK = LockAll; + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 字写 + ** + ** 用于向FLASH写入1个字的数据. + ** + ** \param [in] u32Addr Flash地址 + ** \param [in] u32Data 1个字数据 + ** + ** \retval Ok 写入成功. + ** \retval ErrorInvalidParameter FLASH地址无效 + *****************************************************************************/ +en_result_t Flash_WriteWord(uint32_t u32Addr, uint32_t u32Data) +{ + en_result_t enResult = Ok; + + if ((FLASH_END_ADDR < u32Addr) || (u32Addr % 4)) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + //unlock flash + FLASH_BYPASS(); + M0P_FLASH->SLOCK_f.SLOCK = UnlockAll; + + //busy? + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + ; + } + + //set OP + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = Program; + + //write data + *((volatile uint32_t*)u32Addr) = u32Data; + + //busy? + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + ; + } + + //lock flash + FLASH_BYPASS(); + M0P_FLASH->SLOCK_f.SLOCK = LockAll; + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 扇区擦除 + ** + ** FLASH 扇区擦除. + ** + ** \param [in] u32SectorAddr 所擦除扇区内的地址 + ** + ** \retval Ok 擦除成功. + ** \retval ErrorInvalidParameter FLASH地址无效 + *****************************************************************************/ +en_result_t Flash_SectorErase(uint32_t u32SectorAddr) +{ + + en_result_t enResult = Ok; + + if (FLASH_END_ADDR < u32SectorAddr) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + //unlock flash + FLASH_BYPASS(); + M0P_FLASH->SLOCK_f.SLOCK = UnlockAll; + + //busy? + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + ; + } + + //set OP + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = SectorErase; + + //write data + *((volatile uint8_t*)u32SectorAddr) = 0; + + //busy? + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + ; + } + + //lock flash + FLASH_BYPASS(); + M0P_FLASH->SLOCK_f.SLOCK = LockAll; + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 全片擦除 + ** + ** FLASH 全片擦除. + ** + ** + ** \retval Ok 擦除成功. + ** + *****************************************************************************/ +en_result_t Flash_ChipErase(void) +{ + + en_result_t enResult = Ok; + + //unlock flash + FLASH_BYPASS(); + M0P_FLASH->SLOCK_f.SLOCK = UnlockAll; + + //busy? + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + ; + } + + //set OP + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = ChipErase; + + //write data + *((volatile uint8_t*)0) = 0; + + //busy? + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + ; + } + + //lock flash + FLASH_BYPASS(); + M0P_FLASH->SLOCK_f.SLOCK = LockAll; + + return (enResult); +} + + + +//@} // FlashGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/project/driver/src/gpio.c b/project/driver/src/gpio.c new file mode 100644 index 0000000..062d240 --- /dev/null +++ b/project/driver/src/gpio.c @@ -0,0 +1,530 @@ +/****************************************************************************** +* 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 Gpio.c + ** + ** GPIO driver API. + ** @link Driver Group Some description @endlink + ** + ** - 2017-04-29 1.0 Ronnie First version for Device Driver Library of + ** Module. + ** + ******************************************************************************/ + +/******************************************************************************* + * 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] u8Port IO Port口 + ** \param [in] u8Pin IO Pin脚 + ** \param [in] bFlag TRUE : 模拟功能 + ** FALSE: 数字功能 + ** + ** \retval Ok 设置成功 + ** 其他值 设置失败 + ******************************************************************************/ +en_result_t Gpio_SetAnalog(uint8_t u8Port, uint8_t u8Pin, boolean_t bFlag) +{ + setBit((uint32_t)&M0P_GPIO->P0ADS + u8Port * GPIO_GPSZ, u8Pin, bFlag); + + return Ok; +} + + +/** + ******************************************************************************* + ** \brief GPIO 初始化IO + ** + ** \param [in] u8Port IO Port口 + ** \param [in] u8Pin IO Pin脚 + ** \param [in] enDir IO 方向(输入或输出) + ** + ** \retval Ok 设置成功 + ** 其他值 设置失败 + ******************************************************************************/ +en_result_t Gpio_InitIO(uint8_t u8Port, uint8_t u8Pin, + en_gpio_dir_t enDir) +{ + //force open clock + M0P_CLOCK->PERI_CLKEN_f.GPIO = 1; + //force set mode, ignore result. + Gpio_SetAnalog(u8Port, u8Pin, FALSE); + + //fn + *((volatile uint32_t *)((uint32_t)&M0P_GPIO->P01_SEL + u8Port * GPIO_GPSZ - 4 + u8Pin * 4)) = 0; + //ADS + //setBit((uint32_t)&M0P_GPIO->ADS0 + u8Port * GPIO_GPSZ, u8Pin, 0); + //dir + setBit((uint32_t)&M0P_GPIO->P0DIR + u8Port * GPIO_GPSZ, u8Pin, enDir); + //dr + setBit((uint32_t)&M0P_GPIO->P0PU + u8Port * GPIO_GPSZ, u8Pin, FALSE); + setBit((uint32_t)&M0P_GPIO->P0PD + u8Port * GPIO_GPSZ, u8Pin, FALSE); + setBit((uint32_t)&M0P_GPIO->P0OD + u8Port * GPIO_GPSZ, u8Pin, FALSE); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 初始化2 + ** + ** \param [in] u8Port IO Port口 + ** \param [in] u8Pin IO Pin脚 + ** \param [in] enDir IO 方向(输入或输出) + ** \param [in] bPullup 上拉开关 + ** \param [in] bPulldown 下拉开关 + ** \param [in] bOdr 开漏开关 + ** \param [in] bDrive 驱动能力 + ** 0 = 高 + ** 1 = 低 + ** \retval Ok 设置成功 + ** 其他值 设置失败 + ******************************************************************************/ +en_result_t Gpio_InitIOExt(uint8_t u8Port, uint8_t u8Pin, + en_gpio_dir_t enDir, + boolean_t bPullup, + boolean_t bPulldown, + boolean_t bOdr, + boolean_t bDrive) +{ + //force open clock + M0P_CLOCK->PERI_CLKEN_f.GPIO = 1; + //force set mode, ignore result. + Gpio_SetAnalog(u8Port, u8Pin, FALSE); + + //fn + *((volatile uint32_t *)((uint32_t)&M0P_GPIO->P01_SEL + u8Port * GPIO_GPSZ - 4 + u8Pin * 4)) = 0; + //ADS + //setBit((uint32_t)&M0P_GPIO->ADS0 + u8Port * GPIO_GPSZ, u8Pin, 0); + //dir + setBit((uint32_t)&M0P_GPIO->P0DIR + u8Port * GPIO_GPSZ, u8Pin, enDir); + //dr + setBit((uint32_t)&M0P_GPIO->P0DR + u8Port * GPIO_GPSZ, u8Pin, bDrive); + + setBit((uint32_t)&M0P_GPIO->P0PU + u8Port * GPIO_GPSZ, u8Pin, bPullup); + setBit((uint32_t)&M0P_GPIO->P0PD + u8Port * GPIO_GPSZ, u8Pin, bPulldown); + setBit((uint32_t)&M0P_GPIO->P0OD + u8Port * GPIO_GPSZ, u8Pin, bOdr); + + return Ok; +} + + +/** + ******************************************************************************* + ** \brief GPIO IO输出值设定 + ** + ** \param [in] u8Port IO Port口 + ** \param [in] u8Pin IO Pin脚 + ** \param [in] bVal 输出电平高低 + ** + ** \retval Ok 设置成功 + ** 其他值 设置失败 + ******************************************************************************/ +void Gpio_SetIO(uint8_t u8Port, uint8_t u8Pin, boolean_t bVal) +{ + bVal = !!bVal; + setBit((uint32_t)&M0P_GPIO->P0OUT + u8Port * GPIO_GPSZ, u8Pin, bVal); +} + + + +/** + ******************************************************************************* + ** \brief GPIO IO输入值获取 + ** + ** \param [in] u8Port IO Port口 + ** \param [in] u8Pin IO Pin脚 + ** + ** \retval boolean_t IO电平高低 + ******************************************************************************/ +boolean_t Gpio_GetIO(uint8_t u8Port, uint8_t u8Pin) +{ + return getBit((uint32_t)&M0P_GPIO->P0IN + u8Port * GPIO_GPSZ, u8Pin); +} + +en_result_t _GpioEnableIrq(uint8_t u8Port, + uint8_t u8Pin, + en_gpio_irqtype_t enType, + boolean_t bEnable) +{ + //high level + if (enType & GpioIrqHigh) + { + setBit((uint32_t)&M0P_GPIO->P0HIE + u8Port * GPIO_GPSZ, u8Pin, bEnable); + } + //low level + if (enType & GpioIrqLow) + { + setBit((uint32_t)&M0P_GPIO->P0LIE + u8Port * GPIO_GPSZ, u8Pin, bEnable); + } + //rising + if (enType & GpioIrqRising) + { + setBit((uint32_t)&M0P_GPIO->P0RIE + u8Port * GPIO_GPSZ, u8Pin, bEnable); + } + //falling + if (enType & GpioIrqFalling) + { + setBit((uint32_t)&M0P_GPIO->P0FIE + u8Port * GPIO_GPSZ, u8Pin, bEnable); + } + + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO IO中断使能 + ** + ** \param [in] u8Port IO Port口 + ** \param [in] u8Pin IO Pin脚 + ** \param [in] enType 中断使能类型 + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_EnableIrq(uint8_t u8Port, + uint8_t u8Pin, + en_gpio_irqtype_t enType) +{ + _GpioEnableIrq(u8Port, u8Pin, enType, TRUE); + return Ok; +} + + +/** + ******************************************************************************* + ** \brief GPIO IO中断除能 + ** + ** \param [in] u8Port IO Port口 + ** \param [in] u8Pin IO Pin脚 + ** \param [in] enType 中断使能类型 + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_DisableIrq(uint8_t u8Port, uint8_t u8Pin, en_gpio_irqtype_t enType) +{ + _GpioEnableIrq(u8Port, u8Pin, enType, FALSE); + return Ok; +} + + +/** + ******************************************************************************* + ** \brief GPIO 获得IO中断状态 + ** + ** \param [in] u8Port IO Port口 + ** \param [in] u8Pin IO Pin脚 + ** + ** \retval IO中断状态开关 + ******************************************************************************/ +boolean_t Gpio_GetIrqStat(uint8_t u8Port, uint8_t u8Pin) +{ + return getBit((uint32_t)&M0P_GPIO->P0STAT + u8Port * 0x40, u8Pin); +} + + +/** + ******************************************************************************* + ** \brief GPIO 清除IO中断状态 + ** + ** \param [in] u8Port IO Port口 + ** \param [in] u8Pin IO Pin脚 + ** + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_ClearIrq(uint8_t u8Port, uint8_t u8Pin) +{ + setBit((uint32_t)&M0P_GPIO->P0ICLR + u8Port * GPIO_GPSZ, u8Pin, 0u); + + return Ok; +} + + +/** + ******************************************************************************* + ** \brief GPIO 附加功能设定 + ** + ** \param [in] enFunc 功能 + ** \param [in] u8val 设定值 + ** + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_SetCtrlExt(en_gpio_ctrlext_t enFunc, uint8_t u8val) +{ + en_result_t enRet = Ok; + + switch (enFunc) + { + case GpioCtrlIESEL: + u8val = !!u8val; + M0P_GPIO->CTRL0_f.IESEL = u8val; + break; + + case GpioCtrlIRPOL: + u8val = !!u8val; + M0P_GPIO->CTRL1_f.IR_POL = u8val; + break; + + case GpioCtrlHclkEn: + u8val = !!u8val; + M0P_GPIO->CTRL1_f.HCLK_EN = u8val; + break; + + case GpioCtrlPclkEn: + u8val = !!u8val; + M0P_GPIO->CTRL1_f.PCLK_EN = u8val; + break; + + case GpioCtrlHclkSel: + { + if ( (ClkDiv1 == u8val) || (ClkDiv2 == u8val) || (ClkDiv4 == u8val) || (ClkDiv8 == u8val) ) + { + u8val = Log2(u8val); + M0P_GPIO->CTRL1_f.HCLK_SEL = u8val; + } else + { + enRet = ErrorInvalidParameter; + } + break; + } + case GpioCtrlPclkSel: + { + if ( (ClkDiv1 == u8val) || (ClkDiv2 == u8val) || (ClkDiv4 == u8val) || (ClkDiv8 == u8val) ) + { + u8val = Log2(u8val); + M0P_GPIO->CTRL1_f.PCLK_SEL = u8val; + } else + { + enRet = ErrorInvalidParameter; + } + break; + } + default: + enRet = ErrorInvalidParameter; + break; + } + + return enRet; +} + + +/** + ******************************************************************************* + ** \brief GPIO SSN选择设置 + ** + ** \param [in] enSrc 输入源设定 + ** + ** \retval Ok 设置成功 + ** 其他值 设置失败 + ******************************************************************************/ +en_result_t Gpio_SetSsnSel(en_gpio_ctrl1src_t enSrc) +{ + switch (enSrc) + { + case GpioCtrl1SrcP35: + case GpioCtrl1SrcP36: + case GpioCtrl1SrcP01: + case GpioCtrl1SrcP02: + case GpioCtrl1SrcP03: + case GpioCtrl1SrcP15: + case GpioCtrl1SrcP14: + case GpioCtrl1SrcP23: + case GpioCtrl1SrcP24: + case GpioCtrl1SrcP25: + case GpioCtrl1SrcP26: + case GpioCtrl1SrcP27: + case GpioCtrl1SrcP31: + case GpioCtrl1SrcP32: + case GpioCtrl1SrcP33: + M0P_GPIO->CTRL1_f.SSN_SEL = enSrc; + break; + default: + return ErrorInvalidParameter; + } + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO EXT CLK选择设置 + ** + ** \param [in] enSrc 输入源设定 + ** + ** \retval Ok 设置成功 + ** 其他值 设置失败 + ******************************************************************************/ +en_result_t Gpio_SetExtClkSel(en_gpio_ctrl1src_t enSrc) +{ + switch (enSrc) + { + case GpioCtrl1SrcP35: + case GpioCtrl1SrcP36: + case GpioCtrl1SrcP01: + case GpioCtrl1SrcP02: + case GpioCtrl1SrcP03: + case GpioCtrl1SrcP15: + case GpioCtrl1SrcP14: + case GpioCtrl1SrcP23: + case GpioCtrl1SrcP24: + case GpioCtrl1SrcP25: + case GpioCtrl1SrcP26: + case GpioCtrl1SrcP27: + case GpioCtrl1SrcP31: + case GpioCtrl1SrcP32: + case GpioCtrl1SrcP33: + M0P_GPIO->CTRL1_f.EXT_CLK_SEL = enSrc; + break; + default: + return ErrorInvalidParameter; + } + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 定时器x输入时钟设定 + ** + ** \param [in] enTarget 输入IO + ** \param [in] enType 定时器类型 + ** \retval Ok 设置成功 + ** 其他值 设置失败 + ******************************************************************************/ +en_result_t Gpio_SetSignalSource(en_gpio_target_t enTarget, en_gpio_timex_in_t enType) +{ + if (enType > GpioUart2RxdIn) + { + return ErrorInvalidParameter; + } + + switch (enTarget) + { + case GpioSignalCAP4: + M0P_GPIO->CTRL2_f.PCA_CAP4_SEL = enType; + break; + case GpioSignalCAP3: + M0P_GPIO->CTRL2_f.PCA_CAP3_SEL = enType; + break; + case GpioSignalCAP2: + M0P_GPIO->CTRL2_f.PCA_CAP2_SEL = enType; + break; + case GpioSignalCAP1: + M0P_GPIO->CTRL2_f.PCA_CAP1_SEL = enType; + break; + case GpioSignalCAP0: + M0P_GPIO->CTRL2_f.PCA_CAP0_SEL = enType; + break; + + case GpioSignalTm6A: + M0P_GPIO->CTRL3_f.TM6_A_SEL = enType; + break; + case GpioSignalTm5A: + M0P_GPIO->CTRL3_f.TM5_A_SEL = enType; + break; + case GpioSignalTm4A: + M0P_GPIO->CTRL3_f.TM4_A_SEL = enType; + break; + case GpioSignalTm6B: + M0P_GPIO->CTRL3_f.TM6_B_SEL = enType; + break; + case GpioSignalTm5B: + M0P_GPIO->CTRL3_f.TM5_B_SEL = enType; + break; + case GpioSignalTm4B: + M0P_GPIO->CTRL3_f.TM4_B_SEL = enType; + break; + case GpioSignalTm2: + M0P_GPIO->CTRL4_f.TM2_GATE_SEL = enType; + break; + case GpioSignalTm1: + M0P_GPIO->CTRL4_f.TM1_GATE_SEL = enType; + break; + case GpioSignalTm0: + M0P_GPIO->CTRL4_f.TM0_GATE_SEL = enType; + break; + default: + return ErrorInvalidParameter; + } + + return Ok; +} + +//@} // GpioGroup + + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ + diff --git a/project/driver/src/i2c.c b/project/driver/src/i2c.c new file mode 100644 index 0000000..ba757d7 --- /dev/null +++ b/project/driver/src/i2c.c @@ -0,0 +1,525 @@ +/************************************************************************************* +* 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 I2C.c + ** + ** WDT function driver API. + ** @link SampleGroup Some description @endlink + ** + ** - 2017-06-13 1.0 CJ First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "i2c.h" + +/** + ******************************************************************************* + ** \addtogroup I2cGroup + ******************************************************************************/ +//@{ + +/******************************************************************************/ +/* Local function prototypes ('static') */ +/******************************************************************************/ +static func_ptr_t pfnI2ctCallback = NULL; +/** + ****************************************************************************** + ** \brief I2C设置波特率配置寄存器 + ** + ** \param [in] u8Tm 波特率配置值 + ** + ** \retval enRet 成功或失败 + ** + ******************************************************************************/ + en_result_t I2C_SetBaud(uint8_t u8Tm) + { + en_result_t enRet = Error; + M0P_I2C->TM = u8Tm; + enRet = Ok; + return enRet; + } + /** + ****************************************************************************** + ** \brief I2C功能设置相关函数 + ** + ** \param [in] enFunc功能参数 + ** + ** \retval enRet 成功或失败 + ** + ******************************************************************************/ +en_result_t I2C_SetFunc(en_i2c_func_t enFunc) +{ + en_result_t enRet = Error; + switch(enFunc) + { + case I2cMode_En: + M0P_I2C->CR_f.ENS = 1; + break; + case I2cStart_En: + M0P_I2C->CR_f.STA = 1; + break; + case I2cStop_En: + M0P_I2C->CR_f.STO = 1; + break; + case I2cAck_En: + M0P_I2C->CR_f.AA = 1; + break; + case I2cHlm_En: + M0P_I2C->CR_f.H1M = 1; + break; + case I2cBaud_En: + M0P_I2C->TMRUN = 0x01; + break; + default: + return ErrorInvalidParameter; + } + enRet = Ok; + return enRet; +} + /** + ****************************************************************************** + ** \brief I2C功能清除相关函数 + ** + ** \param [in] enFunc功能参数 + ** + ** \retval enRet 成功或失败 + ** + ******************************************************************************/ + en_result_t I2C_ClearFunc(en_i2c_func_t enFunc) + { + en_result_t enRet = Error; + switch(enFunc) + { + case I2cMode_En: + M0P_I2C->CR_f.ENS = 0; + break; + case I2cStart_En: + M0P_I2C->CR_f.STA = 0; + break; + case I2cStop_En: + M0P_I2C->CR_f.STO = 0; + break; + case I2cAck_En: + M0P_I2C->CR_f.AA = 0; + break; + case I2cHlm_En: + M0P_I2C->CR_f.H1M = 0; + break; + case I2cBaud_En: + M0P_I2C->TMRUN = 0x00; + break; + default: + return ErrorInvalidParameter; + } + enRet = Ok; + return enRet; + } + /** + ****************************************************************************** + ** \brief I2C获取中断标记函数 + ** + ** \param 无 + ** + ** \retval bIrq中断标记 + ** + ******************************************************************************/ +boolean_t I2C_GetIrq(void) +{ + boolean_t bIrq = FALSE; + bIrq = M0P_I2C->CR_f.SI; + return bIrq; +} +/** + ****************************************************************************** + ** \brief I2C清除中断标记函数 + ** + ** \param 无 + ** + ** \retval bIrq中断标记 + ** + ******************************************************************************/ +en_result_t I2C_ClearIrq(void) +{ + en_result_t enRet = Error; + M0P_I2C->CR_f.SI = 0; + enRet = Ok; + return enRet; +} + /** + ****************************************************************************** + ** \brief I2C获取相关状态 + ** + ** \param 无 + ** + ** \retval I2C状态 + ** + ******************************************************************************/ +uint8_t I2C_GetState(void) +{ + uint8_t u8State = 0; + u8State = M0P_I2C->STAT; + return u8State; +} +/** + ****************************************************************************** + ** \brief I2C写从机地址函数 + ** + ** \param u8SlaveAddr从机地址 + ** + ** \retval I2C写成功与否状态 + ** + ******************************************************************************/ + en_result_t I2C_WriteSlaveAddr(stc_i2c_addr_t *pstcSlaveAddr) +{ + en_result_t enRet = Error; + M0P_I2C->ADDR_f.I2CADR = pstcSlaveAddr->Addr; + M0P_I2C->ADDR_f.GC = pstcSlaveAddr->Gc; + enRet = Ok; + return enRet; +} +/** + ****************************************************************************** + ** \brief 字节写从机函数 + ** + ** \param u8Data写数据 + ** + ** \retval 写数据是否成功 + ** + ******************************************************************************/ +en_result_t I2C_WriteByte(uint8_t u8Data) +{ + en_result_t enRet = Error; + M0P_I2C->DATA = u8Data; + enRet = Ok; + return enRet; +} +/** + ****************************************************************************** + ** \brief 字节读从机函数 + ** + ** \param 无 + ** + ** \retval 读取数据 + ** + ******************************************************************************/ +uint8_t I2C_ReadByte(void) +{ + uint8_t u8Data = 0; + u8Data = M0P_I2C->DATA; + return u8Data; +} + /** + ****************************************************************************** + ** \brief 主机发送函数 + ** + ** \param u8Addr从机内存地址,pu8Data写数据,u32Len写数据长度 + ** + ** \retval 写数据是否成功 + ** + ******************************************************************************/ +en_result_t I2C_MasterWriteData(uint8_t u8DevAddr,uint8_t u8Addr,uint8_t *pu8Data,uint32_t u32Len) +{ + en_result_t enRet = Error; + uint8_t u8i=0,u8State; + + I2C_SetFunc(I2cStart_En); + while(1) + { + while(0 == I2C_GetIrq()) + {} + u8State = I2C_GetState(); + switch(u8State) + { + case 0x08: + I2C_ClearFunc(I2cStart_En); + I2C_WriteByte(u8DevAddr);//从设备地址发送 + break; + case 0x18: + I2C_WriteByte(u8Addr);//从设备内存地址发送 + break; + case 0x28: + I2C_WriteByte(pu8Data[u8i++]); + break; + case 0x20: + case 0x38: + I2C_SetFunc(I2cStart_En); + break; + case 0x30: + I2C_SetFunc(I2cStop_En); + break; + default: + break; + } + if(u8i>u32Len) + { + I2C_SetFunc(I2cStop_En);//此顺序不能调换,出停止条件 + I2C_ClearIrq(); + break; + } + I2C_ClearIrq(); + } + enRet = Ok; + return enRet; +} + /** + ****************************************************************************** + ** \brief 从机发送函数 + ** + ** \param pu8Data发送数据缓存,u32Len发送数据长度 + ** + ** \retval 发送数据是否成功 + ** + ******************************************************************************/ + en_result_t I2C_SlaveWriteData(uint8_t *pu8Data,uint32_t *u32Len) + { + //en_result_t enRet = Error; + uint8_t u8i=0,u8State; + // + while(1) + { + + while(0 == I2C_GetIrq()) + {} + u8State = I2C_GetState(); + switch(u8State) + { + case 0xA8: + case 0xB0: + I2C_WriteByte(pu8Data[u8i++]); + break; + case 0xB8: + case 0xC8: + I2C_WriteByte(pu8Data[u8i++]); + break; + case 0xC0://发送数据,接收非ACK + break; + default: + return ErrorInvalidParameter; + } + I2C_ClearIrq(); + if(0xC0 == u8State) + { + return Ok; + } + } + } + /** + ****************************************************************************** + ** \brief 从机接收函数 + ** + ** \param pu8Data接收数据存放缓存,u32Len接收数据指针 + ** + ** \retval 接收数据是否成功 + ** + ******************************************************************************/ +en_result_t I2C_SlaveReadData(uint8_t *pu8Data,uint32_t *pu32Len) +{ + //en_result_t enRet = Error; + uint8_t u8i=0,u8State; + while(0 == I2C_GetIrq()) + {} + while(1) + { + while(0 == I2C_GetIrq()) + {} + u8State = I2C_GetState(); + switch(u8State) + { + case 0x60: + case 0x68: + case 0x78: + case 0x70: + break; + + case 0x80: + case 0x88://只读取一个字节情况: + case 0x90: + case 0x98: + pu8Data[u8i++] = I2C_ReadByte(); + break; + case 0xA0: + *pu32Len = u8i; + break; + default: + return ErrorInvalidParameter; + } + I2C_ClearIrq(); + if(0xA0 == u8State) + { + return Ok; + } + } +} + +/** + ****************************************************************************** + ** \brief 主机接收函数 + ** + ** \param u8Addr从机内存地址,pu8Data读数据存放缓存,u32Len读数据长度 + ** + ** \retval 读数据是否成功 + ** + ******************************************************************************/ + en_result_t I2C_MasterReadData(uint8_t u8DevAddr,uint8_t *pu8Data,uint8_t u8Addr,uint32_t u32Len) +{ + en_result_t enRet = Error; + uint8_t u8i=0,u8State; + + I2C_SetFunc(I2cStart_En); + + while(1) + { + while(0 == I2C_GetIrq()) + {} + u8State = I2C_GetState(); + switch(u8State) + { + case 0x08: + I2C_ClearFunc(I2cStart_En); + I2C_WriteByte(u8DevAddr); + break; + case 0x18: + I2C_WriteByte(u8Addr); + break; + case 0x28: + I2C_SetFunc(I2cStart_En); + break; + case 0x10: + I2C_ClearFunc(I2cStart_En); + I2C_WriteByte(u8DevAddr|0x01);//从机地址发送OK + break; + case 0x40: + if(u32Len>1) + { + I2C_SetFunc(I2cAck_En); + } + break; + case 0x50: + pu8Data[u8i++] = I2C_ReadByte(); + if(u8i==u32Len-1)//倒数第二字节ACK清掉,最后字节不反馈ACK + { + I2C_ClearFunc(I2cAck_En); + } + break; + case 0x58: + pu8Data[u8i++] = I2C_ReadByte(); + I2C_SetFunc(I2cStop_En); + break; + case 0x38: + I2C_SetFunc(I2cStart_En); + break; + case 0x48: + I2C_SetFunc(I2cStop_En); + I2C_SetFunc(I2cStart_En); + break; + default: + I2C_SetFunc(I2cStart_En);//其他错误状态,重新发送起始条件 + break; + } + I2C_ClearIrq(); + if(u8i==u32Len) + { + break; + } + } + enRet = Ok; + return enRet; +} +/** + ****************************************************************************** + ** \brief I2C模块初始化 + ** + ** \param stcI2CCfg初始化配置结构体指针 + ** + ** \retval 初始化是否成功 + ** + ******************************************************************************/ +en_result_t I2C_Init(stc_i2c_config_t* pstcI2CCfg) +{ + en_result_t enRet = Error; + enRet = I2C_SetFunc(pstcI2CCfg->enFunc); + enRet = I2C_SetBaud(pstcI2CCfg->u8Tm); + enRet = I2C_WriteSlaveAddr(&pstcI2CCfg->stcSlaveAddr); + if(NULL != pstcI2CCfg->pfnI2cCb) + { + pfnI2ctCallback = pstcI2CCfg->pfnI2cCb; + } + if(TRUE == pstcI2CCfg->bTouchNvic) + { + EnableNvic(I2C_IRQn,DDL_IRQ_LEVEL_DEFAULT,TRUE); + } + return enRet; +} +/** + ****************************************************************************** + ** \brief I2C模块关闭初始化 + ** + ** \param 无 + ** + ** \retval 设置是否成功 + ** + ******************************************************************************/ + en_result_t I2C_DeInit(void) + { + en_result_t enRet = Error; + M0P_I2C->CR = 0x00; + enRet = Ok; + return enRet; + } + /** + ****************************************************************************** + ** \brief I2C模块中断处理函数 + ** + ** \param u8Param 无意义 + ** + ** \retval 无 + ** + ******************************************************************************/ +void I2c_IRQHandler(uint8_t u8Param) +{ + pfnI2ctCallback(); +} + +//@} // I2cGroup diff --git a/project/driver/src/interrupts_hc32f003.c b/project/driver/src/interrupts_hc32f003.c new file mode 100644 index 0000000..f9fa1d0 --- /dev/null +++ b/project/driver/src/interrupts_hc32f003.c @@ -0,0 +1,359 @@ +/****************************************************************************** +* 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 interrupts_hc32f005.c + ** + ** Interrupt management + ** @link Driver Group Some description @endlink + ** + ** - 2017-04-29 1.0 Ronnie First version. + ** + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "ddl.h" +#include "interrupts_hc32f003.h" +__WEAKDEF void Gpio_IRQHandler(uint8_t u8Param); +__WEAKDEF void Uart_IRQHandler(uint8_t u8Param); +__WEAKDEF void Spi_IRQHandler(uint8_t u8Param); +__WEAKDEF void I2c_IRQHandler(uint8_t u8Param); +__WEAKDEF void Tim_IRQHandler(uint8_t u8Param); +__WEAKDEF void Adt_IRQHandler(uint8_t u8Param); +__WEAKDEF void Pca_IRQHandler(uint8_t u8Param); +__WEAKDEF void Wdt_IRQHandler(uint8_t u8Param); +__WEAKDEF void Vc_IRQHandler(uint8_t u8Param); +__WEAKDEF void Adc_IRQHandler(uint8_t u8Param); +__WEAKDEF void Lvd_IRQHandler(uint8_t u8Param); +__WEAKDEF void EfRam_IRQHandler(uint8_t u8Param); +__WEAKDEF void ClkTrim_IRQHandler(uint8_t u8Param); + +/** + ******************************************************************************* + ** \brief NVIC 中断使能 + ** + ** \param [in] u32Irq 中断号 + ** \param [in] u8Level 中断优先级 + ** \param [in] bEn 中断开关 + ** \retval Ok 设置成功 + ** 其他值 设置失败 + ******************************************************************************/ +void EnableNvic(uint32_t u32Irq,uint8_t u8Level,boolean_t bEn) +{ + IRQn_Type enIrq = (IRQn_Type)u32Irq; + + NVIC_ClearPendingIRQ(enIrq); + NVIC_SetPriority(enIrq, u8Level); + 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 GPIO Port0 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void PORT0_IRQHandler(void) +{ + Gpio_IRQHandler(0); +} + +/** + ******************************************************************************* + ** \brief GPIO Port1 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void PORT1_IRQHandler(void) +{ + Gpio_IRQHandler(1); +} + +/** + ******************************************************************************* + ** \brief GPIO Port2 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void PORT2_IRQHandler(void) +{ + Gpio_IRQHandler(2); +} + +/** + ******************************************************************************* + ** \brief GPIO Port3 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void PORT3_IRQHandler(void) +{ + Gpio_IRQHandler(3); +} + +/** + ******************************************************************************* + ** \brief GPIO 串口0 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void UART0_IRQHandler(void) +{ + Uart_IRQHandler(0); +} + +/** + ******************************************************************************* + ** \brief GPIO 串口1 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void UART1_IRQHandler(void) +{ + Uart_IRQHandler(1); +} +/** + ******************************************************************************* + ** \brief GPIO SPI 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void SPI_IRQHandler(void) +{ + Spi_IRQHandler(0); +} + +/** + ******************************************************************************* + ** \brief GPIO I2C 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void I2C_IRQHandler(void) +{ + I2c_IRQHandler(0); +} + +/** + ******************************************************************************* + ** \brief GPIO 基础时钟0 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void TIM0_IRQHandler(void) +{ + Tim_IRQHandler(0); +} + +/** + ******************************************************************************* + ** \brief GPIO 基础时钟1 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void TIM1_IRQHandler(void) +{ + Tim_IRQHandler(1); +} + +/** + ******************************************************************************* + ** \brief GPIO 基础时钟2 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void TIM2_IRQHandler(void) +{ + Tim_IRQHandler(2); +} + +/** + ******************************************************************************* + ** \brief GPIO 高级时钟4 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void TIM4_IRQHandler(void) +{ + Adt_IRQHandler(4); +} + +/** + ******************************************************************************* + ** \brief GPIO 高级时钟5 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void TIM5_IRQHandler(void) +{ + Adt_IRQHandler(5); +} + +/** + ******************************************************************************* + ** \brief GPIO 高级时钟6 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void TIM6_IRQHandler(void) +{ + Adt_IRQHandler(6); +} + +/** + ******************************************************************************* + ** \brief GPIO PCA 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void PCA_IRQHandler(void) +{ + Pca_IRQHandler(0); +} + +/** + ******************************************************************************* + ** \brief GPIO WDT 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void WDT_IRQHandler(void) +{ + Wdt_IRQHandler(0); +} + + +/** + ******************************************************************************* + ** \brief GPIO ADC 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void ADC_IRQHandler(void) +{ + Adc_IRQHandler(0); +} + +/** + ******************************************************************************* + ** \brief GPIO 电压比较0 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void VC0_IRQHandler(void) +{ + Vc_IRQHandler(0); +} + +/** + ******************************************************************************* + ** \brief GPIO 电压比较1 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void VC1_IRQHandler(void) +{ + Vc_IRQHandler(1); +} + +/** + ******************************************************************************* + ** \brief GPIO 低电压检测 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void LVD_IRQHandler(void) +{ + Lvd_IRQHandler(0); +} + +/** + ******************************************************************************* + ** \brief GPIO RAM 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void EF_RAM_IRQHandler(void) +{ + EfRam_IRQHandler(0); +} + +/** + ******************************************************************************* + ** \brief GPIO 时钟校准 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void CLKTRIM_IRQHandler(void) +{ + ClkTrim_IRQHandler(0); +} + + + +/******************************************************************************/ +/* EOF (not truncated) */ +/******************************************************************************/ diff --git a/project/driver/src/lpm.c b/project/driver/src/lpm.c new file mode 100644 index 0000000..dbba75a --- /dev/null +++ b/project/driver/src/lpm.c @@ -0,0 +1,134 @@ +/****************************************************************************** +*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') + ******************************************************************************/ +#define IS_VALID_SEVONPEND(x) (SevPndDisable == (x) ||\ + SevPndEnable == (x)) +#define IS_VALID_SLEEPDEEP(x) (SlpDpDisable == (x) ||\ + SlpDpEnable == (x)) +#define IS_VALID_SLEEPONEXIT(x) (SlpExtDisable == (x) ||\ + SlpExtEnable == (x)) + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +/** + ***************************************************************************** + ** \brief 低功耗模式配置 + ** + ** + ** \param [in] pstcConfig 低功耗模式配置结构体指针 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Lpm_Config(stc_lpm_config_t* pstcConfig) +{ + en_result_t enResult = Error; + + ASSERT(IS_VALID_SEVONPEND(pstcConfig->enSEVONPEND)); + ASSERT(IS_VALID_SLEEPDEEP(pstcConfig->enSLEEPDEEP)); + ASSERT(IS_VALID_SLEEPONEXIT(pstcConfig->enSLEEPONEXIT)); + + SCB->SCR = pstcConfig->enSEVONPEND ? (SCB->SCR | SCB_SCR_SEVONPEND_Msk) : (SCB->SCR & ~SCB_SCR_SEVONPEND_Msk); + SCB->SCR = pstcConfig->enSLEEPDEEP ? (SCB->SCR | SCB_SCR_SLEEPDEEP_Msk) : (SCB->SCR & ~SCB_SCR_SLEEPDEEP_Msk); + SCB->SCR = pstcConfig->enSLEEPONEXIT ? (SCB->SCR | SCB_SCR_SLEEPONEXIT_Msk) : (SCB->SCR & ~SCB_SCR_SLEEPONEXIT_Msk); + + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief 进入睡眠模式 + ** + ** + ** + ** \retval NULL + *****************************************************************************/ +void Lpm_GotoLpmMode(void) +{ + __WFI(); +} + +//@} // LpmGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/project/driver/src/lvd.c b/project/driver/src/lvd.c new file mode 100644 index 0000000..3b71cee --- /dev/null +++ b/project/driver/src/lvd.c @@ -0,0 +1,316 @@ +/****************************************************************************** +* 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) <= LvdInputP25 ) + +#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') + ******************************************************************************/ +static func_ptr_t pfnLvdIrqCbk; + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + *****************************************************************************/ + + /** + * \brief + * LVD中断服务程序 + * + * \param [in] u8Param 未使用 + * + * \retval 无 + */ +void Lvd_IRQHandler(uint8_t u8Param) +{ + M0P_LVD->IFR_f.INTF = 0u; + if (NULL != pfnLvdIrqCbk) + { + pfnLvdIrqCbk(); + } +} + +/** + * \brief + * 使能NVIC中LVD中断 + * + * \param 无 + * + * \retval 无 + */ +static void LvdEnableNvic(void) +{ + NVIC_ClearPendingIRQ(LVD_IRQn); + NVIC_SetPriority(LVD_IRQn, DDL_IRQ_LEVEL_DEFAULT); + NVIC_EnableIRQ(LVD_IRQn); +} + +/** + * \brief + * 除能NVIC中LVD中断 + * + * \param 无 + * + * \retval 无 + */ +static void LvdDisableNvic(void) +{ + NVIC_ClearPendingIRQ(LVD_IRQn); + NVIC_DisableIRQ(LVD_IRQn); + NVIC_SetPriority(LVD_IRQn, DDL_IRQ_LEVEL_DEFAULT); +} + +/** + * \brief + * 使能LVD中断 + * + * \param [in] enType LVD中断类型 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效类型 + */ +en_result_t Lvd_EnableIrq(en_lvd_irq_type_t enType) +{ + en_result_t enRet = Ok; + + if (enType > LvdIrqFall) + { + return ErrorInvalidParameter; + } + else + { switch (enType) + { + case LvdIrqHigh: + M0P_LVD->CR_f.HTEN = 1u; + M0P_LVD->CR_f.RTEN = 0u; + M0P_LVD->CR_f.FTEN = 0u; + break; + case LvdIrqRise: + M0P_LVD->CR_f.HTEN = 0u; + M0P_LVD->CR_f.RTEN = 1u; + M0P_LVD->CR_f.FTEN = 0u; + break; + case LvdIrqFall: + M0P_LVD->CR_f.HTEN = 0u; + M0P_LVD->CR_f.RTEN = 0u; + M0P_LVD->CR_f.FTEN = 1u; + break; + default: + break; + } + + M0P_LVD->CR_f.IE = 1u; + LvdEnableNvic(); + } + return enRet; +} + +/** + * \brief + * 除能LVD中断 + * + * \param 无 + * + * \retval 无 + */ +void Lvd_DisableIrq(void) +{ + LvdDisableNvic(); + M0P_LVD->CR_f.IE = 0u; + M0P_LVD->CR_f.HTEN = 0u; + M0P_LVD->CR_f.RTEN = 0u; + M0P_LVD->CR_f.FTEN = 0u; +} + +/** + * \brief + * LVD初始化 + * + * \param [in] pstcConfig LVD配置指针 + * + * \retval 无 + */ +void Lvd_Init(stc_lvd_config_t *pstcConfig) +{ + ASSERT(pstcConfig); + ASSERT(IS_VALID_INPUT(pstcConfig->enInput)); + ASSERT(IS_VALID_THRESHOLD(pstcConfig->enThreshold)); + ASSERT(IS_VALID_FILTER(pstcConfig->enFilterTime)); + ASSERT(IS_VALID_IRQTYPE(pstcConfig->enIrqType)); + + //NEED to DISABLE first. + Lvd_Disable(); + Lvd_DisableIrq(); + LvdDisableNvic(); + + M0P_LVD->CR_f.DEBOUNCE_TIME = pstcConfig->enFilterTime; + M0P_LVD->CR_f.FLTEN = pstcConfig->bFilter; + M0P_LVD->CR_f.VTDS = pstcConfig->enThreshold; + M0P_LVD->CR_f.SOURCE_SEL = pstcConfig->enInput; + M0P_LVD->CR_f.ACT = pstcConfig->bLvdReset; + + pfnLvdIrqCbk = pstcConfig->pfnIrqCbk; +} + +/** + * \brief + * LVD deinit + * + * \param 无 + * + * \retval 无 + */ +void Lvd_DeInit(void) +{ + Lvd_DisableIrq(); + LvdDisableNvic(); + + pfnLvdIrqCbk = NULL; + Lvd_Disable(); +} + +/** + * \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_GetIntrStat(void) +{ + return M0P_LVD->IFR_f.INTF; + +} + +/** + * \brief + * 清除LVD中断标志 + * + * \param 无 + * + * \retval 无 + */ +void Lvd_ClearIrq(void) +{ + M0P_LVD->IFR_f.INTF = 0u; +} + + +//@} // LvdGroup + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/project/driver/src/pca.c b/project/driver/src/pca.c new file mode 100644 index 0000000..3ab2c00 --- /dev/null +++ b/project/driver/src/pca.c @@ -0,0 +1,755 @@ +/****************************************************************************** +*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 pca.c + ** + ** Common API of PCA. + ** @link pcaGroup Some description @endlink + ** + ** - 2017-05-16 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "pca.h" +/** + ******************************************************************************* + ** \addtogroup PcaGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define IS_VALID_MODULE(x) (Module0 == (x) ||\ + Module1 == (x) ||\ + Module2 == (x) ||\ + Module3 == (x) ||\ + Module4 == (x)) + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ +static func_ptr_t pfnPcaCallback = NULL; + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +/** + ***************************************************************************** + ** \brief PCA中断标志获取 + ** + ** + ** \param [in] enModule PCA模块选择(Module0、Module1、Module2、Module3、Module4) + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +boolean_t Pca_GetIntFlag(en_pca_module_t enModule) +{ + boolean_t bRetVal = FALSE; + + ASSERT(IS_VALID_MODULE(enModule)); + + switch (enModule) + { + case Module0: + bRetVal = M0P_PCA->CCON_f.CCF0 ? TRUE : FALSE; + break; + case Module1: + bRetVal = M0P_PCA->CCON_f.CCF1 ? TRUE : FALSE; + break; + case Module2: + bRetVal = M0P_PCA->CCON_f.CCF2 ? TRUE : FALSE; + break; + case Module3: + bRetVal = M0P_PCA->CCON_f.CCF3 ? TRUE : FALSE; + break; + case Module4: + bRetVal = M0P_PCA->CCON_f.CCF4 ? TRUE : FALSE; + break; + default: + bRetVal = FALSE; + break; + } + + return bRetVal; +} + +/** + ***************************************************************************** + ** \brief PCA计数器中断标志获取 + ** + ** + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +boolean_t Pca_GetCntIntFlag(void) +{ + boolean_t bRetVal = FALSE; + + bRetVal = M0P_PCA->CCON_f.CF ? TRUE : FALSE; + + return bRetVal; +} + +/** + ***************************************************************************** + ** \brief PCA中断标志清除 + ** + ** + ** \param [in] enModule PCA模块选择(Module0、Module1、Module2、Module3、Module4) + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_ClearIntFlag(en_pca_module_t enModule) +{ + en_result_t enResult = Error; + + ASSERT(IS_VALID_MODULE(enModule)); + + switch (enModule) + { + case Module0: + M0P_PCA->ICLR_f.CCF0 = FALSE; + enResult = Ok; + break; + case Module1: + M0P_PCA->ICLR_f.CCF1 = FALSE; + enResult = Ok; + break; + case Module2: + M0P_PCA->ICLR_f.CCF2 = FALSE; + enResult = Ok; + break; + case Module3: + M0P_PCA->ICLR_f.CCF3 = FALSE; + enResult = Ok; + break; + case Module4: + M0P_PCA->ICLR_f.CCF4 = FALSE; + enResult = Ok; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief PCA计数器中断标志清除 + ** + ** + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_ClearCntIntFlag(void) +{ + en_result_t enResult = Error; + + M0P_PCA->ICLR_f.CF = FALSE; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief PCA中断服务程序 + ** + ** + ** \param [in] u8Param == 0 + ** + *****************************************************************************/ +void Pca_IRQHandler(uint8_t u8Param) +{ + pfnPcaCallback(); +} + +/** + ***************************************************************************** + ** \brief PCA中断使能 + ** + ** + ** \param [in] enModule PCA模块选择(Module0、Module1、Module2、Module3、Module4) + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_EnableIrq(en_pca_module_t enModule) +{ + en_result_t enResult = Error; + + ASSERT(IS_VALID_MODULE(enModule)); + + switch (enModule) + { + case Module0: + M0P_PCA->CCAPM0_f.CCIE = TRUE; + enResult = Ok; + break; + case Module1: + M0P_PCA->CCAPM1_f.CCIE = TRUE; + enResult = Ok; + break; + case Module2: + M0P_PCA->CCAPM2_f.CCIE = TRUE; + enResult = Ok; + break; + case Module3: + M0P_PCA->CCAPM3_f.CCIE = TRUE; + enResult = Ok; + break; + case Module4: + M0P_PCA->CCAPM4_f.CCIE = TRUE; + enResult = Ok; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief PCA计数器中断使能 + ** + ** + ** + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_EnableCntIrq (void) +{ + en_result_t enResult = Error; + + M0P_PCA->CMOD_f.CFIE = TRUE; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief PCA中断使能 + ** + ** + ** \param [in] enModule PCA模块选择(Module0、Module1、Module2、Module3、Module4) + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_DisableIrq(en_pca_module_t enModule) +{ + en_result_t enResult = Error; + + ASSERT(IS_VALID_MODULE(enModule)); + + switch (enModule) + { + case Module0: + M0P_PCA->CCAPM0_f.CCIE = FALSE; + enResult = Ok; + break; + case Module1: + M0P_PCA->CCAPM1_f.CCIE = FALSE; + enResult = Ok; + break; + case Module2: + M0P_PCA->CCAPM2_f.CCIE = FALSE; + enResult = Ok; + break; + case Module3: + M0P_PCA->CCAPM3_f.CCIE = FALSE; + enResult = Ok; + break; + case Module4: + M0P_PCA->CCAPM4_f.CCIE = FALSE; + enResult = Ok; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief PCA计数器中断禁止 + ** + ** + ** + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_DisableCntIrq(void) +{ + en_result_t enResult = Error; + + M0P_PCA->CMOD_f.CFIE = FALSE; + enResult = Ok; + + return enResult; +} + + +/** + ***************************************************************************** + ** \brief PCA初始化配置 + ** + ** + ** \param [in] pstcConfig PCA模块配置结构体指针 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_Init(stc_pca_config_t* pstcConfig) +{ + en_result_t enResult = Error; + + M0P_PCA->CMOD_f.CIDL = pstcConfig->enCIDL; + M0P_PCA->CMOD_f.WDTE = pstcConfig->enWDTE; + M0P_PCA->CMOD_f.CPS = pstcConfig->enCPS; + + pfnPcaCallback = pstcConfig->pfnPcaCb; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief PCA模式配置 + ** + ** + ** \param [in] enModule PCA模块选择(Module0、Module1、Module2、Module3、Module4) + ** \param [in] pstcCapMod PCA模式配置结构体指针 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_CapModConfig(en_pca_module_t enModule, stc_pca_capmodconfig_t* pstcCapMod) +{ + en_result_t enResult = Error; + + ASSERT(IS_VALID_MODULE(enModule)); + + switch (enModule) + { + case Module0: + { + M0P_PCA->CCAPM0_f.ECOM = pstcCapMod->enECOM; + M0P_PCA->CCAPM0_f.CAPP = pstcCapMod->enCAPP; + M0P_PCA->CCAPM0_f.CAPN = pstcCapMod->enCAPN; + M0P_PCA->CCAPM0_f.MAT = pstcCapMod->enMAT; + M0P_PCA->CCAPM0_f.TOG = pstcCapMod->enTOG; + M0P_PCA->CCAPM0_f.PWM = pstcCapMod->enPWM; + enResult = Ok; + } + break; + case Module1: + { + M0P_PCA->CCAPM1_f.ECOM = pstcCapMod->enECOM; + M0P_PCA->CCAPM1_f.CAPP = pstcCapMod->enCAPP; + M0P_PCA->CCAPM1_f.CAPN = pstcCapMod->enCAPN; + M0P_PCA->CCAPM1_f.MAT = pstcCapMod->enMAT; + M0P_PCA->CCAPM1_f.TOG = pstcCapMod->enTOG; + M0P_PCA->CCAPM1_f.PWM = pstcCapMod->enPWM; + enResult = Ok; + } + break; + case Module2: + { + M0P_PCA->CCAPM2_f.ECOM = pstcCapMod->enECOM; + M0P_PCA->CCAPM2_f.CAPP = pstcCapMod->enCAPP; + M0P_PCA->CCAPM2_f.CAPN = pstcCapMod->enCAPN; + M0P_PCA->CCAPM2_f.MAT = pstcCapMod->enMAT; + M0P_PCA->CCAPM2_f.TOG = pstcCapMod->enTOG; + M0P_PCA->CCAPM2_f.PWM = pstcCapMod->enPWM; + enResult = Ok; + } + break; + case Module3: + { + M0P_PCA->CCAPM3_f.ECOM = pstcCapMod->enECOM; + M0P_PCA->CCAPM3_f.CAPP = pstcCapMod->enCAPP; + M0P_PCA->CCAPM3_f.CAPN = pstcCapMod->enCAPN; + M0P_PCA->CCAPM3_f.MAT = pstcCapMod->enMAT; + M0P_PCA->CCAPM3_f.TOG = pstcCapMod->enTOG; + M0P_PCA->CCAPM3_f.PWM = pstcCapMod->enPWM; + enResult = Ok; + } + break; + case Module4: + { + M0P_PCA->CCAPM4_f.ECOM = pstcCapMod->enECOM; + M0P_PCA->CCAPM4_f.CAPP = pstcCapMod->enCAPP; + M0P_PCA->CCAPM4_f.CAPN = pstcCapMod->enCAPN; + M0P_PCA->CCAPM4_f.MAT = pstcCapMod->enMAT; + M0P_PCA->CCAPM4_f.TOG = pstcCapMod->enTOG; + M0P_PCA->CCAPM4_f.PWM = pstcCapMod->enPWM; + enResult = Ok; + } + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief PCA启动运行 + ** + ** + ** + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_Run(void) +{ + en_result_t enResult = Error; + + M0P_PCA->CCON_f.CR = TRUE; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief PCA停止运行 + ** + ** + ** + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_Stop(void) +{ + en_result_t enResult = Error; + + M0P_PCA->CCON_f.CR = FALSE; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief PCA16位捕获数据设置 + ** + ** + ** \param [in] enModule PCA模块选择(Module0、Module1、Module2、Module3、Module4) + ** \param [in] u16Data PCA捕获数据 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_CapData16Set(en_pca_module_t enModule, uint16_t u16Data) +{ + en_result_t enResult = Error; + + ASSERT(IS_VALID_MODULE(enModule)); + + switch (enModule) + { + case Module0: + M0P_PCA->CCAP0_f.CCAP0 = u16Data; + enResult = Ok; + break; + case Module1: + M0P_PCA->CCAP1_f.CCAP1 = u16Data; + enResult = Ok; + break; + case Module2: + M0P_PCA->CCAP2_f.CCAP2 = u16Data; + enResult = Ok; + break; + case Module3: + M0P_PCA->CCAP3_f.CCAP3 = u16Data; + enResult = Ok; + break; + case Module4: + M0P_PCA->CCAP4_f.CCAP4 = u16Data; + enResult = Ok; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + + +/** + ***************************************************************************** + ** \brief PCA16位捕获数据获取 + ** + ** + ** \param [in] enModule PCA模块选择(Module0、Module1、Module2、Module3、Module4) + ** + ** \retval u16Data + *****************************************************************************/ +uint16_t Pca_CapData16Get(en_pca_module_t enModule) +{ + uint16_t u16Data = 0; + + ASSERT(IS_VALID_MODULE(enModule)); + + switch (enModule) + { + case Module0: + u16Data = M0P_PCA->CCAP0_f.CCAP0; + break; + case Module1: + u16Data = M0P_PCA->CCAP1_f.CCAP1; + break; + case Module2: + u16Data = M0P_PCA->CCAP2_f.CCAP2; + break; + case Module3: + u16Data = M0P_PCA->CCAP3_f.CCAP3; + break; + case Module4: + u16Data = M0P_PCA->CCAP4_f.CCAP4; + break; + default: + u16Data = 0; + break; + } + + return u16Data; +} + +/** + ***************************************************************************** + ** \brief PCA高8位捕获数据设置 + ** + ** + ** \param [in] enModule PCA模块选择(Module0、Module1、Module2、Module3、Module4) + ** \param [in] u8Data PCA高8位捕获数据 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_CapDataHSet(en_pca_module_t enModule, uint8_t u8Data) +{ + en_result_t enResult = Error; + + ASSERT(IS_VALID_MODULE(enModule)); + + switch (enModule) + { + case Module0: + M0P_PCA->CCAP0H_f.CCAP0 = u8Data; + enResult = Ok; + break; + case Module1: + M0P_PCA->CCAP1H_f.CCAP1 = u8Data; + enResult = Ok; + break; + case Module2: + M0P_PCA->CCAP2H_f.CCAP2 = u8Data; + enResult = Ok; + break; + case Module3: + M0P_PCA->CCAP3H_f.CCAP3 = u8Data; + enResult = Ok; + break; + case Module4: + M0P_PCA->CCAP4H_f.CCAP4 = u8Data; + enResult = Ok; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief PCA低8位捕获数据设置 + ** + ** + ** \param [in] enModule PCA模块选择(Module0、Module1、Module2、Module3、Module4) + ** \param [in] u8Data PCA低8位捕获数据 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_CapDataLSet(en_pca_module_t enModule, uint8_t u8Data) +{ + en_result_t enResult = Error; + + ASSERT(IS_VALID_MODULE(enModule)); + + switch (enModule) + { + case Module0: + M0P_PCA->CCAP0L_f.CCAP0 = u8Data; + enResult = Ok; + break; + case Module1: + M0P_PCA->CCAP1L_f.CCAP1 = u8Data; + enResult = Ok; + break; + case Module2: + M0P_PCA->CCAP2L_f.CCAP2 = u8Data; + enResult = Ok; + break; + case Module3: + M0P_PCA->CCAP3L_f.CCAP3 = u8Data; + enResult = Ok; + break; + case Module4: + M0P_PCA->CCAP4L_f.CCAP4 = u8Data; + enResult = Ok; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief PCA计数器初值设置 + ** + ** + ** + ** \param [in] u16Data PCA计数器初值 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Pca_Cnt16Set(uint16_t u16Data) +{ + en_result_t enResult = Error; + + M0P_PCA->CNT_f.CNT = u16Data; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief PCA16位计数器值获取 + ** + ** + ** + ** \retval 16位计数器值 + *****************************************************************************/ +uint16_t Pca_Cnt16Get(void) +{ + uint16_t u16CntData = 0; + + u16CntData = M0P_PCA->CNT_f.CNT; + + return u16CntData; +} + +/** + ***************************************************************************** + ** \brief PCA比较高速输出标志获取 + ** + ** + ** \param [in] enModule PCA模块选择(Module0、Module1、Module2、Module3、Module4) + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +boolean_t Pca_GetCmpHighFlag(en_pca_module_t enModule) +{ + boolean_t bRetVal = FALSE; + + ASSERT(IS_VALID_MODULE(enModule)); + + switch (enModule) + { + case Module0: + bRetVal = M0P_PCA->CCAPO_f.CCAPO0 ? TRUE : FALSE; + break; + case Module1: + bRetVal = M0P_PCA->CCAPO_f.CCAPO1 ? TRUE : FALSE; + break; + case Module2: + bRetVal = M0P_PCA->CCAPO_f.CCAPO2 ? TRUE : FALSE; + break; + case Module3: + bRetVal = M0P_PCA->CCAPO_f.CCAPO3 ? TRUE : FALSE; + break; + case Module4: + bRetVal = M0P_PCA->CCAPO_f.CCAPO4 ? TRUE : FALSE; + break; + default: + bRetVal = FALSE; + break; + } + + return bRetVal; +} + +//@} // PcaGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/project/driver/src/reset.c b/project/driver/src/reset.c new file mode 100644 index 0000000..6078206 --- /dev/null +++ b/project/driver/src/reset.c @@ -0,0 +1,204 @@ +/****************************************************************************** +*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] pstcOut 复位源类型列表 + ** + ** \retval Ok 操作成功 + ** 其他 操作失败 + ******************************************************************************/ +en_result_t Reset_GetCause(stc_reset_cause_t *pstcOut) +{ + uint8_t u8val = 0; + if (NULL == pstcOut) + { + return ErrorInvalidParameter; + } + + u8val = M0P_RESET->RESET_FLAG; + + *pstcOut = *((stc_reset_cause_t*)&u8val); + return Ok; +} + + +/** + ******************************************************************************* + ** \brief 清除复位源类型. + ** + ** \param [in] stcval 复位源类型列表,对应标志位写0清除。 + ** + ** \retval Ok 操作成功 + ** 其他 操作失败 + ******************************************************************************/ +en_result_t Reset_Clear(stc_reset_cause_t stcval) +{ + uint8_t u8val = *((uint8_t*)&stcval); + + M0P_RESET->RESET_FLAG = u8val; + + return Ok; +} + + +/** + ******************************************************************************* + ** \brief 设置外设复位源开关. + ** + ** \param [in] enPeri 复位源类型列表 + ** \param [in] bFlag 复位开关 + ** + ** \retval Ok 操作成功 + ** 其他 操作失败 + ******************************************************************************/ +en_result_t Reset_SetPeripheralReset(en_reset_peripheral_t enPeri,boolean_t bFlag) +{ + + bFlag = !!bFlag; + + switch (enPeri) + { + case ResetGpio: + M0P_RESET->PREI_RESET_f.GPIO = bFlag; + break; + case ResetCrc: + M0P_RESET->PREI_RESET_f.CRC = bFlag; + break; + case ResetTick: + M0P_RESET->PREI_RESET_f.TICK = bFlag; + break; + case ResetTrim: + M0P_RESET->PREI_RESET_f.TRIM = bFlag; + break; + case ResetVc: + M0P_RESET->PREI_RESET_f.VC = bFlag; + break; + case ResetAdc: + M0P_RESET->PREI_RESET_f.ADC = bFlag; + break; + case ResetPca: + M0P_RESET->PREI_RESET_f.PCA = bFlag; + break; + case ResetAdcTim: + M0P_RESET->PREI_RESET_f.ADVTIM = bFlag; + break; + case ResetBaseTim: + M0P_RESET->PREI_RESET_f.BASETIM = bFlag; + break; + case ResetSpi: + M0P_RESET->PREI_RESET_f.SPI = bFlag; + break; + case ResetI2c: + M0P_RESET->PREI_RESET_f.I2C = bFlag; + break; + case ResetUart1: + M0P_RESET->PREI_RESET_f.UART1 = bFlag; + break; + case ResetUart0: + M0P_RESET->PREI_RESET_f.UART0 = bFlag; + break; + default: + return ErrorInvalidParameter; + } + return Ok; +} + + + + + +//@} // ResetGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/project/driver/src/spi.c b/project/driver/src/spi.c new file mode 100644 index 0000000..ab9818b --- /dev/null +++ b/project/driver/src/spi.c @@ -0,0 +1,275 @@ +/****************************************************************************** +* 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 spi.c + ** + ** SPI driver API. + ** @link Driver Group Some description @endlink + ** + ** - 2017-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)||\ + SpiWcol == (x)||\ + SpiSserr == (x)||\ + SpiMdf == (x) ) + + +/******************************************************************************/ +/* Local function prototypes ('static') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local variable prototypes ('static') */ +/******************************************************************************/ +static func_ptr_t pfnSpiCallback = NULL; ///< callback function pointer for SPI Irq +/** + ****************************************************************************** + ** \brief SPI 中断处理函数 + ** + ** \param [in] 无 + ** + ** \retval 无 + ** + ******************************************************************************/ +void Spi_IRQHandler(void) +{ + pfnSpiCallback(); +} + +/** + ****************************************************************************** + ** \brief SPI 请求状态获取 + ** + ** \param [in] enStatus 获取请求 + ** + ** \retval 请求状态 + ** + ******************************************************************************/ +boolean_t Spi_GetStatus(en_spi_status_t enStatus) +{ + boolean_t bFlag = FALSE; + + ASSERT(IS_VALID_STAT(enStatus)); + + switch (enStatus) + { + case SpiIf: + bFlag = M0P_SPI->STAT_f.SPIF; + break; + case SpiWcol: + bFlag = M0P_SPI->STAT_f.WCOL; + break; + case SpiSserr: + bFlag = M0P_SPI->STAT_f.SSERR; + break; + case SpiMdf: + bFlag = M0P_SPI->STAT_f.MDF; + break; + default: + break; + } + return bFlag; +} + +/** + ****************************************************************************** + ** \brief SPI 总体初始化函数 + ** + ** \param [in] + pstcSpiConfig初始化结构 + ** + ** \retval Ok初始化成功 + ** \retval ErrorInvalidParameter 初始化错误 + ******************************************************************************/ +en_result_t Spi_Init(stc_spi_config_t *pstcSpiConfig) +{ + ASSERT(NULL != pstcSpiConfig); + + M0P_SPI->CR = 0x00; + + M0P_SPI->CR_f.MSTR = pstcSpiConfig->bMasterMode; + M0P_SPI->CR_f.CPOL = pstcSpiConfig->bCPOL; + M0P_SPI->CR_f.CPHA = pstcSpiConfig->bCPHA; + if(pstcSpiConfig->u8BaudRate > SpiClkDiv16) + { + M0P_SPI->CR_f.SPR2 = 1; + } + M0P_SPI->CR |= (pstcSpiConfig->u8BaudRate&0x03u); + + M0P_SPI->STAT = 0x00; + + M0P_SPI->CR_f.SPEN = TRUE; + if (TRUE == pstcSpiConfig->bIrqEn) + { + EnableNvic(SPI_IRQn,DDL_IRQ_LEVEL_DEFAULT,TRUE); + } + else + { + EnableNvic(SPI_IRQn,DDL_IRQ_LEVEL_DEFAULT,FALSE); + } + if(NULL != pstcSpiConfig->pfnIrqCb) + { + pfnSpiCallback = pstcSpiConfig->pfnIrqCb; + } + return Ok; +} + +/** + ****************************************************************************** + ** \brief SPI 禁止函数 + ** + ** \param [in] 无 + ** + ** \retval Ok禁止设置成功 + ** + ******************************************************************************/ +en_result_t Spi_DeInit(void) +{ + M0P_SPI->DATA = 0x00; + M0P_SPI->STAT = 0x00; + M0P_SPI->CR = 0x00; + pfnSpiCallback = NULL; + EnableNvic(SPI_IRQn,DDL_IRQ_LEVEL_DEFAULT,FALSE); + return Ok; +} +/** + ****************************************************************************** + ** \brief SPI 配置主发送的电平 + ** + ** \param [in] 高低电平 + ** + ** \retval 无 + ** + ******************************************************************************/ +void Spi_SetCS(boolean_t bFlag) +{ + M0P_SPI->SSN = bFlag; +} +/** + ****************************************************************************** + ** \brief SPI 发送一字节函数 + ** + ** \param [in] 发送字节 + ** + ** \retval Ok发送成功 + ** + ******************************************************************************/ +en_result_t Spi_SendData(uint8_t u8Data) +{ + uint32_t u32TimeOut; + + u32TimeOut = 1000; + M0P_SPI->DATA = u8Data; + + while(u32TimeOut--) + { + if(TRUE == Spi_GetStatus(SpiIf)) + { + break; + } + } + if(u32TimeOut == 0) + { + return ErrorTimeout; + } + u8Data = M0P_SPI->DATA; + return Ok; +} + +/** + ****************************************************************************** + ** \brief SPI 接收一字节函数 + ** + ** \param [in] 无 + ** + ** \retval 接收一字节数据 + ** + ******************************************************************************/ +uint8_t Spi_ReceiveData(void) +{ + uint8_t temp; + uint32_t u32TimeOut; + + u32TimeOut = 1000; + + M0P_SPI->DATA = 0x00; + + while(u32TimeOut--) + { + if(TRUE == Spi_GetStatus(SpiIf)) + { + break; + } + } + if(u32TimeOut == 0) + { + return ErrorTimeout; + } + temp = M0P_SPI->DATA; + + + return temp; +} + +//@} // SpiGroup +/****************************************************************************** + * EOF (not truncated) + *****************************************************************************/ + diff --git a/project/driver/src/trim.c b/project/driver/src/trim.c new file mode 100644 index 0000000..f067128 --- /dev/null +++ b/project/driver/src/trim.c @@ -0,0 +1,352 @@ +/****************************************************************************** +*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) (RefStop == (x) ||\ + CalCntOf == (x) ||\ + XTAL32MFault == (x)) + + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ +static func_ptr_t pfnTrimCallback = NULL; + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +/** + ***************************************************************************** + ** \brief Trim中断标志获取 + ** + ** + ** \param [in] enIntType 中断类型(RefStop、CalCntOf、XTAL32MFault) + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +boolean_t Trim_GetIntFlag(en_trim_inttype_t enIntType) +{ + boolean_t bRetVal = FALSE; + + ASSERT(IS_VALID_TRIMINT(enIntType)); + + switch (enIntType) + { + case RefStop: + bRetVal = M0P_CLK_TRIM->IFR_f.STOP ? TRUE : FALSE; + break; + case CalCntOf: + bRetVal = M0P_CLK_TRIM->IFR_f.CALCNT_OF ? TRUE : FALSE; + break; + case XTAL32MFault: + bRetVal = M0P_CLK_TRIM->IFR_f.XTH_FAULT ? TRUE : FALSE; + break; + default: + bRetVal = FALSE; + break; + } + + return bRetVal; +} + +/** + ***************************************************************************** + ** \brief Trim中断标志清除 + ** + ** + ** \param [in] enIntType 中断类型(RefStop、CalCntOf、XTAL32MFault) + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Trim_ClearIntFlag(en_trim_inttype_t enIntType) +{ + en_result_t enResult = Error; + + ASSERT(IS_VALID_TRIMINT(enIntType)); + + switch (enIntType) + { + case RefStop: + M0P_CLK_TRIM->CR_f.TRIM_START = FALSE; + enResult = Ok; + break; + case CalCntOf: + M0P_CLK_TRIM->CR_f.TRIM_START = FALSE; + enResult = Ok; + break; + case XTAL32MFault: + M0P_CLK_TRIM->ICLR_f.XTH_FAULT_CLR = FALSE; + enResult = Ok; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Trim中断服务函数 + ** + ** + ** \param [in] u8Param == 0 + ** + ** \retval NULL + *****************************************************************************/ +void ClkTrim_IRQHandler(uint8_t u8Param) +{ + pfnTrimCallback(); +} + +/** + ***************************************************************************** + ** \brief Trim中断使能 + ** + ** + ** + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Trim_EnableIrq (void) +{ + en_result_t enResult = Error; + + M0P_CLK_TRIM->CR_f.IE = TRUE; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Trim中断禁止 + ** + ** + ** + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Trim_DisableIrq(void) +{ + en_result_t enResult = Error; + + M0P_CLK_TRIM->CR_f.IE = FALSE; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Trim初始化配置 + ** + ** + ** \param [in] pstcConfig Trim配置结构体指针 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Trim_Init(stc_trim_config_t* pstcConfig) +{ + en_result_t enResult = Error; + + M0P_CLK_TRIM->CR_f.MON_EN = pstcConfig->enMON; + M0P_CLK_TRIM->CR_f.CALCLK_SEL = pstcConfig->enCALCLK; + M0P_CLK_TRIM->CR_f.REFCLK_SEL = pstcConfig->enREFCLK; + + pfnTrimCallback = pstcConfig->pfnTrimCb; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Trim校准/监测启动运行 + ** + ** + ** + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Trim_Run(void) +{ + en_result_t enResult = Error; + + M0P_CLK_TRIM->CR_f.TRIM_START = TRUE; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Trim校准/监测停止 + ** + ** + ** + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Trim_Stop(void) +{ + en_result_t enResult = Error; + + M0P_CLK_TRIM->CR_f.TRIM_START = FALSE; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Trim参考计数器初值配置 + ** + ** + ** \param [in] u32Data 参考计数器初值 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Trim_RefConSet(uint32_t u32Data) +{ + en_result_t enResult = Error; + + M0P_CLK_TRIM->REFCON_f.RCNTVAL = u32Data; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Trim校准计数器初值配置 + ** + ** + ** \param [in] u32Data 校准计数器初值 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Trim_CalConSet(uint32_t u32Data) +{ + en_result_t enResult = Error; + + M0P_CLK_TRIM->CALCON_f.CCNTVAL= u32Data; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Trim参考计数器计数值获取 + ** + ** + ** + ** + ** \retval u32Data 参考计数器计数值 + *****************************************************************************/ +uint32_t Trim_RefCntGet(void) +{ + uint32_t u32Data = 0; + + u32Data = M0P_CLK_TRIM->REFCNT_f.REFCNT; + + return u32Data; +} + +/** + ***************************************************************************** + ** \brief Trim校准计数器计数值获取 + ** + ** + ** + ** + ** \retval u32Data 校准计数器计数值 + *****************************************************************************/ +uint32_t Trim_CalCntGet(void) +{ + uint32_t u32Data = 0; + + u32Data = M0P_CLK_TRIM->CALCNT_f.CALCNT; + + return u32Data; +} + +//@} // TrimGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/project/driver/src/uart.c b/project/driver/src/uart.c new file mode 100644 index 0000000..26c0705 --- /dev/null +++ b/project/driver/src/uart.c @@ -0,0 +1,741 @@ +/************************************************************************************* +* 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') */ +/******************************************************************************/ + +#define IS_VALID_CH(x) ((UARTCH0 == (x)) ||\ + (UARTCH1 == (x))) + +#define IS_VALID_IRQSEL(x) ((UartTxIrq == (x)) ||\ + (UartRxIrq == (x))) + +#define IS_VALID_MODE(x) ((UartMode0==(x))||\ + (UartMode1==(x))||\ + (UartMode2==(x))||\ + (UartMode3==(x))) + +#define IS_VALID_STATUS(x) ((UartRFRAMEError == (x))||\ + (UartRxFull == (x))||\ + (UartTxEmpty == (x))) +/******************************************************************************/ +/* Local function prototypes ('static') */ +/******************************************************************************/ +static stc_uart_instance_data_t* UartGetInternDataPtr(uint8_t u8Idx); +static void UartInitNvic(uint8_t u8Idx); +static void UartDeInitNvic(uint8_t u8Idx); +/******************************************************************************/ +/* Local variable definitions ('static') */ +/******************************************************************************/ +static stc_uart_instance_data_t m_astcUartInstanceDataLut[] = +{ + { + UARTCH0, + M0P_UART0, /* pstcInstance */ + {NULL,NULL,NULL}, + }, + { + UARTCH1, + M0P_UART1, /* pstcInstance */ + {NULL,NULL,NULL}, + }, +}; +/** + ****************************************************************************** + ** \brief UART0/1通道 相关地址获取 + ** + ** \param [in] u8Idx通道号 + ** + ** \retval 通道对应的地址结构 + ** + ******************************************************************************/ +static stc_uart_instance_data_t* UartGetInternDataPtr(uint8_t u8Idx) +{ + stc_uart_instance_data_t* pstcData = NULL; + uint8_t u8i = 0; + for (u8i = 0; u8i < ARRAY_SZ(m_astcUartInstanceDataLut); u8i++) + { + if (u8Idx == m_astcUartInstanceDataLut[u8i].u32Idx) + { + pstcData = &m_astcUartInstanceDataLut[u8i]; + break; + } + } + + return (pstcData); +} +/** + ****************************************************************************** + ** \brief UART通信中断使能函数设置 + ** + ** \param [in] u8Idx通道号,enIrqSel发送or接收中断使能 + ** + ** \retval OK配置成功 + **\retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_EnableIrq(uint8_t u8Idx, + en_uart_irq_sel_t enIrqSel) +{ + stc_uart_instance_data_t* pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + ASSERT(IS_VALID_IRQSEL(enIrqSel)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + switch(enIrqSel) + { + case UartTxIrq: + pstcData->pstcInstance->SCON_f.TIEN = 1u; + break; + case UartRxIrq: + pstcData->pstcInstance->SCON_f.RIEN = 1u; + break; + default: + return (ErrorInvalidParameter); + } + return Ok; +} +/** + ****************************************************************************** + ** \brief UART通信中断禁止函数设置 + ** + ** \param [in] u8Idx通道号,enIrqSel发送or接收中断禁止 + ** + ** \retval OK配置成功 + **\retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_DisableIrq(uint8_t u8Idx, + en_uart_irq_sel_t enIrqSel) +{ + stc_uart_instance_data_t *pstcData = NULL; + + ASSERT(IS_VALID_CH(u8Idx)); + ASSERT(IS_VALID_IRQSEL(enIrqSel)); + + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + switch(enIrqSel) + { + case UartTxIrq: + pstcData->pstcInstance->SCON_f.TIEN = 0u; + break; + case UartRxIrq: + pstcData->pstcInstance->SCON_f.RIEN = 0u; + break; + default: + return (ErrorInvalidParameter); + } + + return Ok; +} +/** + ****************************************************************************** + ** \brief UART通道4种模式配置 + ** + ** \param [in] u8Idx通道号,mode哪种模式 + ** + ** \retval OK配置成功 + **\retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_SetMode(uint8_t u8Idx,en_uart_mode_t enMode) +{ + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + ASSERT(IS_VALID_MODE(enMode)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + pstcData->pstcInstance->SCON_f.SM01 = enMode; + return Ok; +} +/** + ****************************************************************************** + ** \brief UART通道多主机模式配置 + ** + ** \param [in] u8Idx通道号,stcMultiConfig多主机模式结构 + ** + ** \retval OK配置成功 + **\retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_SetMultiMode(uint8_t u8Idx,stc_uart_multimode_t* pstcMultiConfig) +{ + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + if(NULL != pstcMultiConfig) + { + pstcData->pstcInstance->SCON_f.SM2 = pstcMultiConfig->enMulti_mode; + if(pstcMultiConfig->enMulti_mode == UartMulti) + { + pstcData->pstcInstance->SADDR = pstcMultiConfig->u8SlaveAddr; + pstcData->pstcInstance->SADEN = pstcMultiConfig->u8SaddEn; + } + } + return Ok; +} +/** + ****************************************************************************** + ** \brief UART通道多主机模式发送数据/地址帧或者奇偶校验配置TB8 + ** + ** \param [in] u8Idx通道号,tb8数据or地址帧或者奇偶校验 + ** + ** \retval OK配置成功 + **\retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_SetMMDOrCk(uint8_t u8Idx,en_uart_mmdorck_t enTb8) +{ + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + pstcData->pstcInstance->SCON_f.TB8 = enTb8; + return Ok; +} +/** + ****************************************************************************** + ** \brief 获取RB8数值 + ** + ** \param [in] u8Idx通道号 + ** + ** \retval RB8 + **\retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +boolean_t Uart_GetRb8(uint8_t u8Idx) +{ + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + return (pstcData->pstcInstance->SCON_f.RB8); +} +/** + ****************************************************************************** + ** \brief 计算字节数据1的个数 + ** + ** \param u8Data计算数据 + ** + ** \retval 个数 + ******************************************************************************/ +en_result_t Uart_SetTb8(uint8_t u8Idx,en_uart_check_t enCheck,uint8_t u8Data) +{ + uint8_t cnt=0,i; + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + for(i=0;i<8;i++) + { + if((u8Data&0x80)==0x80) + { + cnt++; + } + u8Data<<=1; + } + if(enCheck == Even) + { + if(cnt%2!=0) + { + pstcData->pstcInstance->SCON_f.TB8 = 1; + } + else + { + pstcData->pstcInstance->SCON_f.TB8 = 0; + } + } + else + { + if(cnt%2!=0) + { + pstcData->pstcInstance->SCON_f.TB8 = 0; + } + else + { + pstcData->pstcInstance->SCON_f.TB8 = 1; + } + } + return Ok; +} +/** + ****************************************************************************** + ** \brief 计算接收字节奇偶校验是否正确 + ** + ** \param u8Idx通道,enCheck奇偶校验方式,u8Recv校验数据 + ** + ** \retval Error或者成功Ok + ******************************************************************************/ +en_result_t Uart_CheckEvenOrOdd(uint8_t u8Idx,en_uart_check_t enCheck,uint8_t u8Recv) +{ + uint8_t cnt=0,i; + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + for(i=0;i<8;i++) + { + if((u8Recv&0x80)==0x80) + { + cnt++; + } + u8Recv<<=1; + } + if(enCheck == Even) + { + if(cnt%2!=0) + { + if(pstcData->pstcInstance->SCON_f.RB8 != 1) + { + return Error; + } + } + else + { + if(pstcData->pstcInstance->SCON_f.RB8 != 0) + { + return Error; + } + } + } + else + { + if(cnt%2!=0) + { + if(pstcData->pstcInstance->SCON_f.RB8 != 0) + { + return Error; + } + } + else + { + if(pstcData->pstcInstance->SCON_f.RB8 != 1) + { + return Error; + } + } + } + return Ok; +} +/** + ****************************************************************************** + ** \brief UART通道多主机模式从机地址配置函数 + ** + ** \param [in] u8Idx通道号,addr地址 + ** + ** \retval OK配置成功 + **\retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_SetSaddr(uint8_t u8Idx,uint8_t u8Addr) +{ + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + pstcData->pstcInstance->SADDR = u8Addr; + return Ok; +} +/** + ****************************************************************************** + ** \brief UART通道多主机模式从机掩码配置函数 + ** + ** \param [in] u8Idx通道号,addren地址掩码 + ** + ** \retval OK配置成功 + **\retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_SetSaddrEn(uint8_t u8Idx,uint8_t u8Addren) +{ + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + pstcData->pstcInstance->SADEN = u8Addren; + return Ok; +} +/** + ****************************************************************************** + ** \brief UART通道波特率配置 + ** + ** \param [in] u8Idx通道号,u32pclk时钟源,stcBaud波特率配置结构 + ** + ** \retval 定时器配置值 + ** \retval 0,获取值失败 + ******************************************************************************/ +uint16_t Uart_SetBaudRate(uint8_t u8Idx,uint32_t u32pclk,stc_uart_baud_config_t* pstcBaud) +{ + uint16_t u16tmload=0; + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + pstcData = UartGetInternDataPtr(u8Idx); + if ((NULL == pstcData)||(NULL == pstcBaud)) + { + return 0;//test + } + pstcData->pstcInstance->SCON_f.DBAUD = pstcBaud->bDbaud; + switch(pstcBaud->u8Mode) + { + case UartMode0: + case UartMode2: + break; + case UartMode1: + case UartMode3: + u16tmload = 0x10000-((u32pclk*(pstcBaud->bDbaud+1))/(pstcBaud->u32Baud*32));//单双倍波特率,定时器配置 + break; + default: + break; + } + return u16tmload; +} +/** + ****************************************************************************** + ** \brief UART通道发送或接收使能设置 + ** + ** \param [in] u8Idx通道号,enFunc发送或接收 + ** + ** \retval OK配置成功 + **\retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_EnableFunc(uint8_t u8Idx, en_uart_func_t enFunc) +{ + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + pstcData->pstcInstance->SCON_f.REN = enFunc; + return Ok; +} +/** + ****************************************************************************** + ** \brief UART通道通信状态获取 + ** + ** \param [in] u8Idx通道号,enStatus获取哪个状态 + ** + ** \retval 状态值 + **\retval ErrorInvalidParameter获取失败 + ******************************************************************************/ +boolean_t Uart_GetStatus(uint8_t u8Idx,en_uart_status_t enStatus) +{ + boolean_t bStatus=FALSE; + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + ASSERT(IS_VALID_STATUS(enStatus)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter;//4,用户只需判断0或1 + } + switch(enStatus) + { + case UartRFRAMEError: + bStatus = (pstcData->pstcInstance->ISR_f.FE == 1) ? TRUE : FALSE; + break; + case UartRxFull: + bStatus = (pstcData->pstcInstance->ISR_f.RI == 1) ? TRUE : FALSE; + break; + case UartTxEmpty: + bStatus = (pstcData->pstcInstance->ISR_f.TI == 1) ? TRUE : FALSE; + break; + default: + break; + } + return bStatus; +} +/** + ****************************************************************************** + ** \brief UART通道通信状态清除 + ** + ** \param [in] u8Idx通道号,enStatus清除哪个状态 + ** + ** \retval 状态值 + **\retval ErrorInvalidParameter清除失败 + ******************************************************************************/ +en_result_t Uart_ClrStatus(uint8_t u8Idx,en_uart_status_t enStatus) +{ + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + ASSERT(IS_VALID_STATUS(enStatus)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + switch(enStatus) + { + case UartRFRAMEError: + pstcData->pstcInstance->ICR_f.FECLR = 0; + break; + case UartRxFull: + pstcData->pstcInstance->ICR_f.RICLR = 0; + break; + case UartTxEmpty: + pstcData->pstcInstance->ICR_f.TICLR = 0; + break; + default: + return ErrorInvalidParameter; + } + return Ok; +} +/** + ****************************************************************************** + ** \brief UART通道发送数据函数,查询方式调用此函数,中断方式发送不适用 + ** + ** \param [in] u8Idx通道号,Data发送数据 + ** + ** \retval Ok发送成功 + **\retval ErrorInvalidParameter发送失败 + ******************************************************************************/ +en_result_t Uart_SendData(uint8_t u8Idx, uint8_t u8Data) +{ + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + Uart_ClrStatus(u8Idx,UartTxEmpty); + pstcData->pstcInstance->SBUF =u8Data; + while(FALSE == Uart_GetStatus(u8Idx,UartTxEmpty)) + {} + Uart_ClrStatus(u8Idx,UartTxEmpty); + return Ok; +} +/** + ****************************************************************************** + ** \brief UART通道接收数据函数 + ** + ** \param [in] u8Idx通道号 + ** + ** \retval 接收数据 + **\retval ErrorInvalidParameter接收失败 + ******************************************************************************/ +uint8_t Uart_ReceiveData(uint8_t u8Idx) +{ + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + return (pstcData->pstcInstance->SBUF); +} +/** + ****************************************************************************** + ** \brief UART通道中断处理函数 + ** + ** \param [in] u8Param通道号 + ** + ** \retval 无 + ** + ******************************************************************************/ +void Uart_IRQHandler(uint8_t u8Param) +{ + stc_uart_instance_data_t *pstcData = NULL; + pstcData = UartGetInternDataPtr(u8Param); + if (NULL == pstcData) + { + return; + } + if(1 == pstcData->pstcInstance->ISR_f.FE) + { + Uart_ClrStatus(u8Param,UartRFRAMEError); + if(NULL != pstcData->stcUartInternIrqCb.pfnRxErrIrqCb) + { + pstcData->stcUartInternIrqCb.pfnRxErrIrqCb(); + } + return;//若奇偶校验出错则不进行后续数据处理 + } + if(1 == pstcData->pstcInstance->ISR_f.RI) + { + Uart_ClrStatus(u8Param,UartRxFull); + if(NULL != pstcData->stcUartInternIrqCb.pfnRxIrqCb) + { + pstcData->stcUartInternIrqCb.pfnRxIrqCb(); + } + } + if(1 == pstcData->pstcInstance->ISR_f.TI) + { + Uart_ClrStatus(u8Param,UartTxEmpty); + if(NULL != pstcData->stcUartInternIrqCb.pfnTxIrqCb) + { + pstcData->stcUartInternIrqCb.pfnTxIrqCb(); + } + } +} +/** + ****************************************************************************** + ** \brief UART通道使能内核NVIC中断 + ** + ** \param [in] u8Idx通道号 + ** + ** \retval 无 + ** + ******************************************************************************/ +static void UartInitNvic(uint8_t u8Idx) +{ + IRQn_Type enIrqIndex; + + ASSERT(IS_VALID_CH(u8Idx));; + enIrqIndex = (IRQn_Type)(UART0_IRQn + u8Idx); + NVIC_ClearPendingIRQ(enIrqIndex); + NVIC_SetPriority(enIrqIndex,DDL_IRQ_LEVEL_DEFAULT); + NVIC_EnableIRQ(enIrqIndex); + +} +/** + ****************************************************************************** + ** \brief UART通道禁止内核NVIC中断 + ** + ** \param [in] u8Idx通道号 + ** + ** \retval 无 + ** + ******************************************************************************/ +static void UartDeInitNvic(uint8_t u8Idx) +{ + IRQn_Type enIrqIndex; + + ASSERT(IS_VALID_CH(u8Idx)); + enIrqIndex = (IRQn_Type)(UART0_IRQn + u8Idx); + NVIC_ClearPendingIRQ(enIrqIndex); + NVIC_SetPriority(enIrqIndex,DDL_IRQ_LEVEL_DEFAULT); + NVIC_DisableIRQ(enIrqIndex); + +} +/** + ****************************************************************************** + ** \brief UART通道初始化函数 + ** + ** \param [in] u8Idx通道号,pstcConfig初始化结构体 + ** + ** \retval OK配置成功 + **\retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_Init(uint8_t u8Idx, + stc_uart_config_t* pstcConfig) +{ + en_result_t enRet = Error; + stc_uart_instance_data_t *pstcData = NULL; + ASSERT(IS_VALID_CH(u8Idx)); + pstcData = UartGetInternDataPtr(u8Idx); + if (NULL == pstcData) + { + return ErrorInvalidParameter; + } + if(NULL == pstcConfig) + { + return ErrorInvalidParameter; + } + enRet = Uart_SetMode(u8Idx,pstcConfig->enRunMode); + + if(NULL != pstcConfig->pstcMultiMode) + { + enRet = Uart_SetMultiMode(u8Idx,pstcConfig->pstcMultiMode); + } + if(NULL != pstcConfig->pstcIrqCb) + { + pstcData->stcUartInternIrqCb.pfnRxErrIrqCb = pstcConfig->pstcIrqCb->pfnRxErrIrqCb; + pstcData->stcUartInternIrqCb.pfnRxIrqCb = pstcConfig->pstcIrqCb->pfnRxIrqCb; + pstcData->stcUartInternIrqCb.pfnTxIrqCb = pstcConfig->pstcIrqCb->pfnTxIrqCb; + } + if(pstcConfig->bTouchNvic == TRUE) + { + UartInitNvic(u8Idx); + } + else + { + UartDeInitNvic(u8Idx); + } + enRet = Ok; + return enRet; +} +//@} // UartGroup diff --git a/project/driver/src/vc.c b/project/driver/src/vc.c new file mode 100644 index 0000000..b820f2a --- /dev/null +++ b/project/driver/src/vc.c @@ -0,0 +1,683 @@ +/****************************************************************************** +* 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 vc.c + ** + ** voltage comparator driver API. + ** @link VC Group Some description @endlink + ** + ** - 2017-06-28 Alex First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "vc.h" + +/** + ****************************************************************************** + ** \addtogroup VcGroup + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define IS_VALID_CHANNEL(x) ( VcChannel0==(x) || VcChannel1 == (x)) +#define IS_VALID_STAT(x) ( VcCmpResult==(x) || VcIntrResult == (x)) +#define IS_VALID_DIV(x) ( (x) <= 64u ) + +#define IS_VALID_INPUT_P(x) ( (x) <= VcInPCh7 ) + +#define IS_VALID_INPUT_N(x) ( (x) <= AiLdo ) + +#define IS_VALID_DLY(x) ( (VcDelay30mv == (x)) ||\ + (VcDelay20mv == (x)) ||\ + (VcDelay10mv == (x)) ||\ + (VcDelayoff == (x)) ) + +#define IS_VALID_BIAS(x) ( (VcBias300na == (x)) ||\ + (VcBias1200na == (x)) ||\ + (VcBias10ua == (x)) ||\ + (VcBias20ua == (x)) ) + +#define IS_VALID_FILTER(x) ( (x) <= VcFilter28800us ) + + + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ +static en_result_t VcEnableIrq(en_vc_channel_t enChannel, boolean_t bFlag); +static void VcEnableNvic(IRQn_Type enIrqn); +static void VcDisableNvic(IRQn_Type enIrqn); + +/****************************************************************************** + * Local variable definitions ('static') + ******************************************************************************/ +static func_ptr_t pfnVc0IrqCb = NULL; +static func_ptr_t pfnVc1IrqCb = NULL; + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + *****************************************************************************/ + +/** + * \brief + * 指定VC通道中断使能/除能 + * + * \param [in] enChannel VC通道号 + * \param [in] bFlag 使能/除能标志 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +static en_result_t VcEnableIrq(en_vc_channel_t enChannel, boolean_t bFlag) +{ + if (VcChannel0 == enChannel) + { + if (bFlag) + { + VcEnableNvic(VC0_IRQn); + M0P_VC->VC0_CR_f.IE = 1u; + } + else + { + M0P_VC->VC0_CR_f.IE = 0u; + VcDisableNvic(VC0_IRQn); + } + } + else if (VcChannel1 == enChannel) + { + if (bFlag) + { + VcEnableNvic(VC1_IRQn); + M0P_VC->VC1_CR_f.IE = 1u; + } + else + { + M0P_VC->VC1_CR_f.IE = 0u; + VcDisableNvic(VC1_IRQn); + } + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + * \brief + * 使能NVIC中VC中断 + * + * \param [in] enIrqn 中断号 + * + * \retval 无 + */ +static void VcEnableNvic(IRQn_Type enIrqn) +{ + NVIC_ClearPendingIRQ(enIrqn); + NVIC_EnableIRQ(enIrqn); + NVIC_SetPriority(enIrqn, DDL_IRQ_LEVEL_DEFAULT); +} + +/** + * \brief + * 除能NVIC中VC中断 + * + * \param [in] enIrqn 中断号 + * + * \retval 无 + */ +static void VcDisableNvic(IRQn_Type enIrqn) +{ + NVIC_ClearPendingIRQ(enIrqn); + NVIC_DisableIRQ(enIrqn); + NVIC_SetPriority(enIrqn, DDL_IRQ_LEVEL_DEFAULT); +} + +/** + * \brief + * VC中断服务程序 + * + * \param [in] u8Param VC通道号 + * + * \retval 无 + */ +void Vc_IRQHandler(uint8_t u8Param) +{ + if (0 == u8Param) + { + if (TRUE == M0P_VC->IFR_f.VC0_INTF) + { + if (NULL != pfnVc0IrqCb) + { + pfnVc0IrqCb(); + } + M0P_VC->IFR_f.VC0_INTF = 0; + } + } + else if (1 == u8Param) + { + if (TRUE == M0P_VC->IFR_f.VC1_INTF) + { + if (NULL != pfnVc1IrqCb) + { + pfnVc1IrqCb(); + } + M0P_VC->IFR_f.VC1_INTF = 0; + } + } + else + { + ; // just return + } +} + +/** + * \brief + * 配置VC中断触发方式 + * + * \param [in] enChannel VC通道号 + * \param [in] enSel 中断触发方式选择 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Vc_ConfigIrq(en_vc_channel_t enChannel, en_vc_irq_sel_t enSel) +{ + stc_vc_vc0_cr_field_t *stcVcnCr; + en_result_t enRet = Ok; + + if (VcChannel0 == enChannel) + { + stcVcnCr = (stc_vc_vc0_cr_field_t*)&M0P_VC->VC0_CR_f; + } + else if (VcChannel1 == enChannel) + { + stcVcnCr = (stc_vc_vc0_cr_field_t*)&M0P_VC->VC1_CR_f; + } + else + { + return ErrorInvalidParameter; + } + + switch (enSel) + { + case VcIrqRise: + stcVcnCr->RISING = 1u; + break; + case VcIrqFall: + stcVcnCr->FALLING = 1u; + break; + case VcIrqHigh: + stcVcnCr->LEVEL = 1u; + break; + + default: + enRet= ErrorInvalidParameter; + break; + } + + return enRet; +} + +/** + * \brief + * 获取VC状态 + * + * \param [in] enChannel VC通道号 + * \param [in] enStat VC状态类型 + * + * \retval boolean_t TRUE: 状态为高 + * \retval boolean_t FALSE: 状态为低 + */ +boolean_t Vc_GetStat(en_vc_channel_t enChannel, en_vc_stat_t enStat) +{ + boolean_t bFlag = FALSE; + + ASSERT( IS_VALID_CHANNEL(enChannel) ); + ASSERT( IS_VALID_STAT(enStat) ); + + if (VcChannel0 == enChannel) + { + switch (enStat) + { + case VcCmpResult: + bFlag = M0P_VC->IFR_f.VC0_FILTER; + break; + case VcIntrResult: + bFlag = M0P_VC->IFR_f.VC0_INTF; + break; + default: + break; + } + } + else + { + switch (enStat) + { + case VcCmpResult: + bFlag = M0P_VC->IFR_f.VC1_FILTER; + break; + case VcIntrResult: + bFlag = M0P_VC->IFR_f.VC1_INTF; + break; + default: + break; + } + } + + return bFlag; +} + +/** + * \brief + * 清除VC中断标志 + * + * \param [in] enChannel VC通道号 + * + * \retval 无 + */ +void Vc_ClearIrq(en_vc_channel_t enChannel) +{ + ASSERT( IS_VALID_CHANNEL(enChannel) ); + + if (VcChannel0 == enChannel) + { + M0P_VC->IFR_f.VC0_INTF = 0u; + } + else + { + M0P_VC->IFR_f.VC1_INTF = 0u; + } +} + +/** + * \brief + * 指定VC通道中断使能 + * + * \param [in] enChannel VC通道号 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Vc_EnableIrq(en_vc_channel_t enChannel) +{ + return VcEnableIrq(enChannel, TRUE); +} + +/** + * \brief + * 指定VC通道中断除能 + * + * \param [in] enChannel VC通道号 + * + * \retval en_result_t Ok: 设置成功 + * ErrorInvalidParameter: 无效参数 + */ +en_result_t Vc_DisableIrq(en_vc_channel_t enChannel) +{ + return VcEnableIrq(enChannel, FALSE); +} + +/** + * \brief + * VC模块初始化 + * + * \param [in] pstcGeneralConfig VC模块配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Vc_GeneralInit(stc_vc_general_config_t *pstcGeneralConfig) +{ + ASSERT(NULL != pstcGeneralConfig); + + M0P_VC->CR_f.DIV_EN = pstcGeneralConfig->bDivEn; + M0P_VC->CR_f.REF2P5_SEL = pstcGeneralConfig->enDivVref; + + if (pstcGeneralConfig->u8DivVal < 0x40) + { + M0P_VC->CR_f.DIV = pstcGeneralConfig->u8DivVal; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + * \brief + * VC模块deinit + * + * \param 无 + * + * \retval 无 + */ +void Vc_GeneralDeInit(void) +{ + M0P_VC->CR_f.DIV_EN = 0u; + M0P_VC->CR_f.DIV = 0x20u; + M0P_VC->CR_f.REF2P5_SEL = 0u; +} + +/** + * \brief + * VC通道初始化 + * + * \param [in] enChannel VC通道号 + * \param [in] pstcChannelConfig VC通道配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Vc_ChannelInit(en_vc_channel_t enChannel, + stc_vc_channel_config_t *pstcChannelConfig) +{ + //en_result_t enRet = Ok; + + ASSERT(NULL != pstcChannelConfig); + ASSERT(IS_VALID_INPUT_P(pstcChannelConfig->enVcInPin_P)); + ASSERT(IS_VALID_INPUT_N(pstcChannelConfig->enVcInPin_N)); + ASSERT(IS_VALID_DLY(pstcChannelConfig->enVcCmpDly)); + ASSERT(IS_VALID_BIAS(pstcChannelConfig->enVcBiasCurrent)); + ASSERT(IS_VALID_FILTER(pstcChannelConfig->enVcFilterTime)); + + if (VcChannel0 == enChannel) + { + M0P_VC->CR_f.VC0_HYS_SEL = pstcChannelConfig->enVcCmpDly; + M0P_VC->CR_f.VC0_BIAS_SEL = pstcChannelConfig->enVcBiasCurrent; + M0P_VC->VC0_CR_f.DEBOUNCE_TIME = pstcChannelConfig->enVcFilterTime; + M0P_VC->VC0_CR_f.P_SEL = pstcChannelConfig->enVcInPin_P; + M0P_VC->VC0_CR_f.N_SEL = pstcChannelConfig->enVcInPin_N; + M0P_VC->VC0_OUT_CFG = 1<enVcOutConfig; + + switch(pstcChannelConfig->enVcIrqSel) + { + case VcIrqRise: + M0P_VC->VC0_CR_f.LEVEL = 0u; + M0P_VC->VC0_CR_f.RISING = 1u; + M0P_VC->VC0_CR_f.FALLING = 0u; + break; + case VcIrqFall: + M0P_VC->VC0_CR_f.LEVEL = 0u; + M0P_VC->VC0_CR_f.RISING = 0u; + M0P_VC->VC0_CR_f.FALLING = 1u; + break; + case VcIrqHigh: + M0P_VC->VC0_CR_f.LEVEL = 1u; + M0P_VC->VC0_CR_f.RISING = 0u; + M0P_VC->VC0_CR_f.FALLING = 0u; + break; + default: + M0P_VC->VC0_CR_f.LEVEL = 0u; + M0P_VC->VC0_CR_f.RISING = 0u; + M0P_VC->VC0_CR_f.FALLING = 0u; + break; + } + + pfnVc0IrqCb = pstcChannelConfig->pfnAnalogCmpCb; + } + else if (VcChannel1 == enChannel) + { + M0P_VC->CR_f.VC1_HYS_SEL = pstcChannelConfig->enVcCmpDly; + M0P_VC->CR_f.VC1_BIAS_SEL = pstcChannelConfig->enVcBiasCurrent; + M0P_VC->VC1_CR_f.DEBOUNCE_TIME = pstcChannelConfig->enVcFilterTime; + M0P_VC->VC1_CR_f.P_SEL = pstcChannelConfig->enVcInPin_P; + M0P_VC->VC1_CR_f.N_SEL = pstcChannelConfig->enVcInPin_N; + M0P_VC->VC1_OUT_CFG = 1<enVcOutConfig; + + switch(pstcChannelConfig->enVcIrqSel) + { + case VcIrqRise: + M0P_VC->VC1_CR_f.LEVEL = 0u; + M0P_VC->VC1_CR_f.RISING = 1u; + M0P_VC->VC1_CR_f.FALLING = 0u; + break; + case VcIrqFall: + M0P_VC->VC1_CR_f.LEVEL = 0u; + M0P_VC->VC1_CR_f.RISING = 0u; + M0P_VC->VC1_CR_f.FALLING = 1u; + break; + case VcIrqHigh: + M0P_VC->VC1_CR_f.LEVEL = 1u; + M0P_VC->VC1_CR_f.RISING = 0u; + M0P_VC->VC1_CR_f.FALLING = 0u; + break; + default: + M0P_VC->VC1_CR_f.LEVEL = 0u; + M0P_VC->VC1_CR_f.RISING = 0u; + M0P_VC->VC1_CR_f.FALLING = 0u; + break; + } + + pfnVc1IrqCb = pstcChannelConfig->pfnAnalogCmpCb; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + * \brief + * VC通道Deinit + * + * \param [in] enChannel VC通道号 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Vc_ChannelDeInit(en_vc_channel_t enChannel) +{ + if (VcChannel0 == enChannel) + { + M0P_VC->VC0_CR_f.EN = 0u; + M0P_VC->CR_f.VC0_HYS_SEL = 0; + M0P_VC->CR_f.VC0_BIAS_SEL = 0; + M0P_VC->VC0_CR_f.DEBOUNCE_TIME = 0; + M0P_VC->VC0_CR_f.P_SEL = 0; + M0P_VC->VC0_CR_f.N_SEL = 0; + M0P_VC->VC0_OUT_CFG = 0; + M0P_VC->VC0_CR_f.LEVEL = 0u; + M0P_VC->VC0_CR_f.RISING = 0u; + M0P_VC->VC0_CR_f.FALLING = 0u; + pfnVc0IrqCb = NULL; + M0P_VC->VC0_CR_f.IE = 0u; + VcDisableNvic(VC0_IRQn); + } + else if (VcChannel1 == enChannel) + { + M0P_VC->VC1_CR_f.EN = 0u; + M0P_VC->CR_f.VC1_HYS_SEL = 0; + M0P_VC->CR_f.VC1_BIAS_SEL = 0; + M0P_VC->VC1_CR_f.DEBOUNCE_TIME = 0; + M0P_VC->VC1_CR_f.P_SEL = 0; + M0P_VC->VC1_CR_f.N_SEL = 0; + M0P_VC->VC1_OUT_CFG = 0; + M0P_VC->VC1_CR_f.LEVEL = 0u; + M0P_VC->VC1_CR_f.RISING = 0u; + M0P_VC->VC1_CR_f.FALLING = 0u; + pfnVc1IrqCb = NULL; + M0P_VC->VC1_CR_f.IE = 0u; + VcDisableNvic(VC1_IRQn); + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + * \brief + * VC通道使能 + * + * \param [in] enChannel VC通道号 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Vc_EnableChannel(en_vc_channel_t enChannel) +{ + if (VcChannel0 == enChannel) + { + M0P_VC->VC0_CR_f.EN = 1u; + } + else if (VcChannel1 == enChannel) + { + M0P_VC->VC1_CR_f.EN = 1u; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + * \brief + * VC通道除能 + * + * \param [in] enChannel VC通道号 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Vc_DisableChannel(en_vc_channel_t enChannel) +{ + if (VcChannel0 == enChannel) + { + M0P_VC->VC0_CR_f.EN = 0u; + } + else if (VcChannel1 == enChannel) + { + M0P_VC->VC1_CR_f.EN = 0u; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + * \brief + * VC输出滤波使能 + * + * \param [in] enChannel VC通道号 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Vc_EnableFilter(en_vc_channel_t enChannel) +{ + if (VcChannel0 == enChannel) + { + M0P_VC->VC0_CR_f.FLTEN = 1u; + } + else if (VcChannel1 == enChannel) + { + M0P_VC->VC1_CR_f.FLTEN = 1u; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + * \brief + * VC输出滤波除能 + * + * \param [in] enChannel VC通道号 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + */ +en_result_t Vc_DisableFilter(en_vc_channel_t enChannel) +{ + if (VcChannel0 == enChannel) + { + M0P_VC->VC0_CR_f.FLTEN = 0u; + } + else if (VcChannel1 == enChannel) + { + M0P_VC->VC1_CR_f.FLTEN = 0u; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +//@} // VcGroup + + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/project/driver/src/wdt.c b/project/driver/src/wdt.c new file mode 100644 index 0000000..17c9e86 --- /dev/null +++ b/project/driver/src/wdt.c @@ -0,0 +1,187 @@ +/************************************************************************************* +* 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') */ +/******************************************************************************/ +static func_ptr_t pfnWdtCallback; +/** + ****************************************************************************** + ** \brief WDT溢出时间设置函数 + ** + ** \param [in] u8LoadValue 溢出时间 + ** + ** \retval 无 + ** + ******************************************************************************/ +void Wdt_WriteWdtLoad(uint8_t u8LoadValue) +{ + M0P_WDT->CON_f.WOV = u8LoadValue; +} +/** + ****************************************************************************** + ** \brief WDT初始化函数 + ** + ** \param [in] stcConfig 初始化结构 + ** + ** \retval Ok + ** + ******************************************************************************/ +en_result_t Wdt_Init(stc_wdt_config_t* pstcConfig) +{ + en_result_t enRet = Error; + ASSERT(NULL != pstcConfig); + Wdt_WriteWdtLoad(pstcConfig->u8LoadValue); + if(NULL != pstcConfig->pfnWdtIrqCb) + { + pfnWdtCallback = pstcConfig->pfnWdtIrqCb; + } + M0P_WDT->CON_f.WINT_EN = pstcConfig->enResetEnable; + if(pstcConfig->enResetEnable) + { + EnableNvic(WDT_IRQn,DDL_IRQ_LEVEL_DEFAULT,TRUE); + } + enRet = Ok; + return enRet; +} +/** + ****************************************************************************** + ** \brief WDT复位及启动函数 + ** + ** \param [in] 无 + ** + ** \retval Ok + ** + ******************************************************************************/ +en_result_t Wdt_Start(void) +{ + en_result_t enRet = Error; + M0P_WDT->RST = 0x1E; + M0P_WDT->RST = 0xE1; + enRet = Ok; + return enRet; +} +/** + ****************************************************************************** + ** \brief WDT复位及启动函数 + ** + ** \param [in] 无 + ** + ** \retval Ok + ** + ******************************************************************************/ +void Wdt_Feed(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 状态值 + ** + ******************************************************************************/ +uint8_t Wdt_ReadwdtStatus(void) +{ + return M0P_WDT->CON_f.WDTR; +} +/** + ****************************************************************************** + ** \brief WDT中断处理函数 + ** + ** \param [in] 无 + ** + ** \retval 无 + ** + ******************************************************************************/ +void Wdt_IRQHandler(void) +{ + if(M0P_WDT->CON_f.WDINT) + { + Wdt_Start();//clr wdt 标记 + if(NULL != pfnWdtCallback) + { + pfnWdtCallback(); + } + } +} + +//@} // WdtGroup diff --git a/project/handler/EWARM/flashloader/FlashHC32F003.flash b/project/handler/EWARM/flashloader/FlashHC32F003.flash new file mode 100644 index 0000000..86ff3e5 --- /dev/null +++ b/project/handler/EWARM/flashloader/FlashHC32F003.flash @@ -0,0 +1,10 @@ + + + + $PROJ_DIR$\..\..\MCU\EWARM\config\flashloader\FlashHC32F003.out + 1 + 32 0x200 + 0x00000000 + $PROJ_DIR$\..\..\MCU\EWARM\config\flashloader\FlashHC32F003.mac + 0 + diff --git a/project/handler/EWARM/flashloader/HC32F003.board b/project/handler/EWARM/flashloader/HC32F003.board new file mode 100644 index 0000000..6bb9e52 --- /dev/null +++ b/project/handler/EWARM/flashloader/HC32F003.board @@ -0,0 +1,8 @@ + + + + + $PROJ_DIR$\flashloader\FlashHC32F003.flash + CODE 0x0 0x3FFF + + diff --git a/project/handler/EWARM/hc32f003.icf b/project/handler/EWARM/hc32f003.icf new file mode 100644 index 0000000..d25e614 --- /dev/null +++ b/project/handler/EWARM/hc32f003.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__ = 0x0; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_ROM_start__ = 0x00000000; +define symbol __ICFEDIT_region_ROM_end__ = 0x00003FFF; +define symbol __ICFEDIT_region_RAM_start__ = 0x20000000; +define symbol __ICFEDIT_region_RAM_end__ = 0x200007FF; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x100; +define symbol __ICFEDIT_size_heap__ = 0x0; +/**** 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/project/handler/EWARM/startup_hc32f003.s b/project/handler/EWARM/startup_hc32f003.s new file mode 100644 index 0000000..d64c4d4 --- /dev/null +++ b/project/handler/EWARM/startup_hc32f003.s @@ -0,0 +1,353 @@ +;******************************************************************************* +; 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. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2017-04-29 */ +;/* Target-mcu M0+ Device */ +;/*****************************************************************************/ + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + + SECTION .intvec:CODE:ROOT(8) + DATA +__vector_table DCD sfe(CSTACK) + DCD Reset_Handler + 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 ; Debug Monitor + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + DCD IRQ000_Handler + DCD IRQ001_Handler + DCD IRQ002_Handler + DCD IRQ003_Handler + DCD IRQ004_Handler + DCD IRQ005_Handler + DCD IRQ006_Handler + DCD IRQ007_Handler + DCD IRQ008_Handler + DCD IRQ009_Handler + DCD IRQ010_Handler + DCD IRQ011_Handler + DCD IRQ012_Handler + DCD IRQ013_Handler + DCD IRQ014_Handler + DCD IRQ015_Handler + DCD IRQ016_Handler + DCD IRQ017_Handler + DCD IRQ018_Handler + DCD IRQ019_Handler + DCD IRQ020_Handler + DCD IRQ021_Handler + DCD IRQ022_Handler + DCD IRQ023_Handler + DCD IRQ024_Handler + DCD IRQ025_Handler + DCD IRQ026_Handler + DCD IRQ027_Handler + DCD IRQ028_Handler + DCD IRQ029_Handler + DCD IRQ030_Handler + DCD IRQ031_Handler + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:NOROOT:REORDER(2) +Reset_Handler + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 ; vector offset + cmp PC, R0 + bls ROMCODE + + ; ram code base address. + ADD R2, R0,R2 +ROMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + STR R2, [R0] + + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + PUBWEAK NMI_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +NMI_Handler + B NMI_Handler + + PUBWEAK HardFault_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +HardFault_Handler + B HardFault_Handler + + + PUBWEAK SVC_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +SVC_Handler + B SVC_Handler + + PUBWEAK PendSV_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +PendSV_Handler + B PendSV_Handler + + PUBWEAK SysTick_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +SysTick_Handler + B SysTick_Handler + + + PUBWEAK IRQ000_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ000_Handler + B IRQ000_Handler + + + PUBWEAK IRQ001_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ001_Handler + B IRQ001_Handler + + + PUBWEAK IRQ002_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ002_Handler + B IRQ002_Handler + + + PUBWEAK IRQ003_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ003_Handler + B IRQ003_Handler + + + PUBWEAK IRQ004_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ004_Handler + B IRQ004_Handler + + + PUBWEAK IRQ005_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ005_Handler + B IRQ005_Handler + + + PUBWEAK IRQ006_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ006_Handler + B IRQ006_Handler + + + PUBWEAK IRQ007_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ007_Handler + B IRQ007_Handler + + + PUBWEAK IRQ008_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ008_Handler + B IRQ008_Handler + + + PUBWEAK IRQ009_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ009_Handler + B IRQ009_Handler + + + PUBWEAK IRQ010_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ010_Handler + B IRQ010_Handler + + + PUBWEAK IRQ011_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ011_Handler + B IRQ011_Handler + + + PUBWEAK IRQ012_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ012_Handler + B IRQ012_Handler + + + PUBWEAK IRQ013_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ013_Handler + B IRQ013_Handler + + + PUBWEAK IRQ014_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ014_Handler + B IRQ014_Handler + + + PUBWEAK IRQ015_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ015_Handler + B IRQ015_Handler + + + PUBWEAK IRQ016_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ016_Handler + B IRQ016_Handler + + + PUBWEAK IRQ017_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ017_Handler + B IRQ017_Handler + + + PUBWEAK IRQ018_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ018_Handler + B IRQ018_Handler + + + PUBWEAK IRQ019_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ019_Handler + B IRQ019_Handler + + + PUBWEAK IRQ020_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ020_Handler + B IRQ020_Handler + + + PUBWEAK IRQ021_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ021_Handler + B IRQ021_Handler + + + PUBWEAK IRQ022_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ022_Handler + B IRQ022_Handler + + + PUBWEAK IRQ023_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ023_Handler + B IRQ023_Handler + + + PUBWEAK IRQ024_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ024_Handler + B IRQ024_Handler + + + PUBWEAK IRQ025_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ025_Handler + B IRQ025_Handler + + + PUBWEAK IRQ026_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ026_Handler + B IRQ026_Handler + + + PUBWEAK IRQ027_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ027_Handler + B IRQ027_Handler + + + PUBWEAK IRQ028_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ028_Handler + B IRQ028_Handler + + + PUBWEAK IRQ029_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ029_Handler + B IRQ029_Handler + + + PUBWEAK IRQ030_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ030_Handler + B IRQ030_Handler + + + PUBWEAK IRQ031_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +IRQ031_Handler + B IRQ031_Handler + + END diff --git a/project/handler/EWARM/template.ewd b/project/handler/EWARM/template.ewd new file mode 100644 index 0000000..de5117b --- /dev/null +++ b/project/handler/EWARM/template.ewd @@ -0,0 +1,3265 @@ + + + + 2 + + Release + + ARM + + 0 + + C-SPY + 2 + + 28 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ARMSIM_ID + 2 + + 1 + 1 + 0 + + + + + + + + ANGEL_ID + 2 + + 0 + 1 + 0 + + + + + + + + + + + + CADI_ID + 2 + + 0 + 1 + 0 + + + + + + + + + CMSISDAP_ID + 2 + + 4 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GDBSERVER_ID + 2 + + 0 + 1 + 0 + + + + + + + + + + + IARROM_ID + 2 + + 1 + 1 + 0 + + + + + + + + + IJET_ID + 2 + + 8 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JLINK_ID + 2 + + 16 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LMIFTDI_ID + 2 + + 2 + 1 + 0 + + + + + + + + + + MACRAIGOR_ID + 2 + + 3 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + PEMICRO_ID + 2 + + 3 + 1 + 0 + + + + + + + + RDI_ID + 2 + + 2 + 1 + 0 + + + + + + + + + + + + + + + + STLINK_ID + 2 + + 3 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + THIRDPARTY_ID + 2 + + 0 + 1 + 0 + + + + + + + + TIFET_ID + 2 + + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + XDS100_ID + 2 + + 5 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\middleware\PercepioTraceExporter\PercepioTraceExportPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin + 0 + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin + 0 + + + + + debug + + ARM + + 0 + + C-SPY + 2 + + 28 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ARMSIM_ID + 2 + + 1 + 1 + 0 + + + + + + + + ANGEL_ID + 2 + + 0 + 1 + 0 + + + + + + + + + + + + CADI_ID + 2 + + 0 + 1 + 0 + + + + + + + + + CMSISDAP_ID + 2 + + 4 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GDBSERVER_ID + 2 + + 0 + 1 + 0 + + + + + + + + + + + IARROM_ID + 2 + + 1 + 1 + 0 + + + + + + + + + IJET_ID + 2 + + 8 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JLINK_ID + 2 + + 16 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LMIFTDI_ID + 2 + + 2 + 1 + 0 + + + + + + + + + + MACRAIGOR_ID + 2 + + 3 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + PEMICRO_ID + 2 + + 3 + 1 + 0 + + + + + + + + RDI_ID + 2 + + 2 + 1 + 0 + + + + + + + + + + + + + + + + STLINK_ID + 2 + + 3 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + THIRDPARTY_ID + 2 + + 0 + 1 + 0 + + + + + + + + TIFET_ID + 2 + + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + XDS100_ID + 2 + + 5 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\middleware\PercepioTraceExporter\PercepioTraceExportPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin + 0 + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin + 0 + + + + + + diff --git a/project/handler/EWARM/template.ewp b/project/handler/EWARM/template.ewp new file mode 100644 index 0000000..c43569a --- /dev/null +++ b/project/handler/EWARM/template.ewp @@ -0,0 +1,2213 @@ + + + + 2 + + Release + + ARM + + 0 + + General + 3 + + 24 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 31 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 9 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 0 + + + + + + + + + CUSTOM + 3 + + + + 0 + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 17 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 0 + + + + + + + BILINK + 0 + + + + + debug + + ARM + + 0 + + General + 3 + + 24 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 31 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 9 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 0 + + + + + + + + + CUSTOM + 3 + + + + 0 + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 17 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 0 + + + + + + + BILINK + 0 + + + + + common + + $PROJ_DIR$\..\..\mcu\common\system_hc32f003.c + + + $PROJ_DIR$\startup_hc32f003.s + + + $PROJ_DIR$\..\..\driver\src\ddl.c + + + $PROJ_DIR$\..\..\driver\src\interrupts_hc32f003.c + + + + driver + + $PROJ_DIR$\..\..\driver\src\clk.c + + + $PROJ_DIR$\..\..\driver\src\gpio.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/project/handler/EWARM/template.eww b/project/handler/EWARM/template.eww new file mode 100644 index 0000000..c62178f --- /dev/null +++ b/project/handler/EWARM/template.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\template.ewp + + + + + diff --git a/project/handler/MDK/JLinkSettings.ini b/project/handler/MDK/JLinkSettings.ini new file mode 100644 index 0000000..79743a7 --- /dev/null +++ b/project/handler/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/project/handler/MDK/startup_hc32f003.s b/project/handler/MDK/startup_hc32f003.s new file mode 100644 index 0000000..33cde03 --- /dev/null +++ b/project/handler/MDK/startup_hc32f003.s @@ -0,0 +1,294 @@ +;/****************************************************************************** +;* 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. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.2 */ +;/* Date 2016-06-02 */ +;/* Target-mcu {MCU_SERIES} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000400 + + 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 0x00000000 + + 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 IRQ000_Handler ; + DCD IRQ001_Handler ; + DCD IRQ002_Handler ; + DCD IRQ003_Handler ; + DCD IRQ004_Handler ; + DCD IRQ005_Handler ; + DCD IRQ006_Handler ; + DCD IRQ007_Handler ; + DCD IRQ008_Handler ; + DCD IRQ009_Handler ; + DCD IRQ010_Handler ; + DCD IRQ011_Handler ; + DCD IRQ012_Handler ; + DCD IRQ013_Handler ; + DCD IRQ014_Handler ; + DCD IRQ015_Handler ; + DCD IRQ016_Handler ; + DCD IRQ017_Handler ; + DCD IRQ018_Handler ; + DCD IRQ019_Handler ; + DCD IRQ020_Handler ; + DCD IRQ021_Handler ; + DCD IRQ022_Handler ; + DCD IRQ023_Handler ; + DCD IRQ024_Handler ; + DCD IRQ025_Handler ; + DCD IRQ026_Handler ; + DCD IRQ027_Handler ; + DCD IRQ028_Handler ; + DCD IRQ029_Handler ; + DCD IRQ030_Handler ; + DCD IRQ031_Handler ; + +__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 + 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 IRQ000_Handler [WEAK] + EXPORT IRQ001_Handler [WEAK] + EXPORT IRQ002_Handler [WEAK] + EXPORT IRQ003_Handler [WEAK] + EXPORT IRQ004_Handler [WEAK] + EXPORT IRQ005_Handler [WEAK] + EXPORT IRQ006_Handler [WEAK] + EXPORT IRQ007_Handler [WEAK] + EXPORT IRQ008_Handler [WEAK] + EXPORT IRQ009_Handler [WEAK] + EXPORT IRQ010_Handler [WEAK] + EXPORT IRQ011_Handler [WEAK] + EXPORT IRQ012_Handler [WEAK] + EXPORT IRQ013_Handler [WEAK] + EXPORT IRQ014_Handler [WEAK] + EXPORT IRQ015_Handler [WEAK] + EXPORT IRQ016_Handler [WEAK] + EXPORT IRQ017_Handler [WEAK] + EXPORT IRQ018_Handler [WEAK] + EXPORT IRQ019_Handler [WEAK] + EXPORT IRQ020_Handler [WEAK] + EXPORT IRQ021_Handler [WEAK] + EXPORT IRQ022_Handler [WEAK] + EXPORT IRQ023_Handler [WEAK] + EXPORT IRQ024_Handler [WEAK] + EXPORT IRQ025_Handler [WEAK] + EXPORT IRQ026_Handler [WEAK] + EXPORT IRQ027_Handler [WEAK] + EXPORT IRQ028_Handler [WEAK] + EXPORT IRQ029_Handler [WEAK] + EXPORT IRQ030_Handler [WEAK] + EXPORT IRQ031_Handler [WEAK] + + +IRQ000_Handler +IRQ001_Handler +IRQ002_Handler +IRQ003_Handler +IRQ004_Handler +IRQ005_Handler +IRQ006_Handler +IRQ007_Handler +IRQ008_Handler +IRQ009_Handler +IRQ010_Handler +IRQ011_Handler +IRQ012_Handler +IRQ013_Handler +IRQ014_Handler +IRQ015_Handler +IRQ016_Handler +IRQ017_Handler +IRQ018_Handler +IRQ019_Handler +IRQ020_Handler +IRQ021_Handler +IRQ022_Handler +IRQ023_Handler +IRQ024_Handler +IRQ025_Handler +IRQ026_Handler +IRQ027_Handler +IRQ028_Handler +IRQ029_Handler +IRQ030_Handler +IRQ031_Handler + 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/project/handler/MDK/template.uvoptx b/project/handler/MDK/template.uvoptx new file mode 100644 index 0000000..6912cb1 --- /dev/null +++ b/project/handler/MDK/template.uvoptx @@ -0,0 +1,567 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc; *.md + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + template_Release + 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 + 0 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 3 + + + + + + + + + + + BIN\CMSIS_AGDI.dll + + + + 0 + ARMRTXEVENTFLAGS + -L70 -Z18 -C0 -M0 -T1 + + + 0 + DLGTARM + (1010=-1,-1,-1,-1,0)(1007=105,137,312,358,0)(1008=709,153,1085,389,0)(1009=-1,-1,-1,-1,0) + + + 0 + ARMDBGFLAGS + + + + 0 + CMSIS_AGDI + -X"" -O206 -S0 -C0 -P00 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0HC32F003.FLM -FS00 -FL04000 -FP0($$Device:HC32F003C4PA$Flash\HC32F003.FLM) + + + 0 + DLGUARM + + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 ) -FN1 -FC800 -FD20000000 -FF0HC32F003 -FL04000 -FS00 -FP0($$Device:HC32F003C4PA$Flash\HC32F003.FLM) + + + 0 + JL2CM3 + -U158007612 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC1000 -FN1 -FF0Flash_HC32L110 -FS00 -FL08000 + + + + + 0 + 0 + 352 + 1 +
7032
+ 0 + 0 + 0 + 0 + 0 + 1 + ..\..\driver\src\interrupts_hc32f003.c + + \\template\../../../driver/src/interrupts_hc32f003.c\352 +
+
+ + + 0 + 1 + handler_msg + + + 1 + 1 + u32Val,0x0A + + + 2 + 1 + SystemCoreClock,0x0A + + + 3 + 1 + u16ScanResult + + + 4 + 1 + Bat + + + 5 + 1 + SystemCoreClock,0x0A + + + 6 + 1 + handler_msg + + + + 0 + + + 0 + 0 + 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 + 1000000 + +
+
+ + + common + 1 + 0 + 0 + 0 + + 1 + 1 + 2 + 0 + 0 + 0 + .\startup_hc32f003.s + startup_hc32f003.s + 0 + 0 + + + 1 + 2 + 1 + 0 + 0 + 0 + ..\..\mcu\common\system_hc32f003.c + system_hc32f003.c + 0 + 0 + + + + + source + 1 + 0 + 0 + 0 + + 2 + 3 + 1 + 0 + 0 + 0 + ..\source\main.c + main.c + 0 + 0 + + + + + driver + 0 + 0 + 0 + 0 + + 3 + 4 + 1 + 0 + 0 + 0 + ..\..\driver\src\ddl.c + ddl.c + 0 + 0 + + + 3 + 5 + 1 + 0 + 0 + 0 + ..\..\driver\src\interrupts_hc32f003.c + interrupts_hc32f003.c + 0 + 0 + + + 3 + 6 + 1 + 0 + 0 + 0 + ..\..\driver\src\clk.c + clk.c + 0 + 0 + + + 3 + 7 + 1 + 0 + 0 + 0 + ..\..\driver\src\gpio.c + gpio.c + 0 + 0 + + + 3 + 8 + 1 + 0 + 0 + 0 + ..\..\driver\src\uart.c + uart.c + 0 + 0 + + + 3 + 9 + 1 + 0 + 0 + 0 + ..\..\driver\src\adc.c + adc.c + 0 + 0 + + + 3 + 10 + 1 + 0 + 0 + 0 + ..\..\driver\src\bt.c + bt.c + 0 + 0 + + + 3 + 11 + 1 + 0 + 0 + 0 + ..\..\driver\src\wdt.c + wdt.c + 0 + 0 + + + + + custom + 1 + 0 + 0 + 0 + + 4 + 12 + 1 + 0 + 0 + 0 + ..\..\custom\bsp_hw_mcu\bsp_usart.c + bsp_usart.c + 0 + 0 + + + 4 + 13 + 1 + 0 + 0 + 0 + ..\..\custom\api_uart_protocol\api_uart_protocol.c + api_uart_protocol.c + 0 + 0 + + + 4 + 14 + 1 + 0 + 0 + 0 + ..\..\custom\shared_power_handler\api_shared_pwr_handler.c + api_shared_pwr_handler.c + 0 + 0 + + + 4 + 15 + 1 + 0 + 0 + 0 + ..\..\custom\bsp_hw_mcu\bsp_adc.c + bsp_adc.c + 0 + 0 + + + 4 + 16 + 1 + 0 + 0 + 0 + ..\..\custom\bsp_hw_mcu\bsp_iwdg.c + bsp_iwdg.c + 0 + 0 + + + 4 + 17 + 1 + 0 + 0 + 0 + ..\..\custom\bsp_check\bsp_check_dev.c + bsp_check_dev.c + 0 + 0 + + + 4 + 18 + 1 + 0 + 0 + 0 + ..\..\custom\systick\api_sys_timer.c + api_sys_timer.c + 0 + 0 + + + 4 + 19 + 1 + 0 + 0 + 0 + ..\..\custom\bsp_hw_mcu\bsp_clk.c + bsp_clk.c + 0 + 0 + + + 4 + 20 + 1 + 0 + 0 + 0 + ..\..\custom\bsp_hw_mcu\bsp_gpio.c + bsp_gpio.c + 0 + 0 + + + 4 + 21 + 1 + 0 + 0 + 0 + ..\..\custom\bsp_hw_mcu\bsp_mcu_id.c + bsp_mcu_id.c + 0 + 0 + + + 4 + 22 + 1 + 0 + 0 + 0 + ..\..\custom\bsp_charge\bsp_batterymanage.c + bsp_batterymanage.c + 0 + 0 + + + + + ::CMSIS + 0 + 0 + 0 + 1 + + +
diff --git a/project/handler/MDK/template.uvprojx b/project/handler/MDK/template.uvprojx new file mode 100644 index 0000000..4601149 --- /dev/null +++ b/project/handler/MDK/template.uvprojx @@ -0,0 +1,533 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + template_Release + 0x4 + ARM-ADS + 6160000::V6.16::ARMCLANG + 0 + + + HC32F003C4PA + HDSC + HDSC.HC32F003.1.0.1 + https://raw.githubusercontent.com/hdscmcu/pack/master/ + IRAM(0x20000000,0x800) IROM(0x00000000,0x4000) CPUTYPE("Cortex-M0+") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC800 -FN1 -FF0HC32F003 -FS00 -FL04000 -FP0($$Device:HC32F003C4PA$Flash\HC32F003.FLM)) + 0 + $$Device:HC32F003C4PA$Device\Include\HC32F003.h + + + + + + + + + + $$Device:HC32F003C4PA$SVD\HC32F003.SFR + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + template + 1 + 0 + 0 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 1 + 0 + fromelf --bin "$L@L.axf" --output "$L@L.bin" + + 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 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 0 + 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 + 0x800 + + + 1 + 0x0 + 0x4000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x4000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x800 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\mcu\common;..\source;..\..\driver\inc;..\..\custom + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 4 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + template.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f003.s + 2 + .\startup_hc32f003.s + + + system_hc32f003.c + 1 + ..\..\mcu\common\system_hc32f003.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\driver\src\ddl.c + + + interrupts_hc32f003.c + 1 + ..\..\driver\src\interrupts_hc32f003.c + + + clk.c + 1 + ..\..\driver\src\clk.c + + + gpio.c + 1 + ..\..\driver\src\gpio.c + + + uart.c + 1 + ..\..\driver\src\uart.c + + + adc.c + 1 + ..\..\driver\src\adc.c + + + bt.c + 1 + ..\..\driver\src\bt.c + + + wdt.c + 1 + ..\..\driver\src\wdt.c + + + + + custom + + + bsp_usart.c + 1 + ..\..\custom\bsp_hw_mcu\bsp_usart.c + + + api_uart_protocol.c + 1 + ..\..\custom\api_uart_protocol\api_uart_protocol.c + + + api_shared_pwr_handler.c + 1 + ..\..\custom\shared_power_handler\api_shared_pwr_handler.c + + + bsp_adc.c + 1 + ..\..\custom\bsp_hw_mcu\bsp_adc.c + + + bsp_iwdg.c + 1 + ..\..\custom\bsp_hw_mcu\bsp_iwdg.c + + + bsp_check_dev.c + 1 + ..\..\custom\bsp_check\bsp_check_dev.c + + + api_sys_timer.c + 1 + ..\..\custom\systick\api_sys_timer.c + + + bsp_clk.c + 1 + ..\..\custom\bsp_hw_mcu\bsp_clk.c + + + bsp_gpio.c + 1 + ..\..\custom\bsp_hw_mcu\bsp_gpio.c + + + bsp_mcu_id.c + 1 + ..\..\custom\bsp_hw_mcu\bsp_mcu_id.c + + + bsp_batterymanage.c + 1 + ..\..\custom\bsp_charge\bsp_batterymanage.c + + + + + ::CMSIS + + + + + + + + + + + + + + + + + + +
diff --git a/project/handler/source/ddl_device.h b/project/handler/source/ddl_device.h new file mode 100644 index 0000000..0443d86 --- /dev/null +++ b/project/handler/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* 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 ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2017-05-04 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32L110 + + +/** + ******************************************************************************* + ** \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/project/handler/source/main.c b/project/handler/source/main.c new file mode 100644 index 0000000..74e9410 --- /dev/null +++ b/project/handler/source/main.c @@ -0,0 +1,115 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2016-02-16 1.0 XYZ First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "config.h" + +/****************************************************************************** + * 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') * + ******************************************************************************/ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ + +int32_t main(void) +{ + bsp_clk_cfg(); + bsp_gpio_cfg(); + bsp_iwdg_cfg(); + bsp_adc_cfg(); + bsp_usart_cfg(); + api_comm_parm_init(); + while (1) + { + Wdt_Feed(); + api_uart_protocol_task(); + api_sys_timer_task(); + api_shared_hand_msg_task(); + } +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/project/mcu/EWARM/HDSC_HC32F003.svd b/project/mcu/EWARM/HDSC_HC32F003.svd new file mode 100644 index 0000000..c4c1009 --- /dev/null +++ b/project/mcu/EWARM/HDSC_HC32F003.svd @@ -0,0 +1,9170 @@ + + + HDSC Co.Ltd + HDSC + HDSC_HC32F003 + ARMCM0P + 1.2 + + CM0 + r0p0 + little + false + false + 3 + false + + 8 + 32 + 32 + read-write + 0x0 + 0x0 + + + ADC + desc ADC + 0x40002400 + + 0x0 + 0x74 + + + + CR0 + desc CR0 + 0x4 + 32 + read-write + 0x13F0 + 0x5FFF + + + ADCEN + desc ADCEN + 0 + 0 + read-write + + + START + desc START + 1 + 1 + read-write + + + CLKSEL + desc CLKSEL + 3 + 2 + read-write + + + SEL + desc SEL + 7 + 4 + read-write + + + SREF + desc SREF + 9 + 8 + read-write + + + BUFEN + desc BUFEN + 10 + 10 + read-write + + + SAM + desc SAM + 12 + 11 + read-write + + + IE + desc IE + 14 + 14 + read-write + + + STATERST + desc STATERST + 15 + 15 + read-write + + + + + CR1 + desc CR1 + 0x8 + 32 + read-write + 0x7000 + 0xFFFF + + + TRIGS0 + desc TRIGS0 + 4 + 0 + read-write + + + TRIGS1 + desc TRIGS1 + 9 + 5 + read-write + + + CT + desc CT + 10 + 10 + read-write + + + RACC_EN + desc RACC_EN + 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 + + + RACC_CLR + desc RACC_CLR + 15 + 15 + read-write + + + + + CR2 + desc CR2 + 0xC + 32 + read-write + 0x0 + 0xFFFF + + + CH0EN + desc CH0EN + 0 + 0 + read-write + + + CH1EN + desc CH1EN + 1 + 1 + read-write + + + CH2EN + desc CH2EN + 2 + 2 + read-write + + + CH3EN + desc CH3EN + 3 + 3 + read-write + + + CH4EN + desc CH4EN + 4 + 4 + read-write + + + CH5EN + desc CH5EN + 5 + 5 + read-write + + + CH6EN + desc CH6EN + 6 + 6 + read-write + + + CH7EN + desc CH7EN + 7 + 7 + read-write + + + ADCCNT + desc ADCCNT + 15 + 8 + read-write + + + + + RESULT0 + desc RESULT0 + 0x30 + 32 + read-only + 0x0 + 0xFFF + + + RESULT0 + desc RESULT0 + 11 + 0 + read-only + + + + + RESULT1 + desc RESULT1 + 0x34 + 32 + read-only + 0x0 + 0xFFF + + + RESULT1 + desc RESULT1 + 11 + 0 + read-only + + + + + RESULT2 + desc RESULT2 + 0x38 + 32 + read-only + 0x0 + 0xFFF + + + RESULT2 + desc RESULT2 + 11 + 0 + read-only + + + + + RESULT3 + desc RESULT3 + 0x3C + 32 + read-only + 0x0 + 0xFFF + + + RESULT3 + desc RESULT3 + 11 + 0 + read-only + + + + + RESULT4 + desc RESULT4 + 0x40 + 32 + read-only + 0x0 + 0xFFF + + + RESULT4 + desc RESULT4 + 11 + 0 + read-only + + + + + RESULT5 + desc RESULT5 + 0x44 + 32 + read-only + 0x0 + 0xFFF + + + RESULT5 + desc RESULT5 + 11 + 0 + read-only + + + + + RESULT6 + desc RESULT6 + 0x48 + 32 + read-only + 0x0 + 0xFFF + + + RESULT6 + desc RESULT6 + 11 + 0 + read-only + + + + + RESULT7 + desc RESULT7 + 0x4C + 32 + read-only + 0x0 + 0xFFF + + + RESULT7 + desc RESULT7 + 11 + 0 + read-only + + + + + RESULT8 + desc RESULT8 + 0x50 + 32 + read-only + 0x0 + 0xFFF + + + RESULT8 + desc RESULT8 + 11 + 0 + read-only + + + + + RESULT_ACC + desc RESULT_ACC + 0x54 + 32 + read-only + 0x0 + 0xFFFFF + + + RESULT_ACC + desc RESULT_ACC + 19 + 0 + read-only + + + + + HT + desc HT + 0x58 + 32 + read-only + 0xFFF + 0xFFF + + + HT + desc HT + 11 + 0 + read-only + + + + + LT + desc LT + 0x5C + 32 + read-only + 0x0 + 0xFFF + + + LT + desc LT + 11 + 0 + read-only + + + + + IFR + desc IFR + 0x60 + 32 + read-only + 0x0 + 0xF + + + LLT_INTF + desc LLT_INTF + 0 + 0 + read-only + + + HHT_INTF + desc HHT_INTF + 1 + 1 + read-only + + + REG_INTF + desc REG_INTF + 2 + 2 + read-only + + + CONT_INTF + desc CONT_INTF + 3 + 3 + read-only + + + + + ICLR + desc ICLR + 0x64 + 32 + write-only + 0x4 + 0xF + + + LLT_INTC + desc LLT_INTC + 0 + 0 + write-only + + + HHT_INTC + desc HHT_INTC + 1 + 1 + write-only + + + REG_INTC + desc REG_INTC + 2 + 2 + write-only + + + CONT_INTC + desc CONT_INTC + 3 + 3 + write-only + + + + + RESULT + desc RESULT + 0x68 + 32 + read-only + 0x0 + 0xFFF + + + RESULT + desc RESULT + 11 + 0 + read-only + + + + + + + ADT0 + desc ADT + 0x40003000 + + 0x0 + 0x400 + + + + CNTER + desc CNTER + 0x0 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + + + PERAR + desc PERAR + 0x4 + 32 + read-write + 0xFFFF + 0xFFFF + + + PERA + desc PERA + 15 + 0 + read-write + + + + + PERBR + desc PERBR + 0x8 + 32 + read-write + 0xFFFF + 0xFFFF + + + PERB + desc PERB + 15 + 0 + read-write + + + + + GCMAR + desc GCMAR + 0x10 + 32 + read-write + 0xFFFF + 0xFFFF + + + GCMA + desc GCMA + 15 + 0 + read-write + + + + + GCMBR + desc GCMBR + 0x14 + 32 + read-write + 0xFFFF + 0xFFFF + + + GCMB + desc GCMB + 15 + 0 + read-write + + + + + GCMCR + desc GCMCR + 0x18 + 32 + read-write + 0xFFFF + 0xFFFF + + + GCMC + desc GCMC + 15 + 0 + read-write + + + + + GCMDR + desc GCMDR + 0x1C + 32 + read-write + 0xFFFF + 0xFFFF + + + GCMD + desc GCMD + 15 + 0 + read-write + + + + + DTUAR + desc DTUAR + 0x40 + 32 + read-write + 0xFFFF + 0xFFFF + + + DTUA + desc DTUA + 15 + 0 + read-write + + + + + DTDAR + desc DTDAR + 0x44 + 32 + read-write + 0xFFFF + 0xFFFF + + + DTDA + desc DTDA + 15 + 0 + 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 + + + + + ICONR + desc ICONR + 0x54 + 32 + read-write + 0x0 + 0xC1CF + + + 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 + + + + + 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 + + + + + BCONR + desc BCONR + 0x5C + 32 + read-write + 0x0 + 0x185 + + + BENA + desc BENA + 0 + 0 + read-write + + + BENB + desc BENB + 2 + 2 + read-write + + + BENP + desc BENP + 8 + 8 + 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 + + + + + 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 + + + + + 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 + + + + + STFLR + desc STFLR + 0x70 + 32 + read-write + 0x0 + 0x80CE001CF + + + 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 + + + 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 + + + + + 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 + + + + + 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 + + + + + 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 + + + + + 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 + + + + + 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 + + + + + CR + desc CR + 0x108 + 32 + read-write + 0x0 + 0x7CF + + + 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 + + + + + AOSSR + desc AOSSR + 0x110 + 32 + read-write + 0x0 + 0x3F9F + + + FBRAKE + desc FBRAKE + 0 + 0 + read-write + + + FSAME + desc FSAME + 1 + 1 + read-write + + + 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 + + + + + AOSCL + desc AOSCL + 0x114 + 32 + read-only + 0x0 + 0x3 + + + FBRAKE + desc FBRAKE + 0 + 0 + read-only + + + FSAME + desc FSAME + 1 + 1 + read-only + + + + + 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 + + + + + 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 + + + + + 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 + + + + + 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 + + + + + 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 + + + + + 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 + + + + + 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 + + + + + + + ADT1 + desc ADT + 0x40003400 + + 0x0 + 0x400 + + + + ADT2 + desc ADT + 0x40003800 + + 0x0 + 0x400 + + + + BGR + desc BGR + 0x40002400 + ADC + + 0x0 + 0x40002400 + + + + 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 + + + + + + + BT0 + desc BT + 0x40000C00 + + 0x0 + 0x18 + + + + ARR + desc ARR + 0x0 + 32 + read-write + 0x0 + 0xFF + + + ARR + desc ARR + 15 + 0 + read-write + + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFF + + + CNT + desc CNT + 15 + 0 + read-write + + + + + CNT32 + desc CNT32 + 0x8 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + CNT32 + desc CNT32 + 31 + 0 + read-write + + + + + CR + desc CR + 0xC + 32 + read-write + 0x8 + 0x77F + + + 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 + + + PRS + desc PRS + 6 + 4 + read-write + + + GATE + desc GATE + 8 + 8 + read-write + + + GATE_P + desc GATE_P + 9 + 9 + read-write + + + IE + desc IE + 10 + 10 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0x1 + + + TF + desc TF + 0 + 0 + read-only + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0x1 + 0x1 + + + TFC + desc TFC + 0 + 0 + write-only + + + + + + + BT1 + desc BT + 0x40000C20 + + 0x0 + 0x18 + + + + BT2 + desc BT + 0x40000C40 + + 0x0 + 0x18 + + + + 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 + + + + + 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 + + + XTH_FAULT + desc XTH_FAULT + 3 + 3 + read-only + + + + + ICLR + desc ICLR + 0x14 + 32 + read-write + 0x11111111 + 0xC + + + XTH_FAULT_CLR + desc XTH_FAULT_CLR + 3 + 3 + read-write + + + + + CALCON + desc CALCON + 0x18 + 32 + read-write + 0xFFFFFFFF + 0xFFFFFFFF + + + CCNTVAL + desc CCNTVAL + 31 + 0 + read-write + + + + + + + CLOCK + desc CLOCK + 0x40002000 + + 0x0 + 0x54 + + + + SYSCTRL0 + desc SYSCTRL0 + 0x0 + 32 + read-write + 0x1 + 0x87FF + + + 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 + + + CLK_SW4_SEL + desc CLK_SW4_SEL + 5 + 4 + read-write + + + HCLK_PRS + desc HCLK_PRS + 8 + 6 + read-write + + + PCLK_PRS + desc PCLK_PRS + 10 + 9 + read-write + + + WAKEUP_BYRCH + desc WAKEUP_BYRCH + 15 + 15 + read-write + + + + + SYSCTRL1 + desc SYSCTRL1 + 0x4 + 32 + read-write + 0x8 + 0x1DE + + + EXTH_EN + desc EXTH_EN + 1 + 1 + read-write + + + CLOCK_FT_EN + desc CLOCK_FT_EN + 4 + 4 + read-write + + + LOCK_EN + desc LOCK_EN + 6 + 6 + read-write + + + RES_UIO + desc RES_UIO + 7 + 7 + read-write + + + SWD_UIO + desc SWD_UIO + 8 + 8 + read-write + + + + + SYSCTRL2 + desc SYSCTRL2 + 0x8 + 32 + read-write + 0x0 + 0xFFFF + + + SYSCTRL2 + desc SYSCTRL2 + 15 + 0 + 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 + + + + + XTH_CR + desc XTH_CR + 0x10 + 32 + read-write + 0x22 + 0x7F + + + DRIVER + desc DRIVER + 3 + 0 + read-write + + + STARTUP + desc STARTUP + 5 + 4 + read-write + + + STABLE + desc STABLE + 6 + 6 + read-only + + + + + 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 + + + + + PERI_CLKEN + desc PERI_CLKEN + 0x20 + 32 + read-write + 0x0 + 0x9723C573 + + + UART0 + desc UART0 + 0 + 0 + read-write + + + UART1 + desc UART1 + 1 + 1 + read-write + + + I2C + desc I2C + 4 + 4 + read-write + + + SPI + desc SPI + 6 + 6 + read-write + + + BASETIM + desc BASETIM + 8 + 8 + read-write + + + ADVTIM + desc ADVTIM + 10 + 10 + 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 + + + TRIM + desc TRIM + 21 + 21 + read-write + + + TICK + desc TICK + 24 + 24 + read-write + + + CRC + desc CRC + 26 + 26 + read-write + + + GPIO + desc GPIO + 28 + 28 + read-write + + + FLASH + desc FLASH + 31 + 31 + read-write + + + + + SYSTICK_CR + desc SYSTICK_CR + 0x34 + 32 + read-write + 0x1000147 + 0xFFFFFFF + + + STCALIB + desc STCALIB + 23 + 0 + read-write + + + SKEW + desc SKEW + 24 + 24 + read-write + + + NOREF + desc NOREF + 25 + 25 + read-write + + + CLK_SEL + desc CLK_SEL + 27 + 26 + read-write + + + + + DEBUG_ACTIVE + desc DEBUG_ACTIVE + 0x38 + 32 + read-write + 0x7FF + 0x7FF + + + TIM0 + desc TIM0 + 0 + 0 + read-write + + + TIM1 + desc TIM1 + 1 + 1 + read-write + + + TIM2 + desc TIM2 + 2 + 2 + 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 + + + TICK + desc TICK + 10 + 10 + read-write + + + + + + + CRC + desc CRC + 0x40020900 + + 0x0 + 0x100 + + + + RESULT + desc RESULT + 0x4 + 32 + read-write + 0xFFFF + 0x1FFFF + + + RESULT + desc RESULT + 15 + 0 + read-write + + + FLAG + desc FLAG + 16 + 16 + read-only + + + + + DATA + desc DATA + 0x80 + 32 + write-only + 0x0 + 0xFFFFFFFF + + + DATA + desc DATA + 31 + 0 + write-only + + + + + + + FLASH + desc FLASH + 0x40020000 + + 0x0 + 0x34 + + + + TNVS + desc TNVS + 0x0 + 32 + read-write + 0x32 + 0x1FF + + + TNVS + desc TNVS + 8 + 0 + read-write + + + + + TPGS + desc TPGS + 0x4 + 32 + read-write + 0x23 + 0xFF + + + TPGS + desc TPGS + 7 + 0 + read-write + + + + + TPROG + desc TPROG + 0x8 + 32 + read-write + 0x27 + 0xFF + + + TPROG + desc TPROG + 7 + 0 + read-write + + + + + TSERASE + desc TSERASE + 0xC + 32 + read-write + 0x18000 + 0x3FFFF + + + TSERASE + desc TSERASE + 17 + 0 + read-write + + + + + TMERASE + desc TMERASE + 0x10 + 32 + read-write + 0x140000 + 0x1FFFFF + + + TMERASE + desc TMERASE + 20 + 0 + read-write + + + + + TPRCV + desc TPRCV + 0x14 + 32 + read-write + 0x24 + 0xFFF + + + TPRCV + desc TPRCV + 11 + 0 + read-write + + + + + TSRCV + desc TSRCV + 0x18 + 32 + read-write + 0x240 + 0xFFF + + + TSRCV + desc TSRCV + 11 + 0 + read-write + + + + + TMRCV + desc TMRCV + 0x1C + 32 + read-write + 0x1000 + 0x1FFF + + + TMRCV + desc TMRCV + 12 + 0 + read-write + + + + + CR + desc CR + 0x20 + 32 + read-write + 0x0 + 0x7F + + + OP + desc OP + 1 + 0 + read-write + + + WAIT + desc WAIT + 2 + 2 + read-write + + + BUSY + desc BUSY + 4 + 4 + read-only + + + IE + desc IE + 6 + 5 + 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 + + + + + ICLR + desc ICLR + 0x28 + 32 + write-only + 0x3 + 0x3 + + + ICLR0 + desc ICLR0 + 0 + 0 + write-only + + + ICLR1 + desc ICLR1 + 1 + 1 + write-only + + + + + BYPASS + desc BYPASS + 0x2C + 32 + write-only + 0x0 + 0xFFFF + + + BYSEQ + desc BYSEQ + 15 + 0 + write-only + + + + + SLOCK + desc SLOCK + 0x30 + 32 + read-write + 0x0 + 0xFFFF + + + SLOCK + desc SLOCK + 15 + 0 + read-write + + + + + + + GPIO + desc GPIO + 0x40020C00 + + 0x0 + 0x400 + + + + P01_SEL + desc P01_SEL + 0x4 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P02_SEL + desc P02_SEL + 0x8 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P03_SEL + desc P03_SEL + 0xC + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P14_SEL + desc P14_SEL + 0x50 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P15_SEL + desc P15_SEL + 0x54 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P23_SEL + desc P23_SEL + 0x8C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P24_SEL + desc P24_SEL + 0x90 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P25_SEL + desc P25_SEL + 0x94 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P26_SEL + desc P26_SEL + 0x98 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P27_SEL + desc P27_SEL + 0x9C + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P31_SEL + desc P31_SEL + 0xC4 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P32_SEL + desc P32_SEL + 0xC8 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P33_SEL + desc P33_SEL + 0xCC + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P34_SEL + desc P34_SEL + 0xD0 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P35_SEL + desc P35_SEL + 0xD4 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P36_SEL + desc P36_SEL + 0xD8 + 32 + read-write + 0x0 + 0x7 + + + SEL + desc SEL + 2 + 0 + read-write + + + + + P0DIR + desc P0DIR + 0x100 + 32 + read-write + 0xFFFFFFFF + 0xE + + + P01 + desc P01 + 1 + 1 + read-write + + + P02 + desc P02 + 2 + 2 + read-write + + + P03 + desc P03 + 3 + 3 + read-write + + + + + P0IN + desc P0IN + 0x104 + 32 + read-only + 0x0 + 0xF + + + P00 + desc P00 + 0 + 0 + read-only + + + P01 + desc P01 + 1 + 1 + read-only + + + P02 + desc P02 + 2 + 2 + read-only + + + P03 + desc P03 + 3 + 3 + read-only + + + + + P0OUT + desc P0OUT + 0x108 + 32 + read-write + 0x0 + 0xE + + + P01 + desc P01 + 1 + 1 + read-write + + + P02 + desc P02 + 2 + 2 + read-write + + + P03 + desc P03 + 3 + 3 + read-write + + + + + P0ADS + desc P0ADS + 0x10C + 32 + read-write + 0x0 + 0xE + + + P01 + desc P01 + 1 + 1 + read-write + + + P02 + desc P02 + 2 + 2 + read-write + + + P03 + desc P03 + 3 + 3 + read-write + + + + + P0DR + desc P0DR + 0x11C + 32 + read-write + 0x0 + 0xE + + + P01 + desc P01 + 1 + 1 + read-write + + + P02 + desc P02 + 2 + 2 + read-write + + + P03 + desc P03 + 3 + 3 + read-write + + + + + P0PU + desc P0PU + 0x120 + 32 + read-write + 0x0 + 0xE + + + P01 + desc P01 + 1 + 1 + read-write + + + P02 + desc P02 + 2 + 2 + read-write + + + P03 + desc P03 + 3 + 3 + read-write + + + + + P0PD + desc P0PD + 0x124 + 32 + read-write + 0x0 + 0xE + + + P01 + desc P01 + 1 + 1 + read-write + + + P02 + desc P02 + 2 + 2 + read-write + + + P03 + desc P03 + 3 + 3 + read-write + + + + + P0OD + desc P0OD + 0x12C + 32 + read-write + 0x0 + 0xE + + + P01 + desc P01 + 1 + 1 + read-write + + + P02 + desc P02 + 2 + 2 + read-write + + + P03 + desc P03 + 3 + 3 + read-write + + + + + P0HIE + desc P0HIE + 0x130 + 32 + read-only + 0x0 + 0xF + + + P00 + desc P00 + 0 + 0 + read-only + + + P01 + desc P01 + 1 + 1 + read-only + + + P02 + desc P02 + 2 + 2 + read-only + + + P03 + desc P03 + 3 + 3 + read-only + + + + + P0LIE + desc P0LIE + 0x134 + 32 + read-only + 0x0 + 0xF + + + P00 + desc P00 + 0 + 0 + read-only + + + P01 + desc P01 + 1 + 1 + read-only + + + P02 + desc P02 + 2 + 2 + read-only + + + P03 + desc P03 + 3 + 3 + read-only + + + + + P0RIE + desc P0RIE + 0x138 + 32 + read-only + 0x0 + 0xF + + + P00 + desc P00 + 0 + 0 + read-only + + + P01 + desc P01 + 1 + 1 + read-only + + + P02 + desc P02 + 2 + 2 + read-only + + + P03 + desc P03 + 3 + 3 + read-only + + + + + P0FIE + desc P0FIE + 0x13C + 32 + read-only + 0x0 + 0xF + + + P00 + desc P00 + 0 + 0 + read-only + + + P01 + desc P01 + 1 + 1 + read-only + + + P02 + desc P02 + 2 + 2 + read-only + + + P03 + desc P03 + 3 + 3 + read-only + + + + + P1DIR + desc P1DIR + 0x140 + 32 + read-write + 0xFFFFFFFF + 0x30 + + + P14 + desc P14 + 4 + 4 + read-write + + + P15 + desc P15 + 5 + 5 + read-write + + + + + P1IN + desc P1IN + 0x144 + 32 + read-only + 0x0 + 0x3 + + + P14 + desc P14 + 4 + 4 + read-only + + + P15 + desc P15 + 5 + 5 + read-only + + + + + P1OUT + desc P1OUT + 0x148 + 32 + read-write + 0x0 + 0x30 + + + P14 + desc P14 + 4 + 4 + read-write + + + P15 + desc P15 + 5 + 5 + read-write + + + + + P1ADS + desc P1ADS + 0x14C + 32 + read-write + 0x0 + 0x30 + + + P14 + desc P14 + 4 + 4 + read-write + + + P15 + desc P15 + 5 + 5 + read-write + + + + + P1DR + desc P1DR + 0x15C + 32 + read-write + 0x0 + 0x30 + + + P14 + desc P14 + 4 + 4 + read-write + + + P15 + desc P15 + 5 + 5 + read-write + + + + + P1PU + desc P1PU + 0x160 + 32 + read-write + 0x0 + 0x30 + + + P14 + desc P14 + 4 + 4 + read-write + + + P15 + desc P15 + 5 + 5 + read-write + + + + + P1PD + desc P1PD + 0x164 + 32 + read-write + 0x0 + 0x30 + + + P14 + desc P14 + 4 + 4 + read-write + + + P15 + desc P15 + 5 + 5 + read-write + + + + + P1OD + desc P1OD + 0x16C + 32 + read-write + 0x0 + 0x30 + + + P14 + desc P14 + 4 + 4 + read-write + + + P15 + desc P15 + 5 + 5 + read-write + + + + + P1HIE + desc P1HIE + 0x170 + 32 + read-only + 0x0 + 0x3 + + + P14 + desc P14 + 4 + 4 + read-only + + + P15 + desc P15 + 5 + 5 + read-only + + + + + P1LIE + desc P1LIE + 0x174 + 32 + read-only + 0x0 + 0x3 + + + P14 + desc P14 + 4 + 4 + read-only + + + P15 + desc P15 + 5 + 5 + read-only + + + + + P1RIE + desc P1RIE + 0x178 + 32 + read-only + 0x0 + 0x3 + + + P14 + desc P14 + 4 + 4 + read-only + + + P15 + desc P15 + 5 + 5 + read-only + + + + + P1FIE + desc P1FIE + 0x17C + 32 + read-only + 0x0 + 0x3 + + + P14 + desc P14 + 4 + 4 + read-only + + + P15 + desc P15 + 5 + 5 + read-only + + + + + P2DIR + desc P2DIR + 0x180 + 32 + read-write + 0xFFFFFFFF + 0xF8 + + + P23 + desc P23 + 3 + 3 + read-write + + + P24 + desc P24 + 4 + 4 + read-write + + + P25 + desc P25 + 5 + 5 + read-write + + + P26 + desc P26 + 6 + 6 + read-write + + + P27 + desc P27 + 7 + 7 + read-write + + + + + P2IN + desc P2IN + 0x184 + 32 + read-only + 0x0 + 0x3 + + + P23 + desc P23 + 3 + 3 + read-only + + + P24 + desc P24 + 4 + 4 + read-only + + + P25 + desc P25 + 5 + 5 + read-only + + + P26 + desc P26 + 6 + 6 + read-only + + + P27 + desc P27 + 7 + 7 + read-only + + + + + P2OUT + desc P2OUT + 0x188 + 32 + read-write + 0x0 + 0xF8 + + + P23 + desc P23 + 3 + 3 + read-write + + + P24 + desc P24 + 4 + 4 + read-write + + + P25 + desc P25 + 5 + 5 + read-write + + + P26 + desc P26 + 6 + 6 + read-write + + + P27 + desc P27 + 7 + 7 + read-write + + + + + P2ADS + desc P2ADS + 0x18C + 32 + read-write + 0x0 + 0xF8 + + + P23 + desc P23 + 3 + 3 + read-write + + + P24 + desc P24 + 4 + 4 + read-write + + + P25 + desc P25 + 5 + 5 + read-write + + + P26 + desc P26 + 6 + 6 + read-write + + + P27 + desc P27 + 7 + 7 + read-write + + + + + P2DR + desc P2DR + 0x19C + 32 + read-write + 0x0 + 0xF8 + + + P23 + desc P23 + 3 + 3 + read-write + + + P24 + desc P24 + 4 + 4 + read-write + + + P25 + desc P25 + 5 + 5 + read-write + + + P26 + desc P26 + 6 + 6 + read-write + + + P27 + desc P27 + 7 + 7 + read-write + + + + + P2PU + desc P2PU + 0x1A0 + 32 + read-write + 0x0 + 0xF8 + + + P23 + desc P23 + 3 + 3 + read-write + + + P24 + desc P24 + 4 + 4 + read-write + + + P25 + desc P25 + 5 + 5 + read-write + + + P26 + desc P26 + 6 + 6 + read-write + + + P27 + desc P27 + 7 + 7 + read-write + + + + + P2PD + desc P2PD + 0x1A4 + 32 + read-write + 0x0 + 0xF8 + + + P23 + desc P23 + 3 + 3 + read-write + + + P24 + desc P24 + 4 + 4 + read-write + + + P25 + desc P25 + 5 + 5 + read-write + + + P26 + desc P26 + 6 + 6 + read-write + + + P27 + desc P27 + 7 + 7 + read-write + + + + + P2OD + desc P2OD + 0x1AC + 32 + read-write + 0x0 + 0xF8 + + + P23 + desc P23 + 3 + 3 + read-write + + + P24 + desc P24 + 4 + 4 + read-write + + + P25 + desc P25 + 5 + 5 + read-write + + + P26 + desc P26 + 6 + 6 + read-write + + + P27 + desc P27 + 7 + 7 + read-write + + + + + P2HIE + desc P2HIE + 0x1B0 + 32 + read-only + 0x0 + 0x3 + + + P23 + desc P23 + 3 + 3 + read-only + + + P24 + desc P24 + 4 + 4 + read-only + + + P25 + desc P25 + 5 + 5 + read-only + + + P26 + desc P26 + 6 + 6 + read-only + + + P27 + desc P27 + 7 + 7 + read-only + + + + + P2LIE + desc P2LIE + 0x1B4 + 32 + read-only + 0x0 + 0x3 + + + P23 + desc P23 + 3 + 3 + read-only + + + P24 + desc P24 + 4 + 4 + read-only + + + P25 + desc P25 + 5 + 5 + read-only + + + P26 + desc P26 + 6 + 6 + read-only + + + P27 + desc P27 + 7 + 7 + read-only + + + + + P2RIE + desc P2RIE + 0x1B8 + 32 + read-only + 0x0 + 0x3 + + + P23 + desc P23 + 3 + 3 + read-only + + + P24 + desc P24 + 4 + 4 + read-only + + + P25 + desc P25 + 5 + 5 + read-only + + + P26 + desc P26 + 6 + 6 + read-only + + + P27 + desc P27 + 7 + 7 + read-only + + + + + P2FIE + desc P2FIE + 0x1BC + 32 + read-only + 0x0 + 0x3 + + + P23 + desc P23 + 3 + 3 + read-only + + + P24 + desc P24 + 4 + 4 + read-only + + + P25 + desc P25 + 5 + 5 + read-only + + + P26 + desc P26 + 6 + 6 + read-only + + + P27 + desc P27 + 7 + 7 + read-only + + + + + P3DIR + desc P3DIR + 0x1C0 + 32 + read-write + 0xFFFFFFFF + 0x7E + + + P31 + desc P31 + 1 + 1 + read-write + + + P32 + desc P32 + 2 + 2 + read-write + + + P33 + desc P33 + 3 + 3 + read-write + + + P34 + desc P34 + 4 + 4 + read-write + + + P35 + desc P35 + 5 + 5 + read-write + + + P36 + desc P36 + 6 + 6 + read-write + + + + + P3IN + desc P3IN + 0x1C4 + 32 + read-only + 0x0 + 0x7E + + + P31 + desc P31 + 1 + 1 + read-only + + + P32 + desc P32 + 2 + 2 + read-only + + + P33 + desc P33 + 3 + 3 + read-only + + + P34 + desc P34 + 4 + 4 + read-only + + + P35 + desc P35 + 5 + 5 + read-only + + + P36 + desc P36 + 6 + 6 + read-only + + + + + P3OUT + desc P3OUT + 0x1C8 + 32 + read-write + 0x0 + 0x7E + + + P31 + desc P31 + 1 + 1 + read-write + + + P32 + desc P32 + 2 + 2 + read-write + + + P33 + desc P33 + 3 + 3 + read-write + + + P34 + desc P34 + 4 + 4 + read-write + + + P35 + desc P35 + 5 + 5 + read-write + + + P36 + desc P36 + 6 + 6 + read-write + + + + + P3ADS + desc P3ADS + 0x1CC + 32 + read-write + 0x0 + 0x7E + + + P31 + desc P31 + 1 + 1 + read-write + + + P32 + desc P32 + 2 + 2 + read-write + + + P33 + desc P33 + 3 + 3 + read-write + + + P34 + desc P34 + 4 + 4 + read-write + + + P35 + desc P35 + 5 + 5 + read-write + + + P36 + desc P36 + 6 + 6 + read-write + + + + + P3DR + desc P3DR + 0x1DC + 32 + read-write + 0x0 + 0x7E + + + P31 + desc P31 + 1 + 1 + read-write + + + P32 + desc P32 + 2 + 2 + read-write + + + P33 + desc P33 + 3 + 3 + read-write + + + P34 + desc P34 + 4 + 4 + read-write + + + P35 + desc P35 + 5 + 5 + read-write + + + P36 + desc P36 + 6 + 6 + read-write + + + + + P3PU + desc P3PU + 0x1E0 + 32 + read-write + 0x0 + 0x7E + + + P31 + desc P31 + 1 + 1 + read-write + + + P32 + desc P32 + 2 + 2 + read-write + + + P33 + desc P33 + 3 + 3 + read-write + + + P34 + desc P34 + 4 + 4 + read-write + + + P35 + desc P35 + 5 + 5 + read-write + + + P36 + desc P36 + 6 + 6 + read-write + + + + + P3PD + desc P3PD + 0x1E4 + 32 + read-write + 0x0 + 0x7E + + + P31 + desc P31 + 1 + 1 + read-write + + + P32 + desc P32 + 2 + 2 + read-write + + + P33 + desc P33 + 3 + 3 + read-write + + + P34 + desc P34 + 4 + 4 + read-write + + + P35 + desc P35 + 5 + 5 + read-write + + + P36 + desc P36 + 6 + 6 + read-write + + + + + P3OD + desc P3OD + 0x1EC + 32 + read-write + 0x0 + 0x7E + + + P31 + desc P31 + 1 + 1 + read-write + + + P32 + desc P32 + 2 + 2 + read-write + + + P33 + desc P33 + 3 + 3 + read-write + + + P34 + desc P34 + 4 + 4 + read-write + + + P35 + desc P35 + 5 + 5 + read-write + + + P36 + desc P36 + 6 + 6 + read-write + + + + + P3HIE + desc P3HIE + 0x1F0 + 32 + read-only + 0x0 + 0x7E + + + P31 + desc P31 + 1 + 1 + read-only + + + P32 + desc P32 + 2 + 2 + read-only + + + P33 + desc P33 + 3 + 3 + read-only + + + P34 + desc P34 + 4 + 4 + read-only + + + P35 + desc P35 + 5 + 5 + read-only + + + P36 + desc P36 + 6 + 6 + read-only + + + + + P3LIE + desc P3LIE + 0x1F4 + 32 + read-only + 0x0 + 0x7E + + + P31 + desc P31 + 1 + 1 + read-only + + + P32 + desc P32 + 2 + 2 + read-only + + + P33 + desc P33 + 3 + 3 + read-only + + + P34 + desc P34 + 4 + 4 + read-only + + + P35 + desc P35 + 5 + 5 + read-only + + + P36 + desc P36 + 6 + 6 + read-only + + + + + P3RIE + desc P3RIE + 0x1F8 + 32 + read-only + 0x0 + 0x7E + + + P31 + desc P31 + 1 + 1 + read-only + + + P32 + desc P32 + 2 + 2 + read-only + + + P33 + desc P33 + 3 + 3 + read-only + + + P34 + desc P34 + 4 + 4 + read-only + + + P35 + desc P35 + 5 + 5 + read-only + + + P36 + desc P36 + 6 + 6 + read-only + + + + + P3FIE + desc P3FIE + 0x1FC + 32 + read-only + 0x0 + 0x7E + + + P31 + desc P31 + 1 + 1 + read-only + + + P32 + desc P32 + 2 + 2 + read-only + + + P33 + desc P33 + 3 + 3 + read-only + + + P34 + desc P34 + 4 + 4 + read-only + + + P35 + desc P35 + 5 + 5 + read-only + + + P36 + desc P36 + 6 + 6 + read-only + + + + + P0STAT + desc P0STAT + 0x200 + 32 + read-only + 0x0 + 0xF + + + P00 + desc P00 + 0 + 0 + read-only + + + P01 + desc P01 + 1 + 1 + read-only + + + P02 + desc P02 + 2 + 2 + read-only + + + P03 + desc P03 + 3 + 3 + read-only + + + + + P0ICLR + desc P0ICLR + 0x210 + 32 + read-only + 0x0 + 0xF + + + P00 + desc P00 + 0 + 0 + read-only + + + P01 + desc P01 + 1 + 1 + read-only + + + P02 + desc P02 + 2 + 2 + read-only + + + P03 + desc P03 + 3 + 3 + read-only + + + + + P1STAT + desc P1STAT + 0x240 + 32 + read-only + 0x0 + 0x3 + + + P14 + desc P14 + 4 + 4 + read-only + + + P15 + desc P15 + 5 + 5 + read-only + + + + + P1ICLR + desc P1ICLR + 0x250 + 32 + read-only + 0x0 + 0x3 + + + P14 + desc P14 + 4 + 4 + read-only + + + P15 + desc P15 + 5 + 5 + read-only + + + + + P2STAT + desc P2STAT + 0x280 + 32 + read-only + 0x0 + 0x3 + + + P23 + desc P23 + 3 + 3 + read-only + + + P24 + desc P24 + 4 + 4 + read-only + + + P25 + desc P25 + 5 + 5 + read-only + + + P26 + desc P26 + 6 + 6 + read-only + + + P27 + desc P27 + 7 + 7 + read-only + + + + + P2ICLR + desc P2ICLR + 0x290 + 32 + read-only + 0x0 + 0x3 + + + P23 + desc P23 + 3 + 3 + read-only + + + P24 + desc P24 + 4 + 4 + read-only + + + P25 + desc P25 + 5 + 5 + read-only + + + P26 + desc P26 + 6 + 6 + read-only + + + P27 + desc P27 + 7 + 7 + read-only + + + + + P3STAT + desc P3STAT + 0x2C0 + 32 + read-only + 0x0 + 0x7E + + + P31 + desc P31 + 1 + 1 + read-only + + + P32 + desc P32 + 2 + 2 + read-only + + + P33 + desc P33 + 3 + 3 + read-only + + + P34 + desc P34 + 4 + 4 + read-only + + + P35 + desc P35 + 5 + 5 + read-only + + + P36 + desc P36 + 6 + 6 + read-only + + + + + P3ICLR + desc P3ICLR + 0x2D0 + 32 + read-only + 0x0 + 0x7E + + + P31 + desc P31 + 1 + 1 + read-only + + + P32 + desc P32 + 2 + 2 + read-only + + + P33 + desc P33 + 3 + 3 + read-only + + + P34 + desc P34 + 4 + 4 + read-only + + + P35 + desc P35 + 5 + 5 + read-only + + + P36 + desc P36 + 6 + 6 + read-only + + + + + 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 + + + SSN_SEL + desc SSN_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 + + + + + CTRL2 + desc CTRL2 + 0x308 + 32 + read-write + 0x0 + 0x3FF + + + PCA_CAP0_SEL + desc PCA_CAP0_SEL + 1 + 0 + read-write + + + PCA_CAP1_SEL + desc PCA_CAP1_SEL + 3 + 2 + read-write + + + PCA_CAP2_SEL + desc PCA_CAP2_SEL + 5 + 4 + read-write + + + PCA_CAP3_SEL + desc PCA_CAP3_SEL + 7 + 6 + read-write + + + PCA_CAP4_SEL + desc PCA_CAP4_SEL + 9 + 8 + read-write + + + + + CTRL3 + desc CTRL3 + 0x30C + 32 + read-write + 0x0 + 0xFFF + + + TM4_B_SEL + desc TM4_B_SEL + 1 + 0 + read-write + + + TM5_B_SEL + desc TM5_B_SEL + 3 + 2 + read-write + + + TM6_B_SEL + desc TM6_B_SEL + 5 + 4 + read-write + + + TM4_A_SEL + desc TM4_A_SEL + 7 + 6 + read-write + + + TM5_A_SEL + desc TM5_A_SEL + 9 + 8 + read-write + + + TM6_A_SEL + desc TM6_A_SEL + 11 + 10 + read-write + + + + + CTRL4 + desc CTRL4 + 0x310 + 32 + read-write + 0x0 + 0xFF + + + TM0_GATE_SEL + desc TM0_GATE_SEL + 1 + 0 + read-write + + + TM1_GATE_SEL + desc TM1_GATE_SEL + 3 + 2 + read-write + + + TM2_GATE_SEL + desc TM2_GATE_SEL + 5 + 4 + read-write + + + TM3_GATE_SEL + desc TM3_GATE_SEL + 7 + 6 + read-write + + + + + + + I2C + desc I2C + 0x40000400 + + 0x0 + 0x18 + + + + TMRUN + desc TMRUN + 0x0 + 32 + read-write + 0x0 + 0x1 + + + TME + desc TME + 0 + 0 + read-write + + + + + TM + desc TM + 0x4 + 32 + read-write + 0x0 + 0xFF + + + TM + desc TM + 7 + 0 + 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 + + + + + DATA + desc DATA + 0xC + 32 + read-write + 0x0 + 0xFF + + + I2CDAT + desc I2CDAT + 7 + 0 + read-write + + + + + ADDR + desc ADDR + 0x10 + 32 + read-write + 0x0 + 0xFF + + + GC + desc GC + 0 + 0 + read-write + + + I2CADR + desc I2CADR + 7 + 1 + read-write + + + + + STAT + desc STAT + 0x14 + 32 + read-only + 0x0 + 0xFF + + + I2CSTA + desc I2CSTA + 7 + 0 + read-only + + + + + + + LVD + desc LVD + 0x40002400 + ADC + + 0x0 + 0x30 + + + + CR + desc CR + 0x28 + 32 + read-write + 0x100 + 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 + + + + + IFR + desc IFR + 0x2C + 32 + read-write + 0x0 + 0x1 + + + INTF + desc INTF + 0 + 0 + read-write + + + + + + + PCA + desc PCA + 0x40001000 + + 0x0 + 0x64 + + + + 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 + + + + + CMOD + desc CMOD + 0x4 + 32 + read-write + 0x0 + 0xDF + + + 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 + + + + + CNT + desc CNT + 0x8 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + 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 + + + + + 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 + + + + + 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 + + + + + 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 + + + + + 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 + + + + + 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 + + + + + CCAP0H + desc CCAP0H + 0x24 + 32 + read-write + 0x0 + 0xFF + + + CCAP0 + desc CCAP0 + 7 + 0 + read-write + + + + + CCAP0L + desc CCAP0L + 0x28 + 32 + read-write + 0x0 + 0xFF + + + CCAP0 + desc CCAP0 + 7 + 0 + read-write + + + + + CCAP1H + desc CCAP1H + 0x2C + 32 + read-write + 0x0 + 0xFF + + + CCAP1 + desc CCAP1 + 7 + 0 + read-write + + + + + CCAP1L + desc CCAP1L + 0x30 + 32 + read-write + 0x0 + 0xFF + + + CCAP1 + desc CCAP1 + 7 + 0 + read-write + + + + + CCAP2H + desc CCAP2H + 0x34 + 32 + read-write + 0x0 + 0xFF + + + CCAP2 + desc CCAP2 + 7 + 0 + read-write + + + + + CCAP2L + desc CCAP2L + 0x38 + 32 + read-write + 0x0 + 0xFF + + + CCAP2 + desc CCAP2 + 7 + 0 + read-write + + + + + CCAP3H + desc CCAP3H + 0x3C + 32 + read-write + 0x0 + 0xFF + + + CCAP3 + desc CCAP3 + 7 + 0 + read-write + + + + + CCAP3L + desc CCAP3L + 0x40 + 32 + read-write + 0x0 + 0xFF + + + CCAP3 + desc CCAP3 + 7 + 0 + read-write + + + + + CCAP4H + desc CCAP4H + 0x44 + 32 + read-write + 0x0 + 0xFF + + + CCAP4 + desc CCAP4 + 7 + 0 + read-write + + + + + CCAP4L + desc CCAP4L + 0x48 + 32 + read-write + 0x0 + 0xFF + + + CCAP4 + desc CCAP4 + 7 + 0 + 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 + + + + + CCAP0 + desc CCAP0 + 0x50 + 32 + read-write + 0x0 + 0xFFFF + + + CCAP0 + desc CCAP0 + 15 + 0 + read-write + + + + + CCAP1 + desc CCAP1 + 0x54 + 32 + read-write + 0x0 + 0xFFFF + + + CCAP1 + desc CCAP1 + 15 + 0 + read-write + + + + + CCAP2 + desc CCAP2 + 0x58 + 32 + read-write + 0x0 + 0xFFFF + + + CCAP2 + desc CCAP2 + 15 + 0 + read-write + + + + + CCAP3 + desc CCAP3 + 0x5C + 32 + read-write + 0x0 + 0xFFFF + + + CCAP3 + desc CCAP3 + 15 + 0 + read-write + + + + + CCAP4 + desc CCAP4 + 0x60 + 32 + read-write + 0x0 + 0xFFFF + + + CCAP4 + desc CCAP4 + 15 + 0 + read-write + + + + + + + RAM + desc RAM + 0x40020400 + + 0x0 + 0x10 + + + + CR + desc CR + 0x0 + 32 + read-write + 0x0 + 0x3 + + + CHKEN + desc CHKEN + 0 + 0 + read-write + + + IE + desc IE + 1 + 1 + read-write + + + + + ERRADDR + desc ERRADDR + 0x4 + 32 + read-only + 0x0 + 0xFFF + + + ERRADDR + desc ERRADDR + 11 + 0 + read-only + + + + + IFR + desc IFR + 0x8 + 32 + read-only + 0x0 + 0x1 + + + ERR + desc ERR + 0 + 0 + read-only + + + + + ICLR + desc ICLR + 0xC + 32 + read-only + 0x0 + 0x1 + + + ERRCLR + desc ERRCLR + 0 + 0 + write-only + + + + + + + RESET + desc RESET + 0x4000201C + + 0x0 + 0xF + + + + RESET_FLAG + desc RESET_FLAG + 0x0 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + 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 + + + + + PREI_RESET + desc PREI_RESET + 0xC + 32 + read-write + 0xD7B3C757 + 0x97A34553 + + + UART0 + desc UART0 + 0 + 0 + read-write + + + UART1 + desc UART1 + 1 + 1 + read-write + + + I2C + desc I2C + 4 + 4 + read-write + + + SPI + desc SPI + 6 + 6 + read-write + + + BASETIM + desc BASETIM + 8 + 8 + read-write + + + ADVTIM + desc ADVTIM + 10 + 10 + read-write + + + PCA + desc PCA + 14 + 14 + read-write + + + ADC + desc ADC + 16 + 16 + read-write + + + VC + desc VC + 17 + 17 + read-write + + + TRIM + desc TRIM + 21 + 21 + read-write + + + TICK + desc TICK + 24 + 24 + read-write + + + CRC + desc CRC + 26 + 26 + read-write + + + GPIO + desc GPIO + 28 + 28 + read-write + + + + + + + SPI + desc SPI + 0x40000800 + + 0x0 + 0x10 + + + + 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 + + + + + SSN + desc SSN + 0x4 + 32 + read-write + 0x0 + 0x1 + + + SSN + desc SSN + 0 + 0 + read-write + + + + + STAT + desc STAT + 0x8 + 32 + read-only + 0x0 + 0xF0 + + + MDF + desc MDF + 4 + 4 + read-only + + + SSERR + desc SSERR + 5 + 5 + read-only + + + WCOL + desc WCOL + 6 + 6 + read-only + + + SPIF + desc SPIF + 7 + 7 + read-only + + + + + DATA + desc DATA + 0xC + 32 + read-write + 0x0 + 0xFF + + + SPDAT + desc SPDAT + 7 + 0 + read-write + + + + + + + UART0 + desc UART + 0x40000000 + + 0x0 + 0x15 + + + + SBUF + desc SBUF + 0x0 + 32 + read-write + 0x0 + 0xFF + + + SBUF + desc SBUF + 7 + 0 + read-write + + + + + SCON + desc SCON + 0x4 + 32 + read-write + 0x0 + 0x2FF + + + RIEN + desc RIEN + 0 + 0 + read-write + + + TIEN + desc TIEN + 1 + 1 + read-write + + + RB8 + desc RB8 + 2 + 2 + read-write + + + TB8 + desc TB8 + 3 + 3 + read-write + + + REN + desc REN + 4 + 4 + read-write + + + SM2 + desc SM2 + 5 + 5 + read-write + + + SM01 + desc SM01 + 7 + 6 + read-write + + + DBAUD + desc DBAUD + 9 + 9 + read-write + + + + + SADDR + desc SADDR + 0x8 + 32 + read-write + 0x0 + 0xFF + + + SADDR + desc SADDR + 7 + 0 + read-write + + + + + SADEN + desc SADEN + 0xC + 32 + read-write + 0x0 + 0xFF + + + SADEN + desc SADEN + 7 + 0 + read-write + + + + + ISR + desc ISR + 0x10 + 32 + read-only + 0x0 + 0xF + + + RI + desc RI + 0 + 0 + read-only + + + TI + desc TI + 1 + 1 + read-only + + + FE + desc FE + 2 + 2 + read-only + + + TE + desc TE + 3 + 3 + read-only + + + + + ICR + desc ICR + 0x14 + 32 + write-only + 0x0 + 0x7 + + + RICLR + desc RICLR + 0 + 0 + read-write + + + TICLR + desc TICLR + 1 + 1 + read-write + + + FECLR + desc FECLR + 2 + 2 + write-only + + + + + + + UART1 + desc UART + 0x40000100 + + 0x0 + 0x15 + + + + VC + desc VC + 0x40002400 + ADC + + 0x0 + 0x28 + + + + CR + desc CR + 0x10 + 32 + read-write + 0x20 + 0xFFFF + + + 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 + + + + + VC0_CR + desc VC0_CR + 0x14 + 32 + read-write + 0x0 + 0xFFFF + + + EN + desc EN + 0 + 0 + read-write + + + P_SEL + desc P_SEL + 3 + 1 + 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 + + + + + VC1_CR + desc VC1_CR + 0x18 + 32 + read-write + 0x0 + 0xFFFF + + + EN + desc EN + 0 + 0 + read-write + + + P_SEL + desc P_SEL + 3 + 1 + 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 + + + + + VC0_OUT_CFG + desc VC0_OUT_CFG + 0x1C + 32 + read-write + 0x0 + 0xFFFF + + + INV_TIMER + desc INV_TIMER + 0 + 0 + read-write + + + TIM0G + desc TIM0G + 1 + 1 + read-write + + + TIM1G + desc TIM1G + 2 + 2 + read-write + + + TIM2G + desc TIM2G + 3 + 3 + read-write + + + INV_PCA + desc INV_PCA + 6 + 6 + read-write + + + PCACAP0 + desc PCACAP0 + 7 + 7 + read-write + + + PCAECI + desc PCAECI + 8 + 8 + 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 + + + + + VC1_OUT_CFG + desc VC1_OUT_CFG + 0x20 + 32 + read-write + 0x0 + 0xFFFF + + + INV_TIMER + desc INV_TIMER + 0 + 0 + read-write + + + TIM0G + desc TIM0G + 1 + 1 + read-write + + + TIM1G + desc TIM1G + 2 + 2 + read-write + + + TIM2G + desc TIM2G + 3 + 3 + read-write + + + INV_PCA + desc INV_PCA + 6 + 6 + read-write + + + PCACAP0 + desc PCACAP0 + 7 + 7 + read-write + + + PCAECI + desc PCAECI + 8 + 8 + 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 + + + + + IFR + desc IFR + 0x24 + 32 + read-write + 0x0 + 0xF + + + 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 + + + + + + + WDT + desc WDT + 0x40000C00 + BT0 + + 0x0 + 0x86 + + + + RST + desc RST + 0x80 + 32 + write-only + 0x0 + 0xFF + + + WDTRST + desc WDTRST + 7 + 0 + write-only + + + + + CON + desc CON + 0x84 + 32 + read-write + 0xF + 0xFFBF + + + WOV + desc WOV + 3 + 0 + read-write + + + WDTR + desc WDTR + 4 + 4 + read-only + + + WINT_EN + desc WINT_EN + 5 + 5 + read-write + + + WDINT + desc WDINT + 7 + 7 + read-only + + + WCNTL + desc WCNTL + 15 + 8 + read-only + + + + + + + diff --git a/project/mcu/EWARM/config/flashloader/FlashHC32F003.flash b/project/mcu/EWARM/config/flashloader/FlashHC32F003.flash new file mode 100644 index 0000000..c76ef9f --- /dev/null +++ b/project/mcu/EWARM/config/flashloader/FlashHC32F003.flash @@ -0,0 +1,10 @@ + + + + $TOOLKIT_DIR$\config\flashloader\HDSC\FlashHC32F003.out + 1 + 32 0x200 + 0x00000000 + $TOOLKIT_DIR$\config\flashloader\HDSC\FlashHC32F003.mac + 0 + diff --git a/project/mcu/EWARM/config/flashloader/FlashHC32F003.mac b/project/mcu/EWARM/config/flashloader/FlashHC32F003.mac new file mode 100644 index 0000000..b321dac --- /dev/null +++ b/project/mcu/EWARM/config/flashloader/FlashHC32F003.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/project/mcu/EWARM/config/flashloader/HC32F003.board b/project/mcu/EWARM/config/flashloader/HC32F003.board new file mode 100644 index 0000000..78dba89 --- /dev/null +++ b/project/mcu/EWARM/config/flashloader/HC32F003.board @@ -0,0 +1,8 @@ + + + + + $TOOLKIT_DIR$\config\flashloader\HDSC\FlashHC32F003.flash + CODE 0x00000000 0x00003FFF + + diff --git a/project/mcu/EWARM/config/reset.mac b/project/mcu/EWARM/config/reset.mac new file mode 100644 index 0000000..8604cd0 --- /dev/null +++ b/project/mcu/EWARM/config/reset.mac @@ -0,0 +1,8 @@ +execUserReset() +{ + __message("Executing __hwReset"); + __hwReset(0); + __message("__hwReset done"); + + __hwResetWithStrategy(0, 2); +} diff --git a/project/mcu/MDK/HDSC_HC32F003.SFR b/project/mcu/MDK/HDSC_HC32F003.SFR new file mode 100644 index 0000000000000000000000000000000000000000..0a9d5223303f8fa4e987762e60e858faac02b57b GIT binary patch literal 261255 zcmce<37lM2l|Npu-qxMY(g`HS0Zp7i9i1_zIxEABkm~9rZ7S)Su5R4W;3y;fhZ$!; ze>jVP3X1!_FSvvIt|)G}FCZ$Sg2*D9C?K22X8M25J@>wQ?z>xcOK3kIHC3m+-*?Zw z=X~$}j#$-bH14|o{OcE;@s`iLCI2b>E6Y|KT{arKCZClw8gtL?|LY0k<6~?8diy^d z)jx92W4i0tZ#rtj=Dj<|;s5NN>`WZ>oD-h=AOCh#?}TSR^SRG>&QaTsJK^6?din{+ z9Ch3?kJZe%Vc-!d8{z-Cg~O zE)e`37U0CS8`iBG^OBJ9+Q!Lc-pKN*DD{$zM zDsL`3R_?!6Fn8ZPTY-8a!w08#kAeqXS+r-j zi)enNh~}0*oP}XH+!ifTa1d?}Atz`3ZM(t8k0u|t#@4NC1wwk;?!lZqvfrJ2{XCtl zp2%?W<=s9yIh~vU7aT$!_J`TzMA*GcmkJ>8?f1LKAnq_Ex0#9QK4wed;I*w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F$>J5W59E{4aEg5~Mrl~DZFRB;Q{F|Lb+C@oOOlr9wwX`wn+r;AY? z9bGIjKppQ+mx4O>aFk93?@yP4IzFaLWh+n}pGX&@IzE*yMs<89U5x7ZT&lQ@>eyQs z3sKsjj(v5hXh<8?v46T4)p3w6mKdOpW7DOejuRZEQ^85;Qc%Ykx>U9T)p2&Z7}arJ zx){}QVY(RAaZ##x6xDH=E*7GUf;z6!rJ^CDsE+H>#i))Ob+N<%b=;pW1$8{=D4hx( zN|%B<9@nL^6{wCU)5WNcKc$ON9nYnUQ5`Sp;#hPN_%M7BG)v>ycR=SM%h_PDFjd}S z^yBGrM&C`9w;BE3>2gMYSgL%K(O;G>XY{w|a;_VZ-7F}LW9xAxhKYs6klDD3A**o} zj|Q=;cq~{bif@0%r{R7P_O7seKR>r-cKurTFO_@Lcxh0!iePvSby0*={PB3JkUguk z&?;oQSfmSUut$I?(GJ@yz9AOjaKEE2i(u1WeiAc6$UDYSFVJjWxCR`otPAmkGR_l% zP?s@6rtMf4HaO%&cg;w!&{f$XIcwNwOl#-9sgXc*j zkZ+rlQu5hsQcAwaOiIbeejOi&g-@bR2&mOnX8ggFl6fMH=T(LC@X%1{+@H~op#L(qd= G@c#kX1fx*^ literal 0 HcmV?d00001 diff --git a/project/mcu/MDK/config/Flash_HC32F003.FLM b/project/mcu/MDK/config/Flash_HC32F003.FLM new file mode 100644 index 0000000000000000000000000000000000000000..759dcb33aa209b3e144d423959a0c4e0319ca0a3 GIT binary patch literal 16960 zcmeHOdvF`adH)t5AXubKiqz9ql%qu1lubea2)<;!C=e83@c|R0q}Z@eAOMPxKmfr* zqFg^@*AFG*ruNkCq*J$}CeFle`$y~6P1|uYisMPzv@>?6aqA}eLz(GJlWC?^rXH8m zDp7ym-tFCyq9dhoGj)b1ANKox-($c1c5iQQmwq%lG9-i`b-AdW6nAbv(M8E?D!(~i#LO1gJpN1ClluWcXk z47Hy8D`^v2*d}fKusP>DN9VS{>NdY+wQb=xY4xA4Z5V1C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oy@A3!Cy)$#`3^q87#-DaDk(`)}CUx~h0>O@)^8j0J z$MH$F;m+8LGicl0jo4t18dH~yjJH%q1EqYelC*pbV$Q?r8S zQfa4FsWx4Jg9`aEEmu?1D63^z7K&Bar;RrX;8{~3-^XF=?QE=>c-@5cW`N(}{J#FK zxt3DvDPH42rm_4+FZRPXZ+G&=b=vD$V;#siuK`&PD>f;A7mTwWMXxpWcyE~F;utwD zbt%2g0N9_p9%{y3G%q~OOUZ5ruV@w>*n~eUbpVRwxE0NM&!B=nbD_h$k{xi+jK8@9 z|Iax$%Dj}`2zW)a=%JnX&Ts&VL zT?^3TLtSnP{`67ioYVOTZb#TOiv>69sY{Vh0pM>Gb-mk*KMhw5O4T3FfL1mveh+#- XRD;4HdjYhw-b+~6UjU{q<>P+<&}Z#~ literal 0 HcmV?d00001 diff --git a/project/mcu/common/HC32F003.h b/project/mcu/common/HC32F003.h new file mode 100644 index 0000000..4febdae --- /dev/null +++ b/project/mcu/common/HC32F003.h @@ -0,0 +1,3334 @@ +/******************************************************************************* +* 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 HC32F003.h +** +** Auto generate. +** Headerfile for HC32F003 series MCU +** +** History: +** +** - 2018-09-14 0.1 First version for Device Driver Library of Module. +** +******************************************************************************/ + +#ifndef __HC32F003_H__ +#define __HC32F003_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 */ + + PORT0_IRQn = 0 , + PORT1_IRQn = 1 , + PORT2_IRQn = 2 , + PORT3_IRQn = 3 , + UART0_IRQn = 6 , + UART1_IRQn = 7 , + SPI_IRQn = 10, + I2C_IRQn = 12, + TIM0_IRQn = 14, + TIM1_IRQn = 15, + TIM2_IRQn = 16, + TIM4_IRQn = 18, + TIM5_IRQn = 19, + TIM6_IRQn = 20, + PCA_IRQn = 21, + WDT_IRQn = 22, + ADC_IRQn = 24, + VC0_IRQn = 26, + VC1_IRQn = 27, + LVD_IRQn = 28, + FLASH_RAM_IRQn = 30, + CLK_TRIM_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 ADCEN : 1; + __IO uint32_t START : 1; + __IO uint32_t CLKSEL : 2; + __IO uint32_t SEL : 4; + __IO uint32_t SREF : 2; + __IO uint32_t BUFEN : 1; + __IO uint32_t SAM : 2; + uint32_t RESERVED13 : 1; + __IO uint32_t IE : 1; + __IO uint32_t STATERST : 1; +} stc_adc_cr0_field_t; + +typedef struct +{ + __IO uint32_t TRIGS0 : 5; + __IO uint32_t TRIGS1 : 5; + __IO uint32_t CT : 1; + __IO uint32_t RACC_EN : 1; + __IO uint32_t LTCMP : 1; + __IO uint32_t HTCMP : 1; + __IO uint32_t REGCMP : 1; + __IO uint32_t RACC_CLR : 1; +} stc_adc_cr1_field_t; + +typedef struct +{ + __IO uint32_t CH0EN : 1; + __IO uint32_t CH1EN : 1; + __IO uint32_t CH2EN : 1; + __IO uint32_t CH3EN : 1; + __IO uint32_t CH4EN : 1; + __IO uint32_t CH5EN : 1; + __IO uint32_t CH6EN : 1; + __IO uint32_t CH7EN : 1; + __IO uint32_t ADCCNT : 8; +} stc_adc_cr2_field_t; + +typedef struct +{ + __IO uint32_t RESULT0 :12; +} stc_adc_result0_field_t; + +typedef struct +{ + __IO uint32_t RESULT1 :12; +} stc_adc_result1_field_t; + +typedef struct +{ + __IO uint32_t RESULT2 :12; +} stc_adc_result2_field_t; + +typedef struct +{ + __IO uint32_t RESULT3 :12; +} stc_adc_result3_field_t; + +typedef struct +{ + __IO uint32_t RESULT4 :12; +} stc_adc_result4_field_t; + +typedef struct +{ + __IO uint32_t RESULT5 :12; +} stc_adc_result5_field_t; + +typedef struct +{ + __IO uint32_t RESULT6 :12; +} stc_adc_result6_field_t; + +typedef struct +{ + __IO uint32_t RESULT7 :12; +} stc_adc_result7_field_t; + +typedef struct +{ + __IO uint32_t RESULT8 :12; +} stc_adc_result8_field_t; + +typedef struct +{ + __IO uint32_t RESULT_ACC :20; +} stc_adc_result_acc_field_t; + +typedef struct +{ + __IO uint32_t HT :12; +} stc_adc_ht_field_t; + +typedef struct +{ + __IO uint32_t LT :12; +} stc_adc_lt_field_t; + +typedef struct +{ + __IO uint32_t LLT_INTF : 1; + __IO uint32_t HHT_INTF : 1; + __IO uint32_t REG_INTF : 1; + __IO uint32_t CONT_INTF : 1; +} stc_adc_ifr_field_t; + +typedef struct +{ + __IO uint32_t LLT_INTC : 1; + __IO uint32_t HHT_INTC : 1; + __IO uint32_t REG_INTC : 1; + __IO uint32_t CONT_INTC : 1; +} stc_adc_iclr_field_t; + +typedef struct +{ + __IO uint32_t RESULT :12; +} stc_adc_result_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; +} stc_adt_cnter_field_t; + +typedef struct +{ + __IO uint32_t PERA :16; +} stc_adt_perar_field_t; + +typedef struct +{ + __IO uint32_t PERB :16; +} stc_adt_perbr_field_t; + +typedef struct +{ + __IO uint32_t GCMA :16; +} stc_adt_gcmar_field_t; + +typedef struct +{ + __IO uint32_t GCMB :16; +} stc_adt_gcmbr_field_t; + +typedef struct +{ + __IO uint32_t GCMC :16; +} stc_adt_gcmcr_field_t; + +typedef struct +{ + __IO uint32_t GCMD :16; +} stc_adt_gcmdr_field_t; + +typedef struct +{ + __IO uint32_t DTUA :16; +} stc_adt_dtuar_field_t; + +typedef struct +{ + __IO uint32_t DTDA :16; +} stc_adt_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; +} stc_adt_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; +} stc_adt_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; +} stc_adt_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; +} stc_adt_bconr_field_t; + +typedef struct +{ + __IO uint32_t DTCEN : 1; + uint32_t RESERVED1 : 7; + __IO uint32_t SEPA : 1; +} stc_adt_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; +} stc_adt_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; +} stc_adt_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; + uint32_t RESERVED9 :12; + __IO uint32_t VPERNUM : 3; + uint32_t RESERVED24 : 7; + __IO uint32_t DIRF : 1; +} stc_adt_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_adt_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_adt_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_adt_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; +} stc_adt_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; +} stc_adt_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; +} stc_adt_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; +} stc_adt_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; +} stc_adt_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; +} stc_adt_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; +} stc_adt_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; +} stc_adt_aossr_field_t; + +typedef struct +{ + __IO uint32_t FBRAKE : 1; + __IO uint32_t FSAME : 1; +} stc_adt_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; +} stc_adt_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; +} stc_adt_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; +} stc_adt_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; +} stc_adt_ptbkp_field_t; + +typedef struct +{ + __IO uint32_t SSTA0 : 1; + __IO uint32_t SSTA1 : 1; + __IO uint32_t SSTA2 : 1; +} stc_adt_sstar_field_t; + +typedef struct +{ + __IO uint32_t SSTP0 : 1; + __IO uint32_t SSTP1 : 1; + __IO uint32_t SSTP2 : 1; +} stc_adt_sstpr_field_t; + +typedef struct +{ + __IO uint32_t SCLR0 : 1; + __IO uint32_t SCLR1 : 1; + __IO uint32_t SCLR2 : 1; +} stc_adt_sclrr_field_t; + +typedef struct +{ + __IO uint32_t BGR_EN : 1; + __IO uint32_t TS_EN : 1; +} stc_bgr_cr_field_t; + +typedef struct +{ + __IO uint32_t ARR :16; +} stc_bt_arr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; +} stc_bt_cnt_field_t; + +typedef struct +{ + __IO uint32_t CNT32 :32; +} stc_bt_cnt32_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 PRS : 3; + uint32_t RESERVED7 : 1; + __IO uint32_t GATE : 1; + __IO uint32_t GATE_P : 1; + __IO uint32_t IE : 1; +} stc_bt_cr_field_t; + +typedef struct +{ + __IO uint32_t TF : 1; +} stc_bt_ifr_field_t; + +typedef struct +{ + __IO uint32_t TFC : 1; +} stc_bt_iclr_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; +} 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; + uint32_t RESERVED2 : 1; + __IO uint32_t XTH_FAULT : 1; +} stc_clk_trim_ifr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t XTH_FAULT_CLR : 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 RCH_EN : 1; + __IO uint32_t XTH_EN : 1; + __IO uint32_t RCL_EN : 1; + uint32_t RESERVED3 : 1; + __IO uint32_t CLK_SW4_SEL : 2; + __IO uint32_t HCLK_PRS : 3; + __IO uint32_t PCLK_PRS : 2; + uint32_t RESERVED11 : 4; + __IO uint32_t WAKEUP_BYRCH : 1; +} stc_clock_sysctrl0_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t EXTH_EN : 1; + uint32_t RESERVED2 : 2; + __IO uint32_t CLOCK_FT_EN : 1; + uint32_t RESERVED5 : 1; + __IO uint32_t LOCK_EN : 1; + __IO uint32_t RES_UIO : 1; + __IO uint32_t SWD_UIO : 1; +} stc_clock_sysctrl1_field_t; + +typedef struct +{ + __IO uint32_t SYSCTRL2 :16; +} stc_clock_sysctrl2_field_t; + +typedef struct +{ + __IO uint32_t TRIM :11; + __IO uint32_t STABLE : 1; +} stc_clock_rch_cr_field_t; + +typedef struct +{ + __IO uint32_t DRIVER : 4; + __IO uint32_t STARTUP : 2; + __IO uint32_t STABLE : 1; +} stc_clock_xth_cr_field_t; + +typedef struct +{ + __IO uint32_t TRIM :10; + __IO uint32_t STARTUP : 2; + __IO uint32_t STABLE : 1; +} stc_clock_rcl_cr_field_t; + +typedef struct +{ + __IO uint32_t UART0 : 1; + __IO uint32_t UART1 : 1; + uint32_t RESERVED2 : 2; + __IO uint32_t I2C : 1; + uint32_t RESERVED5 : 1; + __IO uint32_t SPI : 1; + uint32_t RESERVED7 : 1; + __IO uint32_t BASETIM : 1; + uint32_t RESERVED9 : 1; + __IO uint32_t ADVTIM : 1; + uint32_t RESERVED11 : 3; + __IO uint32_t PCA : 1; + __IO uint32_t WDT : 1; + __IO uint32_t ADC : 1; + __IO uint32_t VC : 1; + uint32_t RESERVED18 : 3; + __IO uint32_t TRIM : 1; + uint32_t RESERVED22 : 2; + __IO uint32_t TICK : 1; + uint32_t RESERVED25 : 1; + __IO uint32_t CRC : 1; + uint32_t RESERVED27 : 1; + __IO uint32_t GPIO : 1; + uint32_t RESERVED29 : 2; + __IO uint32_t FLASH : 1; +} stc_clock_peri_clken_field_t; + +typedef struct +{ + __IO uint32_t STCALIB :24; + __IO uint32_t SKEW : 1; + __IO uint32_t NOREF : 1; + __IO uint32_t CLK_SEL : 2; +} stc_clock_systick_cr_field_t; + +typedef struct +{ + __IO uint32_t TIM0 : 1; + __IO uint32_t TIM1 : 1; + __IO uint32_t TIM2 : 1; + uint32_t RESERVED3 : 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; + uint32_t RESERVED9 : 1; + __IO uint32_t TICK : 1; +} stc_clock_debug_active_field_t; + +typedef struct +{ + __IO uint32_t RESULT :16; + __IO uint32_t FLAG : 1; +} stc_crc_result_field_t; + +typedef struct +{ + __IO uint32_t DATA :32; +} stc_crc_data_field_t; + +typedef struct +{ + __IO uint32_t TNVS : 9; +} stc_flash_tnvs_field_t; + +typedef struct +{ + __IO uint32_t TPGS : 8; +} stc_flash_tpgs_field_t; + +typedef struct +{ + __IO uint32_t TPROG : 8; +} stc_flash_tprog_field_t; + +typedef struct +{ + __IO uint32_t TSERASE :18; +} stc_flash_tserase_field_t; + +typedef struct +{ + __IO uint32_t TMERASE :21; +} stc_flash_tmerase_field_t; + +typedef struct +{ + __IO uint32_t TPRCV :12; +} stc_flash_tprcv_field_t; + +typedef struct +{ + __IO uint32_t TSRCV :12; +} stc_flash_tsrcv_field_t; + +typedef struct +{ + __IO uint32_t TMRCV :13; +} stc_flash_tmrcv_field_t; + +typedef struct +{ + __IO uint32_t OP : 2; + __IO uint32_t WAIT : 1; + uint32_t RESERVED3 : 1; + __IO uint32_t BUSY : 1; + __IO uint32_t IE : 2; +} stc_flash_cr_field_t; + +typedef struct +{ + __IO uint32_t IF0 : 1; + __IO uint32_t IF1 : 1; +} stc_flash_ifr_field_t; + +typedef struct +{ + __IO uint32_t ICLR0 : 1; + __IO uint32_t ICLR1 : 1; +} stc_flash_iclr_field_t; + +typedef struct +{ + __IO uint32_t BYSEQ :16; +} stc_flash_bypass_field_t; + +typedef struct +{ + __IO uint32_t SLOCK :16; +} stc_flash_slock_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p01_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p02_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p03_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p14_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p15_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p23_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p24_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p25_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p26_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p27_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p31_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p32_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p33_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p34_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p35_sel_field_t; + +typedef struct +{ + __IO uint32_t SEL : 3; +} stc_gpio_p36_sel_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0dir_field_t; + +typedef struct +{ + __IO uint32_t P00 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0in_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0out_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0ads_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0dr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0pu_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0pd_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0od_field_t; + +typedef struct +{ + __IO uint32_t P00 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0hie_field_t; + +typedef struct +{ + __IO uint32_t P00 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0lie_field_t; + +typedef struct +{ + __IO uint32_t P00 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0rie_field_t; + +typedef struct +{ + __IO uint32_t P00 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0fie_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1dir_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1in_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1out_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1ads_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1dr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1pu_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1pd_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1od_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1hie_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1lie_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1rie_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1fie_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2dir_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2in_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2out_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2ads_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2dr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2pu_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2pd_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2od_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2hie_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2lie_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2rie_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2fie_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3dir_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3in_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3out_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3ads_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3dr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3pu_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3pd_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3od_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3hie_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3lie_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3rie_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3fie_field_t; + +typedef struct +{ + __IO uint32_t P00 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0stat_field_t; + +typedef struct +{ + __IO uint32_t P00 : 1; + __IO uint32_t P01 : 1; + __IO uint32_t P02 : 1; + __IO uint32_t P03 : 1; +} stc_gpio_p0iclr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1stat_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t P14 : 1; + __IO uint32_t P15 : 1; +} stc_gpio_p1iclr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2stat_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t P23 : 1; + __IO uint32_t P24 : 1; + __IO uint32_t P25 : 1; + __IO uint32_t P26 : 1; + __IO uint32_t P27 : 1; +} stc_gpio_p2iclr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3stat_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t P31 : 1; + __IO uint32_t P32 : 1; + __IO uint32_t P33 : 1; + __IO uint32_t P34 : 1; + __IO uint32_t P35 : 1; + __IO uint32_t P36 : 1; +} stc_gpio_p3iclr_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 SSN_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; +} stc_gpio_ctrl1_field_t; + +typedef struct +{ + __IO uint32_t PCA_CAP0_SEL : 2; + __IO uint32_t PCA_CAP1_SEL : 2; + __IO uint32_t PCA_CAP2_SEL : 2; + __IO uint32_t PCA_CAP3_SEL : 2; + __IO uint32_t PCA_CAP4_SEL : 2; +} stc_gpio_ctrl2_field_t; + +typedef struct +{ + __IO uint32_t TM4_B_SEL : 2; + __IO uint32_t TM5_B_SEL : 2; + __IO uint32_t TM6_B_SEL : 2; + __IO uint32_t TM4_A_SEL : 2; + __IO uint32_t TM5_A_SEL : 2; + __IO uint32_t TM6_A_SEL : 2; +} stc_gpio_ctrl3_field_t; + +typedef struct +{ + __IO uint32_t TM0_GATE_SEL : 2; + __IO uint32_t TM1_GATE_SEL : 2; + __IO uint32_t TM2_GATE_SEL : 2; + __IO uint32_t TM3_GATE_SEL : 2; +} stc_gpio_ctrl4_field_t; + +typedef struct +{ + __IO uint32_t TME : 1; +} stc_i2c_tmrun_field_t; + +typedef struct +{ + __IO uint32_t TM : 8; +} 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; +} stc_i2c_cr_field_t; + +typedef struct +{ + __IO uint32_t I2CDAT : 8; +} stc_i2c_data_field_t; + +typedef struct +{ + __IO uint32_t GC : 1; + __IO uint32_t I2CADR : 7; +} stc_i2c_addr_field_t; + +typedef struct +{ + __IO uint32_t I2CSTA : 8; +} stc_i2c_stat_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; +} stc_lvd_cr_field_t; + +typedef struct +{ + __IO uint32_t INTF : 1; +} stc_lvd_ifr_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; +} 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; +} stc_pca_cmod_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; +} 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; +} 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; +} 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; +} 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; +} 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; +} 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; +} stc_pca_ccapm4_field_t; + +typedef struct +{ + __IO uint32_t CCAP0 : 8; +} stc_pca_ccap0h_field_t; + +typedef struct +{ + __IO uint32_t CCAP0 : 8; +} stc_pca_ccap0l_field_t; + +typedef struct +{ + __IO uint32_t CCAP1 : 8; +} stc_pca_ccap1h_field_t; + +typedef struct +{ + __IO uint32_t CCAP1 : 8; +} stc_pca_ccap1l_field_t; + +typedef struct +{ + __IO uint32_t CCAP2 : 8; +} stc_pca_ccap2h_field_t; + +typedef struct +{ + __IO uint32_t CCAP2 : 8; +} stc_pca_ccap2l_field_t; + +typedef struct +{ + __IO uint32_t CCAP3 : 8; +} stc_pca_ccap3h_field_t; + +typedef struct +{ + __IO uint32_t CCAP3 : 8; +} stc_pca_ccap3l_field_t; + +typedef struct +{ + __IO uint32_t CCAP4 : 8; +} stc_pca_ccap4h_field_t; + +typedef struct +{ + __IO uint32_t CCAP4 : 8; +} 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; +} stc_pca_ccapo_field_t; + +typedef struct +{ + __IO uint32_t CCAP0 :16; +} stc_pca_ccap0_field_t; + +typedef struct +{ + __IO uint32_t CCAP1 :16; +} stc_pca_ccap1_field_t; + +typedef struct +{ + __IO uint32_t CCAP2 :16; +} stc_pca_ccap2_field_t; + +typedef struct +{ + __IO uint32_t CCAP3 :16; +} stc_pca_ccap3_field_t; + +typedef struct +{ + __IO uint32_t CCAP4 :16; +} stc_pca_ccap4_field_t; + +typedef struct +{ + __IO uint32_t CHKEN : 1; + __IO uint32_t IE : 1; +} stc_ram_cr_field_t; + +typedef struct +{ + __IO uint32_t ERRADDR :12; +} stc_ram_erraddr_field_t; + +typedef struct +{ + __IO uint32_t ERR : 1; +} stc_ram_ifr_field_t; + +typedef struct +{ + __IO uint32_t ERRCLR : 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; +} stc_reset_reset_flag_field_t; + +typedef struct +{ + __IO uint32_t UART0 : 1; + __IO uint32_t UART1 : 1; + uint32_t RESERVED2 : 2; + __IO uint32_t I2C : 1; + uint32_t RESERVED5 : 1; + __IO uint32_t SPI : 1; + uint32_t RESERVED7 : 1; + __IO uint32_t BASETIM : 1; + uint32_t RESERVED9 : 1; + __IO uint32_t ADVTIM : 1; + uint32_t RESERVED11 : 3; + __IO uint32_t PCA : 1; + uint32_t RESERVED15 : 1; + __IO uint32_t ADC : 1; + __IO uint32_t VC : 1; + uint32_t RESERVED18 : 3; + __IO uint32_t TRIM : 1; + uint32_t RESERVED22 : 2; + __IO uint32_t TICK : 1; + uint32_t RESERVED25 : 1; + __IO uint32_t CRC : 1; + uint32_t RESERVED27 : 1; + __IO uint32_t GPIO : 1; +} stc_reset_prei_reset_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; +} stc_spi_cr_field_t; + +typedef struct +{ + __IO uint32_t SSN : 1; +} stc_spi_ssn_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t MDF : 1; + __IO uint32_t SSERR : 1; + __IO uint32_t WCOL : 1; + __IO uint32_t SPIF : 1; +} stc_spi_stat_field_t; + +typedef struct +{ + __IO uint32_t SPDAT : 8; +} stc_spi_data_field_t; + +typedef struct +{ + __IO uint32_t SBUF : 8; +} stc_uart_sbuf_field_t; + +typedef struct +{ + __IO uint32_t RIEN : 1; + __IO uint32_t TIEN : 1; + __IO uint32_t RB8 : 1; + __IO uint32_t TB8 : 1; + __IO uint32_t REN : 1; + __IO uint32_t SM2 : 1; + __IO uint32_t SM01 : 2; + uint32_t RESERVED8 : 1; + __IO uint32_t DBAUD : 1; +} stc_uart_scon_field_t; + +typedef struct +{ + __IO uint32_t SADDR : 8; +} stc_uart_saddr_field_t; + +typedef struct +{ + __IO uint32_t SADEN : 8; +} stc_uart_saden_field_t; + +typedef struct +{ + __IO uint32_t RI : 1; + __IO uint32_t TI : 1; + __IO uint32_t FE : 1; + __IO uint32_t TE : 1; +} stc_uart_isr_field_t; + +typedef struct +{ + __IO uint32_t RICLR : 1; + __IO uint32_t TICLR : 1; + __IO uint32_t FECLR : 1; +} stc_uart_icr_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; +} stc_vc_cr_field_t; + +typedef struct +{ + __IO uint32_t EN : 1; + __IO uint32_t P_SEL : 3; + __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; +} stc_vc_vc0_cr_field_t; + +typedef struct +{ + __IO uint32_t EN : 1; + __IO uint32_t P_SEL : 3; + __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; +} stc_vc_vc1_cr_field_t; + +typedef struct +{ + __IO uint32_t INV_TIMER : 1; + __IO uint32_t TIM0G : 1; + __IO uint32_t TIM1G : 1; + __IO uint32_t TIM2G : 1; + uint32_t RESERVED4 : 2; + __IO uint32_t INV_PCA : 1; + __IO uint32_t PCACAP0 : 1; + __IO uint32_t PCAECI : 1; + __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; +} stc_vc_vc0_out_cfg_field_t; + +typedef struct +{ + __IO uint32_t INV_TIMER : 1; + __IO uint32_t TIM0G : 1; + __IO uint32_t TIM1G : 1; + __IO uint32_t TIM2G : 1; + uint32_t RESERVED4 : 2; + __IO uint32_t INV_PCA : 1; + __IO uint32_t PCACAP0 : 1; + __IO uint32_t PCAECI : 1; + __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; +} 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; +} stc_vc_ifr_field_t; + +typedef struct +{ + __IO uint32_t WDTRST : 8; +} stc_wdt_rst_field_t; + +typedef struct +{ + __IO uint32_t WOV : 4; + __IO uint32_t WDTR : 1; + __IO uint32_t WINT_EN : 1; + uint32_t RESERVED6 : 1; + __IO uint32_t WDINT : 1; + __IO uint32_t WCNTL : 8; +} 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; + }; + union + { + __IO uint32_t CR2; + stc_adc_cr2_field_t CR2_f; + }; + uint8_t RESERVED3[32]; + union + { + __IO uint32_t RESULT0; + stc_adc_result0_field_t RESULT0_f; + }; + union + { + __IO uint32_t RESULT1; + stc_adc_result1_field_t RESULT1_f; + }; + union + { + __IO uint32_t RESULT2; + stc_adc_result2_field_t RESULT2_f; + }; + union + { + __IO uint32_t RESULT3; + stc_adc_result3_field_t RESULT3_f; + }; + union + { + __IO uint32_t RESULT4; + stc_adc_result4_field_t RESULT4_f; + }; + union + { + __IO uint32_t RESULT5; + stc_adc_result5_field_t RESULT5_f; + }; + union + { + __IO uint32_t RESULT6; + stc_adc_result6_field_t RESULT6_f; + }; + union + { + __IO uint32_t RESULT7; + stc_adc_result7_field_t RESULT7_f; + }; + union + { + __IO uint32_t RESULT8; + stc_adc_result8_field_t RESULT8_f; + }; + union + { + __IO uint32_t RESULT_ACC; + stc_adc_result_acc_field_t RESULT_ACC_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 ICLR; + stc_adc_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t RESULT; + stc_adc_result_field_t RESULT_f; + }; +}M0P_ADC_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CNTER; + stc_adt_cnter_field_t CNTER_f; + }; + union + { + __IO uint32_t PERAR; + stc_adt_perar_field_t PERAR_f; + }; + union + { + __IO uint32_t PERBR; + stc_adt_perbr_field_t PERBR_f; + }; + uint8_t RESERVED3[4]; + union + { + __IO uint32_t GCMAR; + stc_adt_gcmar_field_t GCMAR_f; + }; + union + { + __IO uint32_t GCMBR; + stc_adt_gcmbr_field_t GCMBR_f; + }; + union + { + __IO uint32_t GCMCR; + stc_adt_gcmcr_field_t GCMCR_f; + }; + union + { + __IO uint32_t GCMDR; + stc_adt_gcmdr_field_t GCMDR_f; + }; + uint8_t RESERVED7[32]; + union + { + __IO uint32_t DTUAR; + stc_adt_dtuar_field_t DTUAR_f; + }; + union + { + __IO uint32_t DTDAR; + stc_adt_dtdar_field_t DTDAR_f; + }; + uint8_t RESERVED9[8]; + union + { + __IO uint32_t GCONR; + stc_adt_gconr_field_t GCONR_f; + }; + union + { + __IO uint32_t ICONR; + stc_adt_iconr_field_t ICONR_f; + }; + union + { + __IO uint32_t PCONR; + stc_adt_pconr_field_t PCONR_f; + }; + union + { + __IO uint32_t BCONR; + stc_adt_bconr_field_t BCONR_f; + }; + union + { + __IO uint32_t DCONR; + stc_adt_dconr_field_t DCONR_f; + }; + uint8_t RESERVED14[4]; + union + { + __IO uint32_t FCONR; + stc_adt_fconr_field_t FCONR_f; + }; + union + { + __IO uint32_t VPERR; + stc_adt_vperr_field_t VPERR_f; + }; + union + { + __IO uint32_t STFLR; + stc_adt_stflr_field_t STFLR_f; + }; + union + { + __IO uint32_t HSTAR; + stc_adt_hstar_field_t HSTAR_f; + }; + union + { + __IO uint32_t HSTPR; + stc_adt_hstpr_field_t HSTPR_f; + }; + union + { + __IO uint32_t HCELR; + stc_adt_hcelr_field_t HCELR_f; + }; + union + { + __IO uint32_t HCPAR; + stc_adt_hcpar_field_t HCPAR_f; + }; + union + { + __IO uint32_t HCPBR; + stc_adt_hcpbr_field_t HCPBR_f; + }; + union + { + __IO uint32_t HCUPR; + stc_adt_hcupr_field_t HCUPR_f; + }; + union + { + __IO uint32_t HCDOR; + stc_adt_hcdor_field_t HCDOR_f; + }; + uint8_t RESERVED24[112]; + union + { + __IO uint32_t IFR; + stc_adt_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_adt_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t CR; + stc_adt_cr_field_t CR_f; + }; + uint8_t RESERVED27[4]; + union + { + __IO uint32_t AOSSR; + stc_adt_aossr_field_t AOSSR_f; + }; + union + { + __IO uint32_t AOSCL; + stc_adt_aoscl_field_t AOSCL_f; + }; + union + { + __IO uint32_t PTBKS; + stc_adt_ptbks_field_t PTBKS_f; + }; + union + { + __IO uint32_t TTRIG; + stc_adt_ttrig_field_t TTRIG_f; + }; + union + { + __IO uint32_t ITRIG; + stc_adt_itrig_field_t ITRIG_f; + }; + union + { + __IO uint32_t PTBKP; + stc_adt_ptbkp_field_t PTBKP_f; + }; + uint8_t RESERVED33[716]; + union + { + __IO uint32_t SSTAR; + stc_adt_sstar_field_t SSTAR_f; + }; + union + { + __IO uint32_t SSTPR; + stc_adt_sstpr_field_t SSTPR_f; + }; + union + { + __IO uint32_t SCLRR; + stc_adt_sclrr_field_t SCLRR_f; + }; +}M0P_ADT_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CR; + stc_bgr_cr_field_t CR_f; + }; +}M0P_BGR_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t ARR; + stc_bt_arr_field_t ARR_f; + }; + union + { + __IO uint32_t CNT; + stc_bt_cnt_field_t CNT_f; + }; + union + { + __IO uint32_t CNT32; + stc_bt_cnt32_field_t CNT32_f; + }; + union + { + __IO uint32_t CR; + stc_bt_cr_field_t CR_f; + }; + union + { + __IO uint32_t IFR; + stc_bt_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_bt_iclr_field_t ICLR_f; + }; +}M0P_BT_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 SYSCTRL0; + stc_clock_sysctrl0_field_t SYSCTRL0_f; + }; + union + { + __IO uint32_t SYSCTRL1; + stc_clock_sysctrl1_field_t SYSCTRL1_f; + }; + union + { + __IO uint32_t SYSCTRL2; + stc_clock_sysctrl2_field_t SYSCTRL2_f; + }; + union + { + __IO uint32_t RCH_CR; + stc_clock_rch_cr_field_t RCH_CR_f; + }; + union + { + __IO uint32_t XTH_CR; + stc_clock_xth_cr_field_t XTH_CR_f; + }; + union + { + __IO uint32_t RCL_CR; + stc_clock_rcl_cr_field_t RCL_CR_f; + }; + uint8_t RESERVED6[8]; + union + { + __IO uint32_t PERI_CLKEN; + stc_clock_peri_clken_field_t PERI_CLKEN_f; + }; + uint8_t RESERVED7[16]; + union + { + __IO uint32_t SYSTICK_CR; + stc_clock_systick_cr_field_t SYSTICK_CR_f; + }; + union + { + __IO uint32_t DEBUG_ACTIVE; + stc_clock_debug_active_field_t DEBUG_ACTIVE_f; + }; +}M0P_CLOCK_TypeDef; + +typedef struct +{ + uint8_t RESERVED0[4]; + union + { + __IO uint32_t RESULT; + stc_crc_result_field_t RESULT_f; + }; + uint8_t RESERVED1[120]; + union + { + __IO uint32_t DATA; + stc_crc_data_field_t DATA_f; + }; +}M0P_CRC_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 SLOCK; + stc_flash_slock_field_t SLOCK_f; + }; +}M0P_FLASH_TypeDef; + +typedef struct +{ + uint8_t RESERVED0[4]; + union + { + __IO uint32_t P01_SEL; + stc_gpio_p01_sel_field_t P01_SEL_f; + }; + union + { + __IO uint32_t P02_SEL; + stc_gpio_p02_sel_field_t P02_SEL_f; + }; + union + { + __IO uint32_t P03_SEL; + stc_gpio_p03_sel_field_t P03_SEL_f; + }; + uint8_t RESERVED3[64]; + union + { + __IO uint32_t P14_SEL; + stc_gpio_p14_sel_field_t P14_SEL_f; + }; + union + { + __IO uint32_t P15_SEL; + stc_gpio_p15_sel_field_t P15_SEL_f; + }; + uint8_t RESERVED5[52]; + union + { + __IO uint32_t P23_SEL; + stc_gpio_p23_sel_field_t P23_SEL_f; + }; + union + { + __IO uint32_t P24_SEL; + stc_gpio_p24_sel_field_t P24_SEL_f; + }; + union + { + __IO uint32_t P25_SEL; + stc_gpio_p25_sel_field_t P25_SEL_f; + }; + union + { + __IO uint32_t P26_SEL; + stc_gpio_p26_sel_field_t P26_SEL_f; + }; + union + { + __IO uint32_t P27_SEL; + stc_gpio_p27_sel_field_t P27_SEL_f; + }; + uint8_t RESERVED10[36]; + union + { + __IO uint32_t P31_SEL; + stc_gpio_p31_sel_field_t P31_SEL_f; + }; + union + { + __IO uint32_t P32_SEL; + stc_gpio_p32_sel_field_t P32_SEL_f; + }; + union + { + __IO uint32_t P33_SEL; + stc_gpio_p33_sel_field_t P33_SEL_f; + }; + union + { + __IO uint32_t P34_SEL; + stc_gpio_p34_sel_field_t P34_SEL_f; + }; + union + { + __IO uint32_t P35_SEL; + stc_gpio_p35_sel_field_t P35_SEL_f; + }; + union + { + __IO uint32_t P36_SEL; + stc_gpio_p36_sel_field_t P36_SEL_f; + }; + uint8_t RESERVED16[36]; + union + { + __IO uint32_t P0DIR; + stc_gpio_p0dir_field_t P0DIR_f; + }; + union + { + __IO uint32_t P0IN; + stc_gpio_p0in_field_t P0IN_f; + }; + union + { + __IO uint32_t P0OUT; + stc_gpio_p0out_field_t P0OUT_f; + }; + union + { + __IO uint32_t P0ADS; + stc_gpio_p0ads_field_t P0ADS_f; + }; + uint8_t RESERVED20[12]; + union + { + __IO uint32_t P0DR; + stc_gpio_p0dr_field_t P0DR_f; + }; + union + { + __IO uint32_t P0PU; + stc_gpio_p0pu_field_t P0PU_f; + }; + union + { + __IO uint32_t P0PD; + stc_gpio_p0pd_field_t P0PD_f; + }; + uint8_t RESERVED23[4]; + union + { + __IO uint32_t P0OD; + stc_gpio_p0od_field_t P0OD_f; + }; + union + { + __IO uint32_t P0HIE; + stc_gpio_p0hie_field_t P0HIE_f; + }; + union + { + __IO uint32_t P0LIE; + stc_gpio_p0lie_field_t P0LIE_f; + }; + union + { + __IO uint32_t P0RIE; + stc_gpio_p0rie_field_t P0RIE_f; + }; + union + { + __IO uint32_t P0FIE; + stc_gpio_p0fie_field_t P0FIE_f; + }; + union + { + __IO uint32_t P1DIR; + stc_gpio_p1dir_field_t P1DIR_f; + }; + union + { + __IO uint32_t P1IN; + stc_gpio_p1in_field_t P1IN_f; + }; + union + { + __IO uint32_t P1OUT; + stc_gpio_p1out_field_t P1OUT_f; + }; + union + { + __IO uint32_t P1ADS; + stc_gpio_p1ads_field_t P1ADS_f; + }; + uint8_t RESERVED32[12]; + union + { + __IO uint32_t P1DR; + stc_gpio_p1dr_field_t P1DR_f; + }; + union + { + __IO uint32_t P1PU; + stc_gpio_p1pu_field_t P1PU_f; + }; + union + { + __IO uint32_t P1PD; + stc_gpio_p1pd_field_t P1PD_f; + }; + uint8_t RESERVED35[4]; + union + { + __IO uint32_t P1OD; + stc_gpio_p1od_field_t P1OD_f; + }; + union + { + __IO uint32_t P1HIE; + stc_gpio_p1hie_field_t P1HIE_f; + }; + union + { + __IO uint32_t P1LIE; + stc_gpio_p1lie_field_t P1LIE_f; + }; + union + { + __IO uint32_t P1RIE; + stc_gpio_p1rie_field_t P1RIE_f; + }; + union + { + __IO uint32_t P1FIE; + stc_gpio_p1fie_field_t P1FIE_f; + }; + union + { + __IO uint32_t P2DIR; + stc_gpio_p2dir_field_t P2DIR_f; + }; + union + { + __IO uint32_t P2IN; + stc_gpio_p2in_field_t P2IN_f; + }; + union + { + __IO uint32_t P2OUT; + stc_gpio_p2out_field_t P2OUT_f; + }; + union + { + __IO uint32_t P2ADS; + stc_gpio_p2ads_field_t P2ADS_f; + }; + uint8_t RESERVED44[12]; + union + { + __IO uint32_t P2DR; + stc_gpio_p2dr_field_t P2DR_f; + }; + union + { + __IO uint32_t P2PU; + stc_gpio_p2pu_field_t P2PU_f; + }; + union + { + __IO uint32_t P2PD; + stc_gpio_p2pd_field_t P2PD_f; + }; + uint8_t RESERVED47[4]; + union + { + __IO uint32_t P2OD; + stc_gpio_p2od_field_t P2OD_f; + }; + union + { + __IO uint32_t P2HIE; + stc_gpio_p2hie_field_t P2HIE_f; + }; + union + { + __IO uint32_t P2LIE; + stc_gpio_p2lie_field_t P2LIE_f; + }; + union + { + __IO uint32_t P2RIE; + stc_gpio_p2rie_field_t P2RIE_f; + }; + union + { + __IO uint32_t P2FIE; + stc_gpio_p2fie_field_t P2FIE_f; + }; + union + { + __IO uint32_t P3DIR; + stc_gpio_p3dir_field_t P3DIR_f; + }; + union + { + __IO uint32_t P3IN; + stc_gpio_p3in_field_t P3IN_f; + }; + union + { + __IO uint32_t P3OUT; + stc_gpio_p3out_field_t P3OUT_f; + }; + union + { + __IO uint32_t P3ADS; + stc_gpio_p3ads_field_t P3ADS_f; + }; + uint8_t RESERVED56[12]; + union + { + __IO uint32_t P3DR; + stc_gpio_p3dr_field_t P3DR_f; + }; + union + { + __IO uint32_t P3PU; + stc_gpio_p3pu_field_t P3PU_f; + }; + union + { + __IO uint32_t P3PD; + stc_gpio_p3pd_field_t P3PD_f; + }; + uint8_t RESERVED59[4]; + union + { + __IO uint32_t P3OD; + stc_gpio_p3od_field_t P3OD_f; + }; + union + { + __IO uint32_t P3HIE; + stc_gpio_p3hie_field_t P3HIE_f; + }; + union + { + __IO uint32_t P3LIE; + stc_gpio_p3lie_field_t P3LIE_f; + }; + union + { + __IO uint32_t P3RIE; + stc_gpio_p3rie_field_t P3RIE_f; + }; + union + { + __IO uint32_t P3FIE; + stc_gpio_p3fie_field_t P3FIE_f; + }; + union + { + __IO uint32_t P0STAT; + stc_gpio_p0stat_field_t P0STAT_f; + }; + uint8_t RESERVED65[12]; + union + { + __IO uint32_t P0ICLR; + stc_gpio_p0iclr_field_t P0ICLR_f; + }; + uint8_t RESERVED66[44]; + union + { + __IO uint32_t P1STAT; + stc_gpio_p1stat_field_t P1STAT_f; + }; + uint8_t RESERVED67[12]; + union + { + __IO uint32_t P1ICLR; + stc_gpio_p1iclr_field_t P1ICLR_f; + }; + uint8_t RESERVED68[44]; + union + { + __IO uint32_t P2STAT; + stc_gpio_p2stat_field_t P2STAT_f; + }; + uint8_t RESERVED69[12]; + union + { + __IO uint32_t P2ICLR; + stc_gpio_p2iclr_field_t P2ICLR_f; + }; + uint8_t RESERVED70[44]; + union + { + __IO uint32_t P3STAT; + stc_gpio_p3stat_field_t P3STAT_f; + }; + uint8_t RESERVED71[12]; + union + { + __IO uint32_t P3ICLR; + stc_gpio_p3iclr_field_t P3ICLR_f; + }; + uint8_t RESERVED72[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 CTRL3; + stc_gpio_ctrl3_field_t CTRL3_f; + }; + union + { + __IO uint32_t CTRL4; + stc_gpio_ctrl4_field_t CTRL4_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 +{ + 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 +{ + 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; + }; +}M0P_PCA_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_reset_flag_field_t RESET_FLAG_f; + }; + uint8_t RESERVED1[8]; + union + { + __IO uint32_t PREI_RESET; + stc_reset_prei_reset_field_t PREI_RESET_f; + }; +}M0P_RESET_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; + }; +}M0P_SPI_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; + }; +}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; + }; +}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_ADC ((M0P_ADC_TypeDef *)0x40002400UL) +#define M0P_ADT0 ((M0P_ADT_TypeDef *)0x40003000UL) +#define M0P_ADT1 ((M0P_ADT_TypeDef *)0x40003400UL) +#define M0P_ADT2 ((M0P_ADT_TypeDef *)0x40003800UL) +#define M0P_BGR ((M0P_BGR_TypeDef *)0x40002400UL) +#define M0P_BT0 ((M0P_BT_TypeDef *)0x40000C00UL) +#define M0P_BT1 ((M0P_BT_TypeDef *)0x40000C20UL) +#define M0P_BT2 ((M0P_BT_TypeDef *)0x40000C40UL) +#define M0P_CLK_TRIM ((M0P_CLK_TRIM_TypeDef *)0x40001800UL) +#define M0P_CLOCK ((M0P_CLOCK_TypeDef *)0x40002000UL) +#define M0P_CRC ((M0P_CRC_TypeDef *)0x40020900UL) +#define M0P_FLASH ((M0P_FLASH_TypeDef *)0x40020000UL) +#define M0P_GPIO ((M0P_GPIO_TypeDef *)0x40020C00UL) +#define M0P_I2C ((M0P_I2C_TypeDef *)0x40000400UL) +#define M0P_LVD ((M0P_LVD_TypeDef *)0x40002400UL) +#define M0P_PCA ((M0P_PCA_TypeDef *)0x40001000UL) +#define M0P_RAM ((M0P_RAM_TypeDef *)0x40020400UL) +#define M0P_RESET ((M0P_RESET_TypeDef *)0x4000201CUL) +#define M0P_SPI ((M0P_SPI_TypeDef *)0x40000800UL) +#define M0P_UART0 ((M0P_UART_TypeDef *)0x40000000UL) +#define M0P_UART1 ((M0P_UART_TypeDef *)0x40000100UL) +#define M0P_VC ((M0P_VC_TypeDef *)0x40002400UL) +#define M0P_WDT ((M0P_WDT_TypeDef *)0x40000C00UL) + + +#ifdef __cplusplus +} +#endif + +#endif /* __HC32F003_H__ */ + diff --git a/project/mcu/common/base_types.h b/project/mcu/common/base_types.h new file mode 100644 index 0000000..54534fb --- /dev/null +++ b/project/mcu/common/base_types.h @@ -0,0 +1,154 @@ +/******************************************************************************* +* 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 base_types.h + ** + ** Interrupt common define. + ** @link SampleGroup Some description @endlink + ** + ** - 2016-02-16 1.0 QianCP First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +#ifndef __BASE_TYPES_H__ +#define __BASE_TYPES_H__ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include +#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 + +#if defined (__ICCARM__) +#define __WEAKDEF __WEAK __ATTRIBUTES +#elif defined (__CC_ARM) +#define __WEAKDEF __weak +#else +#error "unsupported compiler!!" +#endif + +///< \todo keil version + +/** Returns the minimum value out of two values */ +#define min( X, Y ) ((X) < (Y) ? (X) : (Y)) + +/** Returns the maximum value out of two values */ +#define max( 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; + +/** ASCCI 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 progres +} 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/project/mcu/common/system_hc32f003.c b/project/mcu/common/system_hc32f003.c new file mode 100644 index 0000000..3b9a250 --- /dev/null +++ b/project/mcu/common/system_hc32f003.c @@ -0,0 +1,98 @@ +/******************************************************************************* +* 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 system_hc32f003.c + ** + ** System clock initialization. + ** @link SampleGroup Some description @endlink + ** + ** - 2018-01-30 1.0 Lux First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "base_types.h" +#include "hc32f003.h" +#include "system_hc32f003.h" +#include "ddl.h" + +/** + ****************************************************************************** + ** System Clock Frequency (Core Clock) Variable according CMSIS + ******************************************************************************/ +uint32_t SystemCoreClock = 4000000; + + +//add clock source. +void SystemCoreClockUpdate (void) // Update SystemCoreClock variable +{ + SystemCoreClock = Clk_GetHClkFreq(); +} + +/** + ****************************************************************************** + ** \brief Setup the microcontroller system. Initialize the System and update + ** the SystemCoreClock variable. + ** + ** \param none + ** \return none + ******************************************************************************/ +void SystemInit(void) +{ + stc_clk_systickcfg_t stcCfg; + + // TODO load trim from flash + //hcr 4MHz manual trim. + Clk_SetRCHFreq(ClkFreq4Mhz); + Clk_Enable(ClkRCH, TRUE); + + SystemCoreClockUpdate(); + + DDL_ZERO_STRUCT(stcCfg); + stcCfg.bNoRef = TRUE; + stcCfg.u32LoadVal = 0xFFFFFF; + Clk_SysTickConfig(&stcCfg); +} + + diff --git a/project/mcu/common/system_hc32f003.h b/project/mcu/common/system_hc32f003.h new file mode 100644 index 0000000..58d19ba --- /dev/null +++ b/project/mcu/common/system_hc32f003.h @@ -0,0 +1,102 @@ +/******************************************************************************* +* 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 system_hc32f003.h + ** + ** A detailed description is available at + ** @link SampleGroup Some description @endlink + ** + ** - 2018-02-01 1.0 Lux First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +#ifndef __SYSTEM_HC32F003_H__ +#define __SYSTEM_HC32F003_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 + + +/******************************************************************************/ +/* */ +/* 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_HC32F003_H__ */ diff --git a/src/gcc_template/src/main.c b/src/gcc_template/src/main.c index dd55fa9..b3238e7 100644 --- a/src/gcc_template/src/main.c +++ b/src/gcc_template/src/main.c @@ -6,30 +6,18 @@ #include "HC32F005.h" #include "task.h" -static void App_LedInit(void) -{ - stc_gpio_cfg_t stcGpioCfg; - ///< 打开GPIO外设时钟门控 - Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); - stcGpioCfg.enDir = GpioDirOut; - stcGpioCfg.enPu = GpioPuDisable; - stcGpioCfg.enPd = GpioPdEnable; - Gpio_WriteOutputIO(GpioPort0, GpioPin3, FALSE); - Gpio_Init(GpioPort0, GpioPin3, &stcGpioCfg); -} - void idle_task(void *param) { while (1) { __asm volatile("nop"); vTaskDelay(500); - Gpio_WriteOutputIO(GpioPort0, GpioPin3, FALSE); - vTaskDelay(500); - Gpio_WriteOutputIO(GpioPort0, GpioPin3, TRUE); + // Gpio_WriteOutputIO(GpioPort0, GpioPin3, 0); + // vTaskDelay(500); + // Gpio_WriteOutputIO(GpioPort0, GpioPin3, 1); } } int main(void) { - App_LedInit(); + sysctl_peri_clock_enable(PERI_CLK_GPIO); xTaskCreate(idle_task, "idle_task", configMINIMAL_STACK_SIZE, 0, 0, 0); vTaskStartScheduler(); }