diff --git a/.github/workflows/src.yml b/.github/workflows/src.yml index 1e9f554..8072760 100644 --- a/.github/workflows/src.yml +++ b/.github/workflows/src.yml @@ -29,4 +29,4 @@ jobs: - uses: actions/upload-artifact@v2 with: name: gcc_template - path: src/gcc_template + path: src/gcc_template/build diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..ee02cec --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,21 @@ +.pio/ +.vscode/ +*.bin +*.out +*.o +~$* +*.dep +*.log +*.ewt +*.ewd +*.sfr +*.icf +*uvgui* +*uvopt* +*.txt +*.ini +RTE +output +config +settings +flashloader diff --git a/src/hc32f005_ddl/driver/inc/adc.h b/src/hc32f005_ddl/driver/inc/adc.h new file mode 100644 index 0000000..1431bf0 --- /dev/null +++ b/src/hc32f005_ddl/driver/inc/adc.h @@ -0,0 +1,369 @@ +/****************************************************************************** +* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file adc.h + ** + ** Header file for AD Converter functions + ** @link ADC Group Some description @endlink + ** + ** - 2017-06-28 Alex First Version + ** + ******************************************************************************/ + +#ifndef __ADC_H__ +#define __ADC_H__ + + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "ddl.h" + +/* C binding of definitions if building with C++ compiler */ +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + ****************************************************************************** + ** \defgroup AdcGroup AD Converter (ADC) + ** + ******************************************************************************/ + +//@{ + +/****************************************************************************** + * Global definitions + ******************************************************************************/ +#define ADC_SCAN_CH0_EN (0x1u) /*!< SCAN模式使用ADC CH0 */ +#define ADC_SCAN_CH1_EN (0x1u<<1) /*!< SCAN模式使用ADC CH1 */ +#define ADC_SCAN_CH2_EN (0x1u<<2) /*!< SCAN模式使用ADC CH2 */ +#define ADC_SCAN_CH3_EN (0x1u<<3) /*!< SCAN模式使用ADC CH3 */ +#define ADC_SCAN_CH4_EN (0x1u<<4) /*!< SCAN模式使用ADC CH4 */ +#define ADC_SCAN_CH5_EN (0x1u<<5) /*!< SCAN模式使用ADC CH5 */ +#define ADC_SCAN_CH6_EN (0x1u<<6) /*!< SCAN模式使用ADC CH6 */ +#define ADC_SCAN_CH7_EN (0x1u<<7) /*!< SCAN模式使用ADC CH7 */ + + +/****************************************************************************** + ** Global type definitions + *****************************************************************************/ + + /** + ****************************************************************************** + ** \brief ADC采样模式 + *****************************************************************************/ +typedef enum en_adc_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, /*!>4)*10) + ((x)&0x0F)) + +/** + ****************************************************************************** + ** Global Device Series List + ******************************************************************************/ +#define DDL_DEVICE_SERIES_HC32F005 (0u) + +/** + ****************************************************************************** + ** Global Device Package List + ******************************************************************************/ +// package definitions of HC device. +#define DDL_DEVICE_PACKAGE_HC_C (0x00u) +#define DDL_DEVICE_PACKAGE_HC_F (0x10u) +#define DDL_DEVICE_PACKAGE_HC_J (0x20u) +#define DDL_DEVICE_PACKAGE_HC_K (0x30u) + +/******************************************************************************/ +/* User Device Setting Include file */ +/******************************************************************************/ +#include "ddl_device.h" // MUST be included here! + +/******************************************************************************/ +/* Global type definitions ('typedef') */ +/******************************************************************************/ +/** + ****************************************************************************** + ** \brief Level + ** + ** Specifies levels. + ** + ******************************************************************************/ +typedef enum en_level +{ + DdlLow = 0u, ///< Low level '0' + DdlHigh = 1u ///< High level '1' +} en_level_t; + +/** + ****************************************************************************** + ** \brief Generic Flag Code + ** + ** Specifies flags. + ** + ******************************************************************************/ +typedef enum en_flag +{ + DdlClr = 0u, ///< Flag clr '0' + DdlSet = 1u ///< Flag set '1' +} en_stat_flag_t, en_irq_flag_t; +/******************************************************************************/ +/* Global variable declarations ('extern', definition in C source) */ +/******************************************************************************/ + +/******************************************************************************/ +/* Global function prototypes ('extern', definition in C source) */ +/******************************************************************************/ + +/******************************************************************************* + * Global function prototypes + ******************************************************************************/ +extern void ddl_memclr(void* pu8Address, uint32_t u32Count); +uint32_t Log2(uint32_t u32Val); +/** + ******************************************************************************* + ** This hook is part of wait loops. + ******************************************************************************/ +extern void DDL_WAIT_LOOP_HOOK(void); + +void Debug_UartInit(void); + +void delay1ms(uint32_t u32Cnt); +void delay100us(uint32_t u32Cnt); +void delay10us(uint32_t u32Cnt); +void SetBit(uint32_t addr, uint32_t offset, boolean_t bFlag); +void ClrBit(uint32_t addr, uint32_t offset); +boolean_t GetBit(uint32_t addr, uint32_t offset); +#ifdef __cplusplus +} +#endif + +#endif /* __DDL_H__ */ + +/******************************************************************************/ +/* EOF (not truncated) */ +/******************************************************************************/ + diff --git a/src/hc32f005_ddl/driver/inc/flash.h b/src/hc32f005_ddl/driver/inc/flash.h new file mode 100644 index 0000000..7ece2b2 --- /dev/null +++ b/src/hc32f005_ddl/driver/inc/flash.h @@ -0,0 +1,158 @@ +/************************************************************************************* +* 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 +{ + FlashPCInt = 0x01u, ///<擦写PC地址报警中断 + FlashSlockInt = 0x02u, ///<擦写保护报警中断 +} en_flash_int_type_t; + + +/** + ****************************************************************************** + ** \brief Flash读等待周期类型重定义 + *****************************************************************************/ +typedef enum en_flash_waitcycle +{ + FlashWaitCycle0 = 0u, ///< 读等待周期设置为0(当HCLK小于等于24MHz时) + FlashWaitCycle1 = 1u, ///< 读等待周期设置为1(当HCLK大于24MHz时必须至少为1) +} en_flash_waitcycle_t; + + + +/** + ****************************************************************************** + ** \brief Redefinition of FLASH register structure + ******************************************************************************/ + +/****************************************************************************** + * Global definitions + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions ('extern') + ******************************************************************************/ + +/****************************************************************************** + * Global function prototypes (definition in C source) + ******************************************************************************/ +///PCLK=HCLK=SystemClk=RCH4MHz +en_result_t Sysctrl_ClkDeInit(void); + +///< 系统时钟模块的基本功能设置 +///< 注意:使能需要使用的时钟源之前,必须优先设置目标内部时钟源的TRIM值或外部时钟源的频率范围 +en_result_t Sysctrl_ClkSourceEnable(en_sysctrl_clk_source_t enSource, boolean_t bFlag); + +///<外部晶振驱动配置:系统初始化Sysctrl_ClkInit()之后,可根据需要配置外部晶振的驱动能力,时钟初始化Sysctrl_ClkInit()默认为最大值; +en_result_t Sysctrl_XTHDriverCfg(en_sysctrl_xtal_driver_t enDriver); + +///<时钟稳定周期设置:系统初始化Sysctrl_ClkInit()之后,可根据需要配置时钟开启后的稳定之间,默认为最大值; +en_result_t Sysctrl_SetXTHStableTime(en_sysctrl_xth_cycle_t enCycle); +en_result_t Sysctrl_SetRCLStableTime(en_sysctrl_rcl_cycle_t enCycle); + +///<系统时钟源切换并更新系统时钟:如果需要在系统时钟初始化Sysctrl_ClkInit()之后切换主频时钟源,则使用该函数; +///< 时钟切换前后,必须根据目标频率值设置Flash读等待周期,可配置插入周期为0、1、2, +///< 注意!!!:当HCLK大于24MHz时,FLASH等待周期插入必须至少为1,否则程序运行可能产生未知错误 +en_result_t Sysctrl_SysClkSwitch(en_sysctrl_clk_source_t enSource); + +///< 时钟源频率设定:根据系统情况,单独设置不同时钟源的频率值; +///< 时钟频率设置前,必须根据目标频率值设置Flash读等待周期,可配置插入周期为0、1、2, +///< 其中XTL的时钟由外部晶振决定,无需设置。 +en_result_t Sysctrl_SetRCHTrim(en_sysctrl_rch_freq_t enRCHFreq); +en_result_t Sysctrl_SetRCLTrim(en_sysctrl_rcl_freq_t enRCLFreq); +en_result_t Sysctrl_SetXTHFreq(en_sysctrl_xth_freq_t enXTHFreq); + +///< 时钟分频设置:根据系统情况,单独设置HCLK、PCLK的分配值; +en_result_t Sysctrl_SetHCLKDiv(en_sysctrl_hclk_div_t enHCLKDiv); +en_result_t Sysctrl_SetPCLKDiv(en_sysctrl_pclk_div_t enPCLKDiv); + +///< 时钟频率获取:根据系统需要,获取当前HCLK及PCLK的频率值 +uint32_t Sysctrl_GetHClkFreq(void); +uint32_t Sysctrl_GetPClkFreq(void); + +///< 外设门控开关/状态获取:用于控制外设模块的使能,使用该模块的功能之前,必须使能该模块的门控时钟; +en_result_t Sysctrl_SetPeripheralGate(en_sysctrl_peripheral_gate_t enPeripheral, boolean_t bFlag); +boolean_t Sysctrl_GetPeripheralGate(en_sysctrl_peripheral_gate_t enPeripheral); + +///< 系统功能配置:用于设置其他系统相关特殊功能; +en_result_t Sysctrl_SetFunc(en_sysctrl_func_t enFunc, boolean_t bFlag); + + +//@} // Sysctrl Group + +#ifdef __cplusplus +#endif + +#endif /* __SYSCTRL_H__ */ +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/driver/inc/trim.h b/src/hc32f005_ddl/driver/inc/trim.h new file mode 100644 index 0000000..6558b55 --- /dev/null +++ b/src/hc32f005_ddl/driver/inc/trim.h @@ -0,0 +1,182 @@ +/****************************************************************************** +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/*****************************************************************************/ +/** \file trim.h + ** + ** TRIM 数据结构及API声明 + ** + ** + ** History: + ** - 2018-04-21 Lux V1.0 + ** + *****************************************************************************/ + +#ifndef __TRIM_H__ +#define __TRIM_H__ + +/***************************************************************************** + * Include files + *****************************************************************************/ +#include "ddl.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + ****************************************************************************** + ** \defgroup TrimGroup Clock Trimming (TRIM) + ** + ******************************************************************************/ +//@{ + +/****************************************************************************** + ** Global pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global type definitions + ******************************************************************************/ + + /** + ****************************************************************************** + ** \brief 监测模式使能枚举重定义 (MON_EN) + *****************************************************************************/ +typedef enum en_trim_monitor +{ + TrimMonDisable = 0u, ///< 禁止 + TrimMonEnable = 0x40u, ///< 使能 +}en_trim_monitor_t; + + /** + ****************************************************************************** + ** \brief 待校准/监测时钟选择枚举重定义 (CALCLK_SEL) + *****************************************************************************/ +typedef enum en_trim_calclksel +{ + TrimCalMskRCH = 0x000u, ///< RCH + TrimCalMskXTH = 0x010u, ///< XTH + TrimCalMskRCL = 0x020u, ///< RCL + TrimCalMskXTL = 0x030u, ///< XTL +}en_trim_calclksel_t; + +/** + ****************************************************************************** + ** \brief 参考时钟选择枚举重定义 (REFCLK_SEL) + *****************************************************************************/ +typedef enum en_trim_refclksel +{ + TrimRefMskRCH = 0x0u, ///< RCH + TrimRefMskXTH = 0x2u, ///< XTH + TrimRefMskRCL = 0x4u, ///< RCL + TrimRefMskXTL = 0x6u, ///< XTL + TrimRefMskIRC10K = 0x8u, ///< IRC10K + TrimRefMskExtClk = 0xau, ///< 外部输入时钟 +}en_trim_refclksel_t; + +/** + ****************************************************************************** + ** \brief 中断标志类型枚举重定义 + *****************************************************************************/ +typedef enum en_trim_inttype +{ + TrimStop = 0x01u, ///< 参考计数器停止标志 + TrimCalCntOf = 0x02u, ///< 校准计数器溢出标志 + TrimXTLFault = 0x04u, ///< XTL 失效标志 + TrimXTHFault = 0x08u, ///< XTH 失效标志 +}en_trim_inttype_t; + +/** + ****************************************************************************** + ** \brief TRIM 配置结构体定义 + *****************************************************************************/ +typedef struct stc_trim_cfg +{ + en_trim_monitor_t enMON; ///< 监测模式使能 + en_trim_calclksel_t enCALCLK; ///< 校准时钟选择 + uint32_t u32CalCon; ///< 校准计数器溢出值配置 + en_trim_refclksel_t enREFCLK; ///< 参考时钟选择 + uint32_t u32RefCon; ///< 参考计数器初值配置 +}stc_trim_cfg_t; + +/****************************************************************************** + * Global variable declarations ('extern', definition in C source) + *****************************************************************************/ + +/****************************************************************************** + * Global function prototypes (definition in C source) + *****************************************************************************/ +///<<功能配置及操作函数 +///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; + } + +} + +/** + * \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; +} + +/** + * \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) +{ + Adc_DisableIrq(); + EnableNvic(ADC_IRQn, IrqLevel3, FALSE); + + 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/src/hc32f005_ddl/driver/src/adt.c b/src/hc32f005_ddl/driver/src/adt.c new file mode 100644 index 0000000..24f0827 --- /dev/null +++ b/src/hc32f005_ddl/driver/src/adt.c @@ -0,0 +1,1618 @@ +/****************************************************************************** +* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file adt.c + ** + ** Low Voltage Detect driver API. + ** @link Lvd Group Some description @endlink + ** + ** - 2019-04-19 Husj First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adt.h" + +/** + ****************************************************************************** + ** \addtogroup AdtGroup + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define IS_VALID_ADT_STATE(x) ( AdtCMAF == (x)||\ + AdtCMBF == (x)||\ + AdtCMCF == (x)||\ + AdtCMDF == (x)||\ + AdtOVFF == (x)||\ + AdtUDFF == (x)||\ + AdtDTEF == (x)||\ + AdtCMSAUF == (x)||\ + AdtCMSADF == (x)||\ + AdtCMSBUF == (x)||\ + AdtCMSBDF == (x)||\ + AdtCntDir == (x) ) +#define ADTIM_HW_STASTPCLR_EN 31 +#define ADTIM_HW_STASTPCLR_DIS 0x7FFFFFFF +#define ADTIM_SS_TIM4 1 +#define ADTIM_SS_TIM5 2 +#define ADTIM_SS_TIM6 4 +#define ADTIM_PORT_BKE_NUM 15 +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') * + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/****************************************************************************** + * Local variable definitions ('static') + ******************************************************************************/ + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + *****************************************************************************/ + + + +/***************************************************************** + * \brief + * 配置中断 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtIrq 中断类型 + * \param [in] bEn 中断使能/禁止 + * + * \retval en_result_t Ok: 配置成功 + * + ****************************************************************/ +en_result_t Adt_CfgIrq(M0P_ADTIM_TypeDef *ADTx, + en_adt_irq_type_t enAdtIrq, + boolean_t bEn) +{ + uint32_t u32Val; + + u32Val = ADTx->ICONR; + if (bEn) + { + u32Val |= 1u<ICONR = u32Val; + return Ok; +} + +/******************************************************************* + * \brief + * 获取中断标志 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtIrq 中断类型 + * + * + * \retval TRUE/FALSE + * + *****************************************************************/ +boolean_t Adt_GetIrqFlag(M0P_ADTIM_TypeDef *ADTx, + en_adt_irq_type_t enAdtIrq) +{ + uint32_t u32Val; + boolean_t bEn; + + ASSERT(IS_VALID_ADT_UNIT(enAdtUnit)); + + u32Val = ADTx->IFR; + bEn = (u32Val>>enAdtIrq) & 0x1; + + return bEn; +} + +/**************************************************************** + * \brief + * 清除中断标志 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtIrq 中断类型 + * + * \retval en_result_t Ok: 配置成功 + * + ****************************************************************/ +en_result_t Adt_ClearIrqFlag(M0P_ADTIM_TypeDef *ADTx, + en_adt_irq_type_t enAdtIrq) +{ + ADTx->ICLR = ~(1u<ICLR = 0; + return Ok; +} + +/************************************************************** + * \brief + * 配置硬件递加事件 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtHwCntUp 硬件递加事件 + * + * \retval en_result_t Ok: 设置成功 + * + ****************************************************************/ +en_result_t Adt_CfgHwCntUp(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_cnt_t enAdtHwCntUp) +{ + uint32_t u32Val; + + + if (AdtHwCntMax <= enAdtHwCntUp) + { + return ErrorInvalidParameter; + } + + u32Val = ADTx->HCUPR; + ADTx->HCUPR = u32Val | (1u<HCUPR = 0; + return Ok; +} + + +/********************************************************** + * \brief + * 配置硬件递减事件 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtHwCntDwn 硬件递减事件 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + ***********************************************************/ +en_result_t Adt_CfgHwCntDwn(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_cnt_t enAdtHwCntDwn) +{ + uint32_t u32Val; + + + if(AdtHwCntMax <= enAdtHwCntDwn) + { + return ErrorInvalidParameter; + } + + u32Val = ADTx->HCDOR; + ADTx->HCDOR = u32Val | (1u<HCDOR = 0; + return Ok; +} + +/****************************************************************** + * \brief + * 配置硬件启动事件 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtHwStart 硬件启动事件 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + *******************************************************************/ +en_result_t Adt_CfgHwStart(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwStart) +{ + uint32_t u32Val; + + + if(AdtHwTrigEnd <= enAdtHwStart) + { + return ErrorInvalidParameter; + } + u32Val = ADTx->HSTAR; + ADTx->HSTAR = u32Val | (1u<HSTAR = 0; + return Ok; +} + +/********************************************************************* + * \brief + * 使能硬件启动 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * + * \retval en_result_t Ok: 设置成功 + * + *********************************************************************/ +en_result_t Adt_EnableHwStart(M0P_ADTIM_TypeDef *ADTx) +{ + uint32_t u32Val; + + u32Val = ADTx->HSTAR; + ADTx->HSTAR = u32Val | (1u<HSTAR; + ADTx->HSTAR = u32Val & ADTIM_HW_STASTPCLR_DIS; + return Ok; +} + +/**************************************************************** + * \brief + * 配置硬件停止事件 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtHwStop 硬件停止事件 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + ***************************************************************/ +en_result_t Adt_CfgHwStop(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwStop) +{ + uint32_t u32Val; + + if(AdtHwTrigEnd <= enAdtHwStop) + { + return ErrorInvalidParameter; + } + + u32Val = ADTx->HSTPR; + ADTx->HSTPR = u32Val | (1u<HSTPR = 0; + return Ok; +} + +/************************************************************* + * \brief + * 使能硬件停止 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * + * \retval en_result_t Ok: 设置成功 + * + **********************************************************/ +en_result_t Adt_EnableHwStop(M0P_ADTIM_TypeDef *ADTx) +{ + uint32_t u32Val; + + u32Val = ADTx->HSTPR; + ADTx->HSTPR = u32Val | (1u<HSTPR; + ADTx->HSTPR = u32Val & ADTIM_HW_STASTPCLR_DIS; + return Ok; +} + +/************************************************************************** + * \brief + * 配置硬件清零事件 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtHwClear 硬件清零事件 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + *************************************************************************/ +en_result_t Adt_CfgHwClear(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwClear) +{ + uint32_t u32Val; + + + if(AdtHwTrigEnd <= enAdtHwClear) + { + return ErrorInvalidParameter; + } + + u32Val = ADTx->HCELR; + ADTx->HCELR = u32Val | (1u<HCELR = 0; + return Ok; +} + +/*************************************************************************** + * \brief + * 使能硬件清零 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * + * \retval en_result_t Ok: 设置成功 + * + *************************************************************************/ +en_result_t Adt_EnableHwClear(M0P_ADTIM_TypeDef *ADTx) +{ + uint32_t u32Val; + + u32Val = ADTx->HCELR; + ADTx->HCELR = u32Val | (1u<HCELR; + ADTx->HCELR = u32Val & ADTIM_HW_STASTPCLR_DIS; + return Ok; +} + +/******************************************************************* + * \brief + * 配置硬件捕获A事件 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtHwCaptureA 硬件捕获A事件选择 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + *******************************************************************/ +en_result_t Adt_CfgHwCaptureA(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwCaptureA) +{ + uint32_t u32Val; + + + if(AdtHwTrigEnd <= enAdtHwCaptureA) + { + return ErrorInvalidParameter; + } + + u32Val = ADTx->HCPAR; + ADTx->HCPAR = u32Val | (1u<PCONR_f.CAPCA = 1; + return Ok; +} + +/************************************************************************ + * \brief + * 清除硬件捕获A事件 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * + * \retval en_result_t Ok: 设置成功 + * + ***********************************************************************/ +en_result_t Adt_ClearHwCaptureA(M0P_ADTIM_TypeDef *ADTx) +{ + ADTx->HCPAR = 0; + return Ok; +} + +/********************************************************************* + * \brief + * 配置硬件捕获B事件 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtHwCaptureB 硬件捕获B事件选择 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + ********************************************************************/ +en_result_t Adt_CfgHwCaptureB(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwCaptureB) +{ + uint32_t u32Val; + + + if(AdtHwTrigEnd <= enAdtHwCaptureB) + { + return ErrorInvalidParameter; + } + + u32Val = ADTx->HCPBR; + ADTx->HCPBR = u32Val | (1u<PCONR_f.CAPCB = 1; + return Ok; +} + +/******************************************************************** + * \brief + * 清除硬件捕获B事件 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * + * \retval en_result_t Ok: 设置成功 + * + *******************************************************************/ +en_result_t Adt_ClearHwCaptureB(M0P_ADTIM_TypeDef *ADTx) +{ + ADTx->HCPBR = 0; + return Ok; +} + +/***************************************************************** + * \brief + * 软件同步开始 + * + * \param [in] pstcAdtSwSyncStart 软件同步开始指针 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + ***************************************************************/ +en_result_t Adt_SwSyncStart(stc_adt_sw_sync_t* pstcAdtSwSyncStart) +{ + uint32_t u32Val = 0; + + if (NULL == pstcAdtSwSyncStart) + { + return ErrorInvalidParameter; + } + + if (pstcAdtSwSyncStart->bAdTim4) + { + u32Val |= ADTIM_SS_TIM4; + } + if (pstcAdtSwSyncStart->bAdTim5) + { + u32Val |= ADTIM_SS_TIM5; + } + if (pstcAdtSwSyncStart->bAdTim6) + { + u32Val |= ADTIM_SS_TIM6; + } + + M0P_ADTIM4->SSTAR = u32Val; + return Ok; +} + +/*************************************************************** + * \brief + * 软件同步停止 + * + * \param [in] pstcAdtSwSyncStop 软件同步停止指针 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + ***************************************************************/ +en_result_t Adt_SwSyncStop(stc_adt_sw_sync_t* pstcAdtSwSyncStop) +{ + uint32_t u32Val = 0; + + if (NULL == pstcAdtSwSyncStop) + { + return ErrorInvalidParameter; + } + + if (pstcAdtSwSyncStop->bAdTim4) + { + u32Val |= ADTIM_SS_TIM4; + } + if (pstcAdtSwSyncStop->bAdTim5) + { + u32Val |= ADTIM_SS_TIM5; + } + if (pstcAdtSwSyncStop->bAdTim6) + { + u32Val |= ADTIM_SS_TIM6; + } + + M0P_ADTIM4->SSTPR = u32Val; + return Ok; +} + +/***************************************************************** + * \brief + * 软件同步清零 + * + * \param [in] pstcAdtSwSyncClear 软件同步清零指针 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + *******************************************************************/ +en_result_t Adt_SwSyncClear(stc_adt_sw_sync_t* pstcAdtSwSyncClear) +{ + uint32_t u32Val = 0; + + if (NULL == pstcAdtSwSyncClear) + { + return ErrorInvalidParameter; + } + + if (pstcAdtSwSyncClear->bAdTim4) + { + u32Val |= ADTIM_SS_TIM4; + } + if (pstcAdtSwSyncClear->bAdTim5) + { + u32Val |= ADTIM_SS_TIM5; + } + if (pstcAdtSwSyncClear->bAdTim6) + { + u32Val |= ADTIM_SS_TIM6; + } + + M0P_ADTIM4->SCLRR = u32Val; + return Ok; +} + +/******************************************************************* + * \brief + * 获取软件同步运行状态 + * + * \param [in] pstcAdtSwSyncState ADV Timer软件同步运行状态指针 + * + * \retval en_result_t Ok: 设置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + *******************************************************************/ +en_result_t Adt_GetSwSyncState(stc_adt_sw_sync_t* pstcAdtSwSyncState) +{ + if (NULL == pstcAdtSwSyncState) + { + return ErrorInvalidParameter; + } + + if (M0P_ADTIM4->SSTAR & ADTIM_SS_TIM4) + { + pstcAdtSwSyncState->bAdTim4 = TRUE; + } + else + { + pstcAdtSwSyncState->bAdTim4 = FALSE; + } + if (M0P_ADTIM4->SSTAR & ADTIM_SS_TIM5) + { + pstcAdtSwSyncState->bAdTim5 = TRUE; + } + else + { + pstcAdtSwSyncState->bAdTim5 = FALSE; + } + if (M0P_ADTIM4->SSTAR & ADTIM_SS_TIM6) + { + pstcAdtSwSyncState->bAdTim6 = TRUE; + } + else + { + pstcAdtSwSyncState->bAdTim6 = FALSE; + } + return Ok; +} + +/************************************************************************ + * \brief + * AOS触发配置 + * + * \param [in] pstcAdtAosTrigCfg 触发配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + ************************************************************************/ +en_result_t Adt_AosTrigCfg(stc_adt_aos_trig_cfg_t* pstcAdtAosTrigCfg) +{ + if (NULL == pstcAdtAosTrigCfg) + { + return ErrorInvalidParameter; + } + + M0P_ADTIM4->ITRIG_f.IAOS0S = pstcAdtAosTrigCfg->enAos0TrigSrc; + M0P_ADTIM4->ITRIG_f.IAOS1S = pstcAdtAosTrigCfg->enAos1TrigSrc; + M0P_ADTIM4->ITRIG_f.IAOS2S = pstcAdtAosTrigCfg->enAos2TrigSrc; + M0P_ADTIM4->ITRIG_f.IAOS3S = pstcAdtAosTrigCfg->enAos3TrigSrc; + return Ok; +} + +/********************************************************************** + * \brief + * 中断触发配置 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] pstcAdtIrqTrigCfg 触发配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + ***********************************************************************/ +en_result_t Adt_IrqTrigCfg(M0P_ADTIM_TypeDef *ADTx, + stc_adt_irq_trig_cfg_t* pstcAdtIrqTrigCfg) +{ + if(NULL == pstcAdtIrqTrigCfg) + { + return ErrorInvalidParameter; + } + + ADTx->CR_f.CMAE = pstcAdtIrqTrigCfg->bAdtCntMatchATrigEn; + ADTx->CR_f.CMBE = pstcAdtIrqTrigCfg->bAdtCntMatchBTrigEn; + ADTx->CR_f.CMCE = pstcAdtIrqTrigCfg->bAdtCntMatchCTrigEn; + ADTx->CR_f.CMDE = pstcAdtIrqTrigCfg->bAdtCntMatchDTrigEn; + ADTx->CR_f.OVFE = pstcAdtIrqTrigCfg->bAdtOverFlowTrigEn; + ADTx->CR_f.UDFE = pstcAdtIrqTrigCfg->bAdtUnderFlowTrigEn; + + return Ok; +} + +/************************************************************************* + * \brief + * 端口触发配置 + * + * \param [in] enAdtTrigPort 触发端口 + * \param [in] pstcAdtPortTrigCfg 触发配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + *************************************************************************/ +en_result_t Adt_PortTrigCfg(en_adt_trig_port_t enAdtTrigPort, + stc_adt_port_trig_cfg_t* pstcAdtPortTrigCfg) +{ + if (NULL == pstcAdtPortTrigCfg) + { + return ErrorInvalidParameter; + } + + switch (enAdtTrigPort) + { + case AdtTrigA: + M0P_ADTIM4->TTRIG_f.TRIGAS = pstcAdtPortTrigCfg->enTrigSrc; + M0P_ADTIM4->FCONR_f.NOFIENTA = pstcAdtPortTrigCfg->bFltEn; + M0P_ADTIM4->FCONR_f.NOFICKTA = pstcAdtPortTrigCfg->enFltClk; + break; + + case AdtTrigB: + M0P_ADTIM4->TTRIG_f.TRIGBS = pstcAdtPortTrigCfg->enTrigSrc; + M0P_ADTIM4->FCONR_f.NOFIENTB = pstcAdtPortTrigCfg->bFltEn; + M0P_ADTIM4->FCONR_f.NOFICKTB = pstcAdtPortTrigCfg->enFltClk; + break; + + case AdtTrigC: + M0P_ADTIM4->TTRIG_f.TRIGCS = pstcAdtPortTrigCfg->enTrigSrc; + M0P_ADTIM4->FCONR_f.NOFIENTC = pstcAdtPortTrigCfg->bFltEn; + M0P_ADTIM4->FCONR_f.NOFICKTC = pstcAdtPortTrigCfg->enFltClk; + break; + + case AdtTrigD: + M0P_ADTIM4->TTRIG_f.TRIGDS = pstcAdtPortTrigCfg->enTrigSrc; + M0P_ADTIM4->FCONR_f.NOFIENTD = pstcAdtPortTrigCfg->bFltEn; + M0P_ADTIM4->FCONR_f.NOFICKTD = pstcAdtPortTrigCfg->enFltClk; + break; + + default: + return ErrorInvalidParameter; + } + + return Ok; +} + +/*********************************************************************** + * \brief + * CHxX端口配置 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtCHxXPort CHxX端口 + * \param [in] pstcAdtCHxXCfg CHxX端口配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + *********************************************************************/ +en_result_t Adt_CHxXPortCfg(M0P_ADTIM_TypeDef *ADTx, + en_adt_CHxX_port_t enAdtCHxXPort, + stc_adt_CHxX_port_cfg_t* pstcAdtCHxXCfg) +{ + if(NULL == pstcAdtCHxXCfg) + { + return ErrorInvalidParameter; + } + + switch (enAdtCHxXPort) + { + case AdtCHxA: + ADTx->PCONR_f.CAPCA = pstcAdtCHxXCfg->enCap; + ADTx->PCONR_f.STACA = pstcAdtCHxXCfg->enStaOut; + ADTx->PCONR_f.STPCA = pstcAdtCHxXCfg->enStpOut; + ADTx->PCONR_f.STASTPSA = pstcAdtCHxXCfg->enStaStp; + ADTx->PCONR_f.CMPCA = pstcAdtCHxXCfg->enCmpc; + ADTx->PCONR_f.PERCA = pstcAdtCHxXCfg->enPerc; + ADTx->PCONR_f.OUTENA = pstcAdtCHxXCfg->bOutEn; + ADTx->PCONR_f.DISSELA = pstcAdtCHxXCfg->enDisSel; + ADTx->PCONR_f.DISVALA = pstcAdtCHxXCfg->enDisVal; + ADTx->FCONR_f.NOFIENGA = pstcAdtCHxXCfg->bFltEn; + ADTx->FCONR_f.NOFICKGA = pstcAdtCHxXCfg->enFltClk; + break; + + case AdtCHxB: + ADTx->PCONR_f.CAPCB = pstcAdtCHxXCfg->enCap; + ADTx->PCONR_f.STACB = pstcAdtCHxXCfg->enStaOut; + ADTx->PCONR_f.STPCB = pstcAdtCHxXCfg->enStpOut; + ADTx->PCONR_f.STASTPSB = pstcAdtCHxXCfg->enStaStp; + ADTx->PCONR_f.CMPCB = pstcAdtCHxXCfg->enCmpc; + ADTx->PCONR_f.PERCB = pstcAdtCHxXCfg->enPerc; + ADTx->PCONR_f.OUTENB = pstcAdtCHxXCfg->bOutEn; + ADTx->PCONR_f.DISSELB = pstcAdtCHxXCfg->enDisSel; + ADTx->PCONR_f.DISVALB = pstcAdtCHxXCfg->enDisVal; + ADTx->FCONR_f.NOFIENGB = pstcAdtCHxXCfg->bFltEn; + ADTx->FCONR_f.NOFICKGB = pstcAdtCHxXCfg->enFltClk; + break; + + default: + return ErrorInvalidParameter; + } + + return Ok; +} + +/************************************************************************ + * \brief + * 使能端口刹车 + * + * \param [in] port 端口 + * \param [in] pstcAdtBrkPtCfg 端口刹车配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + ************************************************************************/ +en_result_t Adt_EnableBrakePort(uint8_t port, stc_adt_break_port_cfg_t* pstcAdtBrkPtCfg) +{ + uint32_t u32Val; + + if (NULL == pstcAdtBrkPtCfg) + { + return ErrorInvalidParameter; + } + + u32Val = M0P_ADTIM4->PTBKP; + u32Val &= ~(1u<PTBKP = u32Val | (pstcAdtBrkPtCfg->enPol<PTBKS; + M0P_ADTIM4->PTBKS = u32Val | (1u<PTBKS = 0; +} + +/********************************************************************* + * \brief + * 无效条件3配置 + * + * \param [in] pstcAdtDisable3 无效条件3配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + ********************************************************************/ +en_result_t Adt_Disable3Cfg(stc_adt_disable_3_cfg_t* pstcAdtDisable3) +{ + uint8_t i; + + if (NULL == pstcAdtDisable3) + { + return ErrorInvalidParameter; + } + + Adt_ClearBrakePort(); + for (i = 0; i <= ADTIM_PORT_BKE_NUM; i++) + { + if (TRUE == pstcAdtDisable3->stcBrkPtCfg[i].bPortEn) + { + Adt_EnableBrakePort(i, &pstcAdtDisable3->stcBrkPtCfg[i]); + } + } + + M0P_ADTIM4->AOSSR_f.BFILTEN = pstcAdtDisable3->bFltEn; + M0P_ADTIM4->AOSSR_f.BFILTS = pstcAdtDisable3->enFltClk; + + return Ok; +} + +/********************************************************************* + * \brief 软件刹车 Enable/Disable(仅适用于无效条件3使能的情况下) + * + * \param [in] bSwBrk 软件刹车使能/禁止 + * + * \retval en_result_t Ok: 配置成功 + ********************************************************************/ +en_result_t Adt_SwBrake(boolean_t bSwBrk) +{ + M0P_ADTIM4->AOSSR_f.SOFTBK = bSwBrk; + + return Ok; +} + +/******************************************************************* + * \brief + * 获取端口刹车标志 + * + * \param none + * + * \retval TRUE or FALSE + ******************************************************************/ +boolean_t Adt_GetPortBrakeFlag(void) +{ + return M0P_ADTIM4->AOSSR_f.FBRAKE; +} + +/****************************************************************** + * \brief + * 清除端口刹车标志 + * + * \param none + * + * \retval none + ******************************************************************/ +void Adt_ClearPortBrakeFlag(void) +{ + M0P_ADTIM4->AOSCL_f.FBRAKE = 0; +} + +/******************************************************************** + * \brief + * 无效条件1配置 + * + * \param [in] pstcAdtDisable1 无效条件1配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + ********************************************************************/ +en_result_t Adt_Disable1Cfg(stc_adt_disable_1_cfg_t* pstcAdtDisable1) +{ + + if (NULL == pstcAdtDisable1) + { + return ErrorInvalidParameter; + } + + M0P_ADTIM4->AOSSR_f.SMH2 = pstcAdtDisable1->bTim6OutSH; + M0P_ADTIM4->AOSSR_f.SMH1 = pstcAdtDisable1->bTim5OutSH; + M0P_ADTIM4->AOSSR_f.SMH0 = pstcAdtDisable1->bTim4OutSH; + M0P_ADTIM4->AOSSR_f.SML2 = pstcAdtDisable1->bTim6OutSL; + M0P_ADTIM4->AOSSR_f.SML1 = pstcAdtDisable1->bTim5OutSL; + M0P_ADTIM4->AOSSR_f.SML0 = pstcAdtDisable1->bTim4OutSL; + + return Ok; +} + +/******************************************************************** + * \brief + * 获取同高同低刹车标志 + * + * \param none + * + * \retval TRUE or FALSE + ********************************************************************/ +boolean_t Adt_GetSameBrakeFlag(void) +{ + return M0P_ADTIM4->AOSSR_f.FSAME; +} + +/********************************************************************* + * \brief + * 清除同高同低刹车标志 + * + * \param none + * + * \retval none + *********************************************************************/ +void Adt_ClearSameBrakeFlag(void) +{ + M0P_ADTIM4->AOSCL_f.FSAME = 0; +} + +/******************************************************************** + * \brief + * PWM展频配置 + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] pstcAdtPwmDitherCfg PWM展频配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + *********************************************************************/ +en_result_t Adt_PwmDitherCfg(M0P_ADTIM_TypeDef *ADTx, stc_adt_pwm_dither_cfg_t* pstcAdtPwmDitherCfg) +{ + + + if (NULL == pstcAdtPwmDitherCfg) + { + return ErrorInvalidParameter; + } + + ADTx->CR_f.DITENS = pstcAdtPwmDitherCfg->enAdtPDType; + ADTx->CR_f.DITENB = pstcAdtPwmDitherCfg->bTimxBPDEn; + ADTx->CR_f.DITENA = pstcAdtPwmDitherCfg->bTimxAPDEn; + + return Ok; +} + +/********************************************************************** + * \brief + * ADT初始化 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] pstcAdtBaseCntCfg 计数配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + **********************************************************************/ +en_result_t Adt_Init(M0P_ADTIM_TypeDef *ADTx, stc_adt_basecnt_cfg_t* pstcAdtBaseCntCfg) +{ + + + if(NULL == pstcAdtBaseCntCfg) + { + return ErrorInvalidParameter; + } + + if (AdtTriangleModeB < pstcAdtBaseCntCfg->enCntMode) + { + return ErrorInvalidParameter; + } + + ADTx->GCONR_f.MODE = pstcAdtBaseCntCfg->enCntMode; + ADTx->GCONR_f.DIR = pstcAdtBaseCntCfg->enCntDir; + ADTx->GCONR_f.CKDIV = pstcAdtBaseCntCfg->enCntClkDiv; + + return Ok; +} + +/************************************************************************ + * \brief + * ADT Deinit + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * + * \retval en_result_t Ok: 配置成功 + * + ***********************************************************************/ +en_result_t Adt_DeInit(M0P_ADTIM_TypeDef *ADTx) +{ + ADTx->GCONR_f.START = 0; + ADTx->CNTER = 0; + ADTx->PCONR = 0; + ADTx->GCONR = 0x00000100; + ADTx->DCONR = 0; + ADTx->ICONR = 0; + ADTx->BCONR = 0; + ADTx->FCONR = 0; + ADTx->VPERR = 0; + ADTx->PERAR = 0xFFFF; + ADTx->PERBR = 0xFFFF; + ADTx->GCMAR = 0xFFFF; + ADTx->GCMBR = 0xFFFF; + ADTx->GCMCR = 0xFFFF; + ADTx->GCMDR = 0xFFFF; + ADTx->DTDAR = 0xFFFF; + ADTx->DTUAR = 0xFFFF; + ADTx->HSTAR = 0; + ADTx->HSTPR = 0; + ADTx->HCELR = 0; + ADTx->HCPAR = 0; + ADTx->HCPBR = 0; + ADTx->HCUPR = 0; + ADTx->HCDOR = 0; + ADTx->SSTAR = 0; + ADTx->SSTPR = 0; + ADTx->SCLRR = 0; + ADTx->IFR = 0; + ADTx->CR = 0x00000300; + ADTx->AOSSR = 0; + ADTx->AOSCL = 0; + ADTx->PTBKS = 0; + ADTx->PTBKP = 0; + ADTx->TTRIG = 0; + ADTx->ITRIG = 0; + + return Ok; +} + +/*********************************************************************** + * \brief + * 开始计数 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * + * \retval en_result_t Ok: 配置成功 + * + ***********************************************************************/ +en_result_t Adt_StartCount(M0P_ADTIM_TypeDef *ADTx) +{ + + ADTx->GCONR_f.START = 1; + + return Ok; +} + +/*********************************************************************** + * \brief + * 停止计数 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * + * \retval en_result_t Ok: 配置成功 + * + **********************************************************************/ +en_result_t Adt_StopCount(M0P_ADTIM_TypeDef *ADTx) +{ + ADTx->GCONR_f.START = 0; + + return Ok; +} + +/******************************************************************** + * \brief + * 设置计数值 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] u16Value 计数值 + * + * \retval en_result_t Ok: 配置成功 + * + *******************************************************************/ +en_result_t Adt_SetCount(M0P_ADTIM_TypeDef *ADTx, uint16_t u16Value) +{ + ADTx->CNTER_f.CNT = u16Value; + return Ok; +} + +/******************************************************************** + * \brief + * 获取计数值 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * + * + * \retval uint16_t u16Value: 当前计数值 + * + *******************************************************************/ +uint16_t Adt_GetCount(M0P_ADTIM_TypeDef *ADTx) +{ + uint16_t u16Value; + + ASSERT(IS_VALID_ADT_UNIT(enAdtUnit)); + + u16Value = ADTx->CNTER_f.CNT; + + return u16Value; +} + +/************************************************************************** + * \brief + * 清除计数值 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * + * + * \retval en_result_t Ok: 配置成功 + * + **************************************************************************/ +en_result_t Adt_ClearCount(M0P_ADTIM_TypeDef *ADTx) +{ + ADTx->CNTER_f.CNT = 0; + return Ok; +} + +/************************************************************************* + * \brief + * 获取有效周期计数值 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * + * \retval uint8_t u8TempCnt: 有效周期值 + * + *************************************************************************/ +uint8_t Adt_GetVperNum(M0P_ADTIM_TypeDef *ADTx) +{ + uint8_t u8TempCnt; + + + ASSERT(IS_VALID_ADT_UNIT(enAdtUnit)); + + u8TempCnt = ADTx->STFLR_f.VPERNUM; + + return u8TempCnt; +} + +/************************************************************************* + * \brief + * 获取状态标志 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) +* \param [in] enstate 状态标志类型 + * + * \retval TURE/FALSE + * + *************************************************************************/ +boolean_t Adt_GetState(M0P_ADTIM_TypeDef *ADTx, en_adt_state_type_t enstate) +{ + + + ASSERT(IS_VALID_ADT_UNIT(enAdtUnit)); + ASSERT(IS_VALID_ADT_STATE(enstate)); + + return GetBit(((uint32_t)&ADTx->STFLR), enstate); +} + +/*********************************************************************** + * \brief + * 配置计数周期 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] u16Period 计数周期值 + * + * \retval en_result_t Ok: 配置成功 + * + ***********************************************************************/ +en_result_t Adt_SetPeriod(M0P_ADTIM_TypeDef *ADTx, uint16_t u16Period) +{ + ADTx->PERAR = u16Period; + + return Ok; +} + +/*********************************************************************** + * \brief + * 配置计数周期缓冲 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] u16PeriodBuf 计数周期缓冲值 + * + * \retval en_result_t Ok: 配置成功 + * + ***********************************************************************/ +en_result_t Adt_SetPeriodBuf(M0P_ADTIM_TypeDef *ADTx, uint16_t u16PeriodBuf) +{ + ADTx->PERBR = u16PeriodBuf; + ADTx->BCONR_f.BENP = 1u; + + return Ok; +} + +/********************************************************************** + * \brief + * 清除计数周期缓冲 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * + * \retval en_result_t Ok: 配置成功 + * + **********************************************************************/ +en_result_t Adt_ClearPeriodBuf(M0P_ADTIM_TypeDef *ADTx) +{ + ADTx->BCONR_f.BENP = 0; + ADTx->PERBR = 0; + + return Ok; +} + +/*********************************************************************** + * \brief + * 配置有效计数周期 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] pstcAdtValidPerCfg 有效计数周期配置指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + ***********************************************************************/ +en_result_t Adt_SetValidPeriod(M0P_ADTIM_TypeDef *ADTx, + stc_adt_validper_cfg_t* pstcAdtValidPerCfg) +{ + + + if(NULL == pstcAdtValidPerCfg) + { + return ErrorInvalidParameter; + } + + ADTx->VPERR_f.PCNTS = pstcAdtValidPerCfg->enValidCnt; + ADTx->VPERR_f.PCNTE = pstcAdtValidPerCfg->enValidCdt; + ADTx->VPERR_f.GEPERID = pstcAdtValidPerCfg->bPeriodD; + ADTx->VPERR_f.GEPERIC = pstcAdtValidPerCfg->bPeriodC; + ADTx->VPERR_f.GEPERIB = pstcAdtValidPerCfg->bPeriodB; + ADTx->VPERR_f.GEPERIA = pstcAdtValidPerCfg->bPeriodA; + + return Ok; +} + +/************************************************************************ + * \brief + * 配置比较输出计数基准值 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtCompare 通用比较基准寄存器 + * \param [in] u16Compare 比较基准值 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + *************************************************************************/ +en_result_t Adt_SetCompareValue(M0P_ADTIM_TypeDef *ADTx, + en_adt_compare_t enAdtCompare, + uint16_t u16Compare) +{ + if (AdtCompareA == enAdtCompare) + { + ADTx->GCMAR = u16Compare; + } + else if (AdtCompareB == enAdtCompare) + { + ADTx->GCMBR = u16Compare; + } + else if (AdtCompareC == enAdtCompare) + { + ADTx->GCMCR = u16Compare; + } + else if (AdtCompareD == enAdtCompare) + { + ADTx->GCMDR = u16Compare; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/********************************************************************** + * \brief + * 配置通用比较值/捕获值缓存传送 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtCHxXPort TIMxX通道 + * \param [in] bCompareBufEn 通用比较值缓存传送使能 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + **********************************************************************/ +en_result_t Adt_EnableValueBuf(M0P_ADTIM_TypeDef *ADTx, + en_adt_CHxX_port_t enAdtCHxXPort, + boolean_t bCompareBufEn) +{ + if (AdtCHxA == enAdtCHxXPort) + { + ADTx->BCONR_f.BENA = bCompareBufEn; + } + else if (AdtCHxB == enAdtCHxXPort) + { + ADTx->BCONR_f.BENB = bCompareBufEn; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/*********************************************************************** + * \brief + * 清除比较输出计数值/捕获值缓存 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtCHxXPort TIMxX通道 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + **********************************************************************/ +en_result_t Adt_ClearValueBuf(M0P_ADTIM_TypeDef *ADTx, + en_adt_CHxX_port_t enAdtCHxXPort) +{ + if (AdtCHxA == enAdtCHxXPort) + { + ADTx->GCMCR = 0; + } + else if (AdtCHxB == enAdtCHxXPort) + { + ADTx->GCMDR = 0; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/*********************************************************************** + * \brief + * 获取捕获值 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtCHxXPort TIMxX通道 + * \param [in] pu16Capture 捕获值指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + ***********************************************************************/ +en_result_t Adt_GetCaptureValue(M0P_ADTIM_TypeDef *ADTx, + en_adt_CHxX_port_t enAdtCHxXPort, + uint16_t* pu16Capture) +{ + if (AdtCHxA == enAdtCHxXPort) + { + *pu16Capture = ADTx->GCMAR_f.GCMA; + } + else if (AdtCHxB == enAdtCHxXPort) + { + *pu16Capture = ADTx->GCMBR_f.GCMB; + } + else + { + return ErrorInvalidParameter; + } + return Ok; +} + +/********************************************************************** + * \brief + * 获取捕获缓存值 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] enAdtCHxXPort TIMxX通道 + * \param [in] pu16CaptureBuf 捕获缓存值指针 + * + * \retval en_result_t Ok: 配置成功 + * \retval en_result_t ErrorInvalidParameter: 无效参数 + ***********************************************************************/ +en_result_t Adt_GetCaptureBuf(M0P_ADTIM_TypeDef *ADTx, + en_adt_CHxX_port_t enAdtCHxXPort, + uint16_t* pu16CaptureBuf) +{ + if (AdtCHxA == enAdtCHxXPort) + { + *pu16CaptureBuf = ADTx->GCMCR_f.GCMC; + } + else if (AdtCHxB == enAdtCHxXPort) + { + *pu16CaptureBuf = ADTx->GCMDR_f.GCMD; + } + else + { + return ErrorInvalidParameter; + } + return Ok; +} + +/*********************************************************************** + * \brief + * 设置死区时间上基准值 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] u16Value 死区时间上基准值 + * + * \retval en_result_t Ok: 配置成功 + * + ************************************************************************/ +en_result_t Adt_SetDTUA(M0P_ADTIM_TypeDef *ADTx, + uint16_t u16Value) +{ + ADTx->DTUAR = u16Value; + + return Ok; +} + +/*********************************************************************** + * \brief + * 设置死区时间下基准值 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] u16Value 死区时间下基准值 + * + * \retval en_result_t Ok: 配置成功 + * + ***********************************************************************/ +en_result_t Adt_SetDTDA(M0P_ADTIM_TypeDef *ADTx, + uint16_t u16Value) +{ + ADTx->DTDAR = u16Value; + + return Ok; +} + +/****************************************************************** + * \brief + * 配置死区时间功能 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] bDTEn 死区功能使能 + * \param [in] bEqual DTDAR的值和DTUAR的值自动相等 + * + * \retval en_result_t Ok: 配置成功 + * + *****************************************************************/ +en_result_t Adt_CfgDT(M0P_ADTIM_TypeDef *ADTx, + boolean_t bDTEn, + boolean_t bEqual) +{ + ADTx->DCONR_f.DTCEN = bDTEn; + ADTx->DCONR_f.SEPA = bEqual; + + return Ok; +} + +/************************************************************************* + * \brief + * Z相输入屏蔽设置 + * + * \param [in] ADTx ADV Timer通道选择(M0P_ADTIM4、M0P_ADTIM5、M0P_ADTIM6) + * \param [in] pstcAdtZMaskCfg Z相输入屏蔽功能配置指针 + * + * \retval en_result_t Ok: 配置成功 + * + *************************************************************************/ +en_result_t Adt_CfgZMask(M0P_ADTIM_TypeDef *ADTx, stc_adt_zmask_cfg_t* pstcAdtZMaskCfg) +{ + if(NULL == pstcAdtZMaskCfg) + { + return ErrorInvalidParameter; + } + + ADTx->GCONR_f.ZMSK = pstcAdtZMaskCfg->enZMaskCycle; + ADTx->GCONR_f.ZMSKPOS = pstcAdtZMaskCfg->bFltPosCntMaksEn; + ADTx->GCONR_f.ZMSKREV = pstcAdtZMaskCfg->bFltRevCntMaksEn; + + return Ok; +} + +//@} // AdtGroup + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/src/hc32f005_ddl/driver/src/bgr.c b/src/hc32f005_ddl/driver/src/bgr.c new file mode 100644 index 0000000..c500c87 --- /dev/null +++ b/src/hc32f005_ddl/driver/src/bgr.c @@ -0,0 +1,143 @@ +/****************************************************************************** +*Copyright(C)2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file bgr.c + ** + ** Common API of bgr. + ** @link flashGroup Some description @endlink + ** + ** - 2018-05-08 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "bgr.h" +/** + ******************************************************************************* + ** \addtogroup FlashGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ***************************************************************************** + ** \brief BGR 使能 + ** + ** + ** \retval Null + *****************************************************************************/ +void Bgr_BgrEnable(void) +{ + M0P_BGR->CR |= 0x1u; + + delay10us(2); +} + +/** + ***************************************************************************** + ** \brief BGR 禁止 + ** + ** + ** \retval Null + *****************************************************************************/ +void Bgr_BgrDisable(void) +{ + M0P_BGR->CR &= 0x2u; +} + +/** + ***************************************************************************** + ** \brief BGR 温度传感器使能(需要先开启BGR) + ** + ** + ** \retval Null + *****************************************************************************/ +void Bgr_TempSensorEnable(void) +{ + M0P_BGR->CR |= 0x2u; + + delay10us(2); +} + +/** + ***************************************************************************** + ** \brief BGR 温度传感器禁止 + ** + ** + ** \retval Null + *****************************************************************************/ +void Bgr_TempSensorDisable(void) +{ + M0P_BGR->CR &= 0x1u; +} + + +//@} // BgrGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/src/hc32f005_ddl/driver/src/bt.c b/src/hc32f005_ddl/driver/src/bt.c new file mode 100644 index 0000000..9f84358 --- /dev/null +++ b/src/hc32f005_ddl/driver/src/bt.c @@ -0,0 +1,529 @@ +/****************************************************************************** +*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') + ******************************************************************************/ + +/******************************************************************************* + * 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_TIM0->IFR_f.UIF ? TRUE : FALSE; + break; + case TIM1: + bRetVal = M0P_TIM1->IFR_f.UIF ? TRUE : FALSE; + break; + case TIM2: + bRetVal = M0P_TIM2->IFR_f.UIF ? 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_TIM0->ICLR_f.UIF = FALSE; + break; + case TIM1: + M0P_TIM1->ICLR_f.UIF = FALSE;; + break; + case TIM2: + M0P_TIM2->ICLR_f.UIF = 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_TIM0->CR_f.UIE = TRUE; + break; + case TIM1: + M0P_TIM1->CR_f.UIE = TRUE; + break; + case TIM2: + M0P_TIM2->CR_f.UIE = 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_TIM0->CR_f.UIE = FALSE; + break; + case TIM1: + M0P_TIM1->CR_f.UIE = FALSE; + break; + case TIM2: + M0P_TIM2->CR_f.UIE = FALSE; + break; + default: + enResult = Error; + break; + } + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Base Timer 初始化配置 + ** + ** + ** \param [in] enUnit Timer通道选择(TIM0、TIM1、TIM2) + ** \param [in] pstcCfg 初始化配置结构体指针 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Bt_Init(en_bt_unit_t enUnit, stc_bt_cfg_t* pstcCfg) +{ + en_result_t enResult = Ok; + + ASSERT(IS_VALID_TIM(enUnit)); + + switch (enUnit) + { + case TIM0: + { + M0P_TIM0->CR_f.GATEP = pstcCfg->enGateP; + M0P_TIM0->CR_f.GATE = pstcCfg->enGate; + M0P_TIM0->CR_f.PRS = pstcCfg->enPRS; + M0P_TIM0->CR_f.TOGEN = pstcCfg->enTog; + M0P_TIM0->CR_f.CT = pstcCfg->enCT; + M0P_TIM0->CR_f.MD = pstcCfg->enMD; + + } + break; + case TIM1: + { + M0P_TIM1->CR_f.GATEP = pstcCfg->enGateP; + M0P_TIM1->CR_f.GATE = pstcCfg->enGate; + M0P_TIM1->CR_f.PRS = pstcCfg->enPRS; + M0P_TIM1->CR_f.TOGEN = pstcCfg->enTog; + M0P_TIM1->CR_f.CT = pstcCfg->enCT; + M0P_TIM1->CR_f.MD = pstcCfg->enMD; + + } + break; + case TIM2: + { + M0P_TIM2->CR_f.GATEP = pstcCfg->enGateP; + M0P_TIM2->CR_f.GATE = pstcCfg->enGate; + M0P_TIM2->CR_f.PRS = pstcCfg->enPRS; + M0P_TIM2->CR_f.TOGEN = pstcCfg->enTog; + M0P_TIM2->CR_f.CT = pstcCfg->enCT; + M0P_TIM2->CR_f.MD = pstcCfg->enMD; + + } + 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_TIM0->CR_f.CTEN = TRUE; + break; + case TIM1: + M0P_TIM1->CR_f.CTEN = TRUE; + break; + case TIM2: + M0P_TIM2->CR_f.CTEN = 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_TIM0->CR_f.CTEN = FALSE; + break; + case TIM1: + M0P_TIM1->CR_f.CTEN = FALSE; + break; + case TIM2: + M0P_TIM2->CR_f.CTEN = 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_TIM0->ARR_f.ARR = u16Data; + break; + case TIM1: + M0P_TIM1->ARR_f.ARR = u16Data; + break; + case TIM2: + M0P_TIM2->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_TIM0->CNT_f.CNT = u16Data; + break; + case TIM1: + M0P_TIM1->CNT_f.CNT = u16Data; + break; + case TIM2: + M0P_TIM2->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_TIM0->CNT_f.CNT; + break; + case TIM1: + u16CntData = M0P_TIM1->CNT_f.CNT; + break; + case TIM2: + u16CntData = M0P_TIM2->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_TIM0->CNT32_f.CNT32 = u32Data; + break; + case TIM1: + M0P_TIM1->CNT32_f.CNT32 = u32Data; + break; + case TIM2: + M0P_TIM2->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_TIM0->CNT32_f.CNT32; + break; + case TIM1: + u32CntData = M0P_TIM1->CNT32_f.CNT32; + break; + case TIM2: + u32CntData = M0P_TIM2->CNT32_f.CNT32; + break; + default: + u32CntData = 0; + break; + } + + return u32CntData; +} + +//@} // BtGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/src/hc32f005_ddl/driver/src/crc.c b/src/hc32f005_ddl/driver/src/crc.c new file mode 100644 index 0000000..bccfb7c --- /dev/null +++ b/src/hc32f005_ddl/driver/src/crc.c @@ -0,0 +1,258 @@ +/****************************************************************************** +*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 = 0; + + M0P_CRC->RESULT = 0xFFFF; + for(u32Index = 0;u32IndexDATA))) = 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 = 0; + + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA))) = 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 = 0; + + 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 = 0; + + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA))) = pu8Data[u32Index]; + } + + *((volatile uint8_t*)(&(M0P_CRC->DATA))) = (uint8_t)((((uint32_t)u16CRC)>>0)&0xFF); + *((volatile uint8_t*)(&(M0P_CRC->DATA))) = (uint8_t)(((uint32_t)u16CRC>>8)&0xFF); + + enResult = M0P_CRC->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 = 0; + + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA))) = pu16Data[u32Index]; + } + + *((volatile uint16_t*)(&(M0P_CRC->DATA))) = 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 = 0; + + M0P_CRC->RESULT_f.RESULT = 0xFFFF; + for (u32Index=0; u32IndexDATA))) = pu32Data[u32Index]; + } + + *((volatile uint16_t*)(&(M0P_CRC->DATA))) = u16CRC; + + enResult = M0P_CRC->RESULT_f.FLAG ? Ok : Error; + + return (enResult); +} + + +//@} // CrcGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/src/hc32f005_ddl/driver/src/ddl.c b/src/hc32f005_ddl/driver/src/ddl.c new file mode 100644 index 0000000..5880f67 --- /dev/null +++ b/src/hc32f005_ddl/driver/src/ddl.c @@ -0,0 +1,377 @@ +/******************************************************************************* +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl.c + ** + ** Common API of DDL. + ** @link ddlGroup Some description @endlink + ** + ** - 2019-03-03 + ** + ******************************************************************************/ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "ddl.h" + +/** + ****************************************************************************** + ** \addtogroup DDL Common Functions + ******************************************************************************/ +//@{ + +/******************************************************************************/ +/* Local pre-processor symbols/macros ('#define') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Global variable definitions (declared in header file with 'extern') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local type definitions ('typedef') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local variable definitions ('static') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local function prototypes ('static') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Function implementation - global ('extern') and local ('static') */ +/******************************************************************************/ +#ifndef __DEBUG +#define __DEBUG +//#define __CC_ARM +#endif + + + + + + +uint32_t Log2(uint32_t u32Val) +{ + uint32_t u32V1 = 0; + + if(0u == u32Val) + { + return 0; + } + + while(u32Val > 1u) + { + u32V1++; + u32Val /=2; + } + + return u32V1; +} + + +/** + ******************************************************************************* + ** \brief Memory clear function for DDL_ZERO_STRUCT() + ******************************************************************************/ +void ddl_memclr(void *pu8Address, uint32_t u32Count) +{ + uint8_t *pu8Addr = (uint8_t *)pu8Address; + + if(NULL == pu8Addr) + { + return; + } + + while (u32Count--) + { + *pu8Addr++ = 0; + } +} + +/** + ***************************************************************************** + ** \brief 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) +{ +#ifdef __DEBUG + //uint32_t u32Pclk1 = 0; + //volatile uint32_t u32ReloadVal = 0; + // + //// UART0_TXD/P35, 19200bps + //M0P_GPIO->P3ADS_f.P35 = 0; + //M0P_GPIO->P35_SEL_f.SEL = 3; + //M0P_GPIO->P3DIR_f.P35 = 0; + // + //u32Pclk1 = Sysctrl_GetPClkFreq(); + //u32ReloadVal = 65536 - u32Pclk1 * 2 / 19200 / 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) +{ + //M0P_UART0->SCON_f.REN = 0; + //M0P_UART0->SBUF = u8Data; + // + //while (TRUE != M0P_UART0->ISR_f.TI) + //{ + // ; + //} + //M0P_UART0->ICR_f.TICLR = 0; +} + +//#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; + + SysTick->LOAD = 0xFFFFFF; + SysTick->VAL = 0; + SysTick->CTRL = SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk; + + while(u32Cnt-- > 0) + { + SysTick->VAL = 0; + u32end = 0x1000000 - SystemCoreClock/1000; + while(SysTick->VAL > u32end) + { + ; + } + } + + SysTick->CTRL = (SysTick->CTRL & (~SysTick_CTRL_ENABLE_Msk)); +} + +/** + * \brief delay100us + * delay approximately 100us. + * \param [in] u32Cnt + * \retval void + */ +void delay100us(uint32_t u32Cnt) +{ + uint32_t u32end; + + SysTick->LOAD = 0xFFFFFF; + SysTick->VAL = 0; + SysTick->CTRL = SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk; + + while(u32Cnt-- > 0) + { + SysTick->VAL = 0; + + u32end = 0x1000000 - SystemCoreClock/10000; + while(SysTick->VAL > u32end) + { + ; + } + } + + SysTick->CTRL = (SysTick->CTRL & (~SysTick_CTRL_ENABLE_Msk)); +} + +/** + * \brief delay10us + * delay approximately 10us. + * \param [in] u32Cnt + * \retval void + */ +void delay10us(uint32_t u32Cnt) +{ + uint32_t u32end; + + SysTick->LOAD = 0xFFFFFF; + SysTick->VAL = 0; + SysTick->CTRL = SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk; + + while(u32Cnt-- > 0) + { + SysTick->VAL = 0; + + u32end = 0x1000000 - SystemCoreClock/100000; + while(SysTick->VAL > u32end) + { + ; + } + } + + SysTick->CTRL = (SysTick->CTRL & (~SysTick_CTRL_ENABLE_Msk)); +} + +/** + * \brief set register bit + * + * \param [in] addr + * \param [in] offset + * \retval void + */ +void SetBit(uint32_t addr, uint32_t offset, boolean_t bFlag) +{ + if(TRUE == bFlag) + { + *((volatile uint32_t *)(addr)) |= ((1UL)<<(offset)); + } + else + { + *((volatile uint32_t *)(addr)) &= (~(1UL<<(offset))); + } + + +} + + +/** + * \brief get register bit + * + * \param [in] addr + * \param [in] offset + * \retval void + */ +boolean_t GetBit(uint32_t addr, uint32_t offset) +{ + return ((((*((volatile uint32_t *)(addr))) >> (offset)) & 1u) > 0) ? TRUE : FALSE; +} +//@} // DDL Functions + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/src/hc32f005_ddl/driver/src/flash.c b/src/hc32f005_ddl/driver/src/flash.c new file mode 100644 index 0000000..f3515e1 --- /dev/null +++ b/src/hc32f005_ddl/driver/src/flash.c @@ -0,0 +1,691 @@ +/****************************************************************************** +*Copyright(C)2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file flash.c + ** + ** Common API of flash. + ** @link flashGroup Some description @endlink + ** + ** - 2018-05-08 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "flash.h" +/** + ******************************************************************************* + ** \addtogroup FlashGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define FLASH_END_ADDR (0x00007FFFu) +#define FLASH_BYPASS() M0P_FLASH->BYPASS = 0x5A5A;\ + M0P_FLASH->BYPASS = 0xA5A5; +#define FLASH_IE_TRUE (0x03) +#define FLASH_IE_FALSE (0x00) + +#define FLASH_TIMEOUT_INIT (0xFFu) +#define FLASH_TIMEOUT_PGM (0xFFu) +#define FLASH_TIMEOUT_ERASE (0xFFu) + +#define FLASH_LOCK_ALL (0u) +#define FLASH_UNLOCK_ALL (0xFFFFu) +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ +/** + ****************************************************************************** + ** \brief FLASH OP + ** + ** Flash 操作控制数据类型重定义 + ******************************************************************************/ +typedef enum en_flash_op +{ + Read = 0u, ///<读配置值 + Program = 1u, ///<编程配置值 + SectorErase = 2u, ///<扇区擦除配置值 + ChipErase = 3u, ///<全片擦除配置值 +} en_flash_op_t; + +/** + ****************************************************************************** + ** \brief FLASH 编程时间参数配置 + ** + ** FLASH编程时间参数配置数组定义 (4MHz) + ******************************************************************************/ +const uint32_t pu32PcgTimer4M[] = { + 0x20u, //Tnvs + 0x17u, //Tpgs + 0x1Bu, //Tprog + 0x4650u, //Tserase + 0x222E0u, //Tmerase + 0x18u, //Tprcv + 0xF0u, //Tsrcv + 0x3E8u //Tmrcv + }; +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ***************************************************************************** + ** \brief Flash中断标志获取 + ** + ** + ** \param [in] enFlashIntType Flash中断类型 + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +boolean_t Flash_GetIntFlag(en_flash_int_type_t enFlashIntType) +{ + boolean_t bRetVal = FALSE; + + if(M0P_FLASH->IFR & enFlashIntType) + { + bRetVal = TRUE; + } + + return bRetVal; +} + +/** + ***************************************************************************** + ** \brief Flash中断标志清除 + ** + ** + ** \param [in] enFlashIntType Flash中断类型 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Flash_ClearIntFlag(en_flash_int_type_t enFlashIntType) +{ + en_result_t enResult = Error; + + M0P_FLASH->ICLR &= ~(uint32_t)enFlashIntType; + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Flash中断使能 + ** + ** + ** \param [in] enFlashIntType Flash中断类型 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Flash_EnableIrq (en_flash_int_type_t enFlashIntType) +{ + en_result_t enResult = Error; + + FLASH_BYPASS(); + M0P_FLASH->CR_f.IE |= enFlashIntType; + + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Flash中断禁止 + ** + ** + ** \param [in] enFlashIntType Flash中断类型 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Flash_DisableIrq(en_flash_int_type_t enFlashIntType) +{ + en_result_t enResult = Error; + + FLASH_BYPASS(); + M0P_FLASH->CR_f.IE &= ~(uint32_t)enFlashIntType; + + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief FLASH 初始化函数——中断服务程序、编程时间配置及低功耗模式 + ** + ** 该函数用于配置中断服务函数、低功耗模式、根据系统时钟配置FLASH编程时间相关寄存器. + ** + ** \param [in] u8FreqCfg FLASH编程时钟频率配置(根据HCLK的频率选择配置值): + ** 1 - 4MHz; + ** 2 - 8MHz; + ** 4 - 16MHz; + ** 6 - 24MHz; + ** 8 - 32MHz; + ** other - 无效值 + ** \param [in] bDpstbEn TRUE - 当系统进入DeepSleep模式,FLASH进入低功耗模式; + ** FALSE - 当系统进入DeepSleep模式,FLASH不进入低功耗模式; + ** + ** \retval Ok 操作成功. + ** \retval ErrorInvalidParameter 参数无效. + ** \retval ErrorUninitialized 初始化失败。 + *****************************************************************************/ +en_result_t Flash_Init(uint8_t u8FreqCfg) +{ + uint32_t u32Index = 0; + volatile uint32_t u32TimeOut = FLASH_TIMEOUT_INIT; + en_result_t enResult = Ok; + uint32_t u32PrgTimer[8] = {0}; + volatile uint32_t *pu32PrgTimerReg = (volatile uint32_t*)M0P_FLASH; + + if ((1 != u8FreqCfg) && (2 != u8FreqCfg) && + (4 != u8FreqCfg) && (6 != u8FreqCfg) && + (8 != u8FreqCfg)) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + + //flash时间参数配置值计算 + for(u32Index=0; u32Index<8; u32Index++) + { + u32PrgTimer[u32Index] = u8FreqCfg * pu32PcgTimer4M[u32Index]; + } + + + + //flash时间参数寄存器配置 + for(u32Index=0; u32Index<8; u32Index++) + { + u32TimeOut = FLASH_TIMEOUT_INIT; + while(pu32PrgTimerReg[u32Index] != u32PrgTimer[u32Index]) + { + if(u32TimeOut--) + { + FLASH_BYPASS(); + pu32PrgTimerReg[u32Index] = u32PrgTimer[u32Index]; + } + else + { + return ErrorUninitialized; + } + } + } + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 字节写 + ** + ** 用于向FLASH写入1字节数据. + ** + ** \param [in] u32Addr Flash地址 + ** \param [in] u8Data 1字节数据 + ** + ** \retval Ok 写入成功. + ** \retval ErrorInvalidParameter FLASH地址无效 + ** \retval ErrorTimeout 操作超时 + *****************************************************************************/ +en_result_t Flash_WriteByte(uint32_t u32Addr, uint8_t u8Data) +{ + en_result_t enResult = Ok; + volatile uint32_t u32TimeOut = FLASH_TIMEOUT_PGM; + + if (FLASH_END_ADDR < u32Addr) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + //busy? + u32TimeOut = FLASH_TIMEOUT_PGM; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //set OP + u32TimeOut = FLASH_TIMEOUT_PGM; + while(Program != M0P_FLASH->CR_f.OP) + { + if(u32TimeOut--) + { + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = Program; + } + else + { + return ErrorTimeout; + } + } + + //Flash 解锁 + Flash_UnlockAll(); + + //write data + *((volatile uint8_t*)u32Addr) = u8Data; + + //busy? + u32TimeOut = FLASH_TIMEOUT_PGM; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 加锁 + Flash_LockAll(); + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 半字写 + ** + ** 用于向FLASH写入半字(2字节)数据. + ** + ** \param [in] u32Addr Flash地址 + ** \param [in] u16Data 半字(2字节)数据 + ** + ** \retval Ok 写入成功. + ** \retval ErrorInvalidParameter FLASH地址无效 + ** \retval ErrorTimeout 操作超时 + *****************************************************************************/ +en_result_t Flash_WriteHalfWord(uint32_t u32Addr, uint16_t u16Data) +{ + en_result_t enResult = Ok; + volatile uint32_t u32TimeOut = FLASH_TIMEOUT_PGM; + + if (FLASH_END_ADDR < u32Addr) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + //busy? + u32TimeOut = FLASH_TIMEOUT_PGM; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //set OP + u32TimeOut = FLASH_TIMEOUT_PGM; + while(Program != M0P_FLASH->CR_f.OP) + { + if(u32TimeOut--) + { + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = Program; + } + else + { + return ErrorTimeout; + } + } + + //Flash 解锁 + Flash_UnlockAll(); + + //write data + *((volatile uint16_t*)u32Addr) = u16Data; + + //busy? + u32TimeOut = FLASH_TIMEOUT_PGM; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 加锁 + Flash_LockAll(); + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 字写 + ** + ** 用于向FLASH写入1个字的数据. + ** + ** \param [in] u32Addr Flash地址 + ** \param [in] u32Data 1个字数据 + ** + ** \retval Ok 写入成功. + ** \retval ErrorInvalidParameter FLASH地址无效 + ** \retval ErrorTimeout 操作超时 + *****************************************************************************/ +en_result_t Flash_WriteWord(uint32_t u32Addr, uint32_t u32Data) +{ + en_result_t enResult = Ok; + volatile uint32_t u32TimeOut = FLASH_TIMEOUT_PGM; + + if (FLASH_END_ADDR < u32Addr) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + //busy? + u32TimeOut = FLASH_TIMEOUT_PGM; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 解锁 + Flash_UnlockAll(); + + //set OP + u32TimeOut = FLASH_TIMEOUT_PGM; + while(Program != M0P_FLASH->CR_f.OP) + { + if(u32TimeOut--) + { + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = Program; + } + else + { + return ErrorTimeout; + } + } + + //write data + *((volatile uint32_t*)u32Addr) = u32Data; + + //busy? + u32TimeOut = FLASH_TIMEOUT_PGM; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 加锁 + Flash_LockAll(); + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 扇区擦除 + ** + ** FLASH 扇区擦除. + ** + ** \param [in] u32SectorAddr 所擦除扇区内的地址 + ** + ** \retval Ok 擦除成功. + ** \retval ErrorInvalidParameter FLASH地址无效 + ** \retval ErrorTimeout 操作超时 + *****************************************************************************/ +en_result_t Flash_SectorErase(uint32_t u32SectorAddr) +{ + en_result_t enResult = Ok; + volatile uint32_t u32TimeOut = FLASH_TIMEOUT_ERASE; + + if (FLASH_END_ADDR < u32SectorAddr) + { + enResult = ErrorInvalidParameter; + return (enResult); + } + + //busy? + u32TimeOut = FLASH_TIMEOUT_ERASE; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 解锁 + Flash_UnlockAll(); + + //set OP + u32TimeOut = FLASH_TIMEOUT_ERASE; + while(SectorErase != M0P_FLASH->CR_f.OP) + { + if(u32TimeOut--) + { + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = SectorErase; + } + else + { + return ErrorTimeout; + } + } + + //write data + *((volatile uint8_t*)u32SectorAddr) = 0; + + //busy? + u32TimeOut = FLASH_TIMEOUT_ERASE; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 加锁 + Flash_LockAll(); + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 全片擦除(该函数仅限RAM中运行!!!) + ** + ** FLASH 全片擦除. + ** + ** + ** \retval Ok 擦除成功. + ** \retval ErrorTimeout 操作超时 + ** + *****************************************************************************/ +en_result_t Flash_ChipErase(void) +{ + en_result_t enResult = Ok; + volatile uint32_t u32TimeOut = FLASH_TIMEOUT_ERASE; + + //busy? + u32TimeOut = FLASH_TIMEOUT_ERASE; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //set OP + u32TimeOut = FLASH_TIMEOUT_ERASE; + while(ChipErase != M0P_FLASH->CR_f.OP) + { + if(u32TimeOut--) + { + FLASH_BYPASS(); + M0P_FLASH->CR_f.OP = ChipErase; + } + else + { + return ErrorTimeout; + } + } + + //Flash 解锁 + Flash_UnlockAll(); + + //write data + *((volatile uint8_t*)0) = 0; + + //busy? + u32TimeOut = FLASH_TIMEOUT_ERASE; + while (TRUE == M0P_FLASH->CR_f.BUSY) + { + if(0 == u32TimeOut--) + { + return ErrorTimeout; + } + } + + //Flash 加锁 + Flash_LockAll(); + + return (enResult); +} + +/** + ***************************************************************************** + ** \brief FLASH 编程保护加锁 + ** + ** + ** \retval Null + *****************************************************************************/ +void Flash_LockAll(void) +{ + FLASH_BYPASS(); + M0P_FLASH->SLOCK = FLASH_LOCK_ALL; + +} + +/** + ***************************************************************************** + ** \brief FLASH 编程保护解锁 + ** + ** + ** \retval Null + *****************************************************************************/ +void Flash_UnlockAll(void) +{ + + FLASH_BYPASS(); + M0P_FLASH->SLOCK = FLASH_UNLOCK_ALL; + +} + +/** + ***************************************************************************** + ** \brief FLASH 读等待周期设置 + ** + ** \param [in] enWaitCycle 插入FLASH读等待周期数枚举类型 + ** + ** \retval Ok 解锁成功 + ** \retval ErrorInvalidParameter 参数错误 + *****************************************************************************/ +en_result_t Flash_WaitCycle(en_flash_waitcycle_t enWaitCycle) +{ + en_result_t enResult = Ok; + + FLASH_BYPASS(); + M0P_FLASH->CR_f.WAIT = enWaitCycle; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief FLASH LOCK 设置 + ** + ** \param [in] u32LockValue 32bits,对应bit=0:加锁,对应Sector不允许擦写;对应bit=1:解锁。 + ** \note 加解锁范围Sector:[i*4, i*4+3] + ** (i表示u32LockValue的bit位置,0~31) + ** 例如:u32LockValue = 0x00000002, + ** 则加解锁范围为:[Sector8,Sector11] + ** \retval Ok 解锁成功 + ** \retval ErrorInvalidParameter 参数错误 + *****************************************************************************/ +en_result_t Flash_LockSet(uint32_t u32LockValue) +{ + FLASH_BYPASS(); + M0P_FLASH->SLOCK = u32LockValue; + + return Ok; +} +//@} // FlashGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/src/hc32f005_ddl/driver/src/gpio.c b/src/hc32f005_ddl/driver/src/gpio.c new file mode 100644 index 0000000..fda5a01 --- /dev/null +++ b/src/hc32f005_ddl/driver/src/gpio.c @@ -0,0 +1,435 @@ +/****************************************************************************** +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file Gpio.c + ** + ** GPIO driver API. + ** @link Driver Group Some description @endlink + ** + ** - 2018-04-22 1.0 Lux First version + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "gpio.h" + +/** + ******************************************************************************* + ** \addtogroup GpioGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define IS_VALID_PIN(port,pin) ( ) +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') * + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ******************************************************************************* + ** \brief GPIO 初始化 + ** + ** \param [in] enPort IO Port口 + ** \param [in] enPin IO Pin脚 + ** \param [in] pstcGpioCfg IO 配置结构体指针 + ** + ** \retval Ok 设置成功 + ** 其他值 设置失败 + ******************************************************************************/ +en_result_t Gpio_Init(en_gpio_port_t enPort, en_gpio_pin_t enPin, stc_gpio_cfg_t *pstcGpioCfg) +{ + //配置为默认值,GPIO功能 + SetBit((uint32_t)&M0P_GPIO->P0ADS + enPort, enPin, FALSE); + *((uint32_t*)(((uint32_t)((&(M0P_GPIO->P01_SEL)) - 1u) + enPort) + (((uint32_t)enPin)<<2))) = GpioAf0; + + //方向配置 + SetBit(((uint32_t)&M0P_GPIO->P0DIR + enPort), enPin, (boolean_t)(pstcGpioCfg->enDir)); + //驱动能力配置 + SetBit(((uint32_t)&M0P_GPIO->P0DR + enPort), enPin, (boolean_t)(pstcGpioCfg->enDrv)); + //上拉/下拉配置 + SetBit(((uint32_t)&M0P_GPIO->P0PU + enPort), enPin, (boolean_t)(pstcGpioCfg->enPu)); + SetBit(((uint32_t)&M0P_GPIO->P0PD + enPort), enPin, (boolean_t)(pstcGpioCfg->enPd)); + //开漏输出功能 + SetBit(((uint32_t)&M0P_GPIO->P0OD + enPort), enPin, (boolean_t)(pstcGpioCfg->enOD)); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO IO输入值获取 + ** + ** \param [in] enPort IO Port口 + ** \param [in] enPin IO Pin脚 + ** + ** \retval boolean_t IO电平高低 + ******************************************************************************/ +boolean_t Gpio_GetInputIO(en_gpio_port_t enPort, en_gpio_pin_t enPin) +{ + return GetBit(((uint32_t)&M0P_GPIO->P0IN + enPort), enPin); +} + +/** + ******************************************************************************* + ** \brief GPIO IO Port输入数据获取 + ** + ** \param [in] enPort IO Port + ** + ** \retval boolean_t IO Port数据 + ******************************************************************************/ +uint16_t Gpio_GetInputData(en_gpio_port_t enPort) +{ + return (uint16_t)(*((uint32_t *)((uint32_t)&M0P_GPIO->P0IN + enPort))); +} + +/** + ******************************************************************************* + ** \brief GPIO IO输出值写入 + ** + ** \param [in] enPort IO Port口 + ** \param [in] enPin IO Pin脚 + ** \param [out] bVal 输出值 + ** + ** \retval en_result_t Ok 设置成功 + ** 其他值 设置失败 + ******************************************************************************/ +en_result_t Gpio_WriteOutputIO(en_gpio_port_t enPort, en_gpio_pin_t enPin, boolean_t bVal) +{ + SetBit(((uint32_t)&M0P_GPIO->P0OUT + enPort), enPin, bVal); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO IO输出值获取 + ** + ** \param [in] enPort IO Port口 + ** \param [in] enPin IO Pin脚 + ** + ** \retval boolean_t IO电平高低 + ******************************************************************************/ +boolean_t Gpio_ReadOutputIO(en_gpio_port_t enPort, en_gpio_pin_t enPin) +{ + return GetBit(((uint32_t)&M0P_GPIO->P0OUT + enPort), enPin); +} + + +/** + ******************************************************************************* + ** \brief GPIO IO配置为模拟功能模式 + ** + ** \param [in] enPort IO Port口 + ** \param [in] enPin IO Pin脚 + ** + ** \retval Ok 设置成功 + ** 其他值 设置失败 + ******************************************************************************/ +en_result_t Gpio_SetAnalogMode(en_gpio_port_t enPort, en_gpio_pin_t enPin) +{ + SetBit((uint32_t)&M0P_GPIO->P0ADS + enPort, enPin, TRUE); + + return Ok; +} + +/** + ******************************************************************************* +** \brief GPIO IO复用功能设置 + ** + ** \param [in] enPort IO Port口 + ** \param [in] enPin IO Pin脚 + ** \param [in] enAf 复用功能枚举类型选择 + ** \retval Ok 设置成功 + ** 其他值 设置失败 + ******************************************************************************/ +en_result_t Gpio_SetAfMode(en_gpio_port_t enPort, en_gpio_pin_t enPin, en_gpio_af_t enAf) +{ + *((uint32_t*)(((uint32_t)((&(M0P_GPIO->P01_SEL)) - 1u) + enPort) + (((uint32_t)enPin)<<2))) = enAf; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO IO中断使能 + ** + ** \param [in] enPort IO Port口 + ** \param [in] enPin IO Pin脚 + ** \param [in] enType 中断使能类型 + ** + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_EnableIrq(en_gpio_port_t enPort, en_gpio_pin_t enPin, en_gpio_irqtype_t enType) +{ + uint32_t u32PieAddr; + + u32PieAddr = ((uint32_t)((&M0P_GPIO->P0HIE) + enType)) + enPort; + + SetBit(u32PieAddr, enPin, TRUE); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO IO中断关闭 + ** + ** \param [in] enPort IO Port口 + ** \param [in] enPin IO Pin脚 + ** \param [in] enType 中断使能类型 + ** + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_DisableIrq(en_gpio_port_t enPort, en_gpio_pin_t enPin, en_gpio_irqtype_t enType) +{ + uint32_t u32PieAddr; + + u32PieAddr = ((uint32_t)((&M0P_GPIO->P0HIE) + enType)) + enPort; + + SetBit(u32PieAddr, enPin, FALSE); + + return Ok; +} + + +/** + ******************************************************************************* + ** \brief GPIO 获得IO中断状态 + ** + ** \param [in] u8Port IO Port口 + ** \param [in] u8Pin IO Pin脚 + ** + ** \retval IO中断状态开关 + ******************************************************************************/ +boolean_t Gpio_GetIrqStatus(en_gpio_port_t enPort, en_gpio_pin_t enPin) +{ + return GetBit((uint32_t)&M0P_GPIO->P0STAT + enPort, enPin); +} + +/** + ******************************************************************************* + ** \brief GPIO 清除IO中断状态 + ** + ** \param [in] u8Port IO Port口 + ** \param [in] u8Pin IO Pin脚 + ** + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_ClearIrq(en_gpio_port_t enPort, en_gpio_pin_t enPin) +{ + SetBit((uint32_t)&M0P_GPIO->P0ICLR + enPort, enPin, FALSE); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 端口辅助功能配置——中断模式配置 + ** + ** \param [in] enIrqMode 端口中断模式 + ** + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_SfIrqModeCfg(en_gpio_sf_irqmode_t enIrqMode) +{ + M0P_GPIO->CTRL0_f.IESEL = enIrqMode; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 端口辅助功能配置——IR输出极性配置 + ** + ** \param [in] enIrPolMode IR输出极性配置枚举 + ** + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_SfIrPolCfg(en_gpio_sf_irpol_t enIrPolMode) +{ + M0P_GPIO->CTRL1_f.IR_POL = enIrPolMode; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 端口辅助功能配置——HCLK输出配置 + ** + ** \param [in] enGate HCLK输出使能 + ** \param [in] enDiv 输出分频枚举值 + ** + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_SfHClkOutputCfg(en_gpio_sf_hclkout_g_t enGate, en_gpio_sf_hclkout_div_t enDiv) +{ + M0P_GPIO->CTRL1_f.HCLK_EN = enGate; + M0P_GPIO->CTRL1_f.HCLK_SEL = enDiv; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 端口辅助功能配置——PCLK输出配置 + ** + ** \param [in] enGate PCLK输出使能 + ** \param [in] enDiv 输出分频枚举值 + ** + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_SfPClkOutputCfg(en_gpio_sf_pclkout_g_t enGate, en_gpio_sf_pclkout_div_t enDiv) +{ + M0P_GPIO->CTRL1_f.PCLK_EN = enGate; + M0P_GPIO->CTRL1_f.PCLK_SEL = enDiv; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 端口辅助功能配置——外部时钟输入来源配置 + ** + ** \param [in] enExtClk 外部时钟信号来源选择枚举 + ** + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_SfExtClkCfg(en_gpio_sf_ssn_extclk_t enExtClk) +{ + M0P_GPIO->CTRL1_f.EXT_CLK_SEL = enExtClk; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 端口辅助功能配置——SSN 通道信号来源配置 + ** + ** \param [in] enSsn SSN 信号来源选择枚举 + ** + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_SfSsnCfg(en_gpio_sf_ssn_extclk_t enSsn) +{ + M0P_GPIO->CTRL1_f.SSN_SEL = enSsn; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief GPIO 端口辅助功能配置——Timer 门控输入配置 + ** + ** \param [in] enTimG Timer类型选择枚举 + ** \param [in] enSf Timer互联功能选择枚举 + ** + ** \retval Ok 设置成功 + ******************************************************************************/ +en_result_t Gpio_SfTimGCfg(en_gpio_sf_tim_g_t enTimG, en_gpio_sf_t enSf) +{ + M0P_GPIO->CTRL4 &= (uint32_t)(~(0x03U<CTRL4 |= (uint32_t)(enSf<CTRL3 &= (uint32_t)(~(0x03u<CTRL3 |= (uint32_t)(enSf<CTRL2 &= (uint32_t)(~(0x03u<CTRL2 |= (uint32_t)(enSf<TM = u8Tm; + + enRet = Ok; + return enRet; + } + /** + ****************************************************************************** + ** \brief I2C功能设置相关函数 + ** + ** \param [in] enFunc功能参数 + ** + ** \retval enRet 成功或失败 + ** + ******************************************************************************/ +en_result_t I2C_SetFunc(M0P_I2C_TypeDef* I2Cx, en_i2c_func_t enFunc) +{ + en_result_t enRet = Error; + + SetBit((uint32_t)&I2Cx->CR, enFunc, TRUE); + + enRet = Ok; + return enRet; +} + /** + ****************************************************************************** + ** \brief I2C功能清除相关函数 + ** + ** \param [in] enFunc功能参数 + ** + ** \retval enRet 成功或失败 + ** + ******************************************************************************/ + en_result_t I2C_ClearFunc(M0P_I2C_TypeDef* I2Cx, en_i2c_func_t enFunc) + { + en_result_t enRet = Error; + + SetBit((uint32_t)&I2Cx->CR, enFunc, FALSE); + + enRet = Ok; + return enRet; + } + /** + ****************************************************************************** + ** \brief I2C获取中断标记函数 + ** + ** \param 无 + ** + ** \retval bIrq中断标记 + ** + ******************************************************************************/ +boolean_t I2C_GetIrq(M0P_I2C_TypeDef* I2Cx) +{ + if(I2Cx->CR&0x8) + { + return TRUE; + } + else + { + return FALSE; + } +} +/** + ****************************************************************************** + ** \brief I2C清除中断标记函数 + ** + ** \param 无 + ** + ** \retval bIrq中断标记 + ** + ******************************************************************************/ +en_result_t I2C_ClearIrq(M0P_I2C_TypeDef* I2Cx) +{ + en_result_t enRet = Error; + + I2Cx->CR &= ~0x8u; + + enRet = Ok; + return enRet; +} + /** + ****************************************************************************** + ** \brief I2C获取相关状态 + ** + ** \param 无 + ** + ** \retval I2C状态 + ** + ******************************************************************************/ +uint8_t I2C_GetState(M0P_I2C_TypeDef* I2Cx) +{ + uint8_t u8State = 0; + + u8State = I2Cx->STAT; + + return u8State; +} + +/** + ****************************************************************************** + ** \brief 字节数据写函数 + ** + ** \param u8Data写数据 + ** + ** \retval 写数据是否成功 + ** + ******************************************************************************/ +en_result_t I2C_WriteByte(M0P_I2C_TypeDef* I2Cx, uint8_t u8Data) +{ + en_result_t enRet = Error; + + I2Cx->DATA = u8Data; + + enRet = Ok; + return enRet; +} +/** + ****************************************************************************** + ** \brief 字节数据读函数 + ** + ** \param 无 + ** + ** \retval 读取数据 + ** + ******************************************************************************/ +uint8_t I2C_ReadByte(M0P_I2C_TypeDef* I2Cx) +{ + uint8_t u8Data = 0; + + u8Data = I2Cx->DATA; + + return u8Data; +} + +/** + ****************************************************************************** + ** \brief I2C模块初始化 + ** + ** \param pstcI2CCfg初始化配置结构体 + ** + ** \retval 初始化是否成功 + ** + ******************************************************************************/ +en_result_t I2C_Init(M0P_I2C_TypeDef* I2Cx, stc_i2c_cfg_t *pstcI2CCfg) +{ + en_result_t enRet = Error; + uint8_t u8Tm; + + M0P_RESET->PERI_RESET &= ~(uint32_t)0x10u; + M0P_RESET->PERI_RESET |= (uint32_t)0x10u; + + I2Cx->CR = 0; + I2Cx->CR = pstcI2CCfg->enMode; + + if((pstcI2CCfg->u32Baud<<4) > pstcI2CCfg->u32Pclk) + { + return Error; + } + + if(I2cMasterMode == pstcI2CCfg->enMode) + { + I2Cx->TMRUN = TRUE; + ///< Fsck = Fpclk/8*(Tm+1) + u8Tm = ((pstcI2CCfg->u32Pclk / pstcI2CCfg->u32Baud) >> 3) - 1; + if(9 > u8Tm) + { + I2C_SetFunc(I2Cx,I2cHlm_En); + } + enRet = I2C_SetBaud(I2Cx, u8Tm); + } + else + { + I2Cx->TMRUN = FALSE; + pstcI2CCfg->u8SlaveAddr = (uint8_t)(((uint32_t)pstcI2CCfg->u8SlaveAddr<<1)|(pstcI2CCfg->bGc)); + I2Cx->ADDR = pstcI2CCfg->u8SlaveAddr; + } + + return enRet; +} + +//@} // I2cGroup diff --git a/src/hc32f005_ddl/driver/src/lpm.c b/src/hc32f005_ddl/driver/src/lpm.c new file mode 100644 index 0000000..93bcf7a --- /dev/null +++ b/src/hc32f005_ddl/driver/src/lpm.c @@ -0,0 +1,122 @@ +/****************************************************************************** +*Copyright(C)2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file lpm.c + ** + ** Common API of lpm. + ** @link LpmGroup Some description @endlink + ** + ** - 2017-06-06 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "lpm.h" +/** + ******************************************************************************* + ** \addtogroup LpmGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ***************************************************************************** + ** \brief 进入深度睡眠模式 + ** + ** \input bOnExit - TRUE:当退出异常处理后,自动再次进入休眠; + ** FALSE:唤醒后不再自动进入休眠 + ** + ** \retval NULL + *****************************************************************************/ +void Lpm_GotoDeepSleep(boolean_t bOnExit) +{ + SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; + SCB->SCR |= 1u<SCR &= ~SCB_SCR_SLEEPDEEP_Msk; + SCB->SCR |= 1u<CR_f.IE = TRUE; +} + +/** + * \brief + * 除能LVD中断 + * + * \param 无 + * + * \retval 无 + */ +void Lvd_DisableIrq(void) +{ + M0P_LVD->CR_f.IE = FALSE; +} + +/** + * \brief + * LVD初始化 + * + * \param [in] pstcCfg LVD配置指针 + * + * \retval 无 + */ +void Lvd_Init(stc_lvd_cfg_t *pstcCfg) +{ + M0P_LVD->CR = 0; + + M0P_LVD->CR = (uint32_t)pstcCfg->enAct | + (uint32_t)pstcCfg->enFilter | + (uint32_t)pstcCfg->enFilterTime | + (uint32_t)pstcCfg->enInputSrc | + (uint32_t)pstcCfg->enIrqType | + (uint32_t)pstcCfg->enThreshold; +} + +/** + * \brief + * 使能LVD + * + * \param 无 + * + * \retval 无 + * + */ +void Lvd_Enable(void) +{ + M0P_LVD->CR_f.LVDEN = 1u; +} + +/** + * \brief + * 除能LVD + * + * \param 无 + * + * \retval 无 + */ +void Lvd_Disable(void) +{ + M0P_LVD->CR_f.LVDEN = 0u; +} + +/** + * \brief + * 获取LVD中断标志 + * + * \param 无 + * + * \retval boolean_t 中断标志 + */ +boolean_t Lvd_GetIrqStat(void) +{ + return M0P_LVD->IFR_f.INTF; + +} + +/** + * \brief + * 清除LVD中断标志 + * + * \param 无 + * + * \retval 无 + */ +void Lvd_ClearIrq(void) +{ + M0P_LVD->IFR_f.INTF = 0u; +} + + +//@} // LvdGroup + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/src/hc32f005_ddl/driver/src/pca.c b/src/hc32f005_ddl/driver/src/pca.c new file mode 100644 index 0000000..36e87ac --- /dev/null +++ b/src/hc32f005_ddl/driver/src/pca.c @@ -0,0 +1,532 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file pca.c + ** + ** pca driver API. + ** @link pcnt Group Some description @endlink + ** + ** - 2019-04-09 First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "pca.h" + +/** + ****************************************************************************** + ** \addtogroup PCNTGroup + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/****************************************************************************** + * Local variable definitions ('static') + ******************************************************************************/ + +/** +****************************************************************************** + ** \brief 获取中断源的标志位 + ** @param IT_Src : 中断源标志位 + ** \retval FALSE 或TRUE + ** +******************************************************************************/ +boolean_t Pca_GetItStatus(en_pca_ccficlr_t It_Src) +{ + return (((M0P_PCA->CCON)>>It_Src) & 1) > 0? TRUE : FALSE; +} + +/** +****************************************************************************** + ** \brief 清除中断源的标志位 + ** @param IT_Src : 中断源标志位 + ** \retval 无 + ** +******************************************************************************/ +void Pca_ClrItStatus(en_pca_ccficlr_t It_Src) +{ + M0P_PCA->ICLR &= ~(uint32_t)(1<CCON)), 6, NewStatus); +} + +/** +****************************************************************************** + ** \brief PCA 空闲模式IDLE下,PCA是否停止工作设置 + ** @param NewStatus : TRUE 或 FALSE + ** \retval 无 + ** +******************************************************************************/ +void Pca_SetCidl(boolean_t NewStatus) +{ + SetBit((uint32_t)(&(M0P_PCA->CMOD)), 7, NewStatus); +} + +/** +****************************************************************************** + ** \brief PCA 模块4的看门狗使能控制 + ** @param NewStatus : TRUE 或 FALSE + ** \retval 无 + ** +******************************************************************************/ +void Pca_Set4Wdte(boolean_t NewStatus) +{ + SetBit((uint32_t)(&(M0P_PCA->CMOD)), 6, NewStatus); +} + +/** +****************************************************************************** + ** \brief PCA 计数器中断控制PCA_CMOD中CFIE,对应的控制中断位PCA_CCON中的CF与PCA_ICLR中的CF + ** @param NewStatus : TRUE 或 FALSE + ** \retval 无 + ** +******************************************************************************/ +void Pca_ConfPcaIt(boolean_t NewStatus) +{ + SetBit((uint32_t)(&(M0P_PCA->CMOD)), 0, NewStatus); +} + +/** +****************************************************************************** + ** \brief PCA 比较捕获中断使能控制 PCA_CCAPMx的CCIE + ** @param Modulex : pca_module0~4 + ** @param NewStatus : TRUE 或 FALSE + ** \retval 无 + ** +******************************************************************************/ +void Pca_ConfModulexIt(en_pca_module_t Modulex, boolean_t NewStatus) +{ + switch(Modulex) + { + case PcaModule0: + SetBit((uint32_t)(&(M0P_PCA->CCAPM0)), 0, NewStatus); + break; + case PcaModule1: + SetBit((uint32_t)(&(M0P_PCA->CCAPM1)), 0, NewStatus); + break; + case PcaModule2: + SetBit((uint32_t)(&(M0P_PCA->CCAPM2)), 0, NewStatus); + break; + case PcaModule3: + SetBit((uint32_t)(&(M0P_PCA->CCAPM3)), 0, NewStatus); + break; + case PcaModule4: + SetBit((uint32_t)(&(M0P_PCA->CCAPM4)), 0, NewStatus); + break; + default: + break; + } +} + +/** +****************************************************************************** + ** \brief PCA 模块0的初始化 + ** @param InitStruct : PCA初始化配置的结构体 + ** \retval 无 + ** +******************************************************************************/ +void Pca_M0Init(stc_pcacfg_t* InitStruct) +{ + M0P_PCA->CMOD_f.CPS = InitStruct->pca_clksrc; + M0P_PCA->CMOD_f.CIDL = InitStruct->pca_cidl; + M0P_PCA->CCAPM0_f.ECOM = InitStruct->pca_ecom; + M0P_PCA->CCAPM0_f.CAPP = InitStruct->pca_capp; + M0P_PCA->CCAPM0_f.CAPN = InitStruct->pca_capn; + M0P_PCA->CCAPM0_f.MAT = InitStruct->pca_mat; + M0P_PCA->CCAPM0_f.TOG = InitStruct->pca_tog; + M0P_PCA->CCAPM0_f.PWM = InitStruct->pca_pwm; + + if(InitStruct->pca_pwm == PcaPwm8bitEnable) + { + M0P_PCA->CCAP0L_f.CCAP0 = InitStruct->pca_ccapl; + M0P_PCA->CCAP0H_f.CCAP0 = InitStruct->pca_ccaph; + } + else + { + M0P_PCA->CCAP0_f.CCAP0 = InitStruct->pca_ccap; + } + +} + +/** +****************************************************************************** + ** \brief PCA 模块1的初始化 + ** @param InitStruct : PCA初始化配置的结构体 + ** \retval 无 + ** +******************************************************************************/ +void Pca_M1Init(stc_pcacfg_t* InitStruct) +{ + M0P_PCA->CMOD_f.CPS = InitStruct->pca_clksrc; + M0P_PCA->CMOD_f.CIDL = InitStruct->pca_cidl; + M0P_PCA->CCAPM1_f.ECOM = InitStruct->pca_ecom; + M0P_PCA->CCAPM1_f.CAPP = InitStruct->pca_capp; + M0P_PCA->CCAPM1_f.CAPN = InitStruct->pca_capn; + M0P_PCA->CCAPM1_f.MAT = InitStruct->pca_mat; + M0P_PCA->CCAPM1_f.TOG = InitStruct->pca_tog; + M0P_PCA->CCAPM1_f.PWM = InitStruct->pca_pwm; + + if(InitStruct->pca_pwm == PcaPwm8bitEnable) + { + M0P_PCA->CCAP1L_f.CCAP1 = InitStruct->pca_ccapl; + M0P_PCA->CCAP1H_f.CCAP1 = InitStruct->pca_ccaph; + } + else + { + M0P_PCA->CCAP1_f.CCAP1 = InitStruct->pca_ccap; + } + +} + +/** +****************************************************************************** + ** \brief PCA 模块2的初始化 + ** @param InitStruct : PCA初始化配置的结构体 + ** \retval 无 + ** +******************************************************************************/ +void Pca_M2Init(stc_pcacfg_t* InitStruct) +{ + M0P_PCA->CMOD_f.CPS = InitStruct->pca_clksrc; + M0P_PCA->CMOD_f.CIDL = InitStruct->pca_cidl; + M0P_PCA->CCAPM2_f.ECOM = InitStruct->pca_ecom; + M0P_PCA->CCAPM2_f.CAPP = InitStruct->pca_capp; + M0P_PCA->CCAPM2_f.CAPN = InitStruct->pca_capn; + M0P_PCA->CCAPM2_f.MAT = InitStruct->pca_mat; + M0P_PCA->CCAPM2_f.TOG = InitStruct->pca_tog; + M0P_PCA->CCAPM2_f.PWM = InitStruct->pca_pwm; + + if(InitStruct->pca_pwm == PcaPwm8bitEnable) + { + M0P_PCA->CCAP2L_f.CCAP2 = InitStruct->pca_ccapl; + M0P_PCA->CCAP2H_f.CCAP2 = InitStruct->pca_ccaph; + } + else + { + M0P_PCA->CCAP2_f.CCAP2 = InitStruct->pca_ccap; + } + +} + +/** +****************************************************************************** + ** \brief PCA 模块3的初始化 + ** @param InitStruct : PCA初始化配置的结构体 + ** \retval 无 + ** +******************************************************************************/ +void Pca_M3Init(stc_pcacfg_t* InitStruct) +{ + M0P_PCA->CMOD_f.CPS = InitStruct->pca_clksrc; + M0P_PCA->CMOD_f.CIDL = InitStruct->pca_cidl; + M0P_PCA->CCAPM3_f.ECOM = InitStruct->pca_ecom; + M0P_PCA->CCAPM3_f.CAPP = InitStruct->pca_capp; + M0P_PCA->CCAPM3_f.CAPN = InitStruct->pca_capn; + M0P_PCA->CCAPM3_f.MAT = InitStruct->pca_mat; + M0P_PCA->CCAPM3_f.TOG = InitStruct->pca_tog; + M0P_PCA->CCAPM3_f.PWM = InitStruct->pca_pwm; + + if(InitStruct->pca_pwm == PcaPwm8bitEnable) + { + M0P_PCA->CCAP3L_f.CCAP3 = InitStruct->pca_ccapl; + M0P_PCA->CCAP3H_f.CCAP3 = InitStruct->pca_ccaph; + } + else + { + M0P_PCA->CCAP3_f.CCAP3 = InitStruct->pca_ccap; + } + +} + +/** +****************************************************************************** + ** \brief PCA 模块4的初始化 + ** @param InitStruct : PCA初始化配置的结构体 + ** \retval 无 + ** +******************************************************************************/ +void Pca_M4Init(stc_pcacfg_t* InitStruct) +{ + M0P_PCA->CMOD_f.CPS = InitStruct->pca_clksrc; + M0P_PCA->CMOD_f.CIDL = InitStruct->pca_cidl; + M0P_PCA->CCAPM4_f.ECOM = InitStruct->pca_ecom; + M0P_PCA->CCAPM4_f.CAPP = InitStruct->pca_capp; + M0P_PCA->CCAPM4_f.CAPN = InitStruct->pca_capn; + M0P_PCA->CCAPM4_f.MAT = InitStruct->pca_mat; + M0P_PCA->CCAPM4_f.TOG = InitStruct->pca_tog; + M0P_PCA->CCAPM4_f.PWM = InitStruct->pca_pwm; + + if(InitStruct->pca_pwm == PcaPwm8bitEnable) + { + M0P_PCA->CCAP4L_f.CCAP4 = InitStruct->pca_ccapl; + M0P_PCA->CCAP4H_f.CCAP4 = InitStruct->pca_ccaph; + } + else + { + M0P_PCA->CCAP4_f.CCAP4 = InitStruct->pca_ccap; + } + +} + +/** +****************************************************************************** + ** \brief PCA 读取CNT寄存器的数值 + ** @param 无 + ** \retval CNT的低半字值 + ** +******************************************************************************/ +uint16_t Pca_GetCnt(void) +{ + return (uint16_t)(M0P_PCA->CNT); +} + +/** +****************************************************************************** + ** \brief PCA 向CNT寄存器写入数值 + ** @param cnt : 所要写入的数值 + ** \retval 无 + ** +******************************************************************************/ +void Pca_SetCnt(uint16_t cnt) +{ + if(GetBit((uint32_t)(&(M0P_PCA->CCON)), 6)==TRUE) + { + Pca_StartPca(FALSE); + M0P_PCA->CNT_f.CNT = cnt; + Pca_StartPca(TRUE); + } + else + { + M0P_PCA->CNT_f.CNT = cnt; + } + +} + +/** +****************************************************************************** + ** \brief PCA 返回指定通道比较高速输出标志寄存器的值 + ** @param Modulex : 通道号x=0、1、2、3、4 + ** \retval TRUE 或 FALSE + ** +******************************************************************************/ +boolean_t Pca_GetOut(en_pca_module_t Modulex) +{ + return GetBit((uint32_t)(&(M0P_PCA->CCAPO)), Modulex); +} + +/** +****************************************************************************** + ** \brief PCA 设置比较捕获16位寄存器CCAPx数值 + ** @param Modulex : 通道号x=0、1、2、3、4 + ** @param Value: 所要设置的值 + ** \retval 无 + ** +******************************************************************************/ +void Pca_SetCcap(en_pca_module_t Modulex, uint16_t Value) +{ + switch(Modulex) + { + case 0: + M0P_PCA->CCAP0_f.CCAP0 = Value; + break; + case 1: + M0P_PCA->CCAP1_f.CCAP1 = Value; + break; + case 2: + M0P_PCA->CCAP2_f.CCAP2 = Value; + break; + case 3: + M0P_PCA->CCAP3_f.CCAP3 = Value; + break; + case 4: + M0P_PCA->CCAP4_f.CCAP4 = Value; + break; + default: + break; + } +} + +/** +****************************************************************************** + ** \brief PCA 读取比较捕获16位寄存器CCAPx数值 + ** @param Modulex : 通道号x=0、1、2、3、4 + ** \retval CCAPx的值,x=0、1、2、3、4 + ** +******************************************************************************/ +uint16_t Pca_GetCcap(en_pca_module_t Modulex) +{ + uint16_t tmp; + switch(Modulex) + { + case 0: + tmp = M0P_PCA->CCAP0_f.CCAP0; + break; + case 1: + tmp = M0P_PCA->CCAP1_f.CCAP1; + break; + case 2: + tmp = M0P_PCA->CCAP2_f.CCAP2; + break; + case 3: + tmp = M0P_PCA->CCAP3_f.CCAP3; + break; + case 4: + tmp = M0P_PCA->CCAP4_f.CCAP4; + break; + default: + break; + } + return tmp; +} + + +/** +****************************************************************************** + ** \brief PCA 设置比较捕获寄存器的高8位和低8位 + ** @param Modulex : 通道号x=0、1、2、3、4 + ** @param ValueH : 要写入高8位的数值 + ** @param ValueL : 要写入低8位的数值 + ** \retval 无 + ** +******************************************************************************/ +void Pca_SetCcapHL(en_pca_module_t Modulex, uint8_t ValueH, uint8_t ValueL) +{ + switch(Modulex) + { + case 0: + M0P_PCA->CCAP0H_f.CCAP0 = ValueH; + M0P_PCA->CCAP0L_f.CCAP0 = ValueL; + break; + case 1: + M0P_PCA->CCAP1H_f.CCAP1 = ValueH; + M0P_PCA->CCAP1L_f.CCAP1 = ValueL; + break; + case 2: + M0P_PCA->CCAP2H_f.CCAP2 = ValueH; + M0P_PCA->CCAP2L_f.CCAP2 = ValueL; + break; + case 3: + M0P_PCA->CCAP3H_f.CCAP3 = ValueH; + M0P_PCA->CCAP3L_f.CCAP3 = ValueL; + break; + case 4: + M0P_PCA->CCAP4H_f.CCAP4 = ValueH; + M0P_PCA->CCAP4L_f.CCAP4 = ValueL; + break; + default: + break; + } +} + +/** +****************************************************************************** + ** \brief PCA 读取比较捕获寄存器的高8位和低8位 + ** @param Modulex : 通道号x=0、1、2、3、4 + ** @param ValueH : CCAPx高8位的数值 + ** @param ValueL : CCAPx低8位的数值 + ** \retval 无 + ** +******************************************************************************/ +void Pca_GetCcapHL(en_pca_module_t Modulex, uint8_t *ValueH, uint8_t *ValueL) +{ + switch(Modulex) + { + case 0: + *ValueH = M0P_PCA->CCAP0H_f.CCAP0; + *ValueL = M0P_PCA->CCAP0L_f.CCAP0; + break; + case 1: + *ValueH = M0P_PCA->CCAP1H_f.CCAP1; + *ValueL = M0P_PCA->CCAP1L_f.CCAP1; + break; + case 2: + *ValueH = M0P_PCA->CCAP2H_f.CCAP2; + *ValueL = M0P_PCA->CCAP2L_f.CCAP2; + break; + case 3: + *ValueH = M0P_PCA->CCAP3H_f.CCAP3; + *ValueL = M0P_PCA->CCAP3L_f.CCAP3; + break; + case 4: + *ValueH = M0P_PCA->CCAP4H_f.CCAP4; + *ValueL = M0P_PCA->CCAP4L_f.CCAP4; + break; + default: + break; + } +} +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + + + + diff --git a/src/hc32f005_ddl/driver/src/ram.c b/src/hc32f005_ddl/driver/src/ram.c new file mode 100644 index 0000000..44081b6 --- /dev/null +++ b/src/hc32f005_ddl/driver/src/ram.c @@ -0,0 +1,156 @@ +/****************************************************************************** +*Copyright(C)2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file ram.c + ** + ** Common API of ram. + ** @link RamGroup Some description @endlink + ** + ** - 2018-05-08 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "ram.h" +/** + ******************************************************************************* + ** \addtogroup ramGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ***************************************************************************** + ** \brief Ram奇偶校验出错地址获取 + ** + ** + ** \retval ERROR ADDRESS + *****************************************************************************/ +uint32_t Ram_ErrAddrGet(void) +{ + return M0P_RAM->ERRADDR; +} + +/** + ***************************************************************************** + ** \brief Ram中断标志获取 + ** + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +boolean_t Ram_GetIntFlag(void) +{ + if(M0P_RAM->IFR & 0x1) + { + return TRUE; + } + else + { + return FALSE; + } +} + +/** + ***************************************************************************** + ** \brief Ram中断标志清除 + ** + ** + ** \retval Null + *****************************************************************************/ +void Ram_ClearIntFlag(void) +{ + M0P_RAM->ICLR = 0u; +} + +/** + ***************************************************************************** + ** \brief Ram中断使能 + ** + ** \retval Null + *****************************************************************************/ +void Ram_EnableIrq (void) +{ + M0P_RAM->CR |= 0x2u; +} + +/** + ***************************************************************************** + ** \brief ram中断禁止 + ** + ** \retval Null + *****************************************************************************/ +void Ram_DisableIrq(void) +{ + M0P_RAM->CR &= 0x1; +} + + +//@} // RamGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/src/hc32f005_ddl/driver/src/reset.c b/src/hc32f005_ddl/driver/src/reset.c new file mode 100644 index 0000000..422406b --- /dev/null +++ b/src/hc32f005_ddl/driver/src/reset.c @@ -0,0 +1,170 @@ +/****************************************************************************** +*Copyright(C)2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file reset.c + ** + ** Common API of reset. + ** @link resetGroup Some description @endlink + ** + ** - 2017-05-04 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "reset.h" + +/** + ******************************************************************************* + ** \addtogroup ResetGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ******************************************************************************* + ** \brief 获取复位源类型. + ** + ** \param [out] enRstFlg @ref en_reset_flag_t + ** + ** \retval TRUE or FALSE + ******************************************************************************/ +boolean_t Reset_GetFlag(en_reset_flag_t enRstFlg) +{ + if(M0P_RESET->RESET_FLAG&enRstFlg) + { + return TRUE; + } + else + { + return FALSE; + } +} + +/** + ******************************************************************************* + ** \brief 清除复位源类型. + ** + ** \param [in] pstcFlag @ref en_reset_flag_t + ** + ** \retval Null + ******************************************************************************/ +void Reset_ClearFlag(en_reset_flag_t enRstFlg) +{ + M0P_RESET->RESET_FLAG &= ~(uint32_t)enRstFlg; +} + +/** + ******************************************************************************* + ** \brief 清除所有复位源类型. + ** + ** \param Null + ** + ** \retval Null + ******************************************************************************/ +void Reset_ClearFlagAll(void) +{ + M0P_RESET->RESET_FLAG = 0; +} + +/** + ******************************************************************************* + ** \brief 所有模块进行一次复位. + ** + ** + ** \retval Null + ******************************************************************************/ +void Reset_RstPeripheralAll(void) +{ + M0P_RESET->PERI_RESET = 0u; + M0P_RESET->PERI_RESET = 0xFFFFFFFFu; +} + +/** + ******************************************************************************* + ** \brief 对外设源模块进行一次复位. + ** + ** \param [in] enPeri @ref en_reset_peripheral_t + ** + ** \retval Null + ******************************************************************************/ +void Reset_RstPeripheral(en_reset_peripheral_t enPeri) +{ + M0P_RESET->PERI_RESET &= ~(uint32_t)enPeri; + M0P_RESET->PERI_RESET |= (uint32_t)enPeri; +} + + + +//@} // ResetGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/driver/src/spi.c b/src/hc32f005_ddl/driver/src/spi.c new file mode 100644 index 0000000..234aed9 --- /dev/null +++ b/src/hc32f005_ddl/driver/src/spi.c @@ -0,0 +1,180 @@ +/****************************************************************************** +* Copyright (C) 2016, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with eaenCh copy of this software, whether used in part or whole, +* at all times. +*/ +/*****************************************************************************/ +/** \file spi.c + ** + ** SPI driver API. + ** @link Driver Group Some description @endlink + ** + ** - 2018-05-17 1.0 Devi First version for Device Driver Library of + ** Module. + ** + *****************************************************************************/ + +/****************************************************************************** + * Include files + *****************************************************************************/ +#include "spi.h" + +/** + ****************************************************************************** + ** \addtogroup SpiGroup + *****************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + *****************************************************************************/ + +#define IS_VALID_STAT(x) ( SpiIf == (x)||\ + SpiWcol == (x)||\ + SpiSserr == (x)||\ + SpiMdf == (x) ) + + +/******************************************************************************/ +/* Local function prototypes ('static') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local variable prototypes ('static') */ +/******************************************************************************/ + +/** + ****************************************************************************** + ** \brief SPI 请求状态获取 + ** + ** \param [in]SPIx 通道, enStatus 获取请求 + ** + ** \retval 请求状态 + ** + ******************************************************************************/ +boolean_t Spi_GetStatus(M0P_SPI_TypeDef* SPIx, en_spi_status_t enStatus) +{ + ASSERT(IS_VALID_STAT(enStatus)); + + if(SPIx->STAT&enStatus) + { + return TRUE; + } + else + { + return FALSE; + } + +} + + +/** + ****************************************************************************** + ** \brief SPI 总体初始化函数 + ** + ** \param [in] SPIx 通道 + ** \param [in] pstcSpiCfg 初始化结构 + ** + ** \retval Ok初始化成功 + ** \retval ErrorInvalidParameter 初始化错误 + ******************************************************************************/ +en_result_t Spi_Init(M0P_SPI_TypeDef* SPIx, stc_spi_cfg_t *pstcSpiCfg) +{ + ASSERT(NULL != pstcSpiCfg); + + SPIx->CR = 0; + SPIx->CR = (uint32_t)pstcSpiCfg->enSpiMode | + (uint32_t)pstcSpiCfg->enPclkDiv | + (uint32_t)pstcSpiCfg->enCPOL | + (uint32_t)pstcSpiCfg->enCPHA | + (uint32_t)0x40; + + SPIx->STAT = 0x00; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief SPI 配置主发送的电平 + ** + ** \param [in] SPIx 通道选择,bFlag高低电平 + ** + ** \retval 无 + ** + ******************************************************************************/ +void Spi_SetCS(M0P_SPI_TypeDef* SPIx, boolean_t bFlag) +{ + SPIx->SSN = bFlag; +} +/** + ****************************************************************************** + ** \brief SPI 发送一字节函数 + ** + ** \param [in] SPIx 通道选择,u8Data发送字节 + ** + ** \retval Ok发送成功 + ** + ******************************************************************************/ +en_result_t Spi_SendData(M0P_SPI_TypeDef* SPIx, uint8_t u8Data) +{ + SPIx->DATA = u8Data; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief SPI 接收一字节函数 + ** + ** \param [in] SPIx接收通道 + ** + ** \retval 接收一字节数据 + ** + ******************************************************************************/ +uint8_t Spi_ReceiveData(M0P_SPI_TypeDef* SPIx) +{ + return SPIx->DATA; +} + +//@} // SpiGroup +/****************************************************************************** + * EOF (not truncated) + *****************************************************************************/ + diff --git a/src/hc32f005_ddl/driver/src/sysctrl.c b/src/hc32f005_ddl/driver/src/sysctrl.c new file mode 100644 index 0000000..5334c09 --- /dev/null +++ b/src/hc32f005_ddl/driver/src/sysctrl.c @@ -0,0 +1,542 @@ +/****************************************************************************** +*Copyright(C)2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file sysctrl.c + ** + ** Common API of sysctrl. + ** @link SysctrlGroup Some description @endlink + ** + ** - 2018-04-22 Lux + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "sysctrl.h" + +/** + ******************************************************************************* + ** \addtogroup SysctrlGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define CLK_TIMEOUT (1000000u) + +#define IS_VALID_SRC(x) ( ClkRCH == (x)||\ + ClkXTH == (x)||\ + ClkRCL == (x)||\ + ClkXTL == (x) ) + + +#define IS_VALID_FUNC(x) ( ClkFuncWkupRCH == (x)||\ + ClkFuncXTHEn == (x)||\ + ClkFuncXTLEn == (x)||\ + ClkFuncXTLAWSON == (x)||\ + ClkFuncFaultEn == (x)||\ + ClkFuncRtcLPWEn == (x)||\ + ClkFuncLockUpEn == (x)||\ + ClkFuncRstPinIOEn == (x)||\ + ClkFuncSwdPinIOEn == (x) ) + +#define RC_TRIM_BASE_ADDR ((volatile uint16_t*) (0x00100C00ul)) +#define RCH_CR_TRIM_24M_VAL (*((volatile uint16_t*) (0x00100C00ul))) +#define RCH_CR_TRIM_22_12M_VAL (*((volatile uint16_t*) (0x00100C02ul))) +#define RCH_CR_TRIM_16M_VAL (*((volatile uint16_t*) (0x00100C04ul))) +#define RCH_CR_TRIM_8M_VAL (*((volatile uint16_t*) (0x00100C06ul))) +#define RCH_CR_TRIM_4M_VAL (*((volatile uint16_t*) (0x00100C08ul))) + +#define RCL_CR_TRIM_38400_VAL (*((volatile uint16_t*) (0x00100C20ul))) +#define RCL_CR_TRIM_32768_VAL (*((volatile uint16_t*) (0x00100C22ul))) + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ +extern uint32_t SystemCoreClock; +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +/** + ******************************************************************************* + ** \brief SYSCTRL0\SYSCTRL1寄存器操作解锁 + ** + ** \retval None + ******************************************************************************/ +static void _SysctrlUnlock(void) +{ + M0P_SYSCTRL->SYSCTRL2 = 0x5A5A; + M0P_SYSCTRL->SYSCTRL2 = 0xA5A5; +} + +/** + ******************************************************************************* + ** \brief 系统时钟源使能 + ** \param [in] enSource 目标时钟源 + ** \param [in] bFlag 使能1-开/0-关 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Sysctrl_ClkSourceEnable(en_sysctrl_clk_source_t enSource, boolean_t bFlag) +{ + en_result_t enRet = Ok; + uint32_t u32Temp; + + _SysctrlUnlock(); + bFlag = !!bFlag; + + u32Temp = M0P_SYSCTRL->PERI_CLKEN; + switch (enSource) + { + case SysctrlClkRCH: + M0P_SYSCTRL->SYSCTRL0_f.RCH_EN = bFlag; + while(bFlag && (1 != M0P_SYSCTRL->RCH_CR_f.STABLE)) + { + ; + } + break; + + case SysctrlClkXTH: + M0P_SYSCTRL->PERI_CLKEN_f.GPIO = TRUE; + M0P_GPIO->P0ADS |= 0x06u; + M0P_SYSCTRL->SYSCTRL0_f.XTH_EN = bFlag; + while(bFlag && (1 != M0P_SYSCTRL->XTH_CR_f.STABLE)) + { + ; + } + break; + + case SysctrlClkRCL: + M0P_SYSCTRL->SYSCTRL0_f.RCL_EN = bFlag; + while(bFlag && (1 != M0P_SYSCTRL->RCL_CR_f.STABLE)) + { + ; + } + break; + + default: + enRet = ErrorInvalidParameter; + break; + } + M0P_SYSCTRL->PERI_CLKEN = u32Temp; + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 外部高速晶振驱动配置 + ** \param [in] enFreq 外部高速晶振频率范围选择 + ** \param [in] enDriver 外部高速晶振驱动能力选择 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Sysctrl_XTHDriverCfg(en_sysctrl_xtal_driver_t enDriver) +{ + en_result_t enRet = Ok; + + M0P_SYSCTRL->XTH_CR_f.DRIVER = enDriver; + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 外部高速时钟稳定周期配置 + ** \param [in] enCycle 外部高速时钟稳定周期设置 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Sysctrl_SetXTHStableTime(en_sysctrl_xth_cycle_t enCycle) +{ + en_result_t enRet = Ok; + M0P_SYSCTRL->XTH_CR_f.STARTUP = enCycle; + return enRet; +} + +/** + ******************************************************************************* + ** \brief 内部低速时钟稳定周期配置 + ** \param [in] enCycle 内部低速时钟稳定周期设置 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Sysctrl_SetRCLStableTime(en_sysctrl_rcl_cycle_t enCycle) +{ + en_result_t enRet = Ok; + M0P_SYSCTRL->RCL_CR_f.STARTUP = enCycle; + return enRet; +} + +/** + ******************************************************************************* + ** \brief 时钟源切换,该函数执行后会开启新时钟源 + ** \note 选择时钟源之前,需根据需要配置目标时钟源的频率/驱动参数/使能时钟源等 + ** \param [in] enSource 新时钟源 + ** + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Sysctrl_SysClkSwitch(en_sysctrl_clk_source_t enSource) +{ + en_result_t enRet = Ok; + + en_sysctrl_clk_source_t ClkNew = enSource; + + _SysctrlUnlock(); + M0P_SYSCTRL->SYSCTRL0_f.CLKSW = ClkNew; + + //更新Core时钟(HCLK) + SystemCoreClockUpdate(); + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 获得系统时钟(HCLK)频率值 + ** \retval uint32_t HCLK频率值 + ** + ******************************************************************************/ +uint32_t Sysctrl_GetHClkFreq(void) +{ + uint32_t u32Val = 0; + const uint32_t u32hcr_tbl[] = { 4000000, 8000000, 16000000, 22120000, 24000000}; + const uint16_t u32lcr_tbl[] = { 32768, 38400}; + en_sysctrl_clk_source_t enSrc; + uint16_t u16Trim[5] = {0}; + u16Trim[4] = RCH_CR_TRIM_24M_VAL; + u16Trim[3] = RCH_CR_TRIM_22_12M_VAL; + u16Trim[2] = RCH_CR_TRIM_16M_VAL; + u16Trim[1] = RCH_CR_TRIM_8M_VAL; + u16Trim[0] = RCL_CR_TRIM_38400_VAL; + + //获取当前系统时钟 + enSrc = (en_sysctrl_clk_source_t)(M0P_SYSCTRL->SYSCTRL0_f.CLKSW); + + switch (enSrc) + { + case SysctrlClkRCH: + { + + if((M0P_SYSCTRL->RCH_CR_f.TRIM) == (u16Trim[4])) + { + u32Val = u32hcr_tbl[4]; + } + else if((M0P_SYSCTRL->RCH_CR_f.TRIM) == (u16Trim[3])) + { + u32Val = u32hcr_tbl[3]; + } + else if((M0P_SYSCTRL->RCH_CR_f.TRIM) == (u16Trim[2])) + { + u32Val = u32hcr_tbl[2]; + } + else if((M0P_SYSCTRL->RCH_CR_f.TRIM) == (u16Trim[1])) + { + u32Val = u32hcr_tbl[1]; + } + else + { + u32Val = u32hcr_tbl[0]; + } + } + break; + case SysctrlClkXTH: + u32Val = SYSTEM_XTH; + break; + case SysctrlClkRCL: + { + if(u16Trim[0] == (M0P_SYSCTRL->RCL_CR_f.TRIM)) + { + u32Val = u32lcr_tbl[1]; + } + else + { + u32Val = u32lcr_tbl[0]; + } + } + break; + default: + u32Val = 0u; + break; + } + + u32Val = (u32Val >> M0P_SYSCTRL->SYSCTRL0_f.HCLK_PRS); + + return u32Val; +} + +/** + ******************************************************************************* + ** \brief 获得外设时钟(PCLK)频率值 + ** \retval uint32_t PCLK频率值(Hz) + ** + ******************************************************************************/ +uint32_t Sysctrl_GetPClkFreq(void) +{ + uint32_t u32Val = 0; + + u32Val = Sysctrl_GetHClkFreq(); + u32Val = (u32Val >> (M0P_SYSCTRL->SYSCTRL0_f.PCLK_PRS)); + + return u32Val; +} + + +/** + ******************************************************************************* + ** \brief 时钟初始化函数 + ** \param [in] pstcCfg 初始化配置参数 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Sysctrl_ClkInit(stc_sysctrl_clk_cfg_t *pstcCfg) +{ + en_result_t enRet = Ok; + + //系统时钟参数配置 + switch(pstcCfg->enClkSrc) + { + case SysctrlClkRCH: + + break; + case SysctrlClkXTH: + Sysctrl_XTHDriverCfg(SysctrlXtalDriver3); + Sysctrl_SetXTHStableTime(SysctrlXthStableCycle16384); + break; + case SysctrlClkRCL: + Sysctrl_SetRCLStableTime(SysctrlRclStableCycle256); + break; + default: + enRet = ErrorInvalidParameter; + break; + } + + //时钟源使能 + Sysctrl_ClkSourceEnable(pstcCfg->enClkSrc, TRUE); + + //时钟源切换 + Sysctrl_SysClkSwitch(pstcCfg->enClkSrc); + + //时钟分频设置 + Sysctrl_SetHCLKDiv(pstcCfg->enHClkDiv); + Sysctrl_SetPCLKDiv(pstcCfg->enPClkDiv); + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 时钟去初始化函数 + ** \param [in] + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Sysctrl_ClkDeInit(void) +{ + en_result_t enRet = Ok; + + //配置RCH为内部4Hz + Sysctrl_SetRCHTrim(SysctrlRchFreq4MHz); + + //时钟源使能 + Sysctrl_ClkSourceEnable(SysctrlClkRCH, TRUE); + + //时钟源切换 + Sysctrl_SysClkSwitch(SysctrlClkRCH); + + //其它时钟源使能关闭 + Sysctrl_ClkSourceEnable(SysctrlClkXTH, FALSE); + Sysctrl_ClkSourceEnable(SysctrlClkRCL, FALSE); + Sysctrl_ClkSourceEnable(SysctrlClkXTL, FALSE); + + //时钟分频设置 + Sysctrl_SetHCLKDiv(SysctrlHclkDiv1); + Sysctrl_SetPCLKDiv(SysctrlPclkDiv1); + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 内部高速时钟频率TRIM值加载 + ** \param [in] enRCHFreq 设定的RCH目标频率值 + ** \retval Ok 设定成功 + ** 其他 设定失败或时钟未稳定 + ******************************************************************************/ +en_result_t Sysctrl_SetRCHTrim(en_sysctrl_rch_freq_t enRCHFreq) +{ + //加载RCH Trim值 + M0P_SYSCTRL->RCH_CR_f.TRIM = *(RC_TRIM_BASE_ADDR + enRCHFreq); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief 外部高速时钟频率范围设定 + ** \param [in] enXTHFreq 设定的频率值 + ** \retval Ok 设定成功 + ** 其他 设定失败或时钟未稳定 + ******************************************************************************/ +en_result_t Sysctrl_SetXTHFreq(en_sysctrl_xth_freq_t enXTHFreq) +{ + en_result_t enRet = Ok; + + M0P_SYSCTRL->XTH_CR_f.XTH_FSEL = enXTHFreq; + + return enRet; +} + +/** + ******************************************************************************* + ** \brief 内部低速时钟频率TRIM值加载 + ** \param [in] enRCLFreq 设定的RCL目标频率值 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Sysctrl_SetRCLTrim(en_sysctrl_rcl_freq_t enRCLFreq) +{ + M0P_SYSCTRL->RCL_CR_f.TRIM = *(RC_TRIM_BASE_ADDR + enRCLFreq); + + return Ok; +} + +/** + ******************************************************************************* + ** \brief 系统时钟(HCLK)分频设定 + ** \param [in] enHCLKDiv 分频设定值 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Sysctrl_SetHCLKDiv(en_sysctrl_hclk_div_t enHCLKDiv) +{ + _SysctrlUnlock(); + M0P_SYSCTRL->SYSCTRL0_f.HCLK_PRS = enHCLKDiv; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief 外设时钟(PCLK)分频设定 + ** \param [in] enPCLKDiv 分频设定值 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Sysctrl_SetPCLKDiv(en_sysctrl_pclk_div_t enPCLKDiv) +{ + _SysctrlUnlock(); + M0P_SYSCTRL->SYSCTRL0_f.PCLK_PRS = enPCLKDiv; + + return Ok; +} + +/** + ******************************************************************************* + ** \brief 设置外设时钟门控开关 + ** \param [in] enPeripheral 目标外设 + ** \param [in] bFlag 使能开关 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Sysctrl_SetPeripheralGate(en_sysctrl_peripheral_gate_t enPeripheral, boolean_t bFlag) +{ + + SetBit((uint32_t)(&(M0P_SYSCTRL->PERI_CLKEN)), enPeripheral, bFlag); + + + return Ok; +} + +/** + ******************************************************************************* + ** \brief 获得外设时钟门控开关状态 + ** \param [in] enPeripheral 目标外设 + ** \retval TRUE 开 + ** FALSE 关 + ******************************************************************************/ +boolean_t Sysctrl_GetPeripheralGate(en_sysctrl_peripheral_gate_t enPeripheral) +{ + + return GetBit((uint32_t)(&(M0P_SYSCTRL->PERI_CLKEN)), enPeripheral); + + +} + +/** + ******************************************************************************* + ** \brief 系统功能设定 + ** \param [in] enFunc 系统功能枚举类型 + ** \param [in] bFlag 1-开/0-关 + ** \retval Ok 设定成功 + ** 其他 设定失败 + ******************************************************************************/ +en_result_t Sysctrl_SetFunc(en_sysctrl_func_t enFunc, boolean_t bFlag) +{ + _SysctrlUnlock(); + SetBit((uint32_t)(&(M0P_SYSCTRL->SYSCTRL1)), enFunc, bFlag); + + return Ok; +} + +//@} // SysctrlGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/src/hc32f005_ddl/driver/src/trim.c b/src/hc32f005_ddl/driver/src/trim.c new file mode 100644 index 0000000..df1e040 --- /dev/null +++ b/src/hc32f005_ddl/driver/src/trim.c @@ -0,0 +1,247 @@ +/****************************************************************************** +*Copyright(C)2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ + +/** \file trim.c + ** + ** Common API of trim. + ** @link trimGroup Some description @endlink + ** + ** - 2017-05-16 + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "trim.h" +/** + ******************************************************************************* + ** \addtogroup TrimGroup + ******************************************************************************/ +//@{ + +/******************************************************************************* + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/******************************************************************************* + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ +#define IS_VALID_TRIMINT(x) (TrimStop == (x) ||\ + TrimCalCntOf == (x) ||\ + TrimXTLFault == (x) ||\ + TrimXTHFault == (x)) + + +/******************************************************************************* + * Local type definitions ('typedef') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +/** + ***************************************************************************** + ** \brief Trim中断标志获取 + ** + ** + ** \param [in] enIntType 中断类型(RefStop、CalCntOf、XTAL32KFault、XTAL32MFault) + ** + ** \retval TRUE or FALSE + *****************************************************************************/ +boolean_t Trim_GetIntFlag(en_trim_inttype_t enIntType) +{ + ASSERT(IS_VALID_TRIMINT(enIntType)); + + if(M0P_CLK_TRIM->IFR&enIntType) + { + return TRUE; + } + else + { + return FALSE; + } + +} + +/** + ***************************************************************************** + ** \brief Trim中断标志清除 + ** + ** + ** \param [in] enIntType 中断类型(RefStop、CalCntOf、XTAL32KFault、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)); + + M0P_CLK_TRIM->ICLR &= ~(uint32_t)enIntType; + + return enResult; +} + + + +/** + ***************************************************************************** + ** \brief Trim中断使能 + ** + ** + ** + ** \retval Null + *****************************************************************************/ +void Trim_EnableIrq (void) +{ + M0P_CLK_TRIM->CR_f.IE = TRUE; +} + +/** + ***************************************************************************** + ** \brief Trim中断禁止 + ** + ** + ** + ** + ** \retval Ok or Error + *****************************************************************************/ +void Trim_DisableIrq(void) +{ + M0P_CLK_TRIM->CR_f.IE = FALSE; +} + +/** + ***************************************************************************** + ** \brief Trim初始化配置 + ** + ** + ** \param [in] pstcCfg Trim配置结构体指针 + ** + ** \retval Ok or Error + *****************************************************************************/ +en_result_t Trim_Init(stc_trim_cfg_t* pstcCfg) +{ + en_result_t enResult = Error; + + M0P_CLK_TRIM->CR = 0; + + M0P_CLK_TRIM->CR = (uint32_t)pstcCfg->enCALCLK | + (uint32_t)pstcCfg->enREFCLK | + (uint32_t)pstcCfg->enMON; + + M0P_CLK_TRIM->REFCON = pstcCfg->u32RefCon; + M0P_CLK_TRIM->CALCON = pstcCfg->u32CalCon; + + enResult = Ok; + + return enResult; +} + +/** + ***************************************************************************** + ** \brief Trim校准/监测启动运行 + ** + ** + ** + ** \retval Null + *****************************************************************************/ +void Trim_Run(void) +{ + M0P_CLK_TRIM->CR_f.TRIM_START = TRUE; +} + +/** + ***************************************************************************** + ** \brief Trim校准/监测停止 + ** + ** + ** + ** + ** \retval Null + *****************************************************************************/ +void Trim_Stop(void) +{ + M0P_CLK_TRIM->CR_f.TRIM_START = FALSE; +} + +/** + ***************************************************************************** + ** \brief Trim参考计数器计数值获取 + ** + ** + ** \retval u32Data 参考计数器计数值 + *****************************************************************************/ +uint32_t Trim_RefCntGet(void) +{ + return (uint32_t)M0P_CLK_TRIM->REFCNT; +} + +/** + ***************************************************************************** + ** \brief Trim校准计数器计数值获取 + ** + ** + ** + ** + ** \retval u32Data 校准计数器计数值 + *****************************************************************************/ +uint32_t Trim_CalCntGet(void) +{ + return (uint32_t)M0P_CLK_TRIM->CALCNT; +} + +//@} // TrimGroup + +/******************************************************************************* + * EOF (not truncated) + ******************************************************************************/ diff --git a/src/hc32f005_ddl/driver/src/uart.c b/src/hc32f005_ddl/driver/src/uart.c new file mode 100644 index 0000000..0bcb5f6 --- /dev/null +++ b/src/hc32f005_ddl/driver/src/uart.c @@ -0,0 +1,472 @@ +/************************************************************************************* +* 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') */ +/******************************************************************************/ + +/******************************************************************************/ +/* Local variable definitions ('static') */ +/******************************************************************************/ + +/** + ****************************************************************************** + ** \brief UART通信中断使能函数设置 + ** + ** \param [in] UARTx通道号,enIrqSel发送or接收中断使能 + ** + ** \retval OK配置成功 + ** \retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_EnableIrq(M0P_UART_TypeDef* UARTx, en_uart_irq_sel_t enIrqSel) +{ + SetBit((uint32_t)(&(UARTx->SCON)), enIrqSel, TRUE); + + return Ok; +} + +/** + ****************************************************************************** + ** \brief UART通信中断禁止函数设置 + ** + ** \param [in] UARTx通道号,enIrqSel发送or接收中断禁止 + ** + ** \retval OK配置成功 + ** \retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_DisableIrq(M0P_UART_TypeDef* UARTx, en_uart_irq_sel_t enIrqSel) +{ + SetBit((uint32_t)(&(UARTx->SCON)), enIrqSel, FALSE); + + return Ok; +} + +/** + ****************************************************************************** + ** \brief UART通道多主机模式配置 + ** + ** \param [in] UARTx通道号,stcMultiCfg多主机模式结构 + ** + ** \retval OK配置成功 + ** \retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_SetMultiMode(M0P_UART_TypeDef* UARTx, stc_uart_multimode_t* pstcMultiCfg) +{ + if(NULL != pstcMultiCfg) + { + UARTx->SCON_f.SM2 = TRUE; + UARTx->SADDR = pstcMultiCfg->u8SlaveAddr; + UARTx->SADEN = pstcMultiCfg->u8SaddEn; + + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** + ****************************************************************************** + ** \brief 计算接收字节奇偶校验是否正确 + ** + ** \param u8Idx通道,enCheck奇偶校验方式,u8Recv校验数据 + ** + ** \retval Error或者成功Ok + ******************************************************************************/ +en_result_t Uart_CheckEvenOrOdd(M0P_UART_TypeDef* UARTx, en_uart_check_t enCheck, uint8_t u8Recv) +{ + uint8_t cnt=0,i; + + for(i=0;i<8;i++) + { + if((u8Recv&0x80)==0x80) + { + cnt++; + } + u8Recv<<=1; + } + + if(enCheck == UartEven) + { + if(cnt%2!=0) + { + if(UARTx->SCON_f.RB8 != 1) + { + return Error; + } + } + else + { + if(UARTx->SCON_f.RB8 != 0) + { + return Error; + } + } + } + else + { + if(cnt%2!=0) + { + if(UARTx->SCON_f.RB8 != 0) + { + return Error; + } + } + else + { + if(UARTx->SCON_f.RB8 != 1) + { + return Error; + } + } + } + return Ok; +} + +/** + ****************************************************************************** + ** \brief 获取RB8数值 + ** + ** \param [in] UARTx通道号 + ** + ** \retval RB8 + ******************************************************************************/ +boolean_t Uart_GetRb8(M0P_UART_TypeDef* UARTx) +{ + return (UARTx->SCON_f.RB8); +} + +/** + ****************************************************************************** + ** \brief UART通道多机模式发送数据/地址帧配置TB8 + ** + ** \param [in] UARTx 通道号 + ** \param [in] TRUE-TB8为地址帧标志;FALSE-TB8为数据帧标志; + ** + ** \retval Null + ******************************************************************************/ +en_result_t Uart_SetTb8(M0P_UART_TypeDef* UARTx, en_uart_check_t enCheck, uint8_t u8Data) +{ + uint8_t cnt=0,i; + + for(i=0;i<8;i++) + { + if((u8Data&0x80)==0x80) + { + cnt++; + } + u8Data<<=1; + } + if(enCheck == UartEven) + { + if(cnt%2!=0) + { + UARTx->SCON_f.TB8 = 1; + } + else + { + UARTx->SCON_f.TB8 = 0; + } + } + else + { + if(cnt%2!=0) + { + UARTx->SCON_f.TB8 = 0; + } + else + { + UARTx->SCON_f.TB8 = 1; + } + } + + return Ok; + +} + +/** + ****************************************************************************** + ** \brief UART通道多主机模式从机地址配置函数 + ** + ** \param [in] UARTx通道号,addr地址 + ** + ** \retval OK配置成功 + ** \retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_SetSaddr(M0P_UART_TypeDef* UARTx,uint8_t u8Addr) +{ + UARTx->SADDR = u8Addr; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief UART通道波特率配置 + ** + ** \param [in] u8Idx通道号,u32pclk时钟源,stcBaud波特率配置结构 + ** + ** \retval 定时器配置值 + ** \retval 0,获取值失败 + ******************************************************************************/ +uint16_t Uart_SetBaudRate(M0P_UART_TypeDef* UARTx,stc_uart_baud_cfg_t* pstcBaud) +{ + uint16_t u16tmload=0; + + UARTx->SCON_f.DBAUD = pstcBaud->bDbaud; + + switch(pstcBaud->enMode) + { + case UartMode0: + case UartMode2: + break; + case UartMode1: + case UartMode3: + u16tmload = 0x10000-((pstcBaud->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(M0P_UART_TypeDef* UARTx, en_uart_func_t enFunc) +{ + SetBit((uint32_t)(&(UARTx->SCON)), enFunc, TRUE); + + return Ok; +} +/** + ****************************************************************************** + ** \brief UART通道发送或接收等功能禁止设置 + ** + ** \param [in] UARTx通道号,enFunc功能 + ** + ** \retval OK配置成功 + ** \retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_DisableFunc(M0P_UART_TypeDef* UARTx, en_uart_func_t enFunc) +{ + SetBit((uint32_t)(&(UARTx->SCON)), enFunc, FALSE); + + return Ok; +} + + +/** + ****************************************************************************** + ** \brief UART通道通信状态获取 + ** + ** \param [in] UARTx通道号 + ** + ** \retval 状态值 + ******************************************************************************/ +uint8_t Uart_GetIsr(M0P_UART_TypeDef* UARTx) +{ + return (UARTx->ISR); +} + +/** + ****************************************************************************** + ** \brief UART通道通信状态获取 + ** + ** \param [in] UARTx通道号,enStatus获取哪个状态 + ** + ** \retval 状态值 + ******************************************************************************/ +boolean_t Uart_GetStatus(M0P_UART_TypeDef* UARTx, en_uart_status_t enStatus) +{ + boolean_t bStatus = FALSE; + + + ASSERT(IS_VALID_STATUS(enStatus)); + + bStatus = GetBit((uint32_t)(&(UARTx->ISR)), enStatus); + + return bStatus; +} + +/** + ****************************************************************************** + ** \brief UART通道通信状态清除 + ** + ** \param [in] UARTx通道号 + ** + ** \retval OK + ** \retval ErrorInvalidParameter清除失败 + ******************************************************************************/ +en_result_t Uart_ClrIsr(M0P_UART_TypeDef* UARTx) +{ + UARTx->ICR = 0u; + return Ok; +} + +/** + ****************************************************************************** + ** \brief UART通道通信状态清除 + ** + ** \param [in] UARTx通道号,enStatus清除哪个状态 + ** + ** \retval OK + ** \retval ErrorInvalidParameter清除失败 + ******************************************************************************/ +en_result_t Uart_ClrStatus(M0P_UART_TypeDef* UARTx,en_uart_status_t enStatus) +{ + ASSERT(IS_VALID_STATUS(enStatus)); + + SetBit((uint32_t)(&(UARTx->ICR)), enStatus, FALSE); + + return Ok; +} + + +/** + ****************************************************************************** + ** \brief UART通道发送数据函数,查询方式调用此函数,中断方式发送不适用 + ** + ** \param [in] UARTx通道号,Data发送数据 + ** + ** \retval Ok发送成功 + ** \retval ErrorInvalidParameter发送失败 + ******************************************************************************/ +en_result_t Uart_SendDataPoll(M0P_UART_TypeDef* UARTx, uint8_t u8Data) +{ + UARTx->SBUF_f.SBUF = u8Data; + while(FALSE == Uart_GetStatus(UARTx,UartTC)) + {} + Uart_ClrStatus(UARTx,UartTC); + return Ok; +} + +/** + ****************************************************************************** + ** \brief UART通道发送数据函数,中断方式调用此函数 + ** + ** \param [in] UARTx通道号,Data发送数据 + ** + ** \retval Ok发送成功 + ** \retval ErrorInvalidParameter发送失败 + ******************************************************************************/ +en_result_t Uart_SendDataIt(M0P_UART_TypeDef* UARTx, uint8_t u8Data) +{ + UARTx->SBUF_f.SBUF = u8Data; + + return Ok; +} + +/** + ****************************************************************************** + ** \brief UART通道接收数据函数 + ** + ** \param [in] UARTx通道号 + ** + ** \retval 接收数据 + ******************************************************************************/ +uint8_t Uart_ReceiveData(M0P_UART_TypeDef* UARTx) +{ + return (UARTx->SBUF_f.SBUF); +} + +/** + ****************************************************************************** + ** \brief UART通道初始化函数 + ** + ** \param [in] UARTx通道号,pstcCfg初始化结构体 @ref stc_uart_cfg_t + ** + ** \retval OK配置成功 + ** \retval ErrorInvalidParameter配置失败 + ******************************************************************************/ +en_result_t Uart_Init(M0P_UART_TypeDef* UARTx, stc_uart_cfg_t* pstcCfg) +{ + UARTx->SCON_f.SM01 = pstcCfg->enRunMode; + Uart_EnableFunc(UARTx,UartRenFunc); ///<使能收发 + + return Ok; +} +//@} // UartGroup diff --git a/src/hc32f005_ddl/driver/src/vc.c b/src/hc32f005_ddl/driver/src/vc.c new file mode 100644 index 0000000..2bf121a --- /dev/null +++ b/src/hc32f005_ddl/driver/src/vc.c @@ -0,0 +1,280 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file vc.c + ** + ** voltage comparator driver API. + ** @link VC Group Some description @endlink + ** + ** - 2019-04-10 First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "vc.h" + +/** + ****************************************************************************** + ** \addtogroup VcGroup + ******************************************************************************/ +//@{ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/****************************************************************************** + * Local variable definitions ('static') + ******************************************************************************/ + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + *****************************************************************************/ + +/** +****************************************************************************** + ** \brief 配置VC中断触发方式 + ** + ** @param Channelx : VcChannelx x=0、1 + ** @param enSel : VcIrqRise、VcIrqFall、VcIrqHigh + ** \retval 无 + ** +******************************************************************************/ +void Vc_CfgItType(en_vc_channel_t Channelx, en_vc_irq_sel_t ItType) +{ + stc_vc_vc0_cr_field_t *stcVcnCr; + switch(Channelx) + { + case VcChannel0: + stcVcnCr = (stc_vc_vc0_cr_field_t*)&M0P_VC->VC0_CR_f; + break; + case VcChannel1: + stcVcnCr = (stc_vc_vc0_cr_field_t*)&M0P_VC->VC1_CR_f; + break; + + default: + break; + } + switch (ItType) + { + case VcIrqNone: + stcVcnCr->RISING = 0u; + stcVcnCr->FALLING = 0u; + stcVcnCr->LEVEL = 0u; + break; + case VcIrqRise: + stcVcnCr->RISING = 1u; + break; + case VcIrqFall: + stcVcnCr->FALLING = 1u; + break; + case VcIrqHigh: + stcVcnCr->LEVEL = 1u; + break; + default: + break; + } +} + +/** +****************************************************************************** + ** \brief VC 中断使能与禁止 + ** + ** @param Channelx : VcChannelx x=0、1 + ** @param NewStatus : TRUE 或 FALSE + ** \retval 无 + ** +******************************************************************************/ +void Vc_ItCfg(en_vc_channel_t Channelx, boolean_t NewStatus) +{ + switch(Channelx) + { + case VcChannel0: + SetBit((uint32_t)(&(M0P_VC->VC0_CR)), 15, NewStatus); + break; + case VcChannel1: + SetBit((uint32_t)(&(M0P_VC->VC1_CR)), 15, NewStatus); + break; + default: + break; + } +} + +/** +****************************************************************************** + ** \brief VC 比较结果获取,包含中断标志位和滤波结果 + ** + ** @param Result : 所要读取的结果 + ** \retval TRUE 或 FALSE + ** +******************************************************************************/ +boolean_t Vc_GetItStatus(en_vc_ifr_t Result) +{ + boolean_t bFlag; + bFlag = GetBit((uint32_t)(&(M0P_VC->IFR)), Result); + return bFlag; +} + +/** +****************************************************************************** + ** \brief VC 清除中断标志位 + ** + ** @param NewStatus : Vc0_Intf、Vc1_Intf、Vc2_Intf + ** \retval 无 + ** +******************************************************************************/ +void Vc_ClearItStatus(en_vc_ifr_t NewStatus) +{ + SetBit((uint32_t)(&(M0P_VC->IFR)), NewStatus, 0); +} + +/** +****************************************************************************** + ** \brief VC 配置DAC相关的内容 VC_CR中 VC_REF2P5_SEL VC_DIV_EN VC_DIV + ** + ** @param pstcDacCfg : + ** \retval Ok 或 ErrorInvalidParameter + ** +******************************************************************************/ +en_result_t Vc_DacInit(stc_vc_dac_cfg_t *pstcDacCfg) +{ + if (NULL == pstcDacCfg) + { + return ErrorInvalidParameter; + } + + M0P_VC->CR_f.DIV_EN = pstcDacCfg->bDivEn; + M0P_VC->CR_f.REF2P5_SEL = pstcDacCfg->enDivVref; + + if (pstcDacCfg->u8DivVal < 0x40) + { + M0P_VC->CR_f.DIV = pstcDacCfg->u8DivVal; + } + else + { + return ErrorInvalidParameter; + } + + return Ok; +} + +/** +****************************************************************************** + ** \brief VC通道初始化 + ** + ** @param pstcDacCfg : + ** \retval 无 + ** +******************************************************************************/ +void Vc_Init(stc_vc_channel_cfg_t *pstcChannelCfg) +{ + if (VcChannel0 == pstcChannelCfg->enVcChannel) + { + M0P_VC->CR_f.VC0_HYS_SEL = pstcChannelCfg->enVcCmpDly; + M0P_VC->CR_f.VC0_BIAS_SEL = pstcChannelCfg->enVcBiasCurrent; + M0P_VC->VC0_CR_f.DEBOUNCE_TIME = pstcChannelCfg->enVcFilterTime; + M0P_VC->VC0_CR_f.P_SEL = pstcChannelCfg->enVcInPin_P; + M0P_VC->VC0_CR_f.N_SEL = pstcChannelCfg->enVcInPin_N; + M0P_VC->VC0_CR_f.FLTEN = pstcChannelCfg->bFlten; + M0P_VC->VC0_OUT_CFG = 1<enVcOutCfg; + } + else if (VcChannel1 == pstcChannelCfg->enVcChannel) + { + M0P_VC->CR_f.VC1_HYS_SEL = pstcChannelCfg->enVcCmpDly; + M0P_VC->CR_f.VC1_BIAS_SEL = pstcChannelCfg->enVcBiasCurrent; + M0P_VC->VC1_CR_f.DEBOUNCE_TIME = pstcChannelCfg->enVcFilterTime; + M0P_VC->VC1_CR_f.P_SEL = pstcChannelCfg->enVcInPin_P; + M0P_VC->VC1_CR_f.N_SEL = pstcChannelCfg->enVcInPin_N; + M0P_VC->VC1_CR_f.FLTEN = pstcChannelCfg->bFlten; + M0P_VC->VC1_OUT_CFG = 1<enVcOutCfg; + } + else + { + ; + } +} + +/** +****************************************************************************** + ** \brief VC 通道使能 + ** + ** \param enChannel : 通道号VcChannel0 VcChannel1 + ** \param NewStatus : TRUE FALSE + ** \retval NewStatus : TRUE FALSE + ** +******************************************************************************/ +void Vc_Cmd(en_vc_channel_t enChannel, boolean_t NewStatus) +{ + switch(enChannel) + { + case VcChannel0: + SetBit((uint32_t)(&(M0P_VC->VC0_CR)), 0, NewStatus); + break; + case VcChannel1: + SetBit((uint32_t)(&(M0P_VC->VC1_CR)), 0, NewStatus); + break; + default: + break; + } +} + +//@} // VcGroup + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + diff --git a/src/hc32f005_ddl/driver/src/wdt.c b/src/hc32f005_ddl/driver/src/wdt.c new file mode 100644 index 0000000..4d07496 --- /dev/null +++ b/src/hc32f005_ddl/driver/src/wdt.c @@ -0,0 +1,203 @@ +/************************************************************************************* +* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file wdt.c + ** + ** WDT function driver API. + ** @link WdtGroup Some description @endlink + ** + ** - 2017-05-17 1.0 CJ First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "wdt.h" + +/** + ****************************************************************************** + ** \defgroup WdtGroup + ** + ******************************************************************************/ +//@{ + +/******************************************************************************/ +/* Local function prototypes ('static') */ +/******************************************************************************/ + +/** + ****************************************************************************** + ** \brief WDT溢出时间设置函数 + ** + ** \param [in] u8LoadValue 溢出时间 + ** + ** \retval 无 + ** + ******************************************************************************/ +void Wdt_WriteWdtLoad(uint8_t u8LoadValue) +{ + M0P_WDT->CON_f.WOV = u8LoadValue; +} +/** + ****************************************************************************** + ** \brief WDT初始化函数 + ** + ** \param [in] enFunc @ref en_wdt_func_t + ** \param [in] enTime @ref en_wdt_time_t + ** + ** \retval Ok + ** + ******************************************************************************/ +en_result_t Wdt_Init(en_wdt_func_t enFunc, en_wdt_time_t enTime) +{ + en_result_t enRet = Error; + + Wdt_WriteWdtLoad(enTime); + M0P_WDT->CON_f.WINT_EN = enFunc; + enRet = Ok; + return enRet; +} +/** + ****************************************************************************** + ** \brief WDT复位及启动函数 + ** + ** \param [in] 无 + ** + ** \retval 无 + ** + ******************************************************************************/ +void Wdt_Start(void) +{ + M0P_WDT->RST = 0x1E; + M0P_WDT->RST = 0xE1; +} + +/** + ****************************************************************************** + ** \brief WDT喂狗 + ** + ** \param [in] 无 + ** + ** \retval Ok + ** + ******************************************************************************/ +void Wdt_Feed(void) +{ + M0P_WDT->RST = 0x1E; + M0P_WDT->RST = 0xE1; +} + +/** + ****************************************************************************** + ** \brief WDT中断标志清除 + ** + ** \param [in] 无 + ** + ** \retval Ok + ** + ******************************************************************************/ +void Wdt_IrqClr(void) +{ + M0P_WDT->RST = 0x1E; + M0P_WDT->RST = 0xE1; +} + +/** + ****************************************************************************** + ** \brief WDT读取当前计数值函数 + ** + ** \param [in] 无 + ** + ** \retval 计数值 + ** + ******************************************************************************/ +uint8_t Wdt_ReadWdtValue(void) +{ + uint8_t u8Count; + + u8Count = M0P_WDT->CON_f.WCNTL; + + return u8Count; +} +/** + ****************************************************************************** + ** \brief WDT读取当前运行状态 + ** + ** \param [in] 无 + ** + ** \retval 状态值 + ** + ******************************************************************************/ +boolean_t Wdt_ReadwdtStatus(void) +{ + if(M0P_WDT->CON&0x10u) + { + return TRUE; + } + else + { + return FALSE; + } +} + +/** + ******************************************************************************* + ** \brief WDT 中断状态标记获取 + ** + ** + ** \retval 中断状态 + ******************************************************************************/ +boolean_t Wdt_GetIrqStatus(void) +{ + if(M0P_WDT->CON&0x80u) + { + return TRUE; + } + else + { + return FALSE; + } +} + + +//@} // WdtGroup diff --git a/src/hc32f005_ddl/example/adc/adc_norm_polling/EWARM/adc_norm_polling.ewp b/src/hc32f005_ddl/example/adc/adc_norm_polling/EWARM/adc_norm_polling.ewp new file mode 100644 index 0000000..2c9a694 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_norm_polling/EWARM/adc_norm_polling.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\adc.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\bgr.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/adc/adc_norm_polling/EWARM/adc_norm_polling.eww b/src/hc32f005_ddl/example/adc/adc_norm_polling/EWARM/adc_norm_polling.eww new file mode 100644 index 0000000..a813232 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_norm_polling/EWARM/adc_norm_polling.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\adc_norm_polling.ewp + + + + + diff --git a/src/hc32f005_ddl/example/adc/adc_norm_polling/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/adc/adc_norm_polling/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_norm_polling/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/adc/adc_norm_polling/MDK/adc_norm_polling.uvprojx b/src/hc32f005_ddl/example/adc/adc_norm_polling/MDK/adc_norm_polling.uvprojx new file mode 100644 index 0000000..71d21b5 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_norm_polling/MDK/adc_norm_polling.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + adc_norm_polling_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + adc_norm_polling + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + adc_norm_polling.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +adc.c +1..\..\..\..\driver\src\adc.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +bgr.c +1..\..\..\..\driver\src\bgr.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/adc/adc_norm_polling/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/adc/adc_norm_polling/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_norm_polling/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/adc/adc_norm_polling/source/ddl_device.h b/src/hc32f005_ddl/example/adc/adc_norm_polling/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_norm_polling/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/adc/adc_norm_polling/source/main.c b/src/hc32f005_ddl/example/adc/adc_norm_polling/source/main.c new file mode 100644 index 0000000..1bf924d --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_norm_polling/source/main.c @@ -0,0 +1,162 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2018-09-12 Husj Version0.2 + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adc.h" +#include "gpio.h" +#include "ddl.h" +#include "bgr.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ +static void App_AdcPortInit(void); +static void App_AdcInit(void); +/****************************************************************************** + * Local variable definitions ('static') * + ******************************************************************************/ +static uint16_t u16AdcResult; +stc_adc_cfg_t stcAdcCfg; +stc_adc_norm_cfg_t stcAdcNormCfg; +/***************************************************************************** + * 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) +{ + + App_AdcPortInit(); + App_AdcInit(); + + while(1) + { + delay1ms(1000); + + ///< 通道0 P24 + stcAdcNormCfg.enAdcNormModeCh = AdcExInputCH0; + stcAdcNormCfg.bAdcResultAccEn = FALSE; + Adc_ConfigNormMode(&stcAdcCfg, &stcAdcNormCfg); + + Adc_Start(); + while(FALSE != Adc_PollBusyState()); + Adc_GetResult(&u16AdcResult); + + ///< 通道0 P26 + stcAdcNormCfg.enAdcNormModeCh = AdcExInputCH1; + stcAdcNormCfg.bAdcResultAccEn = FALSE; + Adc_ConfigNormMode(&stcAdcCfg, &stcAdcNormCfg); + + Adc_Start(); + while(FALSE != Adc_PollBusyState()); + Adc_GetResult(&u16AdcResult); + } + + +} + +static void App_AdcPortInit(void) +{ + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //GPIO 外设时钟使能 + + Gpio_SetAnalogMode(GpioPort2, GpioPin4); + Gpio_SetAnalogMode(GpioPort2, GpioPin6); + +} + +static void App_AdcInit(void) +{ + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdcBgr, TRUE); //ADCBGR 外设时钟使能 + + //ADC配置 + Adc_Enable(); + Bgr_BgrEnable(); + + stcAdcCfg.enAdcOpMode = AdcNormalMode; //单次采样模式 + stcAdcCfg.enAdcClkSel = AdcClkSysTDiv1; //PCLK + stcAdcCfg.enAdcSampTimeSel = AdcSampTime4Clk; //4个采样时钟 + stcAdcCfg.enAdcRefVolSel = RefVolSelInBgr2p5; //参考电压:内部2.5V(avdd>3V,SPS<=200kHz) SPS速率 = ADC时钟 / (采样时钟 + 16CLK) + stcAdcCfg.bAdcInBufEn = FALSE; //电压跟随器如果使能,SPS采样速率 <=200K + stcAdcCfg.u32AdcRegHighThd = 0u; //比较阈值上门限 + stcAdcCfg.u32AdcRegLowThd = 0u; //比较阈值下门限 + stcAdcCfg.enAdcTrig0Sel = AdcTrigDisable; //ADC转换自动触发设置 + stcAdcCfg.enAdcTrig1Sel = AdcTrigDisable; + Adc_Init(&stcAdcCfg); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/EWARM/adc_scan_mul_irq.ewp b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/EWARM/adc_scan_mul_irq.ewp new file mode 100644 index 0000000..5ce01b0 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/EWARM/adc_scan_mul_irq.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\adc.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\bgr.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/EWARM/adc_scan_mul_irq.eww b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/EWARM/adc_scan_mul_irq.eww new file mode 100644 index 0000000..7c04bf5 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/EWARM/adc_scan_mul_irq.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\adc_scan_mul_irq.ewp + + + + + diff --git a/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/MDK/adc_scan_mul_irq.uvprojx b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/MDK/adc_scan_mul_irq.uvprojx new file mode 100644 index 0000000..93ae42b --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/MDK/adc_scan_mul_irq.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + adc_scan_mul_irq_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + adc_scan_mul_irq + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + adc_scan_mul_irq.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +adc.c +1..\..\..\..\driver\src\adc.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +bgr.c +1..\..\..\..\driver\src\bgr.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/source/ddl_device.h b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/source/main.c b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/source/main.c new file mode 100644 index 0000000..390619f --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_mul_irq/source/main.c @@ -0,0 +1,201 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2018-09-12 Husj Version0.2 + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adc.h" +#include "gpio.h" +#include "bgr.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ +static void App_AdcPortInit(void); +static void App_AdcInit(void); + +/****************************************************************************** + * Local variable definitions ('static') * + ******************************************************************************/ +static uint8_t u8Channel; +static uint16_t u16ScanResult[8]; + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + App_AdcPortInit(); + App_AdcInit(); + + while(1) + { + Adc_Start(); + + delay1ms(1000); + } +} + +///< ADC 中断服务程序 +void Adc_IRQHandler(void) +{ + if (TRUE == M0P_ADC->IFR_f.REG_INTF) + { + Adc_ClrRegIrqState(); + } + + if (TRUE == M0P_ADC->IFR_f.HHT_INTF) + { + Adc_ClrHhtIrqState(); + } + + if (TRUE == M0P_ADC->IFR_f.LLT_INTF) + { + Adc_ClrIrqLltState(); + } + + if (TRUE == M0P_ADC->IFR_f.CONT_INTF) + { + Adc_ClrContIrqState(); + + for (u8Channel = 0; u8Channel < 8; u8Channel++) + { + Adc_GetScanResult(u8Channel, &u16ScanResult[u8Channel]); + } + + } +} + +static void App_AdcPortInit(void) +{ + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //GPIO 外设时钟使能 + + Gpio_SetAnalogMode(GpioPort2, GpioPin4); + Gpio_SetAnalogMode(GpioPort2, GpioPin6); + Gpio_SetAnalogMode(GpioPort3, GpioPin2); + Gpio_SetAnalogMode(GpioPort3, GpioPin3); + Gpio_SetAnalogMode(GpioPort3, GpioPin4); + Gpio_SetAnalogMode(GpioPort3, GpioPin6); + +} + +static void App_AdcInit(void) +{ + + stc_adc_cfg_t stcAdcCfg; + stc_adc_scan_cfg_t stcAdcScanCfg; + stc_adc_irq_t stcAdcIrq; + + DDL_ZERO_STRUCT(stcAdcCfg); + DDL_ZERO_STRUCT(stcAdcScanCfg); + DDL_ZERO_STRUCT(stcAdcIrq); + + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdcBgr, TRUE); //ADCBGR 外设时钟使能 + + + Adc_Enable(); + Bgr_BgrEnable(); ///< BGR必须使能 + + stcAdcCfg.enAdcOpMode = AdcScanMode; //扫描采样模式 + stcAdcCfg.enAdcClkSel = AdcClkSysTDiv1; //PCLK + stcAdcCfg.enAdcSampTimeSel = AdcSampTime8Clk; //8个采样时钟 + stcAdcCfg.enAdcRefVolSel = RefVolSelAVDD; //参考电压:AVDD + stcAdcCfg.bAdcInBufEn = FALSE; //电压跟随器如果使能,SPS采样速率 <=200K + stcAdcCfg.enAdcTrig0Sel = AdcTrigDisable; //ADC转换自动触发设置 + stcAdcCfg.enAdcTrig1Sel = AdcTrigDisable; + Adc_Init(&stcAdcCfg); + + stcAdcIrq.bAdcIrq = TRUE; //转换完成中断函数入口配置使能 + stcAdcIrq.bAdcRegCmp = FALSE; + stcAdcIrq.bAdcHhtCmp = FALSE; + stcAdcIrq.bAdcLltCmp = FALSE; + Adc_CmpCfg(&stcAdcIrq); //结果比较中断使能/禁止配置 + + stcAdcScanCfg.u8AdcScanModeCh = ADC_SCAN_CH0_EN + | ADC_SCAN_CH1_EN + | ADC_SCAN_CH2_EN + | ADC_SCAN_CH3_EN + | ADC_SCAN_CH4_EN + | ADC_SCAN_CH6_EN; + + stcAdcScanCfg.u8AdcSampCnt = 0x5; //连续扫描转换次数,保持通道的倍数,6通道 = 0x5+1(1倍),或者11+1(2倍)…… + Adc_ConfigScanMode(&stcAdcCfg, &stcAdcScanCfg); + + Adc_EnableIrq(); //中断使能 + EnableNvic(ADC_IRQn, IrqLevel3, TRUE); + +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/EWARM/adc_scan_sqr_acc.ewp b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/EWARM/adc_scan_sqr_acc.ewp new file mode 100644 index 0000000..44c7293 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/EWARM/adc_scan_sqr_acc.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\adc.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\bgr.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/EWARM/adc_scan_sqr_acc.eww b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/EWARM/adc_scan_sqr_acc.eww new file mode 100644 index 0000000..1899cd8 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/EWARM/adc_scan_sqr_acc.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\adc_scan_sqr_acc.ewp + + + + + diff --git a/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/MDK/adc_scan_sqr_acc.uvprojx b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/MDK/adc_scan_sqr_acc.uvprojx new file mode 100644 index 0000000..f56d525 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/MDK/adc_scan_sqr_acc.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + adc_scan_sqr_acc_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + adc_scan_sqr_acc + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + adc_scan_sqr_acc.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +adc.c +1..\..\..\..\driver\src\adc.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +bgr.c +1..\..\..\..\driver\src\bgr.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/source/ddl_device.h b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/source/main.c b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/source/main.c new file mode 100644 index 0000000..a6659fc --- /dev/null +++ b/src/hc32f005_ddl/example/adc/adc_scan_sqr_acc/source/main.c @@ -0,0 +1,185 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2018-09-12 Husj Version0.2 + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adc.h" +#include "gpio.h" +#include "bgr.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ +static void App_AdcPortInit(void); +static void App_AdcInit(void); + +/****************************************************************************** + * Local variable definitions ('static') * + ******************************************************************************/ +volatile uint32_t u32AdcResultAcc; + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + App_AdcPortInit(); + App_AdcInit(); + + while(1) + { + Adc_Start(); //ADC开始转换 + + delay1ms(1000); + + } +} + +///< ADC 中断服务程序 +void Adc_IRQHandler(void) +{ + if (TRUE == M0P_ADC->IFR_f.REG_INTF) + { + Adc_ClrRegIrqState(); + } + + if (TRUE == M0P_ADC->IFR_f.HHT_INTF) + { + Adc_ClrHhtIrqState(); + } + + if (TRUE == M0P_ADC->IFR_f.LLT_INTF) + { + Adc_ClrIrqLltState(); + } + + if (TRUE == M0P_ADC->IFR_f.CONT_INTF) + { + Adc_ClrContIrqState(); + + Adc_GetAccResult((uint32_t *)&u32AdcResultAcc); + Adc_ClrAccResult(); + } +} + +static void App_AdcPortInit(void) +{ + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //GPIO 外设时钟使能 + + Gpio_SetAnalogMode(GpioPort2, GpioPin4); + +} + +static void App_AdcInit(void) +{ + stc_adc_cfg_t stcAdcCfg; + stc_adc_cont_cfg_t stcAdcContCfg; + stc_adc_irq_t stcAdcIrq; + + DDL_ZERO_STRUCT(stcAdcCfg); + DDL_ZERO_STRUCT(stcAdcContCfg); + DDL_ZERO_STRUCT(stcAdcIrq); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdcBgr, TRUE); //ADCBGR 外设时钟使能 + + //ADC配置 + Adc_Enable(); + Bgr_BgrEnable(); + + stcAdcCfg.enAdcOpMode = AdcContMode; //连续采样模式 + stcAdcCfg.enAdcClkSel = AdcClkSysTDiv1; //PCLK + stcAdcCfg.enAdcSampTimeSel = AdcSampTime8Clk; //8个采样时钟 + stcAdcCfg.enAdcRefVolSel = RefVolSelAVDD; //参考电压:AVDD + stcAdcCfg.bAdcInBufEn = FALSE; //电压跟随器如果使能,SPS采样速率 <=200K + stcAdcCfg.enAdcTrig0Sel = AdcTrigDisable; //ADC转换自动触发设置 + stcAdcCfg.enAdcTrig1Sel = AdcTrigDisable; + Adc_Init(&stcAdcCfg); + + stcAdcIrq.bAdcIrq = TRUE; //转换完成中断函数入口配置使能 + stcAdcIrq.bAdcRegCmp = FALSE; + stcAdcIrq.bAdcHhtCmp = FALSE; + stcAdcIrq.bAdcLltCmp = FALSE; + Adc_CmpCfg(&stcAdcIrq); //结果比较中断使能/禁止配置 + + stcAdcContCfg.enAdcContModeCh = AdcExInputCH0; //通道0 P24 + stcAdcContCfg.u8AdcSampCnt = 0x09u; //P24 连续累加次数(次数 = 0x09+1) + stcAdcContCfg.bAdcResultAccEn = TRUE; //累加使能 + Adc_ConfigContMode(&stcAdcCfg, &stcAdcContCfg); + + Adc_EnableIrq(); //中断使能 + EnableNvic(ADC_IRQn, IrqLevel3, TRUE); + +} +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/adt/CaptureInput/EWARM/CaptureInput.ewp b/src/hc32f005_ddl/example/adt/CaptureInput/EWARM/CaptureInput.ewp new file mode 100644 index 0000000..438c6e4 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInput/EWARM/CaptureInput.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\adt.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/src/hc32f005_ddl/example/adt/CaptureInput/EWARM/CaptureInput.eww b/src/hc32f005_ddl/example/adt/CaptureInput/EWARM/CaptureInput.eww new file mode 100644 index 0000000..0b3bb50 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInput/EWARM/CaptureInput.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\CaptureInput.ewp + + + + + diff --git a/src/hc32f005_ddl/example/adt/CaptureInput/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/CaptureInput/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInput/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/adt/CaptureInput/MDK/CaptureInput.uvprojx b/src/hc32f005_ddl/example/adt/CaptureInput/MDK/CaptureInput.uvprojx new file mode 100644 index 0000000..163360d --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInput/MDK/CaptureInput.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + CaptureInput_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + CaptureInput + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + CaptureInput.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +adt.c +1..\..\..\..\driver\src\adt.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/adt/CaptureInput/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/CaptureInput/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInput/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/adt/CaptureInput/source/ddl_device.h b/src/hc32f005_ddl/example/adt/CaptureInput/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInput/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/adt/CaptureInput/source/main.c b/src/hc32f005_ddl/example/adt/CaptureInput/source/main.c new file mode 100644 index 0000000..8120515 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInput/source/main.c @@ -0,0 +1,193 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2019-04-19 Husj First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adt.h" +#include "gpio.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') * + ******************************************************************************/ +static uint16_t u16CaptureA; +static uint16_t u16CaptureB; + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +void Tim4_IRQHandler(void) +{ + //捕获中断A + if(TRUE == Adt_GetIrqFlag(M0P_ADTIM4, AdtCMAIrq)) + { + Adt_GetCaptureValue(M0P_ADTIM4, AdtCHxA, &u16CaptureA); //脉冲低电平计数值 + + Adt_ClearIrqFlag(M0P_ADTIM4, AdtCMAIrq); + } + //捕获中断B + if(TRUE == Adt_GetIrqFlag(M0P_ADTIM4, AdtCMBIrq)) + { + Adt_GetCaptureValue(M0P_ADTIM4, AdtCHxB, &u16CaptureB); //脉冲高电平计数值 + + Adt_ClearIrqFlag(M0P_ADTIM4, AdtCMBIrq); + } +} + + +///< AdvTimer端口初始化 +void App_AdtPortInit(void) +{ + stc_gpio_cfg_t stcTIM4Port; + + DDL_ZERO_STRUCT(stcTIM4Port); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM4Port.enDir = GpioDirIn; + //P34设置为TIM4_CHA + Gpio_Init(GpioPort3, GpioPin4, &stcTIM4Port); + Gpio_SetAfMode(GpioPort3,GpioPin4,GpioAf5); + + //P35设置为TIM4_CHB + //Gpio_Init(GpioPort3, GpioPin5, &stcTIM4Port); + //Gpio_SetAfMode(GpioPort3,GpioPin5,GpioAf5); + +} + + +///< AdvTimer初始化 +void App_AdvTimerInit(void) +{ + uint16_t u16Period; + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4ACfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4BCfg; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtTIM4ACfg); + DDL_ZERO_STRUCT(stcAdtTIM4BCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE); //ADT外设时钟使能 + + + stcAdtBaseCntCfg.enCntMode = AdtSawtoothMode; //Sawtooth Mode + stcAdtBaseCntCfg.enCntDir = AdtCntUp; // Cnt up + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0Div4; // PCLK0/4 + Adt_Init(M0P_ADTIM4, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + u16Period = 0xFFFF; + Adt_SetPeriod(M0P_ADTIM4, u16Period); //周期设置 + + stcAdtTIM4ACfg.enCap = AdtCHxCompareInput; //Channel A 作为捕获输入(used as capture input) + stcAdtTIM4ACfg.bFltEn = TRUE; + stcAdtTIM4ACfg.enFltClk = AdtFltClkPclk0Div16; + Adt_CHxXPortCfg(M0P_ADTIM4, AdtCHxA, &stcAdtTIM4ACfg); //Channel A配置 & GPIO CHA 输入滤波使能 + + stcAdtTIM4BCfg.enCap = AdtCHxCompareInput; //Channel B 作为捕获输入(used as capture input) + Adt_CHxXPortCfg(M0P_ADTIM4, AdtCHxB, &stcAdtTIM4BCfg); + + Adt_CfgHwCaptureA(M0P_ADTIM4, AdtHwTrigCHxARise); //硬件捕获A条件配置:CHA端口上采样到上升沿 + Adt_CfgHwCaptureB(M0P_ADTIM4, AdtHwTrigCHxAFall); //硬件捕获B条件配置:CHA端口上采样到下降沿 + + Adt_CfgHwClear(M0P_ADTIM4, AdtHwTrigCHxARise); //硬件清零条件:CHA 端口采样到上升沿 + Adt_CfgHwClear(M0P_ADTIM4, AdtHwTrigCHxAFall); //硬件清零条件:CHA 端口采样到下降沿 + Adt_EnableHwClear(M0P_ADTIM4); + + Adt_ClearAllIrqFlag(M0P_ADTIM4); + Adt_CfgIrq(M0P_ADTIM4, AdtCMAIrq, TRUE); //捕获中断A配置 + Adt_CfgIrq(M0P_ADTIM4, AdtCMBIrq, TRUE); //捕获中断B配置 + EnableNvic(ADTIM4_IRQn, IrqLevel3, TRUE); //AdvTimer4中断使能 +} + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + App_AdtPortInit(); //AdvTimer4 端口初始化 + + App_AdvTimerInit(); //AdvTimer4 初始化 + + Adt_StartCount(M0P_ADTIM4); //AdvTimer4 运行 + + while(1); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/adt/CaptureInputBuf/EWARM/CaptureInputBuf.ewp b/src/hc32f005_ddl/example/adt/CaptureInputBuf/EWARM/CaptureInputBuf.ewp new file mode 100644 index 0000000..c7648eb --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInputBuf/EWARM/CaptureInputBuf.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\adt.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/src/hc32f005_ddl/example/adt/CaptureInputBuf/EWARM/CaptureInputBuf.eww b/src/hc32f005_ddl/example/adt/CaptureInputBuf/EWARM/CaptureInputBuf.eww new file mode 100644 index 0000000..09bf2d5 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInputBuf/EWARM/CaptureInputBuf.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\CaptureInputBuf.ewp + + + + + diff --git a/src/hc32f005_ddl/example/adt/CaptureInputBuf/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/CaptureInputBuf/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInputBuf/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/adt/CaptureInputBuf/MDK/CaptureInputBuf.uvprojx b/src/hc32f005_ddl/example/adt/CaptureInputBuf/MDK/CaptureInputBuf.uvprojx new file mode 100644 index 0000000..5bdd3a1 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInputBuf/MDK/CaptureInputBuf.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + CaptureInputBuf_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + CaptureInputBuf + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + CaptureInputBuf.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +adt.c +1..\..\..\..\driver\src\adt.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/adt/CaptureInputBuf/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/CaptureInputBuf/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInputBuf/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/adt/CaptureInputBuf/source/ddl_device.h b/src/hc32f005_ddl/example/adt/CaptureInputBuf/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInputBuf/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/adt/CaptureInputBuf/source/main.c b/src/hc32f005_ddl/example/adt/CaptureInputBuf/source/main.c new file mode 100644 index 0000000..71efdcc --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CaptureInputBuf/source/main.c @@ -0,0 +1,185 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2019-04-19 Husj First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adt.h" +#include "gpio.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ +uint16_t u16Capture; +uint16_t u16CaptureBuf; +uint16_t u16CapDuty; +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + + +/****************************************************************************** + * Local variable definitions ('static') * + ******************************************************************************/ + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +void Tim4_IRQHandler(void) +{ + //AdvTimer4 捕获中断A + if(TRUE == Adt_GetIrqFlag(M0P_ADTIM4, AdtCMAIrq)) + { + Adt_GetCaptureValue(M0P_ADTIM4, AdtCHxA, &u16Capture); //读取捕获值A + Adt_GetCaptureBuf(M0P_ADTIM4, AdtCHxA, &u16CaptureBuf); //读取捕获值A的缓存值 + + + u16CapDuty = (u16CaptureBuf*100) / u16Capture; //计算占空比 + + + Adt_ClearIrqFlag(M0P_ADTIM4, AdtCMAIrq); //清除捕获中断A的标志 + } +} + +///< AdvTimer端口初始化 +void App_AdtPortInit(void) +{ + stc_gpio_cfg_t stcTIM4Port; + + DDL_ZERO_STRUCT(stcTIM4Port); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + //P34设置为TIM4_CHA + stcTIM4Port.enDir = GpioDirIn; + //P34设置为TIM4_CHA + Gpio_Init(GpioPort3, GpioPin4, &stcTIM4Port); + Gpio_SetAfMode(GpioPort3,GpioPin4,GpioAf5); +} + +///< AdvTimer初始化 +void App_AdvTimerInit(void) +{ + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4ACfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4BCfg; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtTIM4ACfg); + DDL_ZERO_STRUCT(stcAdtTIM4BCfg); + + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE); //ADT外设时钟使能 + + + stcAdtBaseCntCfg.enCntMode = AdtSawtoothMode; //Sawtooth Mode + stcAdtBaseCntCfg.enCntDir = AdtCntUp; // Cnt up + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0Div4; // PCLK0/4 + Adt_Init(M0P_ADTIM4, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + Adt_SetPeriod(M0P_ADTIM4, 0xFFFF); //周期设置 + + stcAdtTIM4ACfg.enCap = AdtCHxCompareInput; //ChannelA 捕获输入 + stcAdtTIM4ACfg.bFltEn = TRUE; + stcAdtTIM4ACfg.enFltClk = AdtFltClkPclk0Div16; + Adt_CHxXPortCfg(M0P_ADTIM4, AdtCHxA, &stcAdtTIM4ACfg); //ChannelA配置捕获输入 & GPIO CHA 输入滤波使能 + + Adt_EnableValueBuf(M0P_ADTIM4, AdtCHxA, TRUE); //缓存传送功能打开 + + + Adt_CfgHwCaptureA(M0P_ADTIM4, AdtHwTrigCHxARise); //硬件捕获A条件配置: + Adt_CfgHwCaptureA(M0P_ADTIM4, AdtHwTrigCHxAFall); //硬件捕获A条件配置: + + Adt_CfgHwClear(M0P_ADTIM4, AdtHwTrigCHxARise); //硬件清零条件:CHA 端口采样到上升沿 + Adt_EnableHwClear(M0P_ADTIM4); + + + Adt_ClearAllIrqFlag(M0P_ADTIM4); + Adt_CfgIrq(M0P_ADTIM4, AdtCMAIrq, TRUE); //捕获输入A中断配置 + EnableNvic(ADTIM4_IRQn, IrqLevel3, TRUE); //AdvTimer4中断使能 +} + + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + App_AdtPortInit(); //AdvTimer4 端口初始化 + + App_AdvTimerInit(); //AdvTimer4 初始化 + + Adt_StartCount(M0P_ADTIM4); //AdvTimer4 运行 + + while(1); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/adt/CompareOutput/EWARM/CompareOutput.ewp b/src/hc32f005_ddl/example/adt/CompareOutput/EWARM/CompareOutput.ewp new file mode 100644 index 0000000..36330d3 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutput/EWARM/CompareOutput.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\adt.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\flash.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/adt/CompareOutput/EWARM/CompareOutput.eww b/src/hc32f005_ddl/example/adt/CompareOutput/EWARM/CompareOutput.eww new file mode 100644 index 0000000..e8af24e --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutput/EWARM/CompareOutput.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\CompareOutput.ewp + + + + + diff --git a/src/hc32f005_ddl/example/adt/CompareOutput/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/CompareOutput/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutput/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/adt/CompareOutput/MDK/CompareOutput.uvprojx b/src/hc32f005_ddl/example/adt/CompareOutput/MDK/CompareOutput.uvprojx new file mode 100644 index 0000000..1a7ae9e --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutput/MDK/CompareOutput.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + CompareOutput_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + CompareOutput + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + CompareOutput.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +adt.c +1..\..\..\..\driver\src\adt.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +flash.c +1..\..\..\..\driver\src\flash.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/adt/CompareOutput/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/CompareOutput/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutput/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/adt/CompareOutput/source/ddl_device.h b/src/hc32f005_ddl/example/adt/CompareOutput/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutput/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/adt/CompareOutput/source/main.c b/src/hc32f005_ddl/example/adt/CompareOutput/source/main.c new file mode 100644 index 0000000..436dff0 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutput/source/main.c @@ -0,0 +1,183 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2019-04-19 Husj First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adt.h" +#include "gpio.h" +#include "flash.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') * + ******************************************************************************/ + + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +///< AdvTimer端口初始化 +void App_AdvTimerPortInit(void) +{ + stc_gpio_cfg_t stcTIM4Port; + + DDL_ZERO_STRUCT(stcTIM4Port); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM4Port.enDir = GpioDirOut; + //P34设置为TIM4_CHA + Gpio_Init(GpioPort3, GpioPin4, &stcTIM4Port); + Gpio_SetAfMode(GpioPort3,GpioPin4,GpioAf5); + + //P35设置为TIM4_CHB + Gpio_Init(GpioPort3, GpioPin5, &stcTIM4Port); + Gpio_SetAfMode(GpioPort3,GpioPin5,GpioAf5); + +} + + +///< AdvTimer初始化 +void App_AdvTimerInit(uint16_t u16Period, uint16_t u16CHA_PWMDuty, uint16_t u16CHB_PWMDuty) +{ + en_adt_compare_t enAdtCompareA; + en_adt_compare_t enAdtCompareB; + + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4ACfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4BCfg; + + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtTIM4ACfg); + DDL_ZERO_STRUCT(stcAdtTIM4BCfg); + + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE); //ADT外设时钟使能 + + stcAdtBaseCntCfg.enCntMode = AdtSawtoothMode; //锯齿波模式 + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0; + + Adt_Init(M0P_ADTIM4, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + Adt_SetPeriod(M0P_ADTIM4, u16Period); //周期设置 + + enAdtCompareA = AdtCompareA; + Adt_SetCompareValue(M0P_ADTIM4, enAdtCompareA, u16CHA_PWMDuty); //通用比较基准值寄存器A设置 + + enAdtCompareB = AdtCompareB; + Adt_SetCompareValue(M0P_ADTIM4, enAdtCompareB, u16CHB_PWMDuty); //通用比较基准值寄存器B设置 + + stcAdtTIM4ACfg.enCap = AdtCHxCompareOutput; //比较输出 + stcAdtTIM4ACfg.bOutEn = TRUE; //CHA输出使能 + stcAdtTIM4ACfg.enPerc = AdtCHxPeriodLow; //计数值与周期匹配时CHA电平保持不变 + stcAdtTIM4ACfg.enCmpc = AdtCHxCompareHigh; //计数值与比较值A匹配时,CHA电平翻转 + stcAdtTIM4ACfg.enStaStp = AdtCHxStateSelSS; //CHA起始结束电平由STACA与STPCA控制 + stcAdtTIM4ACfg.enStaOut = AdtCHxPortOutLow; //CHA起始电平为低 + stcAdtTIM4ACfg.enStpOut = AdtCHxPortOutLow; //CHA结束电平为低 + Adt_CHxXPortCfg(M0P_ADTIM4, AdtCHxA, &stcAdtTIM4ACfg); //端口CHA配置 + + stcAdtTIM4BCfg.enCap = AdtCHxCompareOutput; + stcAdtTIM4BCfg.bOutEn = TRUE; + stcAdtTIM4BCfg.enPerc = AdtCHxPeriodInv; + stcAdtTIM4BCfg.enCmpc = AdtCHxCompareInv; + stcAdtTIM4BCfg.enStaStp = AdtCHxStateSelSS; + stcAdtTIM4BCfg.enStaOut = AdtCHxPortOutLow; + stcAdtTIM4BCfg.enStpOut = AdtCHxPortOutLow; + Adt_CHxXPortCfg(M0P_ADTIM4, AdtCHxB, &stcAdtTIM4BCfg); //端口CHB配置 +} + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + + App_AdvTimerInit(0xC000, 0x4000, 0x8000); //AdvTimer4初始化 + //配置为锯齿波模式: 周期0xC000, CHA占空比设置0x4000,CHB占空比设置0x8000 + + App_AdvTimerPortInit(); //AdvTimer端口初始化 + + Adt_StartCount(M0P_ADTIM4); //AdvTimer4运行 + + while(1); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/adt/CompareOutputBuf/EWARM/CompareOutputBuf.ewp b/src/hc32f005_ddl/example/adt/CompareOutputBuf/EWARM/CompareOutputBuf.ewp new file mode 100644 index 0000000..c9b1f93 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutputBuf/EWARM/CompareOutputBuf.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\adt.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\flash.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/adt/CompareOutputBuf/EWARM/CompareOutputBuf.eww b/src/hc32f005_ddl/example/adt/CompareOutputBuf/EWARM/CompareOutputBuf.eww new file mode 100644 index 0000000..5776dac --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutputBuf/EWARM/CompareOutputBuf.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\CompareOutputBuf.ewp + + + + + diff --git a/src/hc32f005_ddl/example/adt/CompareOutputBuf/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/CompareOutputBuf/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutputBuf/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/adt/CompareOutputBuf/MDK/CompareOutputBuf.uvprojx b/src/hc32f005_ddl/example/adt/CompareOutputBuf/MDK/CompareOutputBuf.uvprojx new file mode 100644 index 0000000..06c8eca --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutputBuf/MDK/CompareOutputBuf.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + CompareOutputBuf_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + CompareOutputBuf + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + CompareOutputBuf.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +adt.c +1..\..\..\..\driver\src\adt.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +flash.c +1..\..\..\..\driver\src\flash.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/adt/CompareOutputBuf/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/CompareOutputBuf/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutputBuf/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/adt/CompareOutputBuf/source/ddl_device.h b/src/hc32f005_ddl/example/adt/CompareOutputBuf/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutputBuf/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/adt/CompareOutputBuf/source/main.c b/src/hc32f005_ddl/example/adt/CompareOutputBuf/source/main.c new file mode 100644 index 0000000..2762295 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/CompareOutputBuf/source/main.c @@ -0,0 +1,216 @@ +/****************************************************************************** +* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2019-04-19 Husj First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adt.h" +#include "gpio.h" +#include "flash.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') * + ******************************************************************************/ + + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +void Tim4_IRQHandler(void) +{ + static uint32_t i = 0; + + if(TRUE == Adt_GetIrqFlag(M0P_ADTIM4, AdtUDFIrq)) //下溢中断 + { + if (0 == i) + { + Adt_SetCompareValue(M0P_ADTIM4, AdtCompareC, 0x8000); //设置GCMCR寄存器,通过缓存传送GCMCR-->GCMAR,改变CHA通道的PWM占空比 + Adt_SetCompareValue(M0P_ADTIM4, AdtCompareD, 0x4000); //设置GCMDR寄存器,通过缓存传送GCMDR-->GCMBR,改变CHB通道的PWM占空比 + + i = 1; + } + else + { + Adt_SetCompareValue(M0P_ADTIM4, AdtCompareC, 0x4000); //设置GCMCR寄存器,通过缓存传送GCMCR-->GCMAR,改变CHA通道的PWM占空比 + Adt_SetCompareValue(M0P_ADTIM4, AdtCompareD, 0x8000); //设置GCMDR寄存器,通过缓存传送GCMDR-->GCMBR,改变CHB通道的PWM占空比 + + i = 0; + } + + Adt_ClearIrqFlag(M0P_ADTIM4, AdtUDFIrq); + } +} + +///< AdvTimer端口初始化 +void App_AdvTimerPortInit(void) +{ + stc_gpio_cfg_t stcTIM4Port; + + DDL_ZERO_STRUCT(stcTIM4Port); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM4Port.enDir = GpioDirOut; + //P34设置为TIM4_CHA + Gpio_Init(GpioPort3, GpioPin4, &stcTIM4Port); + Gpio_SetAfMode(GpioPort3,GpioPin4,GpioAf5); + + //P35设置为TIM4_CHB + Gpio_Init(GpioPort3, GpioPin5, &stcTIM4Port); + Gpio_SetAfMode(GpioPort3,GpioPin5,GpioAf5); + +} + + +///< AdvTimer初始化 +void App_AdvTimerInit(uint16_t u16Period, uint16_t u16CHA_PWMDuty, uint16_t u16CHB_PWMDuty) +{ + en_adt_compare_t enAdtCompare; + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4ACfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4BCfg; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtTIM4ACfg); + DDL_ZERO_STRUCT(stcAdtTIM4BCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE); //ADT外设时钟使能 + + + stcAdtBaseCntCfg.enCntMode = AdtTriangleModeA; //三角波模式 + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0; + Adt_Init(M0P_ADTIM4, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + Adt_SetPeriod(M0P_ADTIM4, u16Period); //周期设置 + + enAdtCompare = AdtCompareA; + Adt_SetCompareValue(M0P_ADTIM4, enAdtCompare, u16CHA_PWMDuty); //通用比较基准值寄存器A设置 + + enAdtCompare = AdtCompareB; + Adt_SetCompareValue(M0P_ADTIM4, enAdtCompare, u16CHB_PWMDuty); //通用比较基准值寄存器B设置 + + enAdtCompare = AdtCompareC; + Adt_SetCompareValue(M0P_ADTIM4, enAdtCompare, u16CHA_PWMDuty); //通用比较基准值寄存器C设置 + + enAdtCompare = AdtCompareD; + Adt_SetCompareValue(M0P_ADTIM4, enAdtCompare, u16CHB_PWMDuty); //通用比较基准值寄存器D设置 + + Adt_EnableValueBuf(M0P_ADTIM4, AdtCHxA, TRUE); //CHA buffer 使能 + Adt_EnableValueBuf(M0P_ADTIM4, AdtCHxB, TRUE); //CHB buffer 使能 + + stcAdtTIM4ACfg.enCap = AdtCHxCompareOutput; //比较输出 + stcAdtTIM4ACfg.bOutEn = TRUE; //CHA输出使能 + stcAdtTIM4ACfg.enPerc = AdtCHxPeriodKeep; //计数值与周期匹配时CHA电平保持不变 + stcAdtTIM4ACfg.enCmpc = AdtCHxCompareInv; //计数值与比较值A匹配时,CHA电平翻转 + stcAdtTIM4ACfg.enStaStp = AdtCHxStateSelSS; //CHA起始结束电平由STACA与STPCA控制 + stcAdtTIM4ACfg.enStaOut = AdtCHxPortOutLow; //CHA起始电平为低 + stcAdtTIM4ACfg.enStpOut = AdtCHxPortOutLow; //CHA结束电平为低 + Adt_CHxXPortCfg(M0P_ADTIM4, AdtCHxA, &stcAdtTIM4ACfg); //端口CHA配置 + + stcAdtTIM4BCfg.enCap = AdtCHxCompareOutput; + stcAdtTIM4BCfg.bOutEn = TRUE; + stcAdtTIM4BCfg.enPerc = AdtCHxPeriodKeep; + stcAdtTIM4BCfg.enCmpc = AdtCHxCompareInv; + stcAdtTIM4BCfg.enStaStp = AdtCHxStateSelSS; + stcAdtTIM4BCfg.enStaOut = AdtCHxPortOutLow; + stcAdtTIM4BCfg.enStpOut = AdtCHxPortOutLow; + Adt_CHxXPortCfg(M0P_ADTIM4, AdtCHxB, &stcAdtTIM4BCfg); //端口CHB配置 + + Adt_ClearAllIrqFlag(M0P_ADTIM4); + Adt_CfgIrq(M0P_ADTIM4, AdtUDFIrq, TRUE); //下溢中断配置 + EnableNvic(ADTIM4_IRQn, IrqLevel3, TRUE); +} + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + App_AdvTimerInit(0xC000, 0x4000, 0x8000); //AdvTimer4初始化 + //配置为三角波模式: 初始化周期0xC000, CHA占空比设置0x4000,CHB占空比设置0x8000 + + App_AdvTimerPortInit(); //AdvTimer端口初始化 + + Adt_StartCount(M0P_ADTIM4); //AdvTimer4运行 + + while(1); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/adt/Irq/EWARM/Irq.ewp b/src/hc32f005_ddl/example/adt/Irq/EWARM/Irq.ewp new file mode 100644 index 0000000..ae21133 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/Irq/EWARM/Irq.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\adt.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/src/hc32f005_ddl/example/adt/Irq/EWARM/Irq.eww b/src/hc32f005_ddl/example/adt/Irq/EWARM/Irq.eww new file mode 100644 index 0000000..febbf21 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/Irq/EWARM/Irq.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\Irq.ewp + + + + + diff --git a/src/hc32f005_ddl/example/adt/Irq/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/Irq/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/adt/Irq/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/adt/Irq/MDK/Irq.uvprojx b/src/hc32f005_ddl/example/adt/Irq/MDK/Irq.uvprojx new file mode 100644 index 0000000..6ab1639 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/Irq/MDK/Irq.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + Irq_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + Irq + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + Irq.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +adt.c +1..\..\..\..\driver\src\adt.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/adt/Irq/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/Irq/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/Irq/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/adt/Irq/source/ddl_device.h b/src/hc32f005_ddl/example/adt/Irq/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/Irq/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/adt/Irq/source/main.c b/src/hc32f005_ddl/example/adt/Irq/source/main.c new file mode 100644 index 0000000..8b6afbd --- /dev/null +++ b/src/hc32f005_ddl/example/adt/Irq/source/main.c @@ -0,0 +1,476 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2019-04-19 Husj First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adt.h" +#include "gpio.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') * + ******************************************************************************/ +uint16_t u16ADTIM5CntValue; +uint16_t u16Capture; + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +void Tim5_IRQHandler(void) +{ + //比较中断A / 捕获中断A + if(TRUE == Adt_GetIrqFlag(M0P_ADTIM5, AdtCMAIrq)) + { + u16ADTIM5CntValue = Adt_GetCount(M0P_ADTIM5); + Adt_GetCaptureValue(M0P_ADTIM5, AdtCHxA, &u16Capture); + Adt_ClearIrqFlag(M0P_ADTIM5, AdtCMAIrq); + } + + //比较中断B / 捕获中断B + if(TRUE == Adt_GetIrqFlag(M0P_ADTIM5, AdtCMBIrq)) + { + u16ADTIM5CntValue = Adt_GetCount(M0P_ADTIM5); + Adt_GetCaptureValue(M0P_ADTIM5, AdtCHxB, &u16Capture); + Adt_ClearIrqFlag(M0P_ADTIM5, AdtCMBIrq); + } + + //比较中断C + if(TRUE == Adt_GetIrqFlag(M0P_ADTIM5, AdtCMCIrq)) + { + u16ADTIM5CntValue = Adt_GetCount(M0P_ADTIM5); + Adt_ClearIrqFlag(M0P_ADTIM5, AdtCMCIrq); + } + + //比较中断D + if(TRUE == Adt_GetIrqFlag(M0P_ADTIM5, AdtCMDIrq)) + { + u16ADTIM5CntValue = Adt_GetCount(M0P_ADTIM5); + Adt_ClearIrqFlag(M0P_ADTIM5, AdtCMDIrq); + } + + //上溢中断 + if(TRUE == Adt_GetIrqFlag(M0P_ADTIM5, AdtOVFIrq)) + { + u16ADTIM5CntValue = Adt_GetCount(M0P_ADTIM5); + Adt_ClearIrqFlag(M0P_ADTIM5, AdtOVFIrq); + } + + //下溢中断 + if(TRUE == Adt_GetIrqFlag(M0P_ADTIM5, AdtUDFIrq)) + { + u16ADTIM5CntValue = Adt_GetCount(M0P_ADTIM5); + Adt_ClearIrqFlag(M0P_ADTIM5, AdtUDFIrq); + } + + //死区时间错误中断 + if(TRUE == Adt_GetIrqFlag(M0P_ADTIM5, AdtDTEIrq)) + { + Adt_StopCount(M0P_ADTIM5); + Adt_ClearIrqFlag(M0P_ADTIM5, AdtDTEIrq); + } +} + +///< AdvTimer5 比较中断配置 +void App_AdvTimerCmpIrq(void) +{ + uint16_t u16Period; + en_adt_compare_t enAdtCompare; + uint16_t u16Compare; + + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_CHxX_port_cfg_t stcAdtTIMACfg; + stc_adt_CHxX_port_cfg_t stcAdtTIMBCfg; + stc_adt_port_trig_cfg_t stcAdtPortTrig; + stc_gpio_cfg_t stcTIM5Port; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtTIMACfg); + DDL_ZERO_STRUCT(stcAdtTIMBCfg); + DDL_ZERO_STRUCT(stcAdtPortTrig); + DDL_ZERO_STRUCT(stcTIM5Port); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM5Port.enDir = GpioDirOut; + //P25设置为TIM5_CHA + Gpio_Init(GpioPort2, GpioPin5, &stcTIM5Port); + Gpio_SetAfMode(GpioPort2,GpioPin5,GpioAf3); + + //P26设置为TIM5_CHB + Gpio_Init(GpioPort2, GpioPin6, &stcTIM5Port); + Gpio_SetAfMode(GpioPort2,GpioPin6,GpioAf3); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE);//ADT外设时钟使能 + + stcAdtBaseCntCfg.enCntMode = AdtTriangleModeA; + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0; + Adt_Init(M0P_ADTIM5, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + + stcAdtTIMACfg.enCap = AdtCHxCompareOutput; + stcAdtTIMACfg.bOutEn = FALSE; + stcAdtTIMBCfg.enCap = AdtCHxCompareOutput; + stcAdtTIMBCfg.bOutEn = FALSE; + Adt_CHxXPortCfg(M0P_ADTIM5, AdtCHxA, &stcAdtTIMACfg); //TIM5_CHA端口配置 + Adt_CHxXPortCfg(M0P_ADTIM5, AdtCHxB, &stcAdtTIMBCfg); //TIM5_CHA端口配置 + + + u16Period = 0xA000; + Adt_SetPeriod(M0P_ADTIM5, u16Period); //周期设置 + + enAdtCompare = AdtCompareA; + u16Compare = 0x1000; + Adt_SetCompareValue(M0P_ADTIM5, enAdtCompare, u16Compare); //通用比较基准值寄存器A设置 + + enAdtCompare = AdtCompareB; + u16Compare = 0x3000; + Adt_SetCompareValue(M0P_ADTIM5, enAdtCompare, u16Compare); //通用比较基准值寄存器B设置 + + enAdtCompare = AdtCompareC; + u16Compare = 0x5000; + Adt_SetCompareValue(M0P_ADTIM5, enAdtCompare, u16Compare); //通用比较基准值寄存器C设置 + + enAdtCompare = AdtCompareD; + u16Compare = 0x7000; + Adt_SetCompareValue(M0P_ADTIM5, enAdtCompare, u16Compare); //通用比较基准值寄存器D设置 + + Adt_ClearAllIrqFlag(M0P_ADTIM5); + Adt_CfgIrq(M0P_ADTIM5, AdtCMAIrq, TRUE); + Adt_CfgIrq(M0P_ADTIM5, AdtCMBIrq, TRUE); + Adt_CfgIrq(M0P_ADTIM5, AdtCMCIrq, TRUE); + Adt_CfgIrq(M0P_ADTIM5, AdtCMDIrq, TRUE); //比较中断配置 + EnableNvic(ADTIM5_IRQn, IrqLevel3, TRUE); + + Adt_StartCount(M0P_ADTIM5); + + delay1ms(1000); + + Adt_StopCount(M0P_ADTIM5); + Adt_ClearCount(M0P_ADTIM5); + + Adt_ClearAllIrqFlag(M0P_ADTIM5); + Adt_CfgIrq(M0P_ADTIM5, AdtCMAIrq, FALSE); + Adt_CfgIrq(M0P_ADTIM5, AdtCMBIrq, FALSE); + Adt_CfgIrq(M0P_ADTIM5, AdtCMCIrq, FALSE); + Adt_CfgIrq(M0P_ADTIM5, AdtCMDIrq, FALSE); //比较中断解除 + EnableNvic(ADTIM5_IRQn, IrqLevel3, FALSE); + +} + +///< AdvTimer5 捕获中断配置 +void App_AdvTimerCapIrq(void) +{ + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_port_trig_cfg_t stcAdtPortTrig; + stc_gpio_cfg_t stcTIM5Port; + stc_gpio_cfg_t stcTRIBPort; + stc_gpio_cfg_t stcOutPort; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtPortTrig); + DDL_ZERO_STRUCT(stcTIM5Port); + DDL_ZERO_STRUCT(stcTRIBPort); + DDL_ZERO_STRUCT(stcOutPort); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM5Port.enDir = GpioDirOut; + //P25设置为TIM5_CHA + Gpio_Init(GpioPort2, GpioPin5, &stcTIM5Port); + Gpio_SetAfMode(GpioPort2,GpioPin5,GpioAf3); + + //P26设置为TIM5_CHB + Gpio_Init(GpioPort2, GpioPin6, &stcTIM5Port); + Gpio_SetAfMode(GpioPort2,GpioPin6,GpioAf3); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE);//ADT外设时钟使能 + + + stcAdtBaseCntCfg.enCntMode = AdtTriangleModeA; + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0; + Adt_Init(M0P_ADTIM5, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + + // P03 -> P34 Rise -> Time TrigB Rise -> HW Capture A + // P03 -> P34 Fall -> Time TrigB Fall -> HW Capture B + + //PB11设置为ADT TRIB 输入 + stcTRIBPort.enDir = GpioDirIn; + Gpio_Init(GpioPort3, GpioPin4, &stcTRIBPort); + + + //PB14设置为输出信号口 + stcOutPort.enDir = GpioDirOut; + Gpio_Init(GpioPort0, GpioPin3, &stcOutPort); + + Gpio_WriteOutputIO(GpioPort0, GpioPin3, FALSE); //P03输出低 + + stcAdtPortTrig.enTrigSrc = AdtTrigxSelP34; //P34作为TRIB端口 + stcAdtPortTrig.bFltEn = TRUE; //端口滤波使能 + stcAdtPortTrig.enFltClk = AdtFltClkPclk0Div16; //滤波时钟 + Adt_PortTrigCfg(AdtTrigB, &stcAdtPortTrig); //端口触发配置 + + Adt_CfgHwCaptureA(M0P_ADTIM5, AdtHwTrigTimTriBRise); //硬件捕获A条件配置TRIB端口采到上升沿 + Adt_CfgHwCaptureB(M0P_ADTIM5, AdtHwTrigTimTriBFall); //硬件捕获B条件配置TRIB端口采到下降沿 + + Adt_ClearAllIrqFlag(M0P_ADTIM5); + Adt_CfgIrq(M0P_ADTIM5, AdtCMAIrq, TRUE); + Adt_CfgIrq(M0P_ADTIM5, AdtCMBIrq, TRUE); //捕获中断配置 + EnableNvic(ADTIM5_IRQn, IrqLevel3, TRUE); + + Adt_StartCount(M0P_ADTIM5); + + delay1ms(1000); + Gpio_WriteOutputIO(GpioPort0, GpioPin3, TRUE); //P03输出高 + delay1ms(1000); + Gpio_WriteOutputIO(GpioPort0, GpioPin3, FALSE); //P03输出低 + delay1ms(1000); + + Adt_ClearHwCaptureA(M0P_ADTIM5); + Adt_ClearHwCaptureB(M0P_ADTIM5); + Adt_StopCount(M0P_ADTIM5); + Adt_ClearCount(M0P_ADTIM5); + + Adt_ClearAllIrqFlag(M0P_ADTIM5); + Adt_CfgIrq(M0P_ADTIM5, AdtCMAIrq, FALSE); + Adt_CfgIrq(M0P_ADTIM5, AdtCMBIrq, FALSE);//捕获中断解除 + EnableNvic(ADTIM5_IRQn, IrqLevel3, FALSE); +} + + +///< AdvTimer5 上溢下溢中断配置 +void App_AdvTimerOvfUdfIrq(void) +{ + uint16_t u16Period; + + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_port_trig_cfg_t stcAdtPortTrig; + stc_gpio_cfg_t stcTIM5Port; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtPortTrig); + DDL_ZERO_STRUCT(stcTIM5Port); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM5Port.enDir = GpioDirOut; + //P25设置为TIM5_CHA + Gpio_Init(GpioPort2, GpioPin5, &stcTIM5Port); + Gpio_SetAfMode(GpioPort2,GpioPin5,GpioAf3); + + //P26设置为TIM5_CHB + Gpio_Init(GpioPort2, GpioPin6, &stcTIM5Port); + Gpio_SetAfMode(GpioPort2,GpioPin6,GpioAf3); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE);//ADT外设时钟使能 + + + stcAdtBaseCntCfg.enCntMode = AdtTriangleModeA; + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0; + Adt_Init(M0P_ADTIM5, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + + u16Period = 0xA000; + Adt_SetPeriod(M0P_ADTIM5, u16Period); //周期设置 + + Adt_ClearAllIrqFlag(M0P_ADTIM5); + Adt_CfgIrq(M0P_ADTIM5, AdtOVFIrq, TRUE);//上溢中断配置 + Adt_CfgIrq(M0P_ADTIM5, AdtUDFIrq, TRUE);//下溢中断配置 + EnableNvic(ADTIM5_IRQn, IrqLevel3, TRUE); + + Adt_StartCount(M0P_ADTIM5); + + delay1ms(2000); + + Adt_StopCount(M0P_ADTIM5); + Adt_ClearCount(M0P_ADTIM5); + + Adt_ClearAllIrqFlag(M0P_ADTIM5); + Adt_CfgIrq(M0P_ADTIM5, AdtOVFIrq, FALSE);//上溢中断解除 + Adt_CfgIrq(M0P_ADTIM5, AdtUDFIrq, FALSE);//下溢中断解除 + EnableNvic(ADTIM5_IRQn, IrqLevel3, FALSE); + +} + + +///< AdvTimer5 死区时间错误中断配置 +void App_AdvTimerDeadTimeErrIrq(void) +{ + uint16_t u16Period; + en_adt_compare_t enAdtCompare; + uint16_t u16Compare; + + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_CHxX_port_cfg_t stcAdtTIMACfg; + stc_adt_CHxX_port_cfg_t stcAdtTIMBCfg; + stc_adt_port_trig_cfg_t stcAdtPortTrig; + stc_gpio_cfg_t stcTIM5Port; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtTIMACfg); + DDL_ZERO_STRUCT(stcAdtTIMBCfg); + DDL_ZERO_STRUCT(stcAdtPortTrig); + DDL_ZERO_STRUCT(stcTIM5Port); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM5Port.enDir = GpioDirOut; + //P25设置为TIM5_CHA + Gpio_Init(GpioPort2, GpioPin5, &stcTIM5Port); + Gpio_SetAfMode(GpioPort2,GpioPin5,GpioAf3); + + //P25设置为TIM5_CHB + Gpio_Init(GpioPort2, GpioPin6, &stcTIM5Port); + Gpio_SetAfMode(GpioPort2,GpioPin6,GpioAf3); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE);//ADT外设时钟使能 + + + stcAdtBaseCntCfg.enCntMode = AdtTriangleModeA; + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0; + Adt_Init(M0P_ADTIM5, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + u16Period = 0xA000; + Adt_SetPeriod(M0P_ADTIM5, u16Period); //周期设置 + + enAdtCompare = AdtCompareA; + u16Compare = 0x5000; + Adt_SetCompareValue(M0P_ADTIM5, enAdtCompare, u16Compare); //通用比较基准值寄存器A设置 + + enAdtCompare = AdtCompareC; + u16Compare = 0x5000; + Adt_SetCompareValue(M0P_ADTIM5, enAdtCompare, u16Compare); //通用比较基准值寄存器C设置 + + + stcAdtTIMBCfg.enCap = AdtCHxCompareOutput; + stcAdtTIMBCfg.bOutEn = TRUE; + stcAdtTIMBCfg.enPerc = AdtCHxPeriodKeep; + stcAdtTIMBCfg.enCmpc = AdtCHxCompareInv; + stcAdtTIMBCfg.enStaStp = AdtCHxStateSelSS; + stcAdtTIMBCfg.enStaOut = AdtCHxPortOutHigh; + Adt_CHxXPortCfg(M0P_ADTIM5, AdtCHxB, &stcAdtTIMBCfg); //CHxB端口配置 + + Adt_SetDTUA(M0P_ADTIM5, 0x6666); + Adt_SetDTDA(M0P_ADTIM5, 0x6666); + Adt_CfgDT(M0P_ADTIM5, TRUE, TRUE); //死区功能配置 + + Adt_ClearAllIrqFlag(M0P_ADTIM5); + Adt_CfgIrq(M0P_ADTIM5, AdtDTEIrq, TRUE); //死区中断配置 + EnableNvic(ADTIM5_IRQn, IrqLevel3, TRUE); + + Adt_StartCount(M0P_ADTIM5); + + delay1ms(1000); + + Adt_ClearAllIrqFlag(M0P_ADTIM5); + Adt_CfgIrq(M0P_ADTIM5, AdtDTEIrq, FALSE); //死区中断解除 + EnableNvic(ADTIM5_IRQn, IrqLevel3, FALSE); + Adt_CfgDT(M0P_ADTIM5, FALSE, FALSE); + + Adt_StopCount(M0P_ADTIM5); + Adt_ClearCount(M0P_ADTIM5); +} + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + + /******************************比较中断测试********************************/ + App_AdvTimerCmpIrq(); + + /*******************************捕获中断测试*******************************/ + //App_AdvTimerCapIrq(); + + /***************************上下溢中断测试**********************************/ + //App_AdvTimerOvfUdfIrq(); + + /****************************死区时间错误中断测试****************************/ + //App_AdvTimerDeadTimeErrIrq(); + + + + while(1); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/adt/LpBreak/EWARM/LpBreak.ewp b/src/hc32f005_ddl/example/adt/LpBreak/EWARM/LpBreak.ewp new file mode 100644 index 0000000..422d493 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/LpBreak/EWARM/LpBreak.ewp @@ -0,0 +1,2222 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\adt.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lpm.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\flash.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/adt/LpBreak/EWARM/LpBreak.eww b/src/hc32f005_ddl/example/adt/LpBreak/EWARM/LpBreak.eww new file mode 100644 index 0000000..233f647 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/LpBreak/EWARM/LpBreak.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\LpBreak.ewp + + + + + diff --git a/src/hc32f005_ddl/example/adt/LpBreak/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/LpBreak/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/adt/LpBreak/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/adt/LpBreak/MDK/LpBreak.uvprojx b/src/hc32f005_ddl/example/adt/LpBreak/MDK/LpBreak.uvprojx new file mode 100644 index 0000000..bbddb36 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/LpBreak/MDK/LpBreak.uvprojx @@ -0,0 +1,470 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + LpBreak_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + LpBreak + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + LpBreak.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +adt.c +1..\..\..\..\driver\src\adt.c + +lpm.c +1..\..\..\..\driver\src\lpm.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +flash.c +1..\..\..\..\driver\src\flash.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/adt/LpBreak/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/LpBreak/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/LpBreak/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/adt/LpBreak/source/ddl_device.h b/src/hc32f005_ddl/example/adt/LpBreak/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/LpBreak/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/adt/LpBreak/source/main.c b/src/hc32f005_ddl/example/adt/LpBreak/source/main.c new file mode 100644 index 0000000..f7fbb94 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/LpBreak/source/main.c @@ -0,0 +1,195 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2019-04-22 Husj First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adt.h" +#include "lpm.h" +#include "gpio.h" +#include "flash.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') * + ******************************************************************************/ + + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +///< AdvTimer端口初始化 +void App_AdvTimerPortInit(void) +{ + stc_gpio_cfg_t stcTIM5Port; + stc_gpio_cfg_t stcButtonPort; + + DDL_ZERO_STRUCT(stcTIM5Port); + DDL_ZERO_STRUCT(stcButtonPort); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM5Port.enDir = GpioDirOut; + //P25设置为TIM5_CHA + Gpio_Init(GpioPort2, GpioPin5, &stcTIM5Port); + Gpio_SetAfMode(GpioPort2,GpioPin5,GpioAf3); + + //P26设置为TIM5_CHB + Gpio_Init(GpioPort2, GpioPin6, &stcTIM5Port); + Gpio_SetAfMode(GpioPort2,GpioPin6,GpioAf3); + + //PD04设置为GPIO<--SW2控制脚 + stcButtonPort.enDrv = GpioDrvH; + stcButtonPort.enDir = GpioDirIn; + Gpio_Init(STK_USER_PORT, STK_USER_PIN, &stcButtonPort); +} + +///< AdvTimer初始化 +void App_AdvTimerInit(uint16_t u16Period, uint16_t u16CHA_PWMDuty, uint16_t u16CHB_PWMDuty) +{ + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM5ACfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM5BCfg; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtTIM5ACfg); + DDL_ZERO_STRUCT(stcAdtTIM5BCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE);//ADT外设时钟使能 + + + stcAdtBaseCntCfg.enCntMode = AdtSawtoothMode; + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0Div4; + Adt_Init(M0P_ADTIM5, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + Adt_SetPeriod(M0P_ADTIM5, u16Period); //周期设置 + + Adt_SetCompareValue(M0P_ADTIM5, AdtCompareA, u16CHA_PWMDuty); //通用比较基准值寄存器A设置 + + Adt_SetCompareValue(M0P_ADTIM5, AdtCompareB, u16CHB_PWMDuty); //通用比较基准值寄存器B设置 + + stcAdtTIM5ACfg.enCap = AdtCHxCompareOutput; //比较输出 + stcAdtTIM5ACfg.bOutEn = TRUE; //CHA输出使能 + stcAdtTIM5ACfg.enPerc = AdtCHxPeriodLow; //计数值与周期匹配时CHA电平输出低 + stcAdtTIM5ACfg.enCmpc = AdtCHxCompareHigh; //计数值与比较值A匹配时,CHA电平输出高 + stcAdtTIM5ACfg.enStaStp = AdtCHxStateSelSS; //CHA起始结束电平由STACA与STPCA控制 + stcAdtTIM5ACfg.enStaOut = AdtCHxPortOutLow; //CHA起始电平为低 + stcAdtTIM5ACfg.enStpOut = AdtCHxPortOutLow; //CHA结束电平为高 + stcAdtTIM5ACfg.enDisSel = AdtCHxDisSel2; //刹车模式选2(LP 刹车) + stcAdtTIM5ACfg.enDisVal = AdtTIMxDisValLow; + Adt_CHxXPortCfg(M0P_ADTIM5, AdtCHxA, &stcAdtTIM5ACfg); //端口CHA配置 + + stcAdtTIM5BCfg.enCap = AdtCHxCompareOutput; + stcAdtTIM5BCfg.bOutEn = TRUE; + stcAdtTIM5BCfg.enPerc = AdtCHxPeriodInv; //计数值与周期匹配时CHA电平翻转 + stcAdtTIM5BCfg.enCmpc = AdtCHxCompareInv; //计数值与比较值A匹配时,CHA电平翻转 + stcAdtTIM5BCfg.enStaStp = AdtCHxStateSelSS; + stcAdtTIM5BCfg.enStaOut = AdtCHxPortOutLow; + stcAdtTIM5BCfg.enStpOut = AdtCHxPortOutLow; + stcAdtTIM5BCfg.enDisSel = AdtCHxDisSel2; + stcAdtTIM5BCfg.enDisVal = AdtTIMxDisValLow; + Adt_CHxXPortCfg(M0P_ADTIM5, AdtCHxB, &stcAdtTIM5BCfg); //端口CHB配置 +} + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + App_AdvTimerInit(0xC000, 0x8000, 0x4000); //AdvTimer5初始化 + //配置为锯齿波模式: 初始化周期0xC000, CHA占空比设置0x8000,CHB占空比设置0x4000 + + App_AdvTimerPortInit(); //AdvTimer端口初始化 + + Adt_StartCount(M0P_ADTIM5); //AdvTimer5运行 + +#if 1 + //按下user按键(PD04),则进入低功耗模式,否则在等待 + //注:若芯片处于低功耗模式,则芯片无法使用SWD进行调式和下载功能。 + //如需要再次下载程序,需要将芯片复位,且不按user按键 + while (1 == Gpio_GetInputIO(STK_USER_PORT,STK_USER_PIN)); + + //Cfg and goto DeepSleep + Lpm_GotoDeepSleep(TRUE); +#endif + + while(1); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/adt/PortBreak/EWARM/PortBreak.ewp b/src/hc32f005_ddl/example/adt/PortBreak/EWARM/PortBreak.ewp new file mode 100644 index 0000000..3d08e83 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PortBreak/EWARM/PortBreak.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\adt.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\flash.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/adt/PortBreak/EWARM/PortBreak.eww b/src/hc32f005_ddl/example/adt/PortBreak/EWARM/PortBreak.eww new file mode 100644 index 0000000..866f656 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PortBreak/EWARM/PortBreak.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\PortBreak.ewp + + + + + diff --git a/src/hc32f005_ddl/example/adt/PortBreak/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/PortBreak/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PortBreak/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/adt/PortBreak/MDK/PortBreak.uvprojx b/src/hc32f005_ddl/example/adt/PortBreak/MDK/PortBreak.uvprojx new file mode 100644 index 0000000..644f209 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PortBreak/MDK/PortBreak.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + PortBreak_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + PortBreak + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + PortBreak.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +adt.c +1..\..\..\..\driver\src\adt.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +flash.c +1..\..\..\..\driver\src\flash.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/adt/PortBreak/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/PortBreak/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PortBreak/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/adt/PortBreak/source/ddl_device.h b/src/hc32f005_ddl/example/adt/PortBreak/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PortBreak/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/adt/PortBreak/source/main.c b/src/hc32f005_ddl/example/adt/PortBreak/source/main.c new file mode 100644 index 0000000..d47dead --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PortBreak/source/main.c @@ -0,0 +1,276 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2019-04-22 Husj First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adt.h" +#include "gpio.h" +#include "flash.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') * + ******************************************************************************/ + + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +///< AdvTimer端口初始化 +void App_AdvTimerPortInit(void) +{ + stc_gpio_cfg_t stcTIM4Port; + stc_gpio_cfg_t stcBrakePort; + stc_gpio_cfg_t stcBKTestPort; + + DDL_ZERO_STRUCT(stcTIM4Port); + DDL_ZERO_STRUCT(stcBrakePort); + DDL_ZERO_STRUCT(stcBKTestPort); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM4Port.enDir = GpioDirIn; + //P34设置为TIM4_CHA + Gpio_Init(GpioPort3, GpioPin4, &stcTIM4Port); + Gpio_SetAfMode(GpioPort3,GpioPin4,GpioAf5); + + //P35设置为TIM4_CHB + Gpio_Init(GpioPort3, GpioPin5, &stcTIM4Port); + Gpio_SetAfMode(GpioPort3,GpioPin5,GpioAf5); + + //P33设置为刹车端口 + stcBrakePort.enDir = GpioDirIn; + Gpio_Init(GpioPort3, GpioPin3, &stcBrakePort); + + //P03设置为输出信号(给刹车端口) + stcBKTestPort.enDir = GpioDirOut; + Gpio_Init(GpioPort0, GpioPin3, &stcBKTestPort); // P03 -> P33 +} + +///< AdvTimer初始化 +void App_AdvTimerInit(uint16_t u16Period, uint16_t u16CHA_PWMDuty, uint16_t u16CHB_PWMDuty) +{ + en_adt_compare_t enAdtCompareA; + en_adt_compare_t enAdtCompareB; + + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4ACfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4BCfg; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtTIM4ACfg); + DDL_ZERO_STRUCT(stcAdtTIM4BCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE);//ADT外设时钟使能 + + stcAdtBaseCntCfg.enCntMode = AdtTriangleModeA; + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0Div4; + Adt_Init(M0P_ADTIM4, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + Adt_SetPeriod(M0P_ADTIM4, u16Period); //周期值 + + enAdtCompareA = AdtCompareA; + Adt_SetCompareValue(M0P_ADTIM4, enAdtCompareA, u16CHA_PWMDuty); //通用比较基准值寄存器A设置 + + enAdtCompareB = AdtCompareB; + Adt_SetCompareValue(M0P_ADTIM4, enAdtCompareB, u16CHB_PWMDuty); //通用比较基准值寄存器B设置 + + stcAdtTIM4ACfg.enCap = AdtCHxCompareOutput; //比较输出 + stcAdtTIM4ACfg.bOutEn = TRUE; //CHA输出使能 + stcAdtTIM4ACfg.enPerc = AdtCHxPeriodKeep; //计数值与周期匹配时CHA电平保持不变 + stcAdtTIM4ACfg.enCmpc = AdtCHxCompareInv; //计数值与比较值A匹配时,CHA电平翻转 + stcAdtTIM4ACfg.enStaStp = AdtCHxStateSelSS; //CHA起始结束电平由STACA与STPCA控制 + stcAdtTIM4ACfg.enStaOut = AdtCHxPortOutLow; //CHA起始电平为低 + stcAdtTIM4ACfg.enStpOut = AdtCHxPortOutLow; //CHA结束电平为低 + stcAdtTIM4ACfg.enDisSel = AdtCHxDisSel3; //选择强制输出无效条件3(刹车条件3) + stcAdtTIM4ACfg.enDisVal = AdtTIMxDisValLow; //刹车时CHA端口输出低电平 + Adt_CHxXPortCfg(M0P_ADTIM4, AdtCHxA, &stcAdtTIM4ACfg); //CHA端口配置 + + stcAdtTIM4BCfg.enCap = AdtCHxCompareOutput; + stcAdtTIM4BCfg.bOutEn = TRUE; + stcAdtTIM4BCfg.enPerc = AdtCHxPeriodKeep; + stcAdtTIM4BCfg.enCmpc = AdtCHxCompareInv; + stcAdtTIM4BCfg.enStaStp = AdtCHxStateSelSS; + stcAdtTIM4BCfg.enStaOut = AdtCHxPortOutHigh; + stcAdtTIM4BCfg.enStpOut = AdtCHxPortOutLow; + stcAdtTIM4BCfg.enDisSel = AdtCHxDisSel3; + stcAdtTIM4BCfg.enDisVal = AdtTIMxDisValLow; + Adt_CHxXPortCfg(M0P_ADTIM4, AdtCHxB, &stcAdtTIM4BCfg); //CHB端口配置 +} + + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + stc_adt_disable_3_cfg_t stcAdtDisable3; + + DDL_ZERO_STRUCT(stcAdtDisable3); + + App_AdvTimerInit(0xC000, 0x4000, 0x8000); //AdvTimer4初始化 + //配置为三角波模式: 初始化周期0xC000, CHA占空比设置0x4000,CHB占空比设置0x8000 + + App_AdvTimerPortInit(); //AdvTimer端口初始化 + +/********************************高电平刹车功能测试开始***********************************/ + + Gpio_WriteOutputIO(GpioPort0, GpioPin3, FALSE); //P03输出低 + + //cfg Port high break + stcAdtDisable3.stcBrkPtCfg[AdtTrigxSelP33].bPortEn = TRUE; //P33配置为刹车端口 + stcAdtDisable3.stcBrkPtCfg[AdtTrigxSelP33].enPol = AdtPtBrkHigh; //刹车电平:高电平有效 + stcAdtDisable3.bFltEn = TRUE; + stcAdtDisable3.enFltClk = AdtFltClkPclk0; + Adt_Disable3Cfg(&stcAdtDisable3); //失效条件3端口刹车初始化配置 + + + Adt_StartCount(M0P_ADTIM4); + + delay1ms(1000); + + Gpio_WriteOutputIO(GpioPort0, GpioPin3, TRUE); //P03输出高-->P33,使能Port brake,PWM输出指定的电平(低电平) + + delay1ms(1000); + + Gpio_WriteOutputIO(GpioPort0, GpioPin3, FALSE); //P03输出低 + + delay1ms(1); + + Adt_ClearPortBrakeFlag(); //P03输出低以后,再清除端口刹车标志,恢复PWM输出 + + // disable port break + DDL_ZERO_STRUCT(stcAdtDisable3); + stcAdtDisable3.stcBrkPtCfg[AdtTrigxSelP33].bPortEn = FALSE; + Adt_Disable3Cfg(&stcAdtDisable3); //端口刹车功能解除 + + delay1ms(1000); +/********************************高电平刹车功能测试结束***********************************/ + + +/********************************低电平刹车功能测试开始***********************************/ + delay1ms(1000); + + Gpio_WriteOutputIO(GpioPort0, GpioPin3, TRUE); //03输出高 + + //cfg port low break + stcAdtDisable3.stcBrkPtCfg[AdtTrigxSelP33].bPortEn = TRUE; //P33配置为刹车端口 + stcAdtDisable3.stcBrkPtCfg[AdtTrigxSelP33].enPol = AdtPtBrkLow; //刹车电平:低电平有效 + stcAdtDisable3.bFltEn = TRUE; + stcAdtDisable3.enFltClk = AdtFltClkPclk0Div4; + Adt_Disable3Cfg(&stcAdtDisable3); //失效条件3:端口刹车初始化配置 + + delay1ms(1000); + + Gpio_WriteOutputIO(GpioPort0, GpioPin3, FALSE); //P03输出低-->P33,使能Port brake,PWM输出指定的电平(低电平) + + delay1ms(1000); + + Gpio_WriteOutputIO(GpioPort0, GpioPin3, TRUE); //P03输出高 + + delay1ms(1); + + Adt_ClearPortBrakeFlag(); //P03输出高以后,再清除端口刹车标志,恢复PWM输出 + + // disable port break + DDL_ZERO_STRUCT(stcAdtDisable3); + stcAdtDisable3.stcBrkPtCfg[AdtTrigxSelP33].bPortEn = FALSE; + Adt_Disable3Cfg(&stcAdtDisable3); //端口刹车功能解除 + + delay1ms(1000); +/********************************低电平刹车功能测试结束***********************************/ + + +/********************************软件刹车功能测试开始***********************************/ + delay1ms(1000); + + //cfg software break + Adt_SwBrake(TRUE); //软件刹车 + + delay1ms(2000); + + Adt_SwBrake(FALSE); //软件刹车解除,恢复PWM输出 + + delay1ms(2000); +/********************************软件刹车功能测试结束***********************************/ + while(1); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/adt/PwmHwComp/EWARM/PwmHwComp.ewp b/src/hc32f005_ddl/example/adt/PwmHwComp/EWARM/PwmHwComp.ewp new file mode 100644 index 0000000..b774371 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PwmHwComp/EWARM/PwmHwComp.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\adt.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\flash.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/adt/PwmHwComp/EWARM/PwmHwComp.eww b/src/hc32f005_ddl/example/adt/PwmHwComp/EWARM/PwmHwComp.eww new file mode 100644 index 0000000..889cd8d --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PwmHwComp/EWARM/PwmHwComp.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\PwmHwComp.ewp + + + + + diff --git a/src/hc32f005_ddl/example/adt/PwmHwComp/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/PwmHwComp/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PwmHwComp/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/adt/PwmHwComp/MDK/PwmHwComp.uvprojx b/src/hc32f005_ddl/example/adt/PwmHwComp/MDK/PwmHwComp.uvprojx new file mode 100644 index 0000000..e3ca9de --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PwmHwComp/MDK/PwmHwComp.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + PwmHwComp_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + PwmHwComp + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + PwmHwComp.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +adt.c +1..\..\..\..\driver\src\adt.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +flash.c +1..\..\..\..\driver\src\flash.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/adt/PwmHwComp/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/PwmHwComp/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PwmHwComp/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/adt/PwmHwComp/source/ddl_device.h b/src/hc32f005_ddl/example/adt/PwmHwComp/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PwmHwComp/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/adt/PwmHwComp/source/main.c b/src/hc32f005_ddl/example/adt/PwmHwComp/source/main.c new file mode 100644 index 0000000..cc81d18 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/PwmHwComp/source/main.c @@ -0,0 +1,222 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2019-04-22 Husj First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adt.h" +#include "gpio.h" +#include "flash.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') * + ******************************************************************************/ + + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +void Tim4_IRQHandler(void) +{ + static uint32_t i = 0; + + if(TRUE == Adt_GetIrqFlag(M0P_ADTIM4, AdtUDFIrq)) + { + if (0 == i) + { + //设置GCMCR寄存器,通过缓存传送GCMCR-->GCMAR,改变CHA通道的PWM占空比,CHB通道的PWM占空比也跟随变化 + Adt_SetCompareValue(M0P_ADTIM4, AdtCompareC, 0xBBBB); + + i++; + } + else + { + //设置GCMCR寄存器,通过缓存传送GCMCR-->GCMAR,改变CHA通道的PWM占空比,CHB通道的PWM占空比也跟随变化 + Adt_SetCompareValue(M0P_ADTIM4, AdtCompareC, 0x8888); + + i = 0; + } + + Adt_ClearIrqFlag(M0P_ADTIM4, AdtUDFIrq); + } +} + +///< AdvTimer端口初始化 +void App_AdvTimerPortInit(void) +{ + stc_gpio_cfg_t stcTIM4Port; + + DDL_ZERO_STRUCT(stcTIM4Port); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM4Port.enDir = GpioDirOut; + //P34设置为TIM4_CHA + Gpio_Init(GpioPort3, GpioPin4, &stcTIM4Port); + Gpio_SetAfMode(GpioPort3,GpioPin4,GpioAf5); + + //P35设置为TIM4_CHB + Gpio_Init(GpioPort3, GpioPin5, &stcTIM4Port); + Gpio_SetAfMode(GpioPort3,GpioPin5,GpioAf5); +} + + +///< AdvTimer初始化 +void App_AdvTimerInit(uint16_t u16Period, uint16_t u16CHA_PWMDuty, uint16_t u16CHB_PWMDuty) +{ + en_adt_compare_t enAdtCompare; + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4ACfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4BCfg; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtTIM4ACfg); + DDL_ZERO_STRUCT(stcAdtTIM4BCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE); //ADT外设时钟使能 + + stcAdtBaseCntCfg.enCntMode = AdtTriangleModeA; //三角波A + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0Div2; + Adt_Init(M0P_ADTIM4, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + Adt_SetPeriod(M0P_ADTIM4, u16Period); //周期值 + + enAdtCompare = AdtCompareA; + Adt_SetCompareValue(M0P_ADTIM4, enAdtCompare, u16CHA_PWMDuty); //通用比较基准值寄存器A设置 + + enAdtCompare = AdtCompareB; + Adt_SetCompareValue(M0P_ADTIM4, enAdtCompare, u16CHB_PWMDuty); //通用比较基准值寄存器B设置 + + enAdtCompare = AdtCompareC; + Adt_SetCompareValue(M0P_ADTIM4, enAdtCompare, u16CHA_PWMDuty); //通用比较基准值寄存器C设置 + + Adt_EnableValueBuf(M0P_ADTIM4, AdtCHxA, TRUE); //缓存传送A使能 GCMCR--->GCMAR,三角波A模式在下溢点传送 + //Adt_EnableValueBuf(M0P_ADTIM4, AdtCHxB, TRUE); //缓存传送B不需要设置,因为GCMBR由GCMAR和死区时间计算得到 + + stcAdtTIM4ACfg.enCap = AdtCHxCompareOutput; //比较输出模式 + stcAdtTIM4ACfg.bOutEn = TRUE; //CHA输出使能 + stcAdtTIM4ACfg.enPerc = AdtCHxPeriodKeep; //计数值与周期匹配时CHA电平保持不变 + stcAdtTIM4ACfg.enCmpc = AdtCHxCompareInv; //计数值与比较值A匹配时,CHA电平翻转 + stcAdtTIM4ACfg.enStaStp = AdtCHxStateSelSS; //CHA起始结束电平由STACA与STPCA控制 + stcAdtTIM4ACfg.enStaOut = AdtCHxPortOutLow; //CHA起始电平为低 + stcAdtTIM4ACfg.enStpOut = AdtCHxPortOutLow; //CHA结束电平为低 + Adt_CHxXPortCfg(M0P_ADTIM4, AdtCHxA, &stcAdtTIM4ACfg); //端口CHA配置 + + stcAdtTIM4BCfg.enCap = AdtCHxCompareOutput; + stcAdtTIM4BCfg.bOutEn = TRUE; + stcAdtTIM4BCfg.enPerc = AdtCHxPeriodKeep; + stcAdtTIM4BCfg.enCmpc = AdtCHxCompareInv; + stcAdtTIM4BCfg.enStaStp = AdtCHxStateSelSS; + stcAdtTIM4BCfg.enStaOut = AdtCHxPortOutHigh; //CHB起始电平为高(为了上下桥互补) + stcAdtTIM4BCfg.enStpOut = AdtCHxPortOutLow; //CHB结束电平为低 + Adt_CHxXPortCfg(M0P_ADTIM4, AdtCHxB, &stcAdtTIM4BCfg); //端口CHB配置 + + Adt_SetDTUA(M0P_ADTIM4, 0x2000); //CNT向上计数时的死区时间,GCMBR = GCMAR - DTUAR + Adt_SetDTDA(M0P_ADTIM4, 0x2000); //CNT向下计数时的死区时间,GCMBR = GCMAR - DTDAR + Adt_CfgDT(M0P_ADTIM4, TRUE, TRUE); //中断使能,并且DTUAR和DTDAR自动相等 + + Adt_ClearAllIrqFlag(M0P_ADTIM4); //清标志位 + Adt_CfgIrq(M0P_ADTIM4, AdtUDFIrq, TRUE); //下溢中断配置 + EnableNvic(ADTIM4_IRQn, IrqLevel3, TRUE); //使能AdvTimer4 中断 +} + + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + stc_adt_sw_sync_t stcAdtSwSync; + + DDL_ZERO_STRUCT(stcAdtSwSync); + + App_AdvTimerInit(0xEEEE, 0x9999, 0); //AdvTimer4初始化 + //配置为三角波模式: 初始化周期0xC000, CHA占空比设置0x4000,CHB占空比设置0x8000 + + App_AdvTimerPortInit(); //AdvTimer端口初始化 + + + stcAdtSwSync.bAdTim4 = TRUE; + Adt_SwSyncStart(&stcAdtSwSync); //AdvTimer4硬件同步使能 + + while(1); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/adt/SoftwareSync/EWARM/SoftwareSync.ewp b/src/hc32f005_ddl/example/adt/SoftwareSync/EWARM/SoftwareSync.ewp new file mode 100644 index 0000000..5f89a5d --- /dev/null +++ b/src/hc32f005_ddl/example/adt/SoftwareSync/EWARM/SoftwareSync.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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\adt.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/adt/SoftwareSync/EWARM/SoftwareSync.eww b/src/hc32f005_ddl/example/adt/SoftwareSync/EWARM/SoftwareSync.eww new file mode 100644 index 0000000..6f9620c --- /dev/null +++ b/src/hc32f005_ddl/example/adt/SoftwareSync/EWARM/SoftwareSync.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\SoftwareSync.ewp + + + + + diff --git a/src/hc32f005_ddl/example/adt/SoftwareSync/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/SoftwareSync/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/adt/SoftwareSync/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/adt/SoftwareSync/MDK/SoftwareSync.uvprojx b/src/hc32f005_ddl/example/adt/SoftwareSync/MDK/SoftwareSync.uvprojx new file mode 100644 index 0000000..eb01bba --- /dev/null +++ b/src/hc32f005_ddl/example/adt/SoftwareSync/MDK/SoftwareSync.uvprojx @@ -0,0 +1,461 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + SoftwareSync_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + SoftwareSync + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + SoftwareSync.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +adt.c +1..\..\..\..\driver\src\adt.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/adt/SoftwareSync/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/SoftwareSync/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/SoftwareSync/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/adt/SoftwareSync/source/ddl_device.h b/src/hc32f005_ddl/example/adt/SoftwareSync/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/SoftwareSync/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/adt/SoftwareSync/source/main.c b/src/hc32f005_ddl/example/adt/SoftwareSync/source/main.c new file mode 100644 index 0000000..be1a3e6 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/SoftwareSync/source/main.c @@ -0,0 +1,324 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2019-04-22 Husj First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adt.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ +volatile uint16_t u16Adt4CntState; +volatile uint16_t u16Adt5CntState; +volatile uint16_t u16Adt6CntState; + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + + +/****************************************************************************** + * Local variable definitions ('static') * + ******************************************************************************/ + + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +///< AdvTimer4/5/6 软件同步启动、停止、清零 +void App_AdvTimer_All_SwSync_Start(void) +{ + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_sw_sync_t stcAdtSwSync; + stc_adt_sw_sync_t stcAdtSwSState; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtSwSync); + DDL_ZERO_STRUCT(stcAdtSwSState); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE); //ADT外设时钟使能 + + stcAdtBaseCntCfg.enCntMode = AdtTriangleModeB; + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0Div2; + Adt_Init(M0P_ADTIM4, &stcAdtBaseCntCfg); + Adt_Init(M0P_ADTIM5, &stcAdtBaseCntCfg); + Adt_Init(M0P_ADTIM6, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + stcAdtSwSync.bAdTim4 = TRUE; + stcAdtSwSync.bAdTim5 = TRUE; + stcAdtSwSync.bAdTim6 = TRUE; + // start + Adt_SwSyncStart(&stcAdtSwSync); //软件同步开始 + + u16Adt4CntState = Adt_GetCount(M0P_ADTIM4); //读取计数值 + u16Adt5CntState = Adt_GetCount(M0P_ADTIM5); + u16Adt6CntState = Adt_GetCount(M0P_ADTIM6); + Adt_GetSwSyncState(&stcAdtSwSState); //读取软件同步状态 + + delay1ms(1000); + + // stop + Adt_SwSyncStop(&stcAdtSwSync); //软件同步停止 + //delay1ms(20); + u16Adt4CntState = Adt_GetCount(M0P_ADTIM4); //读取计数值 + u16Adt5CntState = Adt_GetCount(M0P_ADTIM5); + u16Adt6CntState = Adt_GetCount(M0P_ADTIM6); + Adt_GetSwSyncState(&stcAdtSwSState); //读取软件同步状态 + + // clear + Adt_SwSyncClear(&stcAdtSwSync); //软件同步清零 + + u16Adt4CntState = Adt_GetCount(M0P_ADTIM4); //读取计数值 + u16Adt5CntState = Adt_GetCount(M0P_ADTIM5); + u16Adt6CntState = Adt_GetCount(M0P_ADTIM6); + Adt_GetSwSyncState(&stcAdtSwSState); //读取软件同步状态 +} + +///< AdvTimer5/6 软件同步启动、停止、清零 +void App_AdvTimer_Tim5Tim6_SwSync_Start(void) +{ + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_sw_sync_t stcAdtSwSync; + stc_adt_sw_sync_t stcAdtSwSState; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtSwSync); + DDL_ZERO_STRUCT(stcAdtSwSState); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE); //ADT外设时钟使能 + + stcAdtBaseCntCfg.enCntMode = AdtTriangleModeB; + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0Div2; + Adt_Init(M0P_ADTIM4, &stcAdtBaseCntCfg); + Adt_Init(M0P_ADTIM5, &stcAdtBaseCntCfg); + Adt_Init(M0P_ADTIM6, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + stcAdtSwSync.bAdTim4 = FALSE; + stcAdtSwSync.bAdTim5 = TRUE; + stcAdtSwSync.bAdTim6 = TRUE; + // start + Adt_SwSyncStart(&stcAdtSwSync); //软件同步开始 + + u16Adt4CntState = Adt_GetCount(M0P_ADTIM4); //读取计数值 + u16Adt5CntState = Adt_GetCount(M0P_ADTIM5); + u16Adt6CntState = Adt_GetCount(M0P_ADTIM6); + Adt_GetSwSyncState(&stcAdtSwSState); //读取软件同步状态 + + delay1ms(1000); + + // stop + Adt_SwSyncStop(&stcAdtSwSync); //软件同步停止 + + u16Adt4CntState = Adt_GetCount(M0P_ADTIM4); //读取计数值 + u16Adt5CntState = Adt_GetCount(M0P_ADTIM5); + u16Adt6CntState = Adt_GetCount(M0P_ADTIM6); + Adt_GetSwSyncState(&stcAdtSwSState); //读取软件同步状态 + + // clear + Adt_SwSyncClear(&stcAdtSwSync); //软件同步清零 + + u16Adt4CntState = Adt_GetCount(M0P_ADTIM4); //读取计数值 + u16Adt5CntState = Adt_GetCount(M0P_ADTIM5); + u16Adt6CntState = Adt_GetCount(M0P_ADTIM6); + Adt_GetSwSyncState(&stcAdtSwSState); //读取软件同步状态 +} + +///< AdvTimer4/6 软件同步启动、停止、清零 +void App_AdvTimer_Tim4Tim6_SwSync_Start(void) +{ + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_sw_sync_t stcAdtSwSync; + stc_adt_sw_sync_t stcAdtSwSState; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtSwSync); + DDL_ZERO_STRUCT(stcAdtSwSState); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE); //ADT外设时钟使能 + + stcAdtBaseCntCfg.enCntMode = AdtTriangleModeB; + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0Div2; + Adt_Init(M0P_ADTIM4, &stcAdtBaseCntCfg); + Adt_Init(M0P_ADTIM5, &stcAdtBaseCntCfg); + Adt_Init(M0P_ADTIM6, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + stcAdtSwSync.bAdTim4 = TRUE; + stcAdtSwSync.bAdTim5 = FALSE; + stcAdtSwSync.bAdTim6 = TRUE; + //start + Adt_SwSyncStart(&stcAdtSwSync); //软件同步开始 + + u16Adt4CntState = Adt_GetCount(M0P_ADTIM4); //读取计数值 + u16Adt5CntState = Adt_GetCount(M0P_ADTIM5); + u16Adt6CntState = Adt_GetCount(M0P_ADTIM6); + Adt_GetSwSyncState(&stcAdtSwSState); //读取软件同步状态 + + delay1ms(1000); + // stop + Adt_SwSyncStop(&stcAdtSwSync); //软件同步停止 + + u16Adt4CntState = Adt_GetCount(M0P_ADTIM4); //读取计数值 + u16Adt5CntState = Adt_GetCount(M0P_ADTIM5); + u16Adt6CntState = Adt_GetCount(M0P_ADTIM6); + Adt_GetSwSyncState(&stcAdtSwSState); //读取软件同步状态 + + // clear + Adt_SwSyncClear(&stcAdtSwSync); //软件同步清零 + + u16Adt4CntState = Adt_GetCount(M0P_ADTIM4); //读取计数值 + u16Adt5CntState = Adt_GetCount(M0P_ADTIM5); + u16Adt6CntState = Adt_GetCount(M0P_ADTIM6); + Adt_GetSwSyncState(&stcAdtSwSState); //读取软件同步状态 +} + +///< AdvTimer4/5 软件同步启动、停止、清零 +void App_AdvTimer_Tim4Tim5_SwSync_Start(void) +{ + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_sw_sync_t stcAdtSwSync; + stc_adt_sw_sync_t stcAdtSwSState; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtSwSync); + DDL_ZERO_STRUCT(stcAdtSwSState); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE); //ADT外设时钟使能 + + stcAdtBaseCntCfg.enCntMode = AdtTriangleModeB; + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0Div2; + Adt_Init(M0P_ADTIM4, &stcAdtBaseCntCfg); + Adt_Init(M0P_ADTIM5, &stcAdtBaseCntCfg); + Adt_Init(M0P_ADTIM6, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + stcAdtSwSync.bAdTim4 = TRUE; + stcAdtSwSync.bAdTim5 = TRUE; + stcAdtSwSync.bAdTim6 = FALSE; + // start + Adt_SwSyncStart(&stcAdtSwSync); //软件同步开始 + + u16Adt4CntState = Adt_GetCount(M0P_ADTIM4); //读取计数值 + u16Adt5CntState = Adt_GetCount(M0P_ADTIM5); + u16Adt6CntState = Adt_GetCount(M0P_ADTIM6); + Adt_GetSwSyncState(&stcAdtSwSState); //读取软件同步状态 + delay1ms(1000); + // stop + Adt_SwSyncStop(&stcAdtSwSync); //软件同步停止 + + u16Adt4CntState = Adt_GetCount(M0P_ADTIM4); //读取计数值 + u16Adt5CntState = Adt_GetCount(M0P_ADTIM5); + u16Adt6CntState = Adt_GetCount(M0P_ADTIM6); + Adt_GetSwSyncState(&stcAdtSwSState); //读取软件同步状态 + + // clear + Adt_SwSyncClear(&stcAdtSwSync); //软件同步清零 + + u16Adt4CntState = Adt_GetCount(M0P_ADTIM4); //读取计数值 + u16Adt5CntState = Adt_GetCount(M0P_ADTIM5); + u16Adt6CntState = Adt_GetCount(M0P_ADTIM6); + Adt_GetSwSyncState(&stcAdtSwSState); //读取软件同步状态 +} + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + + + //AdvTimer4/5/6 软件同步启动、停止、清零 + App_AdvTimer_All_SwSync_Start(); + + //AdvTimer5/6 软件同步启动、停止、清零 + //App_AdvTimer_Tim5Tim6_SwSync_Start(); + + //AdvTimer4/6 软件同步启动、停止、清零 + //App_AdvTimer_Tim4Tim6_SwSync_Start(); + + //AdvTimer4/5 软件同步启动、停止、清零 + //App_AdvTimer_Tim4Tim5_SwSync_Start(); + + while(1); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/adt/VcBreak/EWARM/VcBreak.ewp b/src/hc32f005_ddl/example/adt/VcBreak/EWARM/VcBreak.ewp new file mode 100644 index 0000000..31640ce --- /dev/null +++ b/src/hc32f005_ddl/example/adt/VcBreak/EWARM/VcBreak.ewp @@ -0,0 +1,2222 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\adt.c + + + $PROJ_DIR$\..\..\..\..\driver\src\vc.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\flash.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/adt/VcBreak/EWARM/VcBreak.eww b/src/hc32f005_ddl/example/adt/VcBreak/EWARM/VcBreak.eww new file mode 100644 index 0000000..8f14d11 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/VcBreak/EWARM/VcBreak.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\VcBreak.ewp + + + + + diff --git a/src/hc32f005_ddl/example/adt/VcBreak/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/VcBreak/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/adt/VcBreak/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/adt/VcBreak/MDK/VcBreak.uvprojx b/src/hc32f005_ddl/example/adt/VcBreak/MDK/VcBreak.uvprojx new file mode 100644 index 0000000..d303fa5 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/VcBreak/MDK/VcBreak.uvprojx @@ -0,0 +1,470 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + VcBreak_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + VcBreak + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + VcBreak.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +adt.c +1..\..\..\..\driver\src\adt.c + +vc.c +1..\..\..\..\driver\src\vc.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +flash.c +1..\..\..\..\driver\src\flash.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/adt/VcBreak/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/adt/VcBreak/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/VcBreak/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/adt/VcBreak/source/ddl_device.h b/src/hc32f005_ddl/example/adt/VcBreak/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/VcBreak/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/adt/VcBreak/source/main.c b/src/hc32f005_ddl/example/adt/VcBreak/source/main.c new file mode 100644 index 0000000..21aabb6 --- /dev/null +++ b/src/hc32f005_ddl/example/adt/VcBreak/source/main.c @@ -0,0 +1,244 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2019-04-22 Husj First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "adt.h" +#include "vc.h" +#include "gpio.h" +#include "flash.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') * + ******************************************************************************/ + + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +void Vc1_IRQHandler(void) +{ + if(TRUE == Vc_GetItStatus(Vc1_Intf)) + { + //使用时需要用户添加VC刹车处理代码,退出中断后VC刹车即无效; + delay1ms(1000); //延时仅作为上升沿或下降沿刹车时的效果演示 + + Vc_ClearItStatus(Vc1_Intf); //VC1中断标志清除 + } +} + +///< AdvTimer端口初始化 +void App_AdvTimerPortInit(void) +{ + stc_gpio_cfg_t stcTIM4Port; + + DDL_ZERO_STRUCT(stcTIM4Port); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM4Port.enDir = GpioDirOut; + //P34设置为TIM4_CHA + Gpio_Init(GpioPort3, GpioPin4, &stcTIM4Port); + Gpio_SetAfMode(GpioPort3,GpioPin4,GpioAf5); + + //P35设置为TIM4_CHB + Gpio_Init(GpioPort3, GpioPin5, &stcTIM4Port); + Gpio_SetAfMode(GpioPort3,GpioPin5,GpioAf5); +} + +///< AdvTimer初始化 +void App_AdvTimerInit(uint16_t u16Period, uint16_t u16CHA_PWMDuty, uint16_t u16CHB_PWMDuty) +{ + en_adt_compare_t enAdtCompareA; + en_adt_compare_t enAdtCompareB; + + stc_adt_basecnt_cfg_t stcAdtBaseCntCfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4ACfg; + stc_adt_CHxX_port_cfg_t stcAdtTIM4BCfg; + + DDL_ZERO_STRUCT(stcAdtBaseCntCfg); + DDL_ZERO_STRUCT(stcAdtTIM4ACfg); + DDL_ZERO_STRUCT(stcAdtTIM4BCfg); + + + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdvTim, TRUE);//ADT外设时钟使能 + + stcAdtBaseCntCfg.enCntMode = AdtTriangleModeA; + stcAdtBaseCntCfg.enCntDir = AdtCntUp; + stcAdtBaseCntCfg.enCntClkDiv = AdtClkPClk0Div4; + Adt_Init(M0P_ADTIM4, &stcAdtBaseCntCfg); //ADT载波、计数模式、时钟配置 + + Adt_SetPeriod(M0P_ADTIM4, u16Period); //周期设置 + + enAdtCompareA = AdtCompareA; + Adt_SetCompareValue(M0P_ADTIM4, enAdtCompareA, u16CHA_PWMDuty); //通用比较基准值寄存器A设置 + + enAdtCompareB = AdtCompareB; + Adt_SetCompareValue(M0P_ADTIM4, enAdtCompareB, u16CHB_PWMDuty); //通用比较基准值寄存器B设置 + + stcAdtTIM4ACfg.enCap = AdtCHxCompareOutput; //比较输出 + stcAdtTIM4ACfg.bOutEn = TRUE; //CHA输出使能 + stcAdtTIM4ACfg.enPerc = AdtCHxPeriodKeep; //计数值与周期匹配时CHA电平保持不变 + stcAdtTIM4ACfg.enCmpc = AdtCHxCompareInv; //计数值与比较值A匹配时,CHA电平翻转 + stcAdtTIM4ACfg.enStaStp = AdtCHxStateSelSS; //CHA起始结束电平由STACA与STPCA控制 + stcAdtTIM4ACfg.enStaOut = AdtCHxPortOutLow; //CHA起始电平为低 + stcAdtTIM4ACfg.enStpOut = AdtCHxPortOutLow; //CHA结束电平为低 + stcAdtTIM4ACfg.enDisSel = AdtCHxDisSel0; //选择强制输出无效条件0 (VC刹车) + stcAdtTIM4ACfg.enDisVal = AdtTIMxDisValLow; //刹车时CHA端口输出低电平 + Adt_CHxXPortCfg(M0P_ADTIM4, AdtCHxA, &stcAdtTIM4ACfg); //端口CHA配置 + + stcAdtTIM4BCfg.enCap = AdtCHxCompareOutput; + stcAdtTIM4BCfg.bOutEn = TRUE; + stcAdtTIM4BCfg.enPerc = AdtCHxPeriodKeep; + stcAdtTIM4BCfg.enCmpc = AdtCHxCompareInv; + stcAdtTIM4BCfg.enStaStp = AdtCHxStateSelSS; + stcAdtTIM4BCfg.enStaOut = AdtCHxPortOutHigh; //CHB起始电平为高 + stcAdtTIM4BCfg.enStpOut = AdtCHxPortOutLow; //CHB结束电平为低 + stcAdtTIM4BCfg.enDisSel = AdtCHxDisSel0; //选择强制输出无效条件0 (VC刹车) + stcAdtTIM4BCfg.enDisVal = AdtTIMxDisValLow; //刹车时CHA端口输出低电平 + Adt_CHxXPortCfg(M0P_ADTIM4, AdtCHxB, &stcAdtTIM4BCfg); //端口CHB配置 +} + +void App_VcCfg(void) +{ + stc_gpio_cfg_t stcVC1PInPort; + stc_gpio_cfg_t stcVC1OutPort; + stc_vc_channel_cfg_t stcChannelCfg; + stc_vc_dac_cfg_t stcVcDacCfg; + + DDL_ZERO_STRUCT(stcChannelCfg); + DDL_ZERO_STRUCT(stcVcDacCfg); + DDL_ZERO_STRUCT(stcVC1PInPort); + DDL_ZERO_STRUCT(stcVC1OutPort); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralVcLvd, TRUE); //LVD时钟外设初始化 + + //PB14设置为VC1_IN_P + Gpio_SetAnalogMode(GpioPort2, GpioPin3); + + //PA02设置为VC1_OUT + stcVC1OutPort.enDir = GpioDirOut; + Gpio_Init(GpioPort2, GpioPin4, &stcVC1OutPort); + Gpio_SetAfMode(GpioPort2,GpioPin4,GpioAf7); + + stcVcDacCfg.bDivEn = TRUE; + stcVcDacCfg.u8DivVal =0x10; //Vc_Ref = (16/64)*Vcc + stcVcDacCfg.enDivVref = VcDivVrefAvcc; //电阻分压的参考电压为VCC + Vc_DacInit(&stcVcDacCfg); + + stcChannelCfg.enVcChannel = VcChannel1; //通道1 + stcChannelCfg.enVcCmpDly = VcDelayoff; //迟滞关闭 + stcChannelCfg.enVcBiasCurrent = VcBias10ua; //偏置电流10ua + stcChannelCfg.enVcFilterTime = VcFilter7us; //输出滤波时间7us + stcChannelCfg.bFlten = FALSE; //滤波功能关闭 + stcChannelCfg.enVcInPin_P = VcInPCh0; //VC1_IN_P 选择P23 + stcChannelCfg.enVcInPin_N = ResDivOut; //VC1_IN_N 选择VC自带6bitDAC(Vc_Ref) + stcChannelCfg.enVcOutCfg = VcOutBrake; //结果使能输出到Advanced Timer刹车 + + Vc_Init(&stcChannelCfg); //VC1初始化 + + Vc_CfgItType(VcChannel1, VcIrqHigh); //高电平触发中断 + + Vc_ClearItStatus(Vc1_Intf); + Vc_ItCfg(VcChannel1, TRUE); + EnableNvic(VC1_IRQn, IrqLevel3, TRUE); + + Vc_Cmd(VcChannel1, TRUE); //VC1使能 +} + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + + App_AdvTimerInit(0xC000, 0x6000, 0x6000); //AdvTimer4初始化 + //配置为三角波模式: 初始化周期0xC000, CHA占空比设置0x4000,CHB占空比设置0x8000 + + App_AdvTimerPortInit(); //AdvTimer端口初始化 + + App_VcCfg(); //VC比较器配置 + + Adt_StartCount(M0P_ADTIM4); //AdvTimer4启动 + + while(1); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/crc/crc_crc16/EWARM/crc_crc16.ewp b/src/hc32f005_ddl/example/crc/crc_crc16/EWARM/crc_crc16.ewp new file mode 100644 index 0000000..5a418c0 --- /dev/null +++ b/src/hc32f005_ddl/example/crc/crc_crc16/EWARM/crc_crc16.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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\crc.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/crc/crc_crc16/EWARM/crc_crc16.eww b/src/hc32f005_ddl/example/crc/crc_crc16/EWARM/crc_crc16.eww new file mode 100644 index 0000000..a365374 --- /dev/null +++ b/src/hc32f005_ddl/example/crc/crc_crc16/EWARM/crc_crc16.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\crc_crc16.ewp + + + + + diff --git a/src/hc32f005_ddl/example/crc/crc_crc16/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/crc/crc_crc16/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/crc/crc_crc16/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/crc/crc_crc16/MDK/crc_crc16.uvprojx b/src/hc32f005_ddl/example/crc/crc_crc16/MDK/crc_crc16.uvprojx new file mode 100644 index 0000000..e6df60b --- /dev/null +++ b/src/hc32f005_ddl/example/crc/crc_crc16/MDK/crc_crc16.uvprojx @@ -0,0 +1,478 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + crc_crc16_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.7.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + crc_crc16 + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 4 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + crc_crc16.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + + crc.c + 1 + ..\..\..\..\driver\src\crc.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + + + + + <Project Info> + + + + + + 0 + 1 + + + + +
diff --git a/src/hc32f005_ddl/example/crc/crc_crc16/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/crc/crc_crc16/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/crc/crc_crc16/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/crc/crc_crc16/source/ddl_device.h b/src/hc32f005_ddl/example/crc/crc_crc16/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/crc/crc_crc16/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/crc/crc_crc16/source/main.c b/src/hc32f005_ddl/example/crc/crc_crc16/source/main.c new file mode 100644 index 0000000..fbbe0aa --- /dev/null +++ b/src/hc32f005_ddl/example/crc/crc_crc16/source/main.c @@ -0,0 +1,134 @@ +/****************************************************************************** +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file 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 "ddl.h" +#include "crc.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ +//待编码数据 +uint8_t au8CrcTestData[8] = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0}; +//待编码数据数组长度 +uint32_t u32TestDataLen = 8; +uint16_t u16RefCrc16 = 0x5234; +uint16_t u16ErrRefCrc16 = 0xEEEE; +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * 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) +{ + uint16_t u16CrcResult = 0; + volatile uint8_t u8TestFlag = 0; + volatile en_result_t enResult = Error; + + Sysctrl_SetPeripheralGate(SysctrlPeripheralCrc, TRUE); ///< 开启CRC外设时钟模块 + + /* 8位位宽下输入数据测试示例 */ + u16CrcResult = CRC16_Get8(au8CrcTestData, u32TestDataLen); ///< 产生CRC16编码 + if(u16RefCrc16 == u16CrcResult) ///< 判断CRC16编码值是否正确 + { + u8TestFlag = Ok; + } + ///< 检验待校验数据与校验值是否匹配,如果匹配返回TRUE,否则返回FALSE + enResult = CRC16_Check8(au8CrcTestData, u32TestDataLen, u16CrcResult); + + + /* 16位位宽下输入数据测试示例 */ + u16CrcResult = CRC16_Get16((uint16_t *)au8CrcTestData, u32TestDataLen/2); ///< 产生CRC16编码 + if(u16RefCrc16 == u16CrcResult) ///< 判断CRC16编码值是否正确 + { + u8TestFlag = Ok; + } + ///< 检验待校验数据与校验值是否匹配,如果匹配返回TRUE,否则返回FALSE + enResult = CRC16_Check16((uint16_t *)au8CrcTestData, u32TestDataLen/2, u16CrcResult); + + /* 32位位宽下输入数据测试示例 */ + u16CrcResult = CRC16_Get32((uint32_t *)au8CrcTestData, u32TestDataLen/4); ///< 产生CRC16编码 + if(u16RefCrc16 == u16CrcResult) ///< 判断CRC16编码值是否正确 + { + u8TestFlag = Ok; + } + ///< 检验待校验数据与校验值是否匹配,如果匹配返回TRUE,否则返回FALSE + enResult = CRC16_Check32((uint32_t *)au8CrcTestData, u32TestDataLen/4, u16CrcResult); + while (1) + { + ; + } +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/flash/flash_erase_write/EWARM/flash_erase_write.ewp b/src/hc32f005_ddl/example/flash/flash_erase_write/EWARM/flash_erase_write.ewp new file mode 100644 index 0000000..c6bdba3 --- /dev/null +++ b/src/hc32f005_ddl/example/flash/flash_erase_write/EWARM/flash_erase_write.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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\flash.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/flash/flash_erase_write/EWARM/flash_erase_write.eww b/src/hc32f005_ddl/example/flash/flash_erase_write/EWARM/flash_erase_write.eww new file mode 100644 index 0000000..23ab14a --- /dev/null +++ b/src/hc32f005_ddl/example/flash/flash_erase_write/EWARM/flash_erase_write.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\flash_erase_write.ewp + + + + + diff --git a/src/hc32f005_ddl/example/flash/flash_erase_write/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/flash/flash_erase_write/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/flash/flash_erase_write/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/flash/flash_erase_write/MDK/flash_erase_write.uvprojx b/src/hc32f005_ddl/example/flash/flash_erase_write/MDK/flash_erase_write.uvprojx new file mode 100644 index 0000000..9a20a15 --- /dev/null +++ b/src/hc32f005_ddl/example/flash/flash_erase_write/MDK/flash_erase_write.uvprojx @@ -0,0 +1,461 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + flash_erase_write_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + flash_erase_write + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + flash_erase_write.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +flash.c +1..\..\..\..\driver\src\flash.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/flash/flash_erase_write/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/flash/flash_erase_write/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/flash/flash_erase_write/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/flash/flash_erase_write/source/ddl_device.h b/src/hc32f005_ddl/example/flash/flash_erase_write/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/flash/flash_erase_write/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/flash/flash_erase_write/source/main.c b/src/hc32f005_ddl/example/flash/flash_erase_write/source/main.c new file mode 100644 index 0000000..5b07f3a --- /dev/null +++ b/src/hc32f005_ddl/example/flash/flash_erase_write/source/main.c @@ -0,0 +1,131 @@ +/****************************************************************************** +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2018-05-08 1.0 Lux First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "ddl.h" +#include "flash.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +//#define RUN_IN_RAM 1 //need to cfg *.icf + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * 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) +{ + uint32_t u32Addr = 0x3f00; + uint8_t u8TestData = 0x5a; + + ///< 确保初始化正确执行后方能进行FLASH编程操作,FLASH初始化(编程时间) + while(Ok != Flash_Init(1)) + { + ; + } + + ///< FLASH目标扇区擦除 + while(Ok != Flash_SectorErase(u32Addr)) + { + ; + } + + for (u32Addr=0x3F00; u32Addr<0x4000; u32Addr++) + { + ///< FLASH 字节写、校验 + if (Ok == Flash_WriteByte(u32Addr, u8TestData)) + { + while(*((volatile uint8_t*)u32Addr) != u8TestData) ///< 如果写入的数据不对,在此处死循环 + { + ; + } + } + } + + while (1); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ diff --git a/src/hc32f005_ddl/example/generaltimer/gt_cnt/EWARM/gt_cnt.ewp b/src/hc32f005_ddl/example/generaltimer/gt_cnt/EWARM/gt_cnt.ewp new file mode 100644 index 0000000..7ab3f88 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_cnt/EWARM/gt_cnt.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\bt.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lpm.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/src/hc32f005_ddl/example/generaltimer/gt_cnt/EWARM/gt_cnt.eww b/src/hc32f005_ddl/example/generaltimer/gt_cnt/EWARM/gt_cnt.eww new file mode 100644 index 0000000..b08e7e4 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_cnt/EWARM/gt_cnt.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\gt_cnt.ewp + + + + + diff --git a/src/hc32f005_ddl/example/generaltimer/gt_cnt/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/generaltimer/gt_cnt/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_cnt/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/generaltimer/gt_cnt/MDK/gt_cnt.uvprojx b/src/hc32f005_ddl/example/generaltimer/gt_cnt/MDK/gt_cnt.uvprojx new file mode 100644 index 0000000..d32c6ec --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_cnt/MDK/gt_cnt.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + gt_cnt_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + gt_cnt + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + gt_cnt.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +bt.c +1..\..\..\..\driver\src\bt.c + +lpm.c +1..\..\..\..\driver\src\lpm.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/generaltimer/gt_cnt/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/generaltimer/gt_cnt/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_cnt/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/generaltimer/gt_cnt/source/ddl_device.h b/src/hc32f005_ddl/example/generaltimer/gt_cnt/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_cnt/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/generaltimer/gt_cnt/source/main.c b/src/hc32f005_ddl/example/generaltimer/gt_cnt/source/main.c new file mode 100644 index 0000000..eaaaf9f --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_cnt/source/main.c @@ -0,0 +1,187 @@ +/****************************************************************************** +* 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 "ddl.h" +#include "bt.h" +#include "lpm.h" +#include "gpio.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ +static volatile uint32_t u32BtTestFlag = 0; +//static volatile uint32_t u32Cnt = 0; + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +static void App_GpioInit(void); +static en_result_t App_BtCntTest(void); + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ + +int32_t main(void) +{ + volatile uint32_t u8TestFlag = 0; + + App_GpioInit(); + + if(Ok != App_BtCntTest()) + { + u8TestFlag |= 0x01; + } + + while (1); +} + +/******************************************************************************* + * TIM0中断服务函数 + ******************************************************************************/ +void Tim0_IRQHandler(void) +{ + if (TRUE == Bt_GetIntFlag(TIM0)) + { + Bt_ClearIntFlag(TIM0); + u32BtTestFlag = 0x01; + } +} + + +/******************************************************************************* + * BT计数功能测试 (自由计数) + ******************************************************************************/ +static en_result_t App_BtCntTest(void) +{ + stc_bt_cfg_t stcCfg; + en_result_t enResult = Error; + uint32_t u32InitCntData = 0xFFFFFFF0; + + Sysctrl_SetPeripheralGate(SysctrlPeripheralBt, TRUE); + + stcCfg.enGateP = BtPositive; + stcCfg.enGate = BtGateDisable; + stcCfg.enPRS = BtPCLKDiv8; + stcCfg.enTog = BtTogDisable; + stcCfg.enCT = BtCounter; + stcCfg.enMD = BtMode1; + + //Bt配置初始化 + if (Ok != Bt_Init(TIM0, &stcCfg)) + { + enResult = Error; + } + + //INT ENABLE + Bt_ClearIntFlag(TIM0); + Bt_EnableIrq(TIM0); + EnableNvic(TIM0_IRQn, IrqLevel3, TRUE); + + //设置计数值,启动计数 + Bt_Cnt32Set(TIM0, u32InitCntData); + Bt_Run(TIM0); + + //等待计数完成后进入中断…… + while(1) + { + if (0x01 == u32BtTestFlag) + { + //进入中断后,停止计数 + u32BtTestFlag = (u32BtTestFlag & (~0x01)); + Bt_Stop(TIM0); + enResult = Ok; + break; + } + } + + return enResult; +} + +static void App_GpioInit(void) +{ + stc_gpio_cfg_t stcTIM0Port; + + DDL_ZERO_STRUCT(stcTIM0Port); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM0Port.enDir = GpioDirOut; + //P34设置为TIM0_EXT + Gpio_Init(GpioPort3, GpioPin4, &stcTIM0Port); + Gpio_SetAfMode(GpioPort3,GpioPin4,GpioAf4); +} +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/generaltimer/gt_timer/EWARM/gt_timer.ewp b/src/hc32f005_ddl/example/generaltimer/gt_timer/EWARM/gt_timer.ewp new file mode 100644 index 0000000..0b04f98 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_timer/EWARM/gt_timer.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\bt.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lpm.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/src/hc32f005_ddl/example/generaltimer/gt_timer/EWARM/gt_timer.eww b/src/hc32f005_ddl/example/generaltimer/gt_timer/EWARM/gt_timer.eww new file mode 100644 index 0000000..42c68e5 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_timer/EWARM/gt_timer.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\gt_timer.ewp + + + + + diff --git a/src/hc32f005_ddl/example/generaltimer/gt_timer/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/generaltimer/gt_timer/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_timer/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/generaltimer/gt_timer/MDK/gt_timer.uvprojx b/src/hc32f005_ddl/example/generaltimer/gt_timer/MDK/gt_timer.uvprojx new file mode 100644 index 0000000..6315db7 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_timer/MDK/gt_timer.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + gt_timer_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + gt_timer + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + gt_timer.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +bt.c +1..\..\..\..\driver\src\bt.c + +lpm.c +1..\..\..\..\driver\src\lpm.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/generaltimer/gt_timer/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/generaltimer/gt_timer/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_timer/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/generaltimer/gt_timer/source/ddl_device.h b/src/hc32f005_ddl/example/generaltimer/gt_timer/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_timer/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/generaltimer/gt_timer/source/main.c b/src/hc32f005_ddl/example/generaltimer/gt_timer/source/main.c new file mode 100644 index 0000000..f83d676 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_timer/source/main.c @@ -0,0 +1,198 @@ +/****************************************************************************** +* 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 "ddl.h" +#include "bt.h" +#include "lpm.h" +#include "gpio.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ +static volatile uint32_t u32BtTestFlag = 0; +static volatile uint32_t u32Cnt = 0; + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +static void App_GpioInit(void); +static en_result_t App_BtTimerTest(void); + + + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ + +int32_t main(void) +{ + volatile uint8_t u8TestFlag = 0; + + App_GpioInit(); + + if(Ok != App_BtTimerTest()) + { + u8TestFlag |= 0x02; + } + + while (1); +} + + +/******************************************************************************* + * BT1中断服务函数 + ******************************************************************************/ +void Tim1_IRQHandler(void) +{ + if (TRUE == Bt_GetIntFlag(TIM1)) + { + Bt_ClearIntFlag(TIM1); + u32BtTestFlag = 0x02; + } +} + +/******************************************************************************* + * BT定时功能测试 (重载模式) + ******************************************************************************/ +static en_result_t App_BtTimerTest(void) +{ + stc_bt_cfg_t stcCfg; + en_result_t enResult = Error; + uint16_t u16ArrData = 0x8000; + uint16_t u16InitCntData = 0xC000; + + //打开BT外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralBt, TRUE); + + stcCfg.enGateP = BtPositive; + stcCfg.enGate = BtGateEnable; + stcCfg.enPRS = BtPCLKDiv16; + stcCfg.enTog = BtTogDisable; + stcCfg.enCT = BtTimer; + stcCfg.enMD = BtMode2; + //Bt初始化 + if (Ok != Bt_Init(TIM1, &stcCfg)) + { + enResult = Error; + } + + //TIM1中断使能 + Bt_ClearIntFlag(TIM1); + Bt_EnableIrq(TIM1); + EnableNvic(TIM1_IRQn, IrqLevel3, TRUE); + + //设置重载值和计数值,启动计数 + Bt_ARRSet(TIM1, u16ArrData); + Bt_Cnt16Set(TIM1, u16InitCntData); + Bt_Run(TIM1); + + //此处进入中断…… + while(1) + { + //判断是否第二次进入中断 + if (0x02 == u32BtTestFlag) + { + u32BtTestFlag = u32BtTestFlag & (~0x02); + if (1 == u32Cnt) + { + Bt_Stop(TIM1); + enResult = Ok; + break; + } + u32Cnt++; + } + } + + return enResult; +} + +static void App_GpioInit(void) +{ + stc_gpio_cfg_t stcTIM1Port; + + DDL_ZERO_STRUCT(stcTIM1Port); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM1Port.enDir = GpioDirOut; + //P25设置为TIM1_GATE + Gpio_Init(GpioPort2, GpioPin5, &stcTIM1Port); + Gpio_SetAfMode(GpioPort2,GpioPin5,GpioAf7); + +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/generaltimer/gt_tog/EWARM/gt_tog.ewp b/src/hc32f005_ddl/example/generaltimer/gt_tog/EWARM/gt_tog.ewp new file mode 100644 index 0000000..eebe8e8 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_tog/EWARM/gt_tog.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\bt.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lpm.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/src/hc32f005_ddl/example/generaltimer/gt_tog/EWARM/gt_tog.eww b/src/hc32f005_ddl/example/generaltimer/gt_tog/EWARM/gt_tog.eww new file mode 100644 index 0000000..edfaf90 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_tog/EWARM/gt_tog.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\gt_tog.ewp + + + + + diff --git a/src/hc32f005_ddl/example/generaltimer/gt_tog/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/generaltimer/gt_tog/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_tog/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/generaltimer/gt_tog/MDK/gt_tog.uvprojx b/src/hc32f005_ddl/example/generaltimer/gt_tog/MDK/gt_tog.uvprojx new file mode 100644 index 0000000..f626ff8 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_tog/MDK/gt_tog.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + gt_tog_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + gt_tog + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + gt_tog.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +bt.c +1..\..\..\..\driver\src\bt.c + +lpm.c +1..\..\..\..\driver\src\lpm.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/generaltimer/gt_tog/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/generaltimer/gt_tog/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_tog/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/generaltimer/gt_tog/source/ddl_device.h b/src/hc32f005_ddl/example/generaltimer/gt_tog/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_tog/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/generaltimer/gt_tog/source/main.c b/src/hc32f005_ddl/example/generaltimer/gt_tog/source/main.c new file mode 100644 index 0000000..89ebd9b --- /dev/null +++ b/src/hc32f005_ddl/example/generaltimer/gt_tog/source/main.c @@ -0,0 +1,169 @@ +/****************************************************************************** +* 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 "ddl.h" +#include "bt.h" +#include "lpm.h" +#include "gpio.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ +static volatile uint32_t u32BtTestFlag = 0; +static volatile uint32_t u32Cnt = 0; + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +static void App_GpioInit(void); +static en_result_t App_BtTogTest(void); + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ + +int32_t main(void) +{ + volatile uint8_t u8TestFlag = 0; + + App_GpioInit(); + + if(Ok != App_BtTogTest()) + { + u8TestFlag |= 0x04; + } + + while (1); +} + + +/******************************************************************************* + * BT Buzzer功能测试 (TOG) + ******************************************************************************/ +static en_result_t App_BtTogTest(void) +{ + stc_bt_cfg_t stcCfg; + en_result_t enResult = Ok; + ///<(4Mhz->1000Hz) + uint16_t u16ArrData = 0xF830; + uint16_t u16InitCntData = 0xF830; + + Sysctrl_SetPeripheralGate(SysctrlPeripheralBt, TRUE); + + stcCfg.enGateP = BtPositive; + stcCfg.enGate = BtGateDisable; + stcCfg.enPRS = BtPCLKDiv1; + stcCfg.enTog = BtTogEnable; + stcCfg.enCT = BtTimer; + stcCfg.enMD = BtMode2; + + if (Ok != Bt_Init(TIM2, &stcCfg)) + { + enResult = Error; + } + + //设置重载值,计数值,启动计数 + Bt_ARRSet(TIM2, u16ArrData); + Bt_Cnt16Set(TIM2, u16InitCntData); + Bt_Run(TIM2); + + //等待波形输出…… + u32Cnt = 0x800000; + while(u32Cnt--); + Bt_Stop(TIM2); + + return enResult; +} + +static void App_GpioInit(void) +{ + stc_gpio_cfg_t stcTIM2Port; + + DDL_ZERO_STRUCT(stcTIM2Port); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //端口外设时钟使能 + + stcTIM2Port.enDir = GpioDirOut; + //P14设置为TIM2_TOGN + Gpio_Init(GpioPort1, GpioPin4, &stcTIM2Port); + Gpio_SetAfMode(GpioPort1,GpioPin4,GpioAf2); + //P15设置为TIM2_TOG + Gpio_Init(GpioPort1, GpioPin5, &stcTIM2Port); + Gpio_SetAfMode(GpioPort1,GpioPin5,GpioAf2); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/EWARM/gpio_deepsleep_wakeup.ewp b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/EWARM/gpio_deepsleep_wakeup.ewp new file mode 100644 index 0000000..d9be12e --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/EWARM/gpio_deepsleep_wakeup.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lpm.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/EWARM/gpio_deepsleep_wakeup.eww b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/EWARM/gpio_deepsleep_wakeup.eww new file mode 100644 index 0000000..278e245 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/EWARM/gpio_deepsleep_wakeup.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\gpio_deepsleep_wakeup.ewp + + + + + diff --git a/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/MDK/gpio_deepsleep_wakeup.uvprojx b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/MDK/gpio_deepsleep_wakeup.uvprojx new file mode 100644 index 0000000..008ef4e --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/MDK/gpio_deepsleep_wakeup.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + gpio_deepsleep_wakeup_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + gpio_deepsleep_wakeup + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + gpio_deepsleep_wakeup.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +gpio.c +1..\..\..\..\driver\src\gpio.c + +lpm.c +1..\..\..\..\driver\src\lpm.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/source/ddl_device.h b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/source/main.c b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/source/main.c new file mode 100644 index 0000000..711043e --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_deepsleep_wakeup/source/main.c @@ -0,0 +1,244 @@ +/****************************************************************************** +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2018-05-08 1.0 Lux First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "gpio.h" +#include "lpm.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') + ******************************************************************************/ +static void App_LedInit(void); +static void App_UserKeyInit(void); +static void App_LowPowerModeGpioSet(void); +static void _UserKeyWait(void); + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + + ///< LED 端口初始化 + App_LedInit(); + + ///< KEY 端口初始化 + App_UserKeyInit(); + + ///< =============================================== + ///< ============ 警告,警告,警告!!!============= + ///< =============================================== + ///< 本样例程序会进入深度休眠模式,因此以下两行代码起防护作用(防止进入深度 + ///< 休眠后芯片调试功能不能再次使用), + ///< 在使用本样例时,禁止在没有唤醒机制的情况下删除以下两行代码。 + delay1ms(2000); + _UserKeyWait(); ///< 等待按键按下后进入休眠模式 + + ///< 配置Demo板上所有不使用的IO为高阻输入,避免端口漏电 + App_LowPowerModeGpioSet(); + + ///< 打开并配置按键端口为下降沿中断 + Gpio_EnableIrq(STK_USER_PORT, STK_USER_PIN, GpioIrqFalling); + EnableNvic(PORT3_IRQn, IrqLevel3, TRUE); + + ///< 进入低功耗模式——深度休眠(使能唤醒后退出中断自动休眠特性) + Lpm_GotoDeepSleep(TRUE); + + while(1) + { + ; + } +} + + + +///< Port3 中断服务函数 +void Port3_IRQHandler(void) +{ + if(TRUE == Gpio_GetIrqStatus(STK_USER_PORT, STK_USER_PIN)) + { + ///< LED点亮 + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); + + delay1ms(2000); + + ///< LED关闭 + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); + + Gpio_ClearIrq(STK_USER_PORT, STK_USER_PIN); + } + +} + + +static void _UserKeyWait(void) +{ + while(1) + { + ///< 检测电平(USER按键是否按下(低电平)) + if(FALSE == Gpio_GetInputIO(STK_USER_PORT, STK_USER_PIN)) + { + break; + } + else + { + continue; + } + } +} + + +static void App_LowPowerModeGpioSet(void) +{ + ///< 打开GPIO外设时钟门控 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + //swd as gpio + Sysctrl_SetFunc(SysctrlSWDUseIOEn, TRUE); + + ///< 配置为数字端口 + M0P_GPIO->P0ADS = 0; + M0P_GPIO->P1ADS = 0; + M0P_GPIO->P2ADS = 0; + M0P_GPIO->P3ADS = 0; + + ///< 配置为端口输入(除LED端口外) + M0P_GPIO->P0DIR = 0XFFF7; + M0P_GPIO->P1DIR = 0XFFFF; + M0P_GPIO->P2DIR = 0XFFFF; + M0P_GPIO->P3DIR = 0XFFFF; + + ///< 输入下拉(除KEY端口以外) + M0P_GPIO->P0PD = 0xFFF7; + M0P_GPIO->P1PD = 0xFFFF; + M0P_GPIO->P2PD = 0xFFFF; + M0P_GPIO->P3PD = 0xFFF7; + +} + +static void App_UserKeyInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + ///< 打开GPIO外设时钟门控 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + ///< 端口方向配置->输入 + stcGpioCfg.enDir = GpioDirIn; + ///< 端口驱动能力配置->高驱动能力 + stcGpioCfg.enDrv = GpioDrvL; + ///< 端口上下拉配置->无 + stcGpioCfg.enPu = GpioPuDisable; + stcGpioCfg.enPd = GpioPdDisable; + ///< 端口开漏输出配置->开漏输出关闭 + stcGpioCfg.enOD = GpioOdDisable; + + ///< GPIO IO USER KEY初始化 + Gpio_Init(STK_USER_PORT, STK_USER_PIN, &stcGpioCfg); + + +} + +static void App_LedInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + ///< 打开GPIO外设时钟门控 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + ///< 端口方向配置->输出(其它参数与以上(输入)配置参数一致) + stcGpioCfg.enDir = GpioDirOut; + ////< 端口上下拉配置->无 + stcGpioCfg.enPu = GpioPuDisable; + stcGpioCfg.enPd = GpioPdDisable; + ///< GPIO IO LED端口初始化 + Gpio_Init(STK_LED_PORT, STK_LED_PIN, &stcGpioCfg); + ///< LED关闭 + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/gpio/gpio_input/EWARM/gpio_input.ewp b/src/hc32f005_ddl/example/gpio/gpio_input/EWARM/gpio_input.ewp new file mode 100644 index 0000000..8cfd32f --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_input/EWARM/gpio_input.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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.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/src/hc32f005_ddl/example/gpio/gpio_input/EWARM/gpio_input.eww b/src/hc32f005_ddl/example/gpio/gpio_input/EWARM/gpio_input.eww new file mode 100644 index 0000000..0902615 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_input/EWARM/gpio_input.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\gpio_input.ewp + + + + + diff --git a/src/hc32f005_ddl/example/gpio/gpio_input/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/gpio/gpio_input/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_input/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/gpio/gpio_input/MDK/gpio_input.uvprojx b/src/hc32f005_ddl/example/gpio/gpio_input/MDK/gpio_input.uvprojx new file mode 100644 index 0000000..00abfa8 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_input/MDK/gpio_input.uvprojx @@ -0,0 +1,461 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + gpio_input_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + gpio_input + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + gpio_input.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/gpio/gpio_input/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/gpio/gpio_input/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_input/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/gpio/gpio_input/source/ddl_device.h b/src/hc32f005_ddl/example/gpio/gpio_input/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_input/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/gpio/gpio_input/source/main.c b/src/hc32f005_ddl/example/gpio/gpio_input/source/main.c new file mode 100644 index 0000000..7565740 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_input/source/main.c @@ -0,0 +1,169 @@ +/****************************************************************************** +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2018-05-08 1.0 Lux First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "gpio.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') + ******************************************************************************/ +static void App_UserKeyInit(void); +static void App_LedInit(void); + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + ///< 按键端口初始化 + App_UserKeyInit(); + + ///< LED端口初始化 + App_LedInit(); + + while(1) + { + ///< 检测USER按键是否按下(低电平) + if(FALSE == Gpio_GetInputIO(STK_USER_PORT, STK_USER_PIN)) + { + ///< LED点亮 + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); + } + else + { + ///< LED关闭 + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); + } + } +} + + + +static void App_UserKeyInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + ///< 打开GPIO外设时钟门控 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + ///< 端口方向配置->输入 + stcGpioCfg.enDir = GpioDirIn; + ///< 端口驱动能力配置->高驱动能力 + stcGpioCfg.enDrv = GpioDrvL; + ///< 端口上下拉配置->无 + stcGpioCfg.enPu = GpioPuDisable; + stcGpioCfg.enPd = GpioPdDisable; + ///< 端口开漏输出配置->开漏输出关闭 + stcGpioCfg.enOD = GpioOdDisable; + ///< GPIO IO USER KEY初始化 + Gpio_Init(STK_USER_PORT, STK_USER_PIN, &stcGpioCfg); +} + + +static void App_LedInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + ///< 打开GPIO外设时钟门控 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + ///< 端口方向配置->输出(其它参数与以上(输入)配置参数一致) + stcGpioCfg.enDir = GpioDirOut; + ///< 端口上下拉配置->下拉 + stcGpioCfg.enPu = GpioPuDisable; + stcGpioCfg.enPd = GpioPdEnable; + + ///< LED关闭 + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); + + ///< GPIO IO LED端口初始化 + Gpio_Init(STK_LED_PORT, STK_LED_PIN, &stcGpioCfg); + + +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/gpio/gpio_interrupt/EWARM/gpio_interrupt.ewp b/src/hc32f005_ddl/example/gpio/gpio_interrupt/EWARM/gpio_interrupt.ewp new file mode 100644 index 0000000..1820e14 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_interrupt/EWARM/gpio_interrupt.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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.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/src/hc32f005_ddl/example/gpio/gpio_interrupt/EWARM/gpio_interrupt.eww b/src/hc32f005_ddl/example/gpio/gpio_interrupt/EWARM/gpio_interrupt.eww new file mode 100644 index 0000000..c5cb30d --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_interrupt/EWARM/gpio_interrupt.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\gpio_interrupt.ewp + + + + + diff --git a/src/hc32f005_ddl/example/gpio/gpio_interrupt/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/gpio/gpio_interrupt/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_interrupt/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/gpio/gpio_interrupt/MDK/gpio_interrupt.uvprojx b/src/hc32f005_ddl/example/gpio/gpio_interrupt/MDK/gpio_interrupt.uvprojx new file mode 100644 index 0000000..733ab80 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_interrupt/MDK/gpio_interrupt.uvprojx @@ -0,0 +1,461 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + gpio_interrupt_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + gpio_interrupt + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + gpio_interrupt.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/gpio/gpio_interrupt/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/gpio/gpio_interrupt/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_interrupt/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/gpio/gpio_interrupt/source/ddl_device.h b/src/hc32f005_ddl/example/gpio/gpio_interrupt/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_interrupt/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/gpio/gpio_interrupt/source/main.c b/src/hc32f005_ddl/example/gpio/gpio_interrupt/source/main.c new file mode 100644 index 0000000..f628529 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_interrupt/source/main.c @@ -0,0 +1,180 @@ +/****************************************************************************** +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2018-05-08 1.0 Lux First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "gpio.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ +static void App_UserKeyInit(void); +static void App_LedInit(void); + +/****************************************************************************** + * 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) +{ + ///< 按键端口初始化 + App_UserKeyInit(); + + ///< LED端口初始化 + App_LedInit(); + + ///< 打开并配置USER KEY为下降沿中断 + Gpio_EnableIrq(STK_USER_PORT, STK_USER_PIN, GpioIrqFalling); + ///< 使能端口PORT3系统中断 + EnableNvic(PORT3_IRQn, IrqLevel3, TRUE); + + while(1) + { + ; + } +} + +///< Port3中断服务函数 +void Port3_IRQHandler(void) +{ + if(TRUE == Gpio_GetIrqStatus(STK_USER_PORT, STK_USER_PIN)) + { + ///< LED点亮 + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); + + delay1ms(2000); + + ///< LED关闭 + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); + + Gpio_ClearIrq(STK_USER_PORT, STK_USER_PIN); + } + +} + +static void App_UserKeyInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + ///< 打开GPIO外设时钟门控 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + ///< 端口方向配置->输入 + stcGpioCfg.enDir = GpioDirIn; + ///< 端口驱动能力配置->高驱动能力 + stcGpioCfg.enDrv = GpioDrvL; + ///< 端口上下拉配置->无 + stcGpioCfg.enPu = GpioPuDisable; + stcGpioCfg.enPd = GpioPdDisable; + ///< 端口开漏输出配置->开漏输出关闭 + stcGpioCfg.enOD = GpioOdDisable; + + ///< GPIO IO USER KEY初始化 + Gpio_Init(STK_USER_PORT, STK_USER_PIN, &stcGpioCfg); +} + + +static void App_LedInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + ///< 打开GPIO外设时钟门控 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + ///< 端口方向配置->输出(其它参数与以上(输入)配置参数一致) + stcGpioCfg.enDir = GpioDirOut; + ///< 端口上下拉配置->下拉 + stcGpioCfg.enPu = GpioPuDisable; + stcGpioCfg.enPd = GpioPdEnable; + + ///< LED关闭 + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); + + ///< GPIO IO LED端口初始化 + Gpio_Init(STK_LED_PORT, STK_LED_PIN, &stcGpioCfg); + + +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/gpio/gpio_output/EWARM/gpio_output.ewp b/src/hc32f005_ddl/example/gpio/gpio_output/EWARM/gpio_output.ewp new file mode 100644 index 0000000..986d380 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_output/EWARM/gpio_output.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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.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/src/hc32f005_ddl/example/gpio/gpio_output/EWARM/gpio_output.eww b/src/hc32f005_ddl/example/gpio/gpio_output/EWARM/gpio_output.eww new file mode 100644 index 0000000..3f6bb15 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_output/EWARM/gpio_output.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\gpio_output.ewp + + + + + diff --git a/src/hc32f005_ddl/example/gpio/gpio_output/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/gpio/gpio_output/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_output/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/gpio/gpio_output/MDK/gpio_output.uvprojx b/src/hc32f005_ddl/example/gpio/gpio_output/MDK/gpio_output.uvprojx new file mode 100644 index 0000000..ecce23f --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_output/MDK/gpio_output.uvprojx @@ -0,0 +1,461 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + gpio_output_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + gpio_output + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + gpio_output.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/gpio/gpio_output/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/gpio/gpio_output/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_output/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/gpio/gpio_output/source/ddl_device.h b/src/hc32f005_ddl/example/gpio/gpio_output/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_output/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/gpio/gpio_output/source/main.c b/src/hc32f005_ddl/example/gpio/gpio_output/source/main.c new file mode 100644 index 0000000..7c550a5 --- /dev/null +++ b/src/hc32f005_ddl/example/gpio/gpio_output/source/main.c @@ -0,0 +1,140 @@ +/****************************************************************************** +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2018-05-08 1.0 Lux First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "gpio.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') + ******************************************************************************/ +static void App_LedInit(void); + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + ///< LED端口初始化 + App_LedInit(); + + while(1) + { + ///< LED点亮 + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); + delay1ms(1000); + + ///< LED关闭 + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); + delay1ms(1000); + } +} + + + +static void App_LedInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + ///< 打开GPIO外设时钟门控 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + ///< 端口方向配置->输出(其它参数与以上(输入)配置参数一致) + stcGpioCfg.enDir = GpioDirOut; + ///< 端口上下拉配置->下拉 + stcGpioCfg.enPu = GpioPuDisable; + stcGpioCfg.enPd = GpioPdEnable; + + ///< LED关闭 + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); + + ///< GPIO IO LED端口初始化 + Gpio_Init(STK_LED_PORT, STK_LED_PIN, &stcGpioCfg); + + +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/EWARM/i2c_bl24c08_int.ewp b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/EWARM/i2c_bl24c08_int.ewp new file mode 100644 index 0000000..a5ca69d --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/EWARM/i2c_bl24c08_int.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\i2c.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\reset.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/EWARM/i2c_bl24c08_int.eww b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/EWARM/i2c_bl24c08_int.eww new file mode 100644 index 0000000..eed9098 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/EWARM/i2c_bl24c08_int.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\i2c_bl24c08_int.ewp + + + + + diff --git a/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/MDK/i2c_bl24c08_int.uvprojx b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/MDK/i2c_bl24c08_int.uvprojx new file mode 100644 index 0000000..204900a --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/MDK/i2c_bl24c08_int.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + i2c_bl24c08_int_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + i2c_bl24c08_int + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + i2c_bl24c08_int.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +i2c.c +1..\..\..\..\driver\src\i2c.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +reset.c +1..\..\..\..\driver\src\reset.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/source/ddl_device.h b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/source/main.c b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/source/main.c new file mode 100644 index 0000000..863b588 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_int/source/main.c @@ -0,0 +1,255 @@ +/****************************************************************************** +* 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 "i2c.h" +#include "gpio.h" +//#include "reset.h" +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define I2C_SLAVEWT 0xA0 +#define I2C_SLAVERD 0xA1 +#define READLEN 10 +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/****************************************************************************** + * Local variable definitions ('static') * + ******************************************************************************/ +volatile uint8_t SendFlg = 0; +volatile uint8_t Comm_flg = 0; +volatile uint8_t u8SendLen = 0; +volatile uint8_t u8RecvLen = 0; +volatile uint8_t u8State = 0; +volatile uint8_t u8Addr = 0x00; //EEPROM地址字节 +volatile uint8_t u8Senddata[10] = {0x02,0x34,0x56,0x78,0x90,0x11,0x22,0x33,0x44,0x55}; +volatile uint8_t u8Recdata[10] = {0x00}; +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +void App_I2cCfg(void); +void App_PortCfg(void); +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + ///< IO端口配置 + App_PortCfg(); + + ///< I2C 模块配置 + App_I2cCfg(); + + ///< 向I2C总线发起开始信号 + I2C_SetFunc(M0P_I2C, I2cStart_En); + + while(1) + { + if(1 == Comm_flg) ///< 发送完,转接收信号 + { + Comm_flg = 0; ///< 启动主机接收模式 + delay1ms(100); + I2C_ClearFunc(M0P_I2C, I2cStop_En);///< 清除停止标志位 + I2C_SetFunc(M0P_I2C, I2cStart_En); ///< 重新启动I2C + } + } +} + +///< I2C 模块配置 +void App_I2cCfg(void) +{ + stc_i2c_cfg_t stcI2cCfg; + + DDL_ZERO_STRUCT(stcI2cCfg); ///< 初始化结构体变量的值为0 + + Sysctrl_SetPeripheralGate(SysctrlPeripheralI2c,TRUE); ///< 开启I2C0时钟门控 + + stcI2cCfg.u32Pclk = Sysctrl_GetPClkFreq(); ///< 获取PCLK时钟 + stcI2cCfg.u32Baud = 100000; ///< 100KHz + stcI2cCfg.enMode = I2cMasterMode; ///< 主机模式 + stcI2cCfg.u8SlaveAddr = 0x55; ///< 从地址,主模式无效 + stcI2cCfg.bGc = FALSE; ///< 广播地址应答使能关闭 + I2C_Init(M0P_I2C,&stcI2cCfg); ///< 模块初始化 + + EnableNvic(I2C_IRQn, IrqLevel3, TRUE); ///< 系统中断使能 +} + +///< IO端口配置 +void App_PortCfg(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + DDL_ZERO_STRUCT(stcGpioCfg); ///< 初始化结构体变量的值为0 + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); ///< 开启GPIO时钟门控 + + stcGpioCfg.enDir = GpioDirOut; ///< 端口方向配置->输入 + stcGpioCfg.enOD = GpioOdEnable; ///< 端口开漏输出配置->开漏输出使能 + stcGpioCfg.enPu = GpioPuEnable; ///< 端口上拉配置->使能 + stcGpioCfg.enPd = GpioPdDisable; ///< 端口下拉配置->禁止 + + Gpio_Init(EVB_I2C_EEPROM_SCL_PORT, EVB_I2C_EEPROM_SCL_PIN, &stcGpioCfg); + Gpio_Init(EVB_I2C_EEPROM_SDA_PORT, EVB_I2C_EEPROM_SDA_PIN, &stcGpioCfg); + + Gpio_SetAfMode(EVB_I2C_EEPROM_SCL_PORT, EVB_I2C_EEPROM_SCL_PIN, GpioAf6); ///< 配置SCL + Gpio_SetAfMode(EVB_I2C_EEPROM_SDA_PORT, EVB_I2C_EEPROM_SDA_PIN, GpioAf6); ///< 配置SDA +} + +///< I2c中断函数 +void I2c_IRQHandler(void) +{ + u8State = I2C_GetState(M0P_I2C); + + switch(u8State) + { + case 0x08: //已发送起始条件,将发送SLA+W + I2C_ClearFunc(M0P_I2C, I2cStart_En); + I2C_ClearFunc(M0P_I2C, I2cStop_En); + I2C_WriteByte(M0P_I2C, I2C_SLAVEWT); //写命令 + break; + case 0x10: //已发送重复起始条件 + I2C_ClearFunc(M0P_I2C, I2cStart_En); + I2C_ClearFunc(M0P_I2C, I2cStop_En); + if(0 == SendFlg) //判断当前发送SLA+W还是SLA+R + { + I2C_WriteByte(M0P_I2C, I2C_SLAVEWT);//写命令 + } + else + { + I2C_WriteByte(M0P_I2C, I2C_SLAVERD);//读命令 + } + break; + case 0x18: //已发送SLA+W,并接收到ACK + I2C_ClearFunc(M0P_I2C, I2cStart_En); + I2C_ClearFunc(M0P_I2C, I2cStop_En); + I2C_WriteByte(M0P_I2C, u8Addr); //EEPROM地址字节 + break; + case 0x20: //上一次发送SLA+W后,收到NACK + case 0x38: //上一次在SLA+读或写时丢失仲裁 + case 0x30: //已发送I2Cx_DATA中的数据,收到NACK + case 0x48: //发送SLA+R后,收到一个NACK + I2C_SetFunc(M0P_I2C,I2cStop_En); + I2C_SetFunc(M0P_I2C,I2cStart_En); + break; + case 0x58: //已接收到最后一个数据,NACK已返回 + u8Recdata[u8RecvLen++] = I2C_ReadByte(M0P_I2C);//读最后一字节数据返回NACK后,读取数据并发送停止条件 + I2C_ClearFunc(M0P_I2C, I2cStart_En); + I2C_SetFunc(M0P_I2C, I2cStop_En); //停止条件 + break; + case 0x28: //已发送数据,接收到ACK, 此处是已发送从机内存地址u8Addr并接收到ACK + if(SendFlg == 1) //读数据发送完地址字节后,重复起始条件 + { + I2C_SetFunc(M0P_I2C,I2cStart_En); + I2C_ClearFunc(M0P_I2C,I2cStop_En); + } + else + { + I2C_WriteByte(M0P_I2C, u8Senddata[u8SendLen++]); + if(10 < u8SendLen) + { + u8SendLen = 0; + Comm_flg = 1; + SendFlg = 1; + + I2C_ClearFunc(M0P_I2C,I2cStart_En); + I2C_SetFunc(M0P_I2C, I2cStop_En); //将发送停止条件 + } + } + break; + case 0x40: //已发送SLA+R,并接收到ACK + u8RecvLen = 0; + I2C_ClearFunc(M0P_I2C, I2cStart_En); + I2C_ClearFunc(M0P_I2C, I2cStop_En); + if(1 < READLEN) + { + I2C_SetFunc(M0P_I2C, I2cAck_En); //读取数据超过1个字节才发送ACK + } + break; + case 0x50: //已发送SLA+R,并接收到ACK + u8Recdata[u8RecvLen++] = I2C_ReadByte(M0P_I2C); //读取数据 + I2C_ClearFunc(M0P_I2C, I2cStart_En); + I2C_ClearFunc(M0P_I2C, I2cStop_En); + if(u8RecvLen == READLEN - 1) //准备接收最后一字节后返回NACK + { + I2C_ClearFunc(M0P_I2C, I2cAck_En); + } + break; + default: + break; + } + + I2C_ClearIrq(M0P_I2C); //清除中断状态标志位 +} + + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/EWARM/i2c_bl24c08_poll.ewp b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/EWARM/i2c_bl24c08_poll.ewp new file mode 100644 index 0000000..c917f94 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/EWARM/i2c_bl24c08_poll.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\i2c.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/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/EWARM/i2c_bl24c08_poll.eww b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/EWARM/i2c_bl24c08_poll.eww new file mode 100644 index 0000000..a2fd377 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/EWARM/i2c_bl24c08_poll.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\i2c_bl24c08_poll.ewp + + + + + diff --git a/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/MDK/i2c_bl24c08_poll.uvprojx b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/MDK/i2c_bl24c08_poll.uvprojx new file mode 100644 index 0000000..e863c4b --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/MDK/i2c_bl24c08_poll.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + i2c_bl24c08_poll_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + i2c_bl24c08_poll + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + i2c_bl24c08_poll.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +i2c.c +1..\..\..\..\driver\src\i2c.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/source/ddl_device.h b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/source/main.c b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/source/main.c new file mode 100644 index 0000000..d9699fd --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_bl24c08_poll/source/main.c @@ -0,0 +1,288 @@ +/****************************************************************************** +* 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 "i2c.h" +#include "gpio.h" +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define I2C_SLAVEADDR 0xA0 +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/****************************************************************************** + * Local variable definitions ('static') * + ******************************************************************************/ +static uint8_t u8Senddata[10] = {0x12,0x34,0x77,0x66,0x55,0x44,0x33,0x22,0xEE,0xDD}; +uint8_t u8Recdata[10]={0x00}; + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +en_result_t I2C_MasterWriteData(M0P_I2C_TypeDef* I2CX,uint8_t u8Addr,uint8_t *pu8Data,uint32_t u32Len); +en_result_t I2C_MasterReadData(M0P_I2C_TypeDef* I2CX,uint8_t u8Addr,uint8_t *pu8Data,uint32_t u32Len); +void App_I2cCfg(void); +void App_PortCfg(void); +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + ///< IO端口配置 + App_PortCfg(); + + ///< I2C 模块配置 + App_I2cCfg(); + + ///< 向I2C总线发起开始信号 + I2C_SetFunc(M0P_I2C,I2cStart_En); + + ///< eeprom写数据 + I2C_MasterWriteData(M0P_I2C,0x10,u8Senddata,10); + delay1ms(100); + + ///< eeprom读数据 + I2C_MasterReadData(M0P_I2C,0x10,u8Recdata,10); + + while(1) + { + ; + } +} + + +///< IO端口配置 +void App_PortCfg(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + DDL_ZERO_STRUCT(stcGpioCfg); ///< 初始化结构体变量的值为0 + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); ///< 开启GPIO时钟门控 + + stcGpioCfg.enDir = GpioDirOut; ///< 端口方向配置->输出 + stcGpioCfg.enOD = GpioOdEnable; ///< 端口开漏输出配置->开漏输出使能 + stcGpioCfg.enPu = GpioPuDisable; ///< 端口上拉配置->使能 + stcGpioCfg.enPd = GpioPdDisable; ///< 端口下拉配置->禁止 + + Gpio_Init(EVB_I2C_EEPROM_SCL_PORT, EVB_I2C_EEPROM_SCL_PIN,&stcGpioCfg); + Gpio_Init(EVB_I2C_EEPROM_SDA_PORT, EVB_I2C_EEPROM_SDA_PIN,&stcGpioCfg); ///< 初始化PA12 + + Gpio_SetAfMode(EVB_I2C_EEPROM_SCL_PORT, EVB_I2C_EEPROM_SCL_PIN,GpioAf6);///< 配置PA11为SCL + Gpio_SetAfMode(EVB_I2C_EEPROM_SDA_PORT, EVB_I2C_EEPROM_SDA_PIN,GpioAf6);///< 配置PA12为SDA +} + +///< I2C 模块配置 +void App_I2cCfg(void) +{ + stc_i2c_cfg_t stcI2cCfg; + + DDL_ZERO_STRUCT(stcI2cCfg); ///< 初始化结构体变量的值为0 + + Sysctrl_SetPeripheralGate(SysctrlPeripheralI2c,TRUE); ///< 开启I2C时钟门控 + + stcI2cCfg.u32Pclk = Sysctrl_GetPClkFreq(); ///< 获取PCLK时钟 + stcI2cCfg.u32Baud = 100000; ///< 波特率100kHz + stcI2cCfg.enMode = I2cMasterMode; ///< I2C主机模式 + stcI2cCfg.u8SlaveAddr = 0x55; ///< 从地址,主模式无效 + stcI2cCfg.bGc = FALSE; ///< 广播地址应答使能关闭,主模式无效 + I2C_Init(M0P_I2C, &stcI2cCfg); ///< 模块初始化 +} + +/** + ****************************************************************************** + ** \brief 主机接收函数 + ** + ** \param u8Addr从机内存地址,pu8Data读数据存放缓存,u32Len读数据长度 + ** + ** \retval 读数据是否成功 + ** + ******************************************************************************/ + en_result_t I2C_MasterReadData(M0P_I2C_TypeDef* I2CX,uint8_t u8Addr,uint8_t *pu8Data,uint32_t u32Len) +{ + en_result_t enRet = Error; + uint8_t u8i=0,u8State; + + I2C_SetFunc(I2CX,I2cStart_En); + + while(1) + { + while(0 == I2C_GetIrq(I2CX)) + {} + u8State = I2C_GetState(I2CX); + switch(u8State) + { + case 0x08: ///< 已发送起始条件,将发送SLA+W + I2C_ClearFunc(I2CX,I2cStart_En); + I2C_WriteByte(I2CX,I2C_SLAVEADDR); + break; + case 0x18: ///< 已发送SLA+W,并接收到ACK + I2C_WriteByte(I2CX,u8Addr); ///< 发送从机内存地址 + break; + case 0x28: ///< 已发送数据,接收到ACK, 此处是已发送从机内存地址u8Addr并接收到ACK + I2C_SetFunc(I2CX,I2cStart_En); ///< 发送重复起始条件 + break; + case 0x10: ///< 已发送重复起始条件 + I2C_ClearFunc(I2CX,I2cStart_En); + I2C_WriteByte(I2CX,I2C_SLAVEADDR|0x01);///< 发送SLA+R,开始从从机读取数据 + break; + case 0x40: ///< 已发送SLA+R,并接收到ACK + if(u32Len>1) + { + I2C_SetFunc(I2CX,I2cAck_En); ///< 使能主机应答功能 + } + break; + case 0x50: ///< 已接收数据字节,并已返回ACK信号 + pu8Data[u8i++] = I2C_ReadByte(I2CX); + if(u8i==u32Len-1) + { + I2C_ClearFunc(I2CX,I2cAck_En); ///< 已接收到倒数第二个字节,关闭ACK应答功能 + } + break; + case 0x58: ///< 已接收到最后一个数据,NACK已返回 + pu8Data[u8i++] = I2C_ReadByte(I2CX); + I2C_SetFunc(I2CX,I2cStop_En); ///< 发送停止条件 + break; + case 0x38: ///< 在发送地址或数据时,仲裁丢失 + I2C_SetFunc(I2CX,I2cStart_En); ///< 当总线空闲时发起起始条件 + break; + case 0x48: ///< 发送SLA+R后,收到一个NACK + I2C_SetFunc(I2CX,I2cStop_En); ///< 发送停止条件 + I2C_SetFunc(I2CX,I2cStart_En); ///< 发送起始条件 + break; + default: + I2C_SetFunc(I2CX,I2cStart_En); ///< 其他错误状态,重新发送起始条件 + break; + } + I2C_ClearIrq(I2CX); ///< 清除中断状态标志位 + if(u8i==u32Len) ///< 数据全部读取完成,跳出while循环 + { + break; + } + } + enRet = Ok; + return enRet; +} +/** + ****************************************************************************** + ** \brief 主机发送函数 + ** + ** \param u8Addr从机内存地址,pu8Data写数据,u32Len写数据长度 + ** + ** \retval 写数据是否成功 + ** + ******************************************************************************/ +en_result_t I2C_MasterWriteData(M0P_I2C_TypeDef* I2CX,uint8_t u8Addr,uint8_t *pu8Data,uint32_t u32Len) +{ + en_result_t enRet = Error; + uint8_t u8i=0,u8State; + I2C_SetFunc(I2CX,I2cStart_En); + while(1) + { + while(0 == I2C_GetIrq(I2CX)) + {;} + u8State = I2C_GetState(I2CX); + switch(u8State) + { + case 0x08: ///< 已发送起始条件 + I2C_ClearFunc(I2CX,I2cStart_En); + I2C_WriteByte(I2CX,I2C_SLAVEADDR); ///< 从设备地址发送 + break; + case 0x18: ///< 已发送SLA+W,并接收到ACK + I2C_WriteByte(I2CX,u8Addr); ///< 从设备内存地址发送 + break; + case 0x28: ///< 上一次发送数据后接收到ACK + I2C_WriteByte(I2CX,pu8Data[u8i++]); ///< 继续发送数据 + break; + case 0x20: ///< 上一次发送SLA+W后,收到NACK + case 0x38: ///< 上一次在SLA+读或写时丢失仲裁 + I2C_SetFunc(I2CX,I2cStart_En); ///< 当I2C总线空闲时发送起始条件 + break; + case 0x30: ///< 已发送I2Cx_DATA中的数据,收到NACK,将传输一个STOP条件 + I2C_SetFunc(I2CX,I2cStop_En); ///< 发送停止条件 + break; + default: + break; + } + if(u8i>u32Len) + { + I2C_SetFunc(I2CX,I2cStop_En); ///< 此顺序不能调换,出停止条件 + I2C_ClearIrq(I2CX); + break; + } + I2C_ClearIrq(I2CX); ///< 清除中断状态标志位 + } + enRet = Ok; + return enRet; +} +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/EWARM/i2c_mcu_master_int.ewp b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/EWARM/i2c_mcu_master_int.ewp new file mode 100644 index 0000000..e7c26b7 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/EWARM/i2c_mcu_master_int.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\i2c.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/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/EWARM/i2c_mcu_master_int.eww b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/EWARM/i2c_mcu_master_int.eww new file mode 100644 index 0000000..2b4a4cb --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/EWARM/i2c_mcu_master_int.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\i2c_mcu_master_int.ewp + + + + + diff --git a/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/MDK/i2c_mcu_master_int.uvprojx b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/MDK/i2c_mcu_master_int.uvprojx new file mode 100644 index 0000000..6aaa42f --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/MDK/i2c_mcu_master_int.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + i2c_mcu_master_int_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + i2c_mcu_master_int + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + i2c_mcu_master_int.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +i2c.c +1..\..\..\..\driver\src\i2c.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/source/ddl_device.h b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/source/main.c b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/source/main.c new file mode 100644 index 0000000..a722d17 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_master_int/source/main.c @@ -0,0 +1,295 @@ +/****************************************************************************** +* 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 "i2c.h" +#include "gpio.h" +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define I2C_DEVADDR 0x50 + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/****************************************************************************** + * Local variable definitions ('static') * + ******************************************************************************/ +uint8_t u8Senddata[10] = {0x12,0x34,0x77,0x66,0x55,0x44,0x33,0x22,0x11,0x99}; +uint8_t u8Recdata[10]={0x00}; + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +en_result_t I2C_MasterWriteData(M0P_I2C_TypeDef* I2CX,uint8_t *pu8Data,uint32_t u32Len);//主发送函数 +en_result_t I2C_MasterReadData(M0P_I2C_TypeDef* I2CX,uint8_t *pu8Data,uint32_t u32Len); //主接收函数 +void App_ClkCfg(void); +void App_PortCfg(void); +void App_I2cCfg(void); +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + ///< 时钟配置,配置时钟24mHz + App_ClkCfg(); + + ///< IO端口配置 + App_PortCfg(); + + ///< I2C 模块配置 + App_I2cCfg(); + + ///< 启动I2C数据传输 + I2C_SetFunc(M0P_I2C,I2cStart_En); //开始信号 + I2C_MasterWriteData(M0P_I2C,u8Senddata,10);//主机发送10字节数据 + delay1ms(10); + I2C_MasterReadData(M0P_I2C,u8Recdata,10); //主机读取10字节数据 + while(1) + { + } +} + +///< 时钟配置,配置时钟24mHz +void App_ClkCfg(void) +{ + Sysctrl_ClkSourceEnable(SysctrlClkRCL,TRUE); + Sysctrl_SysClkSwitch(SysctrlClkRCL); + Sysctrl_SetRCHTrim(SysctrlRchFreq24MHz); //配置为外部24MHz时钟 + Sysctrl_SysClkSwitch(SysctrlClkRCH); + Sysctrl_ClkSourceEnable(SysctrlClkRCL,FALSE); +} + +///< IO端口配置 +void App_PortCfg(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + DDL_ZERO_STRUCT(stcGpioCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); //开启GPIO时钟门控 + + stcGpioCfg.enDir = GpioDirOut; ///< 端口方向配置->输出 + stcGpioCfg.enOD = GpioOdEnable; ///< 开漏输出 + stcGpioCfg.enPu = GpioPuEnable; ///< 端口上拉配置->使能 + stcGpioCfg.enPd = GpioPdDisable; ///< 端口下拉配置->禁止 + + Gpio_Init(EVB_I2C_EEPROM_SCL_PORT,EVB_I2C_EEPROM_SCL_PIN,&stcGpioCfg); ///< 端口初始化 + Gpio_Init(EVB_I2C_EEPROM_SDA_PORT,EVB_I2C_EEPROM_SDA_PIN,&stcGpioCfg); + + Gpio_SetAfMode(EVB_I2C_EEPROM_SCL_PORT,EVB_I2C_EEPROM_SCL_PIN,GpioAf6); ///< 配置SCL + Gpio_SetAfMode(EVB_I2C_EEPROM_SDA_PORT,EVB_I2C_EEPROM_SDA_PIN,GpioAf6); ///< 配置SDA +} + +///< I2C 模块配置 +void App_I2cCfg(void) +{ + stc_i2c_cfg_t stcI2cCfg; + + DDL_ZERO_STRUCT(stcI2cCfg); ///< 初始化结构体变量的值为0 + + Sysctrl_SetPeripheralGate(SysctrlPeripheralI2c,TRUE); ///< 开启I2C0时钟门控 + + stcI2cCfg.u32Pclk = Sysctrl_GetPClkFreq(); ///< 获取PCLK时钟 + stcI2cCfg.u32Baud = 1000000; ///< 1MHz + stcI2cCfg.enMode = I2cMasterMode; ///< 主机模式 + stcI2cCfg.u8SlaveAddr = 0x55; ///< 从地址,主模式无效 + stcI2cCfg.bGc = FALSE; ///< 广播地址应答使能关闭 + I2C_Init(M0P_I2C,&stcI2cCfg); ///< 模块初始化 +} + +/** + ****************************************************************************** + ** \brief 主机接收函数 + ** + ** \param u8Addr从机内存地址,pu8Data读数据存放缓存,u32Len读数据长度 + ** + ** \retval 读数据是否成功 + ** + ******************************************************************************/ +en_result_t I2C_MasterReadData(M0P_I2C_TypeDef* I2CX,uint8_t *pu8Data,uint32_t u32Len) +{ + en_result_t enRet = Error; + uint8_t u8i=0,u8State; + + I2C_SetFunc(I2CX,I2cStart_En); + + while(1) + { + while(0 == I2C_GetIrq(I2CX)) + {;} + u8State = I2C_GetState(I2CX); + switch(u8State) + { + case 0x08: //已发送起始条件,将发送SLA+R + I2C_ClearFunc(I2CX,I2cStart_En); + I2C_WriteByte(I2CX,(I2C_DEVADDR<<1)|0x01);//发送SLA+W + break; + case 0x18: //已发送SLA+W,并接收到ACK + I2C_WriteByte(I2CX,0); //发送内存地址 + break; + case 0x28: //已发送数据,接收到ACK + I2C_SetFunc(I2CX,I2cStart_En); + break; + case 0x10: //已发送重复起始条件 + I2C_ClearFunc(I2CX,I2cStart_En); + I2C_WriteByte(I2CX,(I2C_DEVADDR<<1)|0x01);//读命令发送 + break; + case 0x40: //已发送SLA+R,并接收到ACK + if(u32Len>1) + { + I2C_SetFunc(I2CX,I2cAck_En); + } + break; + case 0x50: //已接收数据字节,并已返回ACK信号 + pu8Data[u8i++] = I2C_ReadByte(I2CX); + if(u8i==u32Len-1) + { + I2C_ClearFunc(I2CX,I2cAck_En); //读数据时,倒数第二个字节ACK关闭 + } + break; + case 0x58: //已接收到最后一个数据,NACK已返回 + pu8Data[u8i++] = I2C_ReadByte(I2CX); + I2C_SetFunc(I2CX,I2cStop_En); //发送停止条件 + break; + case 0x38: //在发送地址或数据时,仲裁丢失 + I2C_SetFunc(I2CX,I2cStart_En); //当总线空闲时发起起始条件 + break; + case 0x48: //发送SLA+R后,收到一个NACK + I2C_SetFunc(I2CX,I2cStop_En); + I2C_SetFunc(I2CX,I2cStart_En); + break; + default: //其他错误状态,重新发送起始条件 + I2C_SetFunc(I2CX,I2cStart_En); //其他错误状态,重新发送起始条件 + break; + } + I2C_ClearIrq(I2CX); //清除中断状态标志位 + if(u8i==u32Len) //数据全部读取完成,跳出while循环 + { + break; + } + } + enRet = Ok; + return enRet; +} +/** + ****************************************************************************** + ** \brief 主机发送函数 + ** + ** \param u8Addr从机内存地址,pu8Data写数据,u32Len写数据长度 + ** + ** \retval 写数据是否成功 + ** + ******************************************************************************/ +en_result_t I2C_MasterWriteData(M0P_I2C_TypeDef* I2CX,uint8_t *pu8Data,uint32_t u32Len) +{ + en_result_t enRet = Error; + uint8_t u8i=0,u8State; + I2C_SetFunc(I2CX,I2cStart_En); + while(1) + { + while(0 == I2C_GetIrq(I2CX)) + {;} + u8State = I2C_GetState(I2CX); + switch(u8State) + { + case 0x08: ///已发送起始条件 + I2C_ClearFunc(I2CX,I2cStart_En); + I2C_WriteByte(I2CX,(I2C_DEVADDR<<1)); ///从设备地址发送 + break; + case 0x18: ///已发送SLA+W,并接收到ACK + case 0x28: ///上一次发送数据后接收到ACK + I2C_WriteByte(I2CX,pu8Data[u8i++]); + break; + case 0x20: ///上一次发送SLA+W后,收到NACK + case 0x38: ///上一次在SLA+读或写时丢失仲裁 + I2C_SetFunc(I2CX,I2cStart_En); ///当I2C总线空闲时发送起始条件 + break; + case 0x30: ///已发送I2Cx_DATA中的数据,收到NACK,将传输一个STOP条件 + I2C_SetFunc(I2CX,I2cStop_En); ///发送停止条件 + break; + default: + break; + } + if(u8i>u32Len) + { + I2C_SetFunc(I2CX,I2cStop_En); ///此顺序不能调换,出停止条件 + I2C_ClearIrq(I2CX); + break; + } + I2C_ClearIrq(I2CX); ///清除中断状态标志位 + } + enRet = Ok; + return enRet; +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/EWARM/i2c_mcu_slave_int.ewp b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/EWARM/i2c_mcu_slave_int.ewp new file mode 100644 index 0000000..e4de091 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/EWARM/i2c_mcu_slave_int.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\i2c.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/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/EWARM/i2c_mcu_slave_int.eww b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/EWARM/i2c_mcu_slave_int.eww new file mode 100644 index 0000000..dfd6fec --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/EWARM/i2c_mcu_slave_int.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\i2c_mcu_slave_int.ewp + + + + + diff --git a/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/MDK/i2c_mcu_slave_int.uvprojx b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/MDK/i2c_mcu_slave_int.uvprojx new file mode 100644 index 0000000..47d61fd --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/MDK/i2c_mcu_slave_int.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + i2c_mcu_slave_int_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + i2c_mcu_slave_int + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + i2c_mcu_slave_int.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +i2c.c +1..\..\..\..\driver\src\i2c.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/source/ddl_device.h b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/source/main.c b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/source/main.c new file mode 100644 index 0000000..d6761f8 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_int/source/main.c @@ -0,0 +1,207 @@ +/****************************************************************************** +* 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 "i2c.h" +#include "gpio.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') * + ******************************************************************************/ +uint8_t u8Recdata[10]={0x00}; +uint8_t u8SendLen=0; +uint8_t u8RecvLen=0; +uint8_t u8State = 0; +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +void App_ClkCfg(void); +void App_PortCfg(void); +void App_I2cCfg(void); +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + ///< 时钟配置,配置时钟24mHz + App_ClkCfg(); + + ///< IO端口配置 + App_PortCfg(); + + ///< I2C 模块配置 + App_I2cCfg(); + + ///< 启动I2c数据传输 + I2C_SetFunc(M0P_I2C,I2cAck_En); ///< ACK打开 + + while(1) + { + ; + } +} + +///< 时钟配置,配置时钟24mHz +void App_ClkCfg(void) +{ + Sysctrl_ClkSourceEnable(SysctrlClkRCL,TRUE); + Sysctrl_SysClkSwitch(SysctrlClkRCL); + Sysctrl_SetRCHTrim(SysctrlRchFreq24MHz); ///< 配置为外部24MHz时钟 + Sysctrl_SysClkSwitch(SysctrlClkRCH); + Sysctrl_ClkSourceEnable(SysctrlClkRCL,FALSE); +} + +///< IO端口配置 +void App_PortCfg(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + DDL_ZERO_STRUCT(stcGpioCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); ///< 开启GPIO时钟门控 + + stcGpioCfg.enDir = GpioDirOut; ///< 端口方向配置->输出 + stcGpioCfg.enOD = GpioOdEnable; ///< 端口开漏输出配置->开漏输出使能 + stcGpioCfg.enPu = GpioPuEnable; ///< 端口上拉配置->使能 + stcGpioCfg.enPd = GpioPdDisable; ///< 端口下拉配置->禁止 + + Gpio_Init(EVB_I2C_EEPROM_SCL_PORT, EVB_I2C_EEPROM_SCL_PIN,&stcGpioCfg); ///< 端口初始化 + Gpio_Init(EVB_I2C_EEPROM_SDA_PORT, EVB_I2C_EEPROM_SDA_PIN,&stcGpioCfg); + + Gpio_SetAfMode(EVB_I2C_EEPROM_SCL_PORT, EVB_I2C_EEPROM_SCL_PIN,GpioAf6); ///< 配置为SCL + Gpio_SetAfMode(EVB_I2C_EEPROM_SDA_PORT, EVB_I2C_EEPROM_SDA_PIN,GpioAf6); ///< 配置为SDA +} + +///< I2C 模块配置 +void App_I2cCfg(void) +{ + stc_i2c_cfg_t stcI2cCfg; + + DDL_ZERO_STRUCT(stcI2cCfg); + Sysctrl_SetPeripheralGate(SysctrlPeripheralI2c,TRUE); ///< 开启I2C0时钟门控 + + EnableNvic(I2C_IRQn,IrqLevel3,TRUE); ///< 使能NVIC对应中断位 + + stcI2cCfg.enMode = I2cSlaveMode; ///< I2C从机模式 + stcI2cCfg.u8SlaveAddr = 0x50; ///< 从地址,主模式无效 + stcI2cCfg.bGc = FALSE; ///< 广播地址应答使能关闭,主模式无效 + I2C_Init(M0P_I2C, &stcI2cCfg); ///< 模块初始化 + I2C_SetFunc(M0P_I2C,I2cHlm_En); ///< 使能I2C0高速通讯功能(高于100KHz必须使能) + +} + +///< I2c中断函数 +void I2c_IRQHandler(void) +{ + u8State = I2C_GetState(M0P_I2C); + switch(u8State) + { + case 0x60: //已接收到(与自身匹配的)SLA+W;已接收ACK + case 0x70: //已接收通用调用地址(0x00);已接收ACK + case 0xa0: //接收到停止条件或重复起始条件 + u8RecvLen = 0; + I2C_SetFunc(M0P_I2C,I2cAck_En); + break; + case 0x68: //主控时在SLA+读写丢失仲裁;已接收自身的SLA+W;已返回ACK + case 0x78: //主控时在SLA+读写中丢失仲裁;已接收通用调用地址;已返回ACK + case 0x88: //前一次寻址使用自身从地址;已接收数据字节;已返回非ACK + I2C_SetFunc(M0P_I2C,I2cAck_En); + break; + case 0x80: //前一次寻址使用自身从地址;已接收数据字节;已返回ACK + case 0x98: //前一次寻址使用通用调用地址;已接收数据;已返回非ACK + case 0x90: //前一次寻址使用通用调用地址;已接收数据;已返回ACK + I2C_SetFunc(M0P_I2C,I2cAck_En); + u8Recdata[u8RecvLen++] = I2C_ReadByte(M0P_I2C);//接收数据 + break; + case 0xa8: //已接收自身的SLA+R;已返回ACK,将要发出数据并将收到ACK位 + case 0xb0: //当主控时在SLA+读写中丢失仲裁;已接收自身SLA+R;已返回ACK + u8SendLen = 0; + I2C_WriteByte(M0P_I2C,u8Recdata[u8SendLen++]); //发送数据首字节 + break; + case 0xc8: //装入的数据字节已被发送;已接收ACK + case 0xb8: //已发送数据;已接收ACK + I2C_WriteByte(M0P_I2C,u8Recdata[u8SendLen++]); + break; + case 0xc0: //发送数据,接收非ACK + break; + } + + I2C_ClearIrq(M0P_I2C); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/EWARM/i2c_mcu_slave_poll.ewp b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/EWARM/i2c_mcu_slave_poll.ewp new file mode 100644 index 0000000..b2ee3bb --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/EWARM/i2c_mcu_slave_poll.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\i2c.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/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/EWARM/i2c_mcu_slave_poll.eww b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/EWARM/i2c_mcu_slave_poll.eww new file mode 100644 index 0000000..98f98a3 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/EWARM/i2c_mcu_slave_poll.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\i2c_mcu_slave_poll.ewp + + + + + diff --git a/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/MDK/i2c_mcu_slave_poll.uvprojx b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/MDK/i2c_mcu_slave_poll.uvprojx new file mode 100644 index 0000000..d4ac342 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/MDK/i2c_mcu_slave_poll.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + i2c_mcu_slave_poll_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + i2c_mcu_slave_poll + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + i2c_mcu_slave_poll.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +i2c.c +1..\..\..\..\driver\src\i2c.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/source/ddl_device.h b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/source/main.c b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/source/main.c new file mode 100644 index 0000000..4d13593 --- /dev/null +++ b/src/hc32f005_ddl/example/i2c/i2c_mcu_slave_poll/source/main.c @@ -0,0 +1,241 @@ +/****************************************************************************** +* 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 "i2c.h" +#include "gpio.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') * + ******************************************************************************/ +uint8_t u8Recdata[10]={0x00}; +uint32_t u32SendLen=0; +uint32_t u32RecvLen=0; +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +en_result_t I2C_SlaveWriteData(M0P_I2C_TypeDef* I2CX,uint8_t *pu8Data,uint32_t *u32Len); +en_result_t I2C_SlaveReadData(M0P_I2C_TypeDef* I2CX,uint8_t *pu8Data,uint32_t *pu32Len); +void App_ClkCfg(void); +void App_PortCfg(void); +void App_I2cCfg(void); +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ + +int32_t main(void) +{ + ///< 时钟配置,配置时钟24mHz + App_ClkCfg(); + + ///< IO端口配置 + App_PortCfg(); + + ///< I2C 模块配置 + App_I2cCfg(); + + ///< 启动I2C数据传输 + I2C_SetFunc(M0P_I2C,I2cAck_En); //ACK打开 + I2C_SlaveReadData(M0P_I2C,u8Recdata,&u32RecvLen); //等主机写数据 + I2C_SlaveWriteData(M0P_I2C,u8Recdata,&u32SendLen);//等主机读数据 + while(1) + { + ; + } +} + +///< 时钟配置,配置时钟24mHz +void App_ClkCfg(void) +{ + Sysctrl_ClkSourceEnable(SysctrlClkRCL,TRUE); + Sysctrl_SysClkSwitch(SysctrlClkRCL); + Sysctrl_SetRCHTrim(SysctrlRchFreq24MHz); ///< 配置为外部24MHz时钟 + Sysctrl_SysClkSwitch(SysctrlClkRCH); + Sysctrl_ClkSourceEnable(SysctrlClkRCL,FALSE); +} + +///< IO端口配置 +void App_PortCfg(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + DDL_ZERO_STRUCT(stcGpioCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); //开启GPIO时钟门控 + + stcGpioCfg.enDir = GpioDirOut; ///< 端口方向配置->输出 + stcGpioCfg.enOD = GpioOdEnable; ///< 端口开漏输出配置->开漏输出使能 + stcGpioCfg.enPu = GpioPuEnable; ///< 端口上拉配置->使能 + stcGpioCfg.enPd = GpioPdDisable; ///< 端口下拉配置->禁止 + + Gpio_Init(EVB_I2C_EEPROM_SCL_PORT, EVB_I2C_EEPROM_SCL_PIN,&stcGpioCfg); ///< 端口初始化 + Gpio_Init(EVB_I2C_EEPROM_SDA_PORT, EVB_I2C_EEPROM_SDA_PIN,&stcGpioCfg); + + Gpio_SetAfMode(EVB_I2C_EEPROM_SCL_PORT, EVB_I2C_EEPROM_SCL_PIN,GpioAf6); ///< 配置为SCL + Gpio_SetAfMode(EVB_I2C_EEPROM_SDA_PORT, EVB_I2C_EEPROM_SDA_PIN,GpioAf6); ///< 配置为SDA +} + +///< I2C 模块配置 +void App_I2cCfg(void) +{ + stc_i2c_cfg_t stcI2cCfg; + + DDL_ZERO_STRUCT(stcI2cCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralI2c,TRUE); ///< 开启I2C0时钟门控 + + stcI2cCfg.enMode = I2cSlaveMode; ///< I2C从机模式 + stcI2cCfg.u8SlaveAddr = 0x50; ///< 从地址,主模式无效 + stcI2cCfg.bGc = FALSE; ///< 广播地址应答使能关闭,主模式无效 + + I2C_Init(M0P_I2C, &stcI2cCfg); ///< 模块初始化 + I2C_SetFunc(M0P_I2C,I2cHlm_En); ///< 快速模式或高速模式(大于100kHz时)必须高速使能 + +} + +///< 等主机读数据 +en_result_t I2C_SlaveWriteData(M0P_I2C_TypeDef* I2CX,uint8_t *pu8Data,uint32_t *u32Len) +{ + uint8_t u8i=0,u8State; + while(1) + { + while(0 == I2C_GetIrq(I2CX)) + {;} + u8State = I2C_GetState(I2CX); + switch(u8State) + { + case 0xA8: //已接收自身的SLA+R;已返回ACK,将要发出数据并将收到ACK位 + case 0xB0: //当主控时在SLA+读写中丢失仲裁;已接收自身SLA+R;已返回ACK + I2C_WriteByte(I2CX,pu8Data[u8i++]); + break; + case 0xB8: //已发送数据;已接收ACK + case 0xC8: //装入的数据字节已被发送;已接收ACK + I2C_WriteByte(I2CX,pu8Data[u8i++]); + break; + case 0xC0: //发送数据,接收非ACK + break; + default: + return ErrorInvalidParameter; + } + I2C_ClearIrq(I2CX); + if(0xC0 == u8State) + { + return Ok; + } + } + } + +///< 等主机写数据 +en_result_t I2C_SlaveReadData(M0P_I2C_TypeDef* I2CX,uint8_t *pu8Data,uint32_t *pu32Len) +{ + uint8_t u8i=0,u8State; + while(1) + { + while(0 == I2C_GetIrq(I2CX)) + {;} + u8State = I2C_GetState(I2CX); + switch(u8State) + { + case 0x60: //已接收到(与自身匹配的)SLA+W;已接收ACK + case 0x68: //主控时在SLA+读写丢失仲裁;已接收自身的SLA+W;已返回ACK + case 0x70: //已接收通用调用地址(0x00);已接收ACK + case 0x78: //主控时在SLA+读写中丢失仲裁;已接收通用调用地址;已返回ACK + I2C_SetFunc(M0P_I2C,I2cAck_En); + break; + case 0x80: //前一次寻址使用自身从地址;已接收数据字节;已返回ACK + case 0x90: //前一次寻址使用通用调用地址;已接收数据;已返回ACK + case 0x88: //只读取一个字节情况: + case 0x98: //前一次寻址使用通用调用地址;已接收数据;已返回非ACK + pu8Data[u8i++] = I2C_ReadByte(I2CX); + break; + case 0xA0: //接收到停止条件 + *pu32Len = u8i; + break; + default: + return ErrorInvalidParameter; + } + + delay1ms(1); + I2C_ClearIrq(I2CX); + if(0xA0 == u8State) + { + return Ok; + } + } +} +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/EWARM/lvd_detect_falling_irq.ewp b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/EWARM/lvd_detect_falling_irq.ewp new file mode 100644 index 0000000..7225748 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/EWARM/lvd_detect_falling_irq.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lvd.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/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/EWARM/lvd_detect_falling_irq.eww b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/EWARM/lvd_detect_falling_irq.eww new file mode 100644 index 0000000..87b69fb --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/EWARM/lvd_detect_falling_irq.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\lvd_detect_falling_irq.ewp + + + + + diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/MDK/lvd_detect_falling_irq.uvprojx b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/MDK/lvd_detect_falling_irq.uvprojx new file mode 100644 index 0000000..8de493d --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/MDK/lvd_detect_falling_irq.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + lvd_detect_falling_irq_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + lvd_detect_falling_irq + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + lvd_detect_falling_irq.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +lvd.c +1..\..\..\..\driver\src\lvd.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/source/ddl_device.h b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/source/main.c b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/source/main.c new file mode 100644 index 0000000..fdb40c4 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_falling_irq/source/main.c @@ -0,0 +1,168 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2017-05-28 LiuHL First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "lvd.h" +#include "gpio.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') + ******************************************************************************/ +static void App_LvdPortInit(void); +static void App_LvdInit(void); + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int main(void) +{ + ///< LVD 端口初始化 + App_LvdPortInit(); + ///< LVD 初始化 + App_LvdInit(); + + while (1) + { + ; + } +} + + +///< LVD 中断服务函数 +void Lvd_IRQHandler(void) +{ + Lvd_ClearIrq(); + + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); //中断受触发设置限制,LVD输出不受限制 + delay1ms(1000); + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); //中断受触发设置限制,LVD输出不受限制 +} + +///< LVD相关端口初始化 +static void App_LvdPortInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + DDL_ZERO_STRUCT(stcGpioCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //开LVD时钟 + + stcGpioCfg.enDir = GpioDirOut; + Gpio_Init(STK_LED_PORT,STK_LED_PIN,&stcGpioCfg); + + ///< LVD OUT + Gpio_Init(GpioPort2,GpioPin5,&stcGpioCfg); + Gpio_SetAfMode(GpioPort2,GpioPin5,GpioAf4); + + ///< LVD INPUT SOURCE + Gpio_SetAnalogMode(GpioPort2, GpioPin3); +} + +static void App_LvdInit(void) +{ + stc_lvd_cfg_t stcLvdCfg; + + DDL_ZERO_STRUCT(stcLvdCfg); //变量清0 + + Sysctrl_SetPeripheralGate(SysctrlPeripheralVcLvd, TRUE); //开LVD时钟 + + stcLvdCfg.enAct = LvdActMskInt; ///< 配置触发产生中断 + stcLvdCfg.enInputSrc = LvdInputSrcMskP23; ///< 配置LVD输入源 + stcLvdCfg.enThreshold = LvdMskTH1_8V; ///< 配置LVD基准电压 + stcLvdCfg.enFilter = LvdFilterMskEnable; ///< 滤波使能 + stcLvdCfg.enFilterTime = LvdFilterMsk28_8ms; ///< 滤波时间设置 + stcLvdCfg.enIrqType = LvdIrqMskFall; ///< 中断触发类型 + Lvd_Init(&stcLvdCfg); + + ///< 中断开启 + Lvd_EnableIrq(); + Lvd_ClearIrq(); + EnableNvic(LVD_IRQn, IrqLevel3, TRUE); ///< NVIC 中断使能 + + ///< LVD 模块使能 + Lvd_Enable(); +} +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/EWARM/lvd_detect_high_irq.ewp b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/EWARM/lvd_detect_high_irq.ewp new file mode 100644 index 0000000..ceeaf43 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/EWARM/lvd_detect_high_irq.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lvd.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/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/EWARM/lvd_detect_high_irq.eww b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/EWARM/lvd_detect_high_irq.eww new file mode 100644 index 0000000..49256e0 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/EWARM/lvd_detect_high_irq.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\lvd_detect_high_irq.ewp + + + + + diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/MDK/lvd_detect_high_irq.uvprojx b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/MDK/lvd_detect_high_irq.uvprojx new file mode 100644 index 0000000..e4ed252 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/MDK/lvd_detect_high_irq.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + lvd_detect_high_irq_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + lvd_detect_high_irq + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + lvd_detect_high_irq.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +lvd.c +1..\..\..\..\driver\src\lvd.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/source/ddl_device.h b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/source/main.c b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/source/main.c new file mode 100644 index 0000000..9f3b202 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_high_irq/source/main.c @@ -0,0 +1,168 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2017-05-28 LiuHL First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "lvd.h" +#include "gpio.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') + ******************************************************************************/ +static void App_LvdPortInit(void); +static void App_LvdInit(void); + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int main(void) +{ + ///< LVD 端口初始化 + App_LvdPortInit(); + ///< LVD 初始化 + App_LvdInit(); + + while (1) + { + ; + } +} + + +///< LVD 中断服务函数 +void Lvd_IRQHandler(void) +{ + Lvd_ClearIrq(); + + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); //中断受触发设置限制,LVD输出不受限制 + delay1ms(1000); + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); //中断受触发设置限制,LVD输出不受限制 + delay1ms(1000); +} + +///< LVD相关端口初始化 +static void App_LvdPortInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + DDL_ZERO_STRUCT(stcGpioCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //开LVD时钟 + + stcGpioCfg.enDir = GpioDirOut; + Gpio_Init(STK_LED_PORT,STK_LED_PIN,&stcGpioCfg); + + ///< LVD OUT + Gpio_Init(GpioPort2,GpioPin5,&stcGpioCfg); + Gpio_SetAfMode(GpioPort2,GpioPin5,GpioAf4); + +} + +static void App_LvdInit(void) +{ + stc_lvd_cfg_t stcLvdCfg; + + DDL_ZERO_STRUCT(stcLvdCfg); //变量清0 + + Sysctrl_SetPeripheralGate(SysctrlPeripheralVcLvd, TRUE); //开LVD时钟 + + stcLvdCfg.enAct = LvdActMskInt; ///< 配置触发产生中断 + stcLvdCfg.enInputSrc = LvdInputSrcMskVCC; ///< 配置LVD输入源 + stcLvdCfg.enThreshold = LvdMskTH2_5V; ///< 配置LVD基准电压 + stcLvdCfg.enFilter = LvdFilterMskEnable; ///< 滤波使能 + stcLvdCfg.enFilterTime = LvdFilterMsk28_8ms; ///< 滤波时间设置 + stcLvdCfg.enIrqType = LvdIrqMskHigh; ///< 中断触发类型 + Lvd_Init(&stcLvdCfg); + + ///< 中断开启 + Lvd_EnableIrq(); + Lvd_ClearIrq(); + EnableNvic(LVD_IRQn, IrqLevel3, TRUE); ///< NVIC 中断使能 + + ///< LVD 模块使能 + Lvd_Enable(); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_reset/EWARM/lvd_detect_reset.ewp b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/EWARM/lvd_detect_reset.ewp new file mode 100644 index 0000000..8d8d944 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/EWARM/lvd_detect_reset.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lvd.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\reset.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_reset/EWARM/lvd_detect_reset.eww b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/EWARM/lvd_detect_reset.eww new file mode 100644 index 0000000..41bb978 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/EWARM/lvd_detect_reset.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\lvd_detect_reset.ewp + + + + + diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_reset/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_reset/MDK/lvd_detect_reset.uvprojx b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/MDK/lvd_detect_reset.uvprojx new file mode 100644 index 0000000..69ed0dc --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/MDK/lvd_detect_reset.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + lvd_detect_reset_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + lvd_detect_reset + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + lvd_detect_reset.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +lvd.c +1..\..\..\..\driver\src\lvd.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +reset.c +1..\..\..\..\driver\src\reset.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_reset/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/lvd/lvd_detect_reset/source/ddl_device.h b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/lvd/lvd_detect_reset/source/main.c b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/source/main.c new file mode 100644 index 0000000..a7bcc24 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_reset/source/main.c @@ -0,0 +1,176 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2017-05-28 LiuHL First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "lvd.h" +#include "gpio.h" +#include "reset.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') + ******************************************************************************/ +static void App_LvdPortInit(void); +static void App_LvdInit(void); + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int main(void) +{ + stc_lvd_cfg_t stcLvdCfg; + + DDL_ZERO_STRUCT(stcLvdCfg); //变量清0 + + ///< 首次上电FLAG清零 + if(TRUE == Reset_GetFlag(ResetFlagMskPor5V)) + { + Reset_ClearFlagAll(); + } + + ///< LVD 端口初始化 + App_LvdPortInit(); + + ///< 低电压复位检测 + if(TRUE == Reset_GetFlag(ResetFlagMskLvd)) + { + Lvd_ClearIrq(); + + Reset_ClearFlag(ResetFlagMskLvd); + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); + delay1ms(1000); + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); + delay1ms(1000); + } + + ///< LVD 初始化 + App_LvdInit(); + + while (1) + { + ; + } +} + + +///< LVD相关端口初始化 +static void App_LvdPortInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + DDL_ZERO_STRUCT(stcGpioCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //开LVD时钟 + + stcGpioCfg.enDir = GpioDirOut; + Gpio_Init(STK_LED_PORT,STK_LED_PIN,&stcGpioCfg); + + ///< LVD OUT + Gpio_Init(GpioPort2,GpioPin5,&stcGpioCfg); + Gpio_SetAfMode(GpioPort2,GpioPin5,GpioAf4); + + ///< LVD INPUT SOURCE + Gpio_SetAnalogMode(GpioPort2, GpioPin3); +} + +static void App_LvdInit(void) +{ + stc_lvd_cfg_t stcLvdCfg; + + DDL_ZERO_STRUCT(stcLvdCfg); //变量清0 + + Sysctrl_SetPeripheralGate(SysctrlPeripheralVcLvd, TRUE); //开LVD时钟 + + stcLvdCfg.enAct = LvdActMskReset; ///< 配置触发产生复位 + stcLvdCfg.enInputSrc = LvdInputSrcMskP23; ///< 配置LVD输入源 + stcLvdCfg.enThreshold = LvdMskTH1_8V; ///< 配置LVD基准电压 + stcLvdCfg.enFilter = LvdFilterMskEnable; ///< 滤波使能 + stcLvdCfg.enFilterTime = LvdFilterMsk28_8ms; ///< 滤波时间设置 + stcLvdCfg.enIrqType = LvdIrqMskHigh; ///< 复位触发类型 + Lvd_Init(&stcLvdCfg); + + ///< LVD 模块使能 + Lvd_Enable(); +} +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/EWARM/lvd_detect_rising_irq.ewp b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/EWARM/lvd_detect_rising_irq.ewp new file mode 100644 index 0000000..fedea63 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/EWARM/lvd_detect_rising_irq.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lvd.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/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/EWARM/lvd_detect_rising_irq.eww b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/EWARM/lvd_detect_rising_irq.eww new file mode 100644 index 0000000..3130fb4 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/EWARM/lvd_detect_rising_irq.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\lvd_detect_rising_irq.ewp + + + + + diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/MDK/lvd_detect_rising_irq.uvprojx b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/MDK/lvd_detect_rising_irq.uvprojx new file mode 100644 index 0000000..e44ee0b --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/MDK/lvd_detect_rising_irq.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + lvd_detect_rising_irq_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + lvd_detect_rising_irq + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + lvd_detect_rising_irq.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +lvd.c +1..\..\..\..\driver\src\lvd.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/source/ddl_device.h b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/source/main.c b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/source/main.c new file mode 100644 index 0000000..faf4841 --- /dev/null +++ b/src/hc32f005_ddl/example/lvd/lvd_detect_rising_irq/source/main.c @@ -0,0 +1,170 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2017-05-28 LiuHL First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "lvd.h" +#include "gpio.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') + ******************************************************************************/ +static void App_LvdPortInit(void); +static void App_LvdInit(void); + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int main(void) +{ + ///< LVD 端口初始化 + App_LvdPortInit(); + ///< LVD 初始化 + App_LvdInit(); + + while (1) + { + ; + } +} + +///< LVD 中断服务函数 +void Lvd_IRQHandler(void) +{ + Lvd_ClearIrq(); + + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); //中断受触发设置限制,LVD输出不受限制 + delay1ms(1000); + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); //中断受触发设置限制,LVD输出不受限制 +} + +///< LVD相关端口初始化 +static void App_LvdPortInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + DDL_ZERO_STRUCT(stcGpioCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //开LVD时钟 + + stcGpioCfg.enDir = GpioDirOut; + Gpio_Init(STK_LED_PORT,STK_LED_PIN,&stcGpioCfg); + + ///< LVD OUT + Gpio_Init(GpioPort2,GpioPin5,&stcGpioCfg); + Gpio_SetAfMode(GpioPort2,GpioPin5,GpioAf4); + + ///< LVD INPUT SOURCE + Gpio_SetAnalogMode(GpioPort2, GpioPin3); +} + + +static void App_LvdInit(void) +{ + stc_lvd_cfg_t stcLvdCfg; + + DDL_ZERO_STRUCT(stcLvdCfg); //变量清0 + + Sysctrl_SetPeripheralGate(SysctrlPeripheralVcLvd, TRUE); //开LVD时钟 + + stcLvdCfg.enAct = LvdActMskInt; ///< 配置触发产生中断 + stcLvdCfg.enInputSrc = LvdInputSrcMskP23; ///< 配置LVD输入源 + stcLvdCfg.enThreshold = LvdMskTH1_8V; ///< 配置LVD基准电压 + stcLvdCfg.enFilter = LvdFilterMskEnable; ///< 滤波使能 + stcLvdCfg.enFilterTime = LvdFilterMsk28_8ms; ///< 滤波时间设置 + stcLvdCfg.enIrqType = LvdIrqMskRise; ///< 中断触发类型 + Lvd_Init(&stcLvdCfg); + + ///< 中断开启 + Lvd_EnableIrq(); + Lvd_ClearIrq(); + EnableNvic(LVD_IRQn, IrqLevel3, TRUE); ///< NVIC 中断使能 + + ///< LVD 模块使能 + Lvd_Enable(); +} + + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/pca/pca_16bit_pwm/EWARM/pca_16bit_pwm.ewp b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/EWARM/pca_16bit_pwm.ewp new file mode 100644 index 0000000..a2ab2f8 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/EWARM/pca_16bit_pwm.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\pca.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lpm.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/src/hc32f005_ddl/example/pca/pca_16bit_pwm/EWARM/pca_16bit_pwm.eww b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/EWARM/pca_16bit_pwm.eww new file mode 100644 index 0000000..379faa9 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/EWARM/pca_16bit_pwm.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\pca_16bit_pwm.ewp + + + + + diff --git a/src/hc32f005_ddl/example/pca/pca_16bit_pwm/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/pca/pca_16bit_pwm/MDK/pca_16bit_pwm.uvprojx b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/MDK/pca_16bit_pwm.uvprojx new file mode 100644 index 0000000..b6f8f2e --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/MDK/pca_16bit_pwm.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + pca_16bit_pwm_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + pca_16bit_pwm + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + pca_16bit_pwm.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +pca.c +1..\..\..\..\driver\src\pca.c + +lpm.c +1..\..\..\..\driver\src\lpm.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/pca/pca_16bit_pwm/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/pca/pca_16bit_pwm/source/ddl_device.h b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/pca/pca_16bit_pwm/source/main.c b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/source/main.c new file mode 100644 index 0000000..3819173 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_16bit_pwm/source/main.c @@ -0,0 +1,164 @@ +/****************************************************************************** +* 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 "pca.h" +#include "lpm.h" +#include "gpio.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 function prototypes ('static') + ******************************************************************************/ +static void App_GpioInit(void); +static void App_PcaInit(void); + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + + +/** +****************************************************************************** + ** \brief 主函数 + ** + ** @param 无 + ** \retval 无 + ** +******************************************************************************/ +int32_t main(void) +{ + ///< 端口初始化 + App_GpioInit(); + ///< PCA初始化 + App_PcaInit(); + + ///< PCA 运行 + Pca_StartPca(TRUE); + + while (1) + { + ; + } +} + + +/** + ****************************************************************************** + ** \brief 初始化外部GPIO引脚 + ** + ** \return 无 + ******************************************************************************/ +static void App_GpioInit(void) +{ + stc_gpio_cfg_t GpioInitStruct; + DDL_ZERO_STRUCT(GpioInitStruct); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + //P34 + GpioInitStruct.enDrv = GpioDrvH; + GpioInitStruct.enDir = GpioDirOut; + Gpio_Init(GpioPort3, GpioPin4, &GpioInitStruct); + Gpio_SetAfMode(GpioPort3, GpioPin4, GpioAf1); +} + +/** + ****************************************************************************** + ** \brief 配置PCA + ** + ** \return 无 + ******************************************************************************/ +static void App_PcaInit(void) +{ + stc_pcacfg_t PcaInitStruct; + + Sysctrl_SetPeripheralGate(SysctrlPeripheralPca, TRUE); + + PcaInitStruct.pca_clksrc = PcaPclkdiv32; + PcaInitStruct.pca_cidl = FALSE; + PcaInitStruct.pca_ecom = PcaEcomEnable; //允许比较器功能 + PcaInitStruct.pca_capp = PcaCappDisable; //禁止上升沿捕获 + PcaInitStruct.pca_capn = PcaCapnDisable; //禁止下降沿捕获 + PcaInitStruct.pca_mat = PcaMatEnable; //禁止匹配功能 + PcaInitStruct.pca_tog = PcaTogEnable; //禁止翻转控制功能 + PcaInitStruct.pca_pwm = PcaPwm8bitDisable; //使能PWM控制输出 + + PcaInitStruct.pca_ccap = 500; + + + Pca_M0Init(&PcaInitStruct); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ \ No newline at end of file diff --git a/src/hc32f005_ddl/example/pca/pca_8bit_pwm/EWARM/pca_8bit_pwm.ewp b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/EWARM/pca_8bit_pwm.ewp new file mode 100644 index 0000000..30dfb9c --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/EWARM/pca_8bit_pwm.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\pca.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lpm.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/src/hc32f005_ddl/example/pca/pca_8bit_pwm/EWARM/pca_8bit_pwm.eww b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/EWARM/pca_8bit_pwm.eww new file mode 100644 index 0000000..bd6f85e --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/EWARM/pca_8bit_pwm.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\pca_8bit_pwm.ewp + + + + + diff --git a/src/hc32f005_ddl/example/pca/pca_8bit_pwm/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/pca/pca_8bit_pwm/MDK/pca_8bit_pwm.uvprojx b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/MDK/pca_8bit_pwm.uvprojx new file mode 100644 index 0000000..60d5e32 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/MDK/pca_8bit_pwm.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + pca_8bit_pwm_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + pca_8bit_pwm + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + pca_8bit_pwm.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +pca.c +1..\..\..\..\driver\src\pca.c + +lpm.c +1..\..\..\..\driver\src\lpm.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/pca/pca_8bit_pwm/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/pca/pca_8bit_pwm/source/ddl_device.h b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/pca/pca_8bit_pwm/source/main.c b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/source/main.c new file mode 100644 index 0000000..f879ede --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_8bit_pwm/source/main.c @@ -0,0 +1,165 @@ +/****************************************************************************** +* 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 "pca.h" +#include "lpm.h" +#include "gpio.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') + ******************************************************************************/ +__IO uint8_t pulse=100; //脉冲宽度,占空比=(255-pulse)/100*100% + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +static void App_GpioInit(void); +static void App_PcaInit(void); + +/** +****************************************************************************** + ** \brief 主函数 + ** + ** @param 无 + ** \retval 无 + ** +******************************************************************************/ +int32_t main(void) +{ + ///< 端口初始化 + App_GpioInit(); + ///< PCA初始化 + App_PcaInit(); + + ///< PCA 运行 + Pca_StartPca(TRUE); + + while (1) + { + ; + } +} + +/** + ****************************************************************************** + ** \brief 初始化外部GPIO引脚 + ** + ** \return 无 + ******************************************************************************/ +static void App_GpioInit(void) +{ + stc_gpio_cfg_t GpioInitStruct; + DDL_ZERO_STRUCT(GpioInitStruct); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + //P34 + GpioInitStruct.enDrv = GpioDrvH; + GpioInitStruct.enDir = GpioDirOut; + Gpio_Init(GpioPort3, GpioPin4, &GpioInitStruct); + Gpio_SetAfMode(GpioPort3, GpioPin4, GpioAf1); +} + +/** + ****************************************************************************** + ** \brief 配置PCA + ** + ** \return 无 + ******************************************************************************/ +static void App_PcaInit(void) +{ + stc_pcacfg_t PcaInitStruct; + + Sysctrl_SetPeripheralGate(SysctrlPeripheralPca, TRUE); + + PcaInitStruct.pca_clksrc = PcaPclkdiv32; + PcaInitStruct.pca_cidl = FALSE; + PcaInitStruct.pca_ecom = PcaEcomEnable; //允许比较器功能 + PcaInitStruct.pca_capp = PcaCappDisable; //禁止上升沿捕获 + PcaInitStruct.pca_capn = PcaCapnDisable; //禁止下降沿捕获 + PcaInitStruct.pca_mat = PcaMatDisable; //禁止匹配功能 + PcaInitStruct.pca_tog = PcaTogDisable; //禁止翻转控制功能 + PcaInitStruct.pca_pwm = PcaPwm8bitEnable; //使能PWM控制输出 + + PcaInitStruct.pca_ccapl = 255-pulse; + PcaInitStruct.pca_ccaph = 255-pulse; + Pca_M0Init(&PcaInitStruct); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/pca/pca_cmp_cnt/EWARM/pca_cmp_cnt.ewp b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/EWARM/pca_cmp_cnt.ewp new file mode 100644 index 0000000..e9320e8 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/EWARM/pca_cmp_cnt.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\pca.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lpm.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/src/hc32f005_ddl/example/pca/pca_cmp_cnt/EWARM/pca_cmp_cnt.eww b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/EWARM/pca_cmp_cnt.eww new file mode 100644 index 0000000..4853521 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/EWARM/pca_cmp_cnt.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\pca_cmp_cnt.ewp + + + + + diff --git a/src/hc32f005_ddl/example/pca/pca_cmp_cnt/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/pca/pca_cmp_cnt/MDK/pca_cmp_cnt.uvprojx b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/MDK/pca_cmp_cnt.uvprojx new file mode 100644 index 0000000..0264b59 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/MDK/pca_cmp_cnt.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + pca_cmp_cnt_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + pca_cmp_cnt + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + pca_cmp_cnt.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +pca.c +1..\..\..\..\driver\src\pca.c + +lpm.c +1..\..\..\..\driver\src\lpm.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/pca/pca_cmp_cnt/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/pca/pca_cmp_cnt/source/ddl_device.h b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/pca/pca_cmp_cnt/source/main.c b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/source/main.c new file mode 100644 index 0000000..67f2942 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_cmp_cnt/source/main.c @@ -0,0 +1,162 @@ +/****************************************************************************** +* 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 "pca.h" +#include "lpm.h" +#include "gpio.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 function prototypes ('static') + ******************************************************************************/ +static void App_PcaInit(void); + +/** +****************************************************************************** + ** \brief 主函数 + ** + ** @param 无 + ** \retval 无 + ** +******************************************************************************/ +int32_t main(void) +{ + App_PcaInit(); + + Pca_StartPca(TRUE); + + while (1) + { + ; + } +} + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + /** +****************************************************************************** + ** \brief RTC中断入口函数 + ** + ** @param 无 + ** \retval 无 + ** +******************************************************************************/ +void Pca_IRQHandler(void) +{ + if(Pca_GetItStatus(PcaCcf2) != FALSE) + { + Pca_ClrItStatus(PcaCcf2); + } + else if(Pca_GetItStatus(PcaCf) != FALSE) + { + Pca_ClrItStatus(PcaCf); + } +} + +/** + ****************************************************************************** + ** \brief 配置PCA + ** + ** \return 无 + ******************************************************************************/ +static void App_PcaInit(void) +{ + stc_pcacfg_t PcaInitStruct; + + //使能PCA外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralPca, TRUE); + + PcaInitStruct.pca_clksrc = PcaPclkdiv32; + PcaInitStruct.pca_cidl = FALSE; + PcaInitStruct.pca_ecom = PcaEcomEnable; //允许比较器功能 + PcaInitStruct.pca_capp = PcaCappDisable; //禁止上升沿捕获 + PcaInitStruct.pca_capn = PcaCapnDisable; //禁止下降沿捕获 + PcaInitStruct.pca_mat = PcaMatEnable; //禁止匹配功能 + PcaInitStruct.pca_tog = PcaTogDisable; //禁止翻转控制功能 + PcaInitStruct.pca_pwm = PcaPwm8bitDisable; //使能PWM控制输出 + PcaInitStruct.pca_ccap = 0x0120; + Pca_M2Init(&PcaInitStruct); + + Pca_ClrItStatus(PcaCcf2); + EnableNvic(PCA_IRQn, IrqLevel3, TRUE); + Pca_ConfModulexIt(PcaModule2, TRUE); + Pca_ConfPcaIt(TRUE); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/pca/pca_wdt/EWARM/pca_wdt.ewp b/src/hc32f005_ddl/example/pca/pca_wdt/EWARM/pca_wdt.ewp new file mode 100644 index 0000000..815af0a --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_wdt/EWARM/pca_wdt.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\pca.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lpm.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/src/hc32f005_ddl/example/pca/pca_wdt/EWARM/pca_wdt.eww b/src/hc32f005_ddl/example/pca/pca_wdt/EWARM/pca_wdt.eww new file mode 100644 index 0000000..18ad7d5 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_wdt/EWARM/pca_wdt.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\pca_wdt.ewp + + + + + diff --git a/src/hc32f005_ddl/example/pca/pca_wdt/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/pca/pca_wdt/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_wdt/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/pca/pca_wdt/MDK/pca_wdt.uvprojx b/src/hc32f005_ddl/example/pca/pca_wdt/MDK/pca_wdt.uvprojx new file mode 100644 index 0000000..91ee5b3 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_wdt/MDK/pca_wdt.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + pca_wdt_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + pca_wdt + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + pca_wdt.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +pca.c +1..\..\..\..\driver\src\pca.c + +lpm.c +1..\..\..\..\driver\src\lpm.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/pca/pca_wdt/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/pca/pca_wdt/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_wdt/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/pca/pca_wdt/source/ddl_device.h b/src/hc32f005_ddl/example/pca/pca_wdt/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_wdt/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/pca/pca_wdt/source/main.c b/src/hc32f005_ddl/example/pca/pca_wdt/source/main.c new file mode 100644 index 0000000..aba50c4 --- /dev/null +++ b/src/hc32f005_ddl/example/pca/pca_wdt/source/main.c @@ -0,0 +1,179 @@ +/****************************************************************************** +* 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 "pca.h" +#include "lpm.h" +#include "gpio.h" +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define FEEDDOG + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local variable definitions ('static') + ******************************************************************************/ + +/******************************************************************************* + * Local function prototypes ('static') + ******************************************************************************/ + + +/******************************************************************************* + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +static void App_GpioInit(void); +static void App_PcaInit(void); + +/** +****************************************************************************** + ** \brief 主函数 + ** + ** @param 无 + ** \retval 无 + ** +******************************************************************************/ +int32_t main(void) +{ + ///防止WDT开启无法下载 + delay1ms(2000); + + ///< 端口初始化 + App_GpioInit(); + ///< PCA初始化 + App_PcaInit(); + ///< PCA 运行 + Pca_StartPca(TRUE); + + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); + +#ifdef FEEDDOG + while(1) + { + + if(Pca_GetCnt()>=1000) + { + Pca_SetCnt(0); + } + + } +#else + while(1); +#endif +} + + +/** + ****************************************************************************** + ** \brief 初始化外部GPIO引脚 + ** + ** \return 无 + ******************************************************************************/ +static void App_GpioInit(void) +{ + stc_gpio_cfg_t GpioInitStruct; + DDL_ZERO_STRUCT(GpioInitStruct); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + GpioInitStruct.enDrv = GpioDrvH; + GpioInitStruct.enDir = GpioDirOut; + Gpio_Init(STK_LED_PORT, STK_LED_PIN, &GpioInitStruct); + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); +} + +/** + ****************************************************************************** + ** \brief 配置PCA + ** + ** \return 无 + ******************************************************************************/ +static void App_PcaInit(void) +{ + stc_pcacfg_t PcaInitStruct; + + //使能PCA外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralPca, TRUE); + + PcaInitStruct.pca_clksrc = PcaPclkdiv32; + PcaInitStruct.pca_cidl = FALSE; + PcaInitStruct.pca_ecom = PcaEcomEnable; //允许比较器功能 + PcaInitStruct.pca_capp = PcaCappDisable; //禁止上升沿捕获 + PcaInitStruct.pca_capn = PcaCapnDisable; //禁止下降沿捕获 + PcaInitStruct.pca_mat = PcaMatEnable; //禁止匹配功能 + PcaInitStruct.pca_tog = PcaTogDisable; //禁止翻转控制功能 + PcaInitStruct.pca_pwm = PcaPwm8bitDisable; //使能PWM控制输出 + + PcaInitStruct.pca_ccap = 4000; + Pca_M4Init(&PcaInitStruct); + + Pca_Set4Wdte(TRUE); ///< 看门狗使能 +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/spi/spi_master/EWARM/spi_master.ewp b/src/hc32f005_ddl/example/spi/spi_master/EWARM/spi_master.ewp new file mode 100644 index 0000000..ff3aab1 --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_master/EWARM/spi_master.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\spi.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/src/hc32f005_ddl/example/spi/spi_master/EWARM/spi_master.eww b/src/hc32f005_ddl/example/spi/spi_master/EWARM/spi_master.eww new file mode 100644 index 0000000..60da47d --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_master/EWARM/spi_master.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\spi_master.ewp + + + + + diff --git a/src/hc32f005_ddl/example/spi/spi_master/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/spi/spi_master/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_master/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/spi/spi_master/MDK/spi_master.uvprojx b/src/hc32f005_ddl/example/spi/spi_master/MDK/spi_master.uvprojx new file mode 100644 index 0000000..19b8e08 --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_master/MDK/spi_master.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + spi_master_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + spi_master + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + spi_master.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +spi.c +1..\..\..\..\driver\src\spi.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/spi/spi_master/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/spi/spi_master/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_master/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/spi/spi_master/source/ddl_device.h b/src/hc32f005_ddl/example/spi/spi_master/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_master/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/spi/spi_master/source/main.c b/src/hc32f005_ddl/example/spi/spi_master/source/main.c new file mode 100644 index 0000000..8908511 --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_master/source/main.c @@ -0,0 +1,228 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2019-04-23 1.0 First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "ddl.h" +#include "spi.h" +#include "gpio.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ +__IO uint8_t tx_cnt, rx_cnt; +uint8_t tx_buf[10]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, rx_buf[10]; +/****************************************************************************** + * 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') + ******************************************************************************/ +static void App_GpioInit(void); +static void App_SPIInit(void); + + + +/** +****************************************************************************** + ** \brief 主函数 + ** + ** @param 无 + ** \retval 无 + ** +******************************************************************************/ +int32_t main(void) +{ + uint16_t tmp; + volatile uint8_t tmp1; + tx_cnt = 0; + tmp = 0; + + ///< 端口初始化 + App_GpioInit(); + ///< SPI初始化 + App_SPIInit(); + + ///< USER 按下启动通信 + while(TRUE == Gpio_GetInputIO(STK_USER_PORT, STK_USER_PIN)); + + ///< 片选,开始通讯 + Spi_SetCS(M0P_SPI, FALSE); + + ///< 主机向从机发送数据 + while(tx_cnt<10) //主机发送数据给从机 + { + Spi_SendData(M0P_SPI, tx_buf[tx_cnt++]); + while(Spi_GetStatus(M0P_SPI, SpiIf) == FALSE); //等待发送结束 + } + + ///< 主机接收从机数据 + while(rx_cnt<10) //接收从机的数据 + { + Spi_SendData(M0P_SPI, 0); //发送空数据 + delay10us(20); + while(Spi_GetStatus(M0P_SPI, SpiIf) == FALSE); + rx_buf[rx_cnt++] = Spi_ReceiveData(M0P_SPI); + } + + ///< 结束通信 + Spi_SetCS(M0P_SPI, TRUE); + + ///< 判断发送的数据与接收的数据是否相等 + for(tmp = 0; tmp<10; ) + { + if(rx_buf[tmp] == tx_buf[tmp]) + tmp++; + else + break; + } + if(tmp == 10) //如果接收到的数据与发送的数据相等则点亮板上LED + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); + + while(1); +} + + +/** + ****************************************************************************** + ** \brief 初始化外部GPIO引脚 + ** + ** \return 无 + ******************************************************************************/ +static void App_GpioInit(void) +{ + stc_gpio_cfg_t GpioInitStruct; + DDL_ZERO_STRUCT(GpioInitStruct); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); + + //SPI0引脚配置:主机 + GpioInitStruct.enDrv = GpioDrvH; + GpioInitStruct.enDir = GpioDirOut; + + Gpio_Init(EVB_SPI_MOSI_PORT, EVB_SPI_MOSI_PIN, &GpioInitStruct); + Gpio_SetAfMode(EVB_SPI_MOSI_PORT, EVB_SPI_MOSI_PIN, GpioAf5); //配置引脚SPI_MOSI + + Gpio_Init(EVB_SPI_CS_PORT, EVB_SPI_CS_PIN,&GpioInitStruct); + Gpio_SetAfMode(EVB_SPI_CS_PORT, EVB_SPI_CS_PIN,GpioAf2); //配置引脚SPI_CS + + Gpio_Init(EVB_SPI_SCK_PORT, EVB_SPI_SCK_PIN,&GpioInitStruct); + Gpio_SetAfMode(EVB_SPI_SCK_PORT, EVB_SPI_SCK_PIN,GpioAf1); //配置引脚SPI_SCK + + GpioInitStruct.enDir = GpioDirIn; + Gpio_Init(EVB_SPI_MISO_PORT, EVB_SPI_MISO_PIN,&GpioInitStruct); + Gpio_SetAfMode(EVB_SPI_MISO_PORT, EVB_SPI_MISO_PIN,GpioAf5); //配置引脚SPI_MISO + + + ///< 端口方向配置->输入 + GpioInitStruct.enDir = GpioDirIn; + ///< 端口驱动能力配置->高驱动能力 + GpioInitStruct.enDrv = GpioDrvL; + ///< 端口上下拉配置->无 + GpioInitStruct.enPu = GpioPuDisable; + GpioInitStruct.enPd = GpioPdDisable; + ///< 端口开漏输出配置->开漏输出关闭 + GpioInitStruct.enOD = GpioOdDisable; + + ///< GPIO IO USER KEY初始化 + Gpio_Init(STK_USER_PORT, STK_USER_PIN, &GpioInitStruct); + + + //板上LED + GpioInitStruct.enDrv = GpioDrvH; + GpioInitStruct.enDir = GpioDirOut; + Gpio_Init(STK_LED_PORT, STK_LED_PIN, &GpioInitStruct); + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); //输出高,熄灭LED +} + +/** + ****************************************************************************** + ** \brief 初始化SPI + ** + ** \return 无 + ******************************************************************************/ +static void App_SPIInit(void) +{ + stc_spi_cfg_t SpiInitStruct; + + Sysctrl_SetPeripheralGate(SysctrlPeripheralSpi,TRUE); + + //SPI0模块配置:主机 + SpiInitStruct.enSpiMode = SpiMskMaster; //配置位主机模式 + SpiInitStruct.enPclkDiv = SpiClkMskDiv128; //波特率:fsys/128 + SpiInitStruct.enCPHA = SpiMskCphafirst;//第一边沿采样 + SpiInitStruct.enCPOL = SpiMskcpollow; //极性为低 + Spi_Init(M0P_SPI, &SpiInitStruct); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/spi/spi_slave/EWARM/spi_slave.ewp b/src/hc32f005_ddl/example/spi/spi_slave/EWARM/spi_slave.ewp new file mode 100644 index 0000000..d2936eb --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_slave/EWARM/spi_slave.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\spi.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/src/hc32f005_ddl/example/spi/spi_slave/EWARM/spi_slave.eww b/src/hc32f005_ddl/example/spi/spi_slave/EWARM/spi_slave.eww new file mode 100644 index 0000000..65d5946 --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_slave/EWARM/spi_slave.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\spi_slave.ewp + + + + + diff --git a/src/hc32f005_ddl/example/spi/spi_slave/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/spi/spi_slave/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_slave/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/spi/spi_slave/MDK/spi_slave.uvprojx b/src/hc32f005_ddl/example/spi/spi_slave/MDK/spi_slave.uvprojx new file mode 100644 index 0000000..0f46a97 --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_slave/MDK/spi_slave.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + spi_slave_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + spi_slave + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + spi_slave.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +spi.c +1..\..\..\..\driver\src\spi.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/spi/spi_slave/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/spi/spi_slave/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_slave/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/spi/spi_slave/source/ddl_device.h b/src/hc32f005_ddl/example/spi/spi_slave/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_slave/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/spi/spi_slave/source/main.c b/src/hc32f005_ddl/example/spi/spi_slave/source/main.c new file mode 100644 index 0000000..54e9f50 --- /dev/null +++ b/src/hc32f005_ddl/example/spi/spi_slave/source/main.c @@ -0,0 +1,210 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2019-04-23 1.0 First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "ddl.h" +#include "spi.h" +#include "gpio.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ +__IO uint8_t rx_buf[10], rx0_buf[10], rx_cnt, tx_cnt; +uint8_t tx_buf[10]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; +/****************************************************************************** + * 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') + ******************************************************************************/ +static void App_GpioInit(void); +static void App_SPIInit(void); + + +/** +****************************************************************************** + ** \brief 主函数 + ** + ** @param 无 + ** \retval 无 + ** +******************************************************************************/ +int32_t main(void) +{ + uint16_t tmp; + tx_cnt = 0; + rx_cnt = 0; + tmp = 0; + + App_GpioInit(); + App_SPIInit(); + + while(1 == Gpio_GetInputIO(EVB_SPI_CS_PORT,EVB_SPI_CS_PIN));//等待片选信号生效 + + ///< 从机接收主机发送 + while(rx_cnt<10) //等待接收主机所发送的数据 + { + if (rx_cnt == 9) ///< 预存下一次主机接收的数据 + { + Spi_SendData(M0P_SPI, rx_buf[0]); + } + + while(Spi_GetStatus(M0P_SPI, SpiIf) == FALSE);//等待接收缓冲器非空 + rx_buf[rx_cnt++] = Spi_ReceiveData(M0P_SPI); //读取接收到的数据 + } + + ///< 从机发送主机接收 + rx_cnt = 1; + while(rx_cnt<10) + { + Spi_SendData(M0P_SPI, rx_buf[rx_cnt++]); + while(Spi_GetStatus(M0P_SPI, SpiIf) == FALSE) + {} + } + + + for(tmp = 0; tmp<10;) //判断发送的数据与接收的数据是否相等 + { + if(rx_buf[tmp] == tx_buf[tmp]) + tmp++; + else + break; + } + if(tmp == 10) //如果接收到的数据与发送的数据相等则点亮板上蓝色LED + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); + + while(1) + { + } +} + + +/** + ****************************************************************************** + ** \brief 初始化外部GPIO引脚 + ** + ** \return 无 + ******************************************************************************/ +static void App_GpioInit(void) +{ + stc_gpio_cfg_t GpioInitStruct; + DDL_ZERO_STRUCT(GpioInitStruct); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); + + //SPI引脚配置:从机 + GpioInitStruct.enDir = GpioDirIn; + Gpio_Init(EVB_SPI_MOSI_PORT, EVB_SPI_MOSI_PIN, &GpioInitStruct); + Gpio_SetAfMode(EVB_SPI_MOSI_PORT, EVB_SPI_MOSI_PIN, GpioAf5); //配置引脚SPI_MOSI + + Gpio_Init(EVB_SPI_CS_PORT, EVB_SPI_CS_PIN,&GpioInitStruct); + Gpio_SetAfMode(EVB_SPI_CS_PORT, EVB_SPI_CS_PIN,GpioAf2); //配置引脚SPI_CS + Gpio_SfSsnCfg(GpioSfSsnExtClkP03); + + Gpio_Init(EVB_SPI_SCK_PORT, EVB_SPI_SCK_PIN,&GpioInitStruct); + Gpio_SetAfMode(EVB_SPI_SCK_PORT, EVB_SPI_SCK_PIN,GpioAf1); //配置引脚SPI_SCK + + GpioInitStruct.enDir = GpioDirOut; + Gpio_Init(EVB_SPI_MISO_PORT, EVB_SPI_MISO_PIN,&GpioInitStruct); + Gpio_SetAfMode(EVB_SPI_MISO_PORT, EVB_SPI_MISO_PIN,GpioAf5); //配置引脚SPI_MISO + + + //板上LED + GpioInitStruct.enDrv = GpioDrvH; + GpioInitStruct.enDir = GpioDirOut; + Gpio_Init(STK_LED_PORT, STK_LED_PIN, &GpioInitStruct); + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); //输出高,熄灭LED +} + +/** + ****************************************************************************** + ** \brief 配置SPI + ** + ** \return 无 + ******************************************************************************/ +static void App_SPIInit(void) +{ + stc_spi_cfg_t SpiInitStruct; + + Sysctrl_SetPeripheralGate(SysctrlPeripheralSpi, TRUE); + + //SPI1模块配置:从机 + SpiInitStruct.enSpiMode = SpiMskSlave; //配置位主机模式 + SpiInitStruct.enPclkDiv = SpiClkMskDiv128; //波特率:fsys/128 + SpiInitStruct.enCPHA = SpiMskCphafirst;//第一边沿采样 + SpiInitStruct.enCPOL = SpiMskcpollow; //极性为低 + Spi_Init(M0P_SPI, &SpiInitStruct); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/EWARM/sysctrl_clk_div_output.ewp b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/EWARM/sysctrl_clk_div_output.ewp new file mode 100644 index 0000000..819288c --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/EWARM/sysctrl_clk_div_output.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\flash.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/EWARM/sysctrl_clk_div_output.eww b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/EWARM/sysctrl_clk_div_output.eww new file mode 100644 index 0000000..48faea4 --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/EWARM/sysctrl_clk_div_output.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\sysctrl_clk_div_output.ewp + + + + + diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/MDK/sysctrl_clk_div_output.uvprojx b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/MDK/sysctrl_clk_div_output.uvprojx new file mode 100644 index 0000000..bd2b763 --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/MDK/sysctrl_clk_div_output.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + sysctrl_clk_div_output_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + sysctrl_clk_div_output + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + sysctrl_clk_div_output.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +sysctrl.c +1..\..\..\..\driver\src\sysctrl.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +flash.c +1..\..\..\..\driver\src\flash.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/source/ddl_device.h b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/source/main.c b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/source/main.c new file mode 100644 index 0000000..ee838f8 --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_div_output/source/main.c @@ -0,0 +1,187 @@ +/****************************************************************************** +* 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 "sysctrl.h" +#include "gpio.h" +#include "flash.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ +static void App_UserKeyWait(void); +static void App_PortCfg(void); +static void App_ClkCfg(void); +/****************************************************************************** + * 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 + ** + ** check Pxx to verify the clock frequency. + ** + ******************************************************************************/ +int32_t main(void) +{ + //系统时钟配置 + App_ClkCfg(); + + //端口配置:等待按键按下,配置相关时钟信号从IO口输出 + App_PortCfg(); + + while (1) + { + ; + } +} + +//系统时钟配置 +static void App_ClkCfg(void) +{ + stc_sysctrl_clk_cfg_t stcCfg; + + ///< 因要使用的时钟源HCLK小于24M:此处设置FLASH 读等待周期为0 cycle(默认值也为0 cycle) + Flash_WaitCycle(FlashWaitCycle0); + + ///< 时钟初始化前,优先设置要使用的时钟源:此处设置RCH为4MHz(默认值为4MHz) + Sysctrl_SetRCHTrim(SysctrlRchFreq4MHz); + + ///< 选择内部RCH作为HCLK时钟源; + stcCfg.enClkSrc = SysctrlClkRCH; + ///< HCLK SYSCLK/2 + stcCfg.enHClkDiv = SysctrlHclkDiv2; + ///< PCLK 为HCLK/8 + stcCfg.enPClkDiv = SysctrlPclkDiv8; + ///< 系统时钟初始化 + Sysctrl_ClkInit(&stcCfg); +} + +//端口配置:等待按键按下,配置相关时钟信号从IO口输出 +static void App_PortCfg(void) +{ + stc_gpio_cfg_t pstcGpioCfg; + + ///< 开启GPIO外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + //USER KEY按下后继续执行程序 + App_UserKeyWait(); + + ///< 端口方向配置->输出 + pstcGpioCfg.enDir = GpioDirOut; + ///< 端口驱动能力配置->高驱动能力 + pstcGpioCfg.enDrv = GpioDrvH; + ///< 端口上下拉配置->无上下拉 + pstcGpioCfg.enPu = GpioPuDisable; + pstcGpioCfg.enPd = GpioPdDisable; + ///< 端口开漏输出配置->开漏输出关闭 + pstcGpioCfg.enOD = GpioOdDisable; + ///< GPIO IO P27初始化 + Gpio_Init(GpioPort2, GpioPin7, &pstcGpioCfg); + + Sysctrl_SetFunc(SysctrlSWDUseIOEn, TRUE); + + ///< 设置RCH从PB00输出 + Gpio_SetAfMode(GpioPort2, GpioPin7, GpioAf6); + +} + +//等待按键按下 +static void App_UserKeyWait(void) +{ + stc_gpio_cfg_t pstcGpioCfg; + + ///< 端口方向配置->输出 + pstcGpioCfg.enDir = GpioDirIn; + ///< 端口驱动能力配置->低驱动能力 + pstcGpioCfg.enDrv = GpioDrvL; + ///< 端口上下拉配置->上拉 + pstcGpioCfg.enPu = GpioPuEnable; + pstcGpioCfg.enPd = GpioPdDisable; + ///< 端口开漏输出配置->开漏输出关闭 + pstcGpioCfg.enOD = GpioOdDisable; + ///< GPIO IO 初始化(STK上外接KEY(USER)) + Gpio_Init(STK_USER_PORT, STK_USER_PIN, &pstcGpioCfg); + ///< 检测电平(USER按键是否按下(低电平)) + while(TRUE == Gpio_GetInputIO(STK_USER_PORT, STK_USER_PIN)); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + + diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/EWARM/sysctrl_clk_switch.ewp b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/EWARM/sysctrl_clk_switch.ewp new file mode 100644 index 0000000..09362b1 --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/EWARM/sysctrl_clk_switch.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\flash.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/EWARM/sysctrl_clk_switch.eww b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/EWARM/sysctrl_clk_switch.eww new file mode 100644 index 0000000..599384a --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/EWARM/sysctrl_clk_switch.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\sysctrl_clk_switch.ewp + + + + + diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/MDK/sysctrl_clk_switch.uvprojx b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/MDK/sysctrl_clk_switch.uvprojx new file mode 100644 index 0000000..bb46189 --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/MDK/sysctrl_clk_switch.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + sysctrl_clk_switch_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + sysctrl_clk_switch + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + sysctrl_clk_switch.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +sysctrl.c +1..\..\..\..\driver\src\sysctrl.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +flash.c +1..\..\..\..\driver\src\flash.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/source/ddl_device.h b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/source/main.c b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/source/main.c new file mode 100644 index 0000000..30625dc --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_clk_switch/source/main.c @@ -0,0 +1,252 @@ +/****************************************************************************** +* 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 "sysctrl.h" +#include "gpio.h" +#include "flash.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') * + ******************************************************************************/ + +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ +void App_PortCfg(void); +void App_ClkInit(void); +void App_Rch4MHzTo24MHz(void); +void App_Rch24MHzToXth32MHz (void); +void App_Xth32MHzToPll48MHz (void); +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** check Pxx to verify the clock frequency. + ** + ******************************************************************************/ +int32_t main(void) +{ + //端口配置,按键按下,继续运行 + App_PortCfg(); + + //时钟初始化配置 + App_ClkInit(); + + //将时钟从RCH4MHz切换至RCH24MHz, PA01观察时钟波形,(3s后)按下按键继续运行 + App_Rch4MHzTo24MHz(); + + //将时钟从RCH24MHz切换至XTH32MHz, PA01观察时钟波形,(3s后)按下按键继续运行 + App_Rch24MHzToXth32MHz(); + + while (1) + { + ; + } +} + +//等待按键按下 +static void _UserKeyWait(void) +{ + while(TRUE == Gpio_GetInputIO(STK_USER_PORT, STK_USER_PIN)); +} + +//将时钟从RCH24MHz切换至XTH32MHz +void App_Rch24MHzToXth32MHz (void) +{ +///<======================== 将时钟从RCH24MHz切换至XTH32MHz ============================== + ///< 因要使用的时钟源HCLK将大于24M:此处设置FLASH 读等待周期为1 cycle(默认值也为1 cycle) + Flash_WaitCycle(FlashWaitCycle1); + + ///< 切换时钟前(根据外部高速晶振)设置XTH频率范围,配置晶振参数,使能目标时钟,此处为32MHz + Sysctrl_SetXTHFreq(SysctrlXthFreq20_32MHz); + Sysctrl_XTHDriverCfg(SysctrlXtalDriver3); + Sysctrl_SetXTHStableTime(SysctrlXthStableCycle16384); + Sysctrl_ClkSourceEnable(SysctrlClkXTH, TRUE); + + ///< 时钟切换 + Sysctrl_SysClkSwitch(SysctrlClkXTH); + ///< 根据需要选择是否关闭原时钟(此处不关闭) + //Sysctrl_ClkSourceEnable(SysctrlClkRCH, FALSE); + + ///< 使能HCLK从PA01输出 + Gpio_SfHClkOutputCfg(GpioSfHclkOutEnable, GpioSfHclkOutDiv1); + + delay1ms(3000); + _UserKeyWait(); //USER KEY 按下后继续执行 + + ///< 禁止HCLK从PA01输出 + Gpio_SfHClkOutputCfg(GpioSfHclkOutDisable, GpioSfHclkOutDiv1); +} + +//将时钟从RCH4MHz切换至RCH24MHz, +void App_Rch4MHzTo24MHz(void) +{ +///<============== 将时钟从RCH4MHz切换至RCH24MHz ============================== + ///< RCH时钟不同频率的切换,需要先将时钟切换到RCL,设置好频率后再切回RCH + Sysctrl_SetRCLTrim(SysctrlRclFreq32768); + Sysctrl_ClkSourceEnable(SysctrlClkRCL, TRUE); + Sysctrl_SysClkSwitch(SysctrlClkRCL); + + ///< 加载目标频率的RCH的TRIM值 + Sysctrl_SetRCHTrim(SysctrlRchFreq24MHz); + ///< 使能RCH(默认打开,此处可不需要再次打开) + //Sysctrl_ClkSourceEnable(SysctrlClkRCH, TRUE); + ///< 时钟切换到RCH + Sysctrl_SysClkSwitch(SysctrlClkRCH); + ///< 关闭RCL时钟 + Sysctrl_ClkSourceEnable(SysctrlClkRCL, FALSE); + + ///< 使能HCLK从PA01输出 + Gpio_SfHClkOutputCfg(GpioSfHclkOutEnable, GpioSfHclkOutDiv1); + + delay1ms(3000); + _UserKeyWait(); //USER KEY 按下后继续执行 + + ///< 禁止HCLK从PA01输出 + Gpio_SfHClkOutputCfg(GpioSfHclkOutDisable, GpioSfHclkOutDiv1); + +} + +//时钟初始化配置 +void App_ClkInit(void) +{ + stc_sysctrl_clk_cfg_t stcCfg; + + ///< 开启FLASH外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralFlash, TRUE); + + ///<========================== 时钟初始化配置 =================================== + ///< 因要使用的时钟源HCLK小于24M:此处设置FLASH 读等待周期为0 cycle(默认值也为0 cycle) + Flash_WaitCycle(FlashWaitCycle0); + + ///< 时钟初始化前,优先设置要使用的时钟源:此处设置RCH为4MHz + Sysctrl_SetRCHTrim(SysctrlRchFreq4MHz); + + ///< 选择内部RCH作为HCLK时钟源; + stcCfg.enClkSrc = SysctrlClkRCH; + ///< HCLK SYSCLK/1 + stcCfg.enHClkDiv = SysctrlHclkDiv1; + ///< PCLK 为HCLK/1 + stcCfg.enPClkDiv = SysctrlPclkDiv1; + ///< 系统时钟初始化 + Sysctrl_ClkInit(&stcCfg); +} + + +//端口配置,按键按下,继续运行 +void App_PortCfg(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + ///< 开启GPIO外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + ///<========================== 按键端口配置 =========================== + ///< 端口方向配置->输出 + stcGpioCfg.enDir = GpioDirIn; + ///< 端口驱动能力配置->低驱动能力 + stcGpioCfg.enDrv = GpioDrvL; + ///< 端口上下拉配置->上拉 + stcGpioCfg.enPu = GpioPuEnable; + stcGpioCfg.enPd = GpioPdDisable; + ///< 端口开漏输出配置->开漏输出关闭 + stcGpioCfg.enOD = GpioOdDisable; + ///< GPIO IO 初始化(在STK上外接KEY(USER)) + Gpio_Init(STK_USER_PORT, STK_USER_PIN, &stcGpioCfg); + ///< User KEY 按下后程序继续执行 + _UserKeyWait(); + + ///<========================== 时钟输出端口模式配置 =========================== + ///< 端口方向配置->输出 + stcGpioCfg.enDir = GpioDirOut; + ///< 端口驱动能力配置->高驱动能力 + stcGpioCfg.enDrv = GpioDrvH; + ///< 端口上下拉配置->无上下拉 + stcGpioCfg.enPu = GpioPuDisable; + stcGpioCfg.enPd = GpioPdDisable; + ///< 端口开漏输出配置->开漏输出关闭 + stcGpioCfg.enOD = GpioOdDisable; + ///< GPIO IO P31初始化 + Gpio_Init(GpioPort3, GpioPin1, &stcGpioCfg); + ///< 配置P31复用功能为HCLK输出 + Gpio_SetAfMode(GpioPort3, GpioPin1, GpioAf7); + + Sysctrl_SetFunc(SysctrlSWDUseIOEn, TRUE); + +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + + diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/EWARM/sysctrl_systick.ewp b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/EWARM/sysctrl_systick.ewp new file mode 100644 index 0000000..fb93f31 --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/EWARM/sysctrl_systick.ewp @@ -0,0 +1,2216 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.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/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/EWARM/sysctrl_systick.eww b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/EWARM/sysctrl_systick.eww new file mode 100644 index 0000000..56cfc15 --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/EWARM/sysctrl_systick.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\sysctrl_systick.ewp + + + + + diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/MDK/sysctrl_systick.uvprojx b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/MDK/sysctrl_systick.uvprojx new file mode 100644 index 0000000..3ff1dbc --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/MDK/sysctrl_systick.uvprojx @@ -0,0 +1,464 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + sysctrl_systick_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + sysctrl_systick + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + sysctrl_systick.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +sysctrl.c +1..\..\..\..\driver\src\sysctrl.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/source/ddl_device.h b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/source/main.c b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/source/main.c new file mode 100644 index 0000000..d5b634e --- /dev/null +++ b/src/hc32f005_ddl/example/sysctrl/sysctrl_systick/source/main.c @@ -0,0 +1,151 @@ +/****************************************************************************** +* 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 "sysctrl.h" +#include "gpio.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') + ******************************************************************************/ +void App_PortCfg(void); +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** check Pxx to verify the clock frequency. + ** + ******************************************************************************/ +int32_t main(void) +{ + ///< 配置LED端口 + App_PortCfg(); + + ///< 内核函数,SysTick配置,定时1s,系统时钟默认RCH 4MHz + SysTick_Config(SystemCoreClock); + + while (1) + { + ; + } +} + +//systick中断函数 +void SysTick_IRQHandler(void) +{ + static boolean_t bFlag = TRUE; + + if(TRUE == bFlag) + { + bFlag = FALSE; + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); + } + else + { + bFlag = TRUE; + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); + } +} + +//配置LED端口 +void App_PortCfg(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + ///< 开启GPIO外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); + + ///< 端口方向配置->输出 + stcGpioCfg.enDir = GpioDirOut; + ///< 端口驱动能力配置->高驱动能力 + stcGpioCfg.enDrv = GpioDrvH; + ///< 端口上下拉配置->下拉 + stcGpioCfg.enPu = GpioPuEnable; + stcGpioCfg.enPd = GpioPdDisable; + ///< 端口开漏输出配置->开漏输出关闭 + stcGpioCfg.enOD = GpioOdDisable; + ///< GPIO IO (LED)初始化 + Gpio_Init(STK_LED_PORT, STK_LED_PIN, &stcGpioCfg); +} +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + + diff --git a/src/hc32f005_ddl/example/template/template/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/template/template/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/template/template/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/template/template/EWARM/template.ewp b/src/hc32f005_ddl/example/template/template/EWARM/template.ewp new file mode 100644 index 0000000..e595256 --- /dev/null +++ b/src/hc32f005_ddl/example/template/template/EWARM/template.ewp @@ -0,0 +1,2210 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/template/template/EWARM/template.eww b/src/hc32f005_ddl/example/template/template/EWARM/template.eww new file mode 100644 index 0000000..c62178f --- /dev/null +++ b/src/hc32f005_ddl/example/template/template/EWARM/template.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\template.ewp + + + + + diff --git a/src/hc32f005_ddl/example/template/template/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/template/template/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/template/template/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/template/template/MDK/template.uvprojx b/src/hc32f005_ddl/example/template/template/MDK/template.uvprojx new file mode 100644 index 0000000..133cc28 --- /dev/null +++ b/src/hc32f005_ddl/example/template/template/MDK/template.uvprojx @@ -0,0 +1,458 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + template_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + template + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + template.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/template/template/source/ddl_device.h b/src/hc32f005_ddl/example/template/template/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/template/template/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/template/template/source/main.c b/src/hc32f005_ddl/example/template/template/source/main.c new file mode 100644 index 0000000..6908cc8 --- /dev/null +++ b/src/hc32f005_ddl/example/template/template/source/main.c @@ -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 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 "ddl.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) +{ + + /* + Add your codes…… + */ + + while (1) + { + ; + } +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/uart/uart_int/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/uart/uart_int/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/uart/uart_int/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/uart/uart_int/EWARM/uart_int.ewp b/src/hc32f005_ddl/example/uart/uart_int/EWARM/uart_int.ewp new file mode 100644 index 0000000..64c6f3d --- /dev/null +++ b/src/hc32f005_ddl/example/uart/uart_int/EWARM/uart_int.ewp @@ -0,0 +1,2222 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\uart.c + + + $PROJ_DIR$\..\..\..\..\driver\src\bt.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lpm.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/src/hc32f005_ddl/example/uart/uart_int/EWARM/uart_int.eww b/src/hc32f005_ddl/example/uart/uart_int/EWARM/uart_int.eww new file mode 100644 index 0000000..19c86f5 --- /dev/null +++ b/src/hc32f005_ddl/example/uart/uart_int/EWARM/uart_int.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\uart_int.ewp + + + + + diff --git a/src/hc32f005_ddl/example/uart/uart_int/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/uart/uart_int/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/uart/uart_int/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/uart/uart_int/MDK/uart_int.uvprojx b/src/hc32f005_ddl/example/uart/uart_int/MDK/uart_int.uvprojx new file mode 100644 index 0000000..c255a83 --- /dev/null +++ b/src/hc32f005_ddl/example/uart/uart_int/MDK/uart_int.uvprojx @@ -0,0 +1,470 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + uart_int_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + uart_int + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + uart_int.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +uart.c +1..\..\..\..\driver\src\uart.c + +bt.c +1..\..\..\..\driver\src\bt.c + +lpm.c +1..\..\..\..\driver\src\lpm.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/uart/uart_int/source/ddl_device.h b/src/hc32f005_ddl/example/uart/uart_int/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/uart/uart_int/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/uart/uart_int/source/main.c b/src/hc32f005_ddl/example/uart/uart_int/source/main.c new file mode 100644 index 0000000..25b303c --- /dev/null +++ b/src/hc32f005_ddl/example/uart/uart_int/source/main.c @@ -0,0 +1,216 @@ +/****************************************************************************** +* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2017-05-17 1.0 cj First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "ddl.h" +#include "uart.h" +#include "bt.h" +#include "lpm.h" +#include "gpio.h" + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ + +/****************************************************************************** + * Global variable definitions (declared in header file with 'extern') + ******************************************************************************/ + +/****************************************************************************** + * Local type definitions ('typedef') + ******************************************************************************/ + +/****************************************************************************** + * Local function prototypes ('static') + ******************************************************************************/ +static void App_UartInit(void); +static void App_PortInit(void); +/****************************************************************************** + * Local variable definitions ('static') * + ******************************************************************************/ + +/****************************************************************************** + * Local pre-processor symbols/macros ('#define') + ******************************************************************************/ +#define T1_PORT (3) +#define T1_PIN (3) +/***************************************************************************** + * Function implementation - global ('extern') and local ('static') + ******************************************************************************/ + +uint8_t u8RxData[2] = {0x55,0x00}; +uint8_t u8RxFlg = 0; +uint8_t CheckFlg = 0; + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + ///< UART 端口初始化 + App_PortInit(); + + ///< UART 初始化 + App_UartInit(); + + while(1) + { + CheckFlg = 0; + if(u8RxFlg) + { + u8RxFlg = 0; + if(Uart_CheckEvenOrOdd(M0P_UART1,UartEven,u8RxData[1])!=Ok) + { + CheckFlg = 1;//奇偶校验出错 + } + else + { + Uart_SetTb8(M0P_UART1,UartEven,u8RxData[0]); + Uart_SendDataPoll(M0P_UART1,u8RxData[0]); + Uart_SetTb8(M0P_UART1,UartEven,u8RxData[1]); + Uart_SendDataPoll(M0P_UART1,u8RxData[1]); + } + } + } +} + +///< UART1 中断服务函数 +void Uart1_IRQHandler(void) +{ + if(TRUE == Uart_GetStatus(M0P_UART1, UartRC)) + { + Uart_ClrStatus(M0P_UART1, UartRC); + + u8RxData[1] = Uart_ReceiveData(M0P_UART1); + u8RxFlg = 1; + + } + +} + +//串口引脚配置 +static void App_PortInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + DDL_ZERO_STRUCT(stcGpioCfg); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); //使能GPIO模块时钟 + + /// + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\vc.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\bgr.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/EWARM/vc_detect_falling_irq.eww b/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/EWARM/vc_detect_falling_irq.eww new file mode 100644 index 0000000..1fbfd0b --- /dev/null +++ b/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/EWARM/vc_detect_falling_irq.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\vc_detect_falling_irq.ewp + + + + + diff --git a/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/MDK/vc_detect_falling_irq.uvprojx b/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/MDK/vc_detect_falling_irq.uvprojx new file mode 100644 index 0000000..157b854 --- /dev/null +++ b/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/MDK/vc_detect_falling_irq.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + vc_detect_falling_irq_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + vc_detect_falling_irq + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + vc_detect_falling_irq.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +vc.c +1..\..\..\..\driver\src\vc.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +bgr.c +1..\..\..\..\driver\src\bgr.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/source/ddl_device.h b/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/source/main.c b/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/source/main.c new file mode 100644 index 0000000..b9b1859 --- /dev/null +++ b/src/hc32f005_ddl/example/vc/vc_detect_falling_irq/source/main.c @@ -0,0 +1,190 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2017-05-28 LiuHL First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "vc.h" +#include "gpio.h" +#include "bgr.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') + ******************************************************************************/ +static void App_GpioInit(void); +static void App_VC0Init(void); + +/** +****************************************************************************** + ** \brief 主函数 + ** + ** @param 无 + ** \retval 无 + ** +******************************************************************************/ +int main(void) +{ + ///< GPIO初始化 + App_GpioInit(); + ///< VC0 初始化 + App_VC0Init(); + + Vc_Cmd(VcChannel0, TRUE); + + while (1) + { + ; + } +} + + +/** + ****************************************************************************** + ** \brief LPTIMER0中断服务函数 + ** + ** \return 无 + ******************************************************************************/ +void Vc0_IRQHandler(void) +{ + if(Vc_GetItStatus(Vc0_Intf) == TRUE) + { + Vc_ClearItStatus(Vc0_Intf); + + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); //输出低,熄灭LED + delay1ms(500); + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); //输出高,点亮LED + delay1ms(500); + } +} + +/** + ****************************************************************************** + ** \brief 初始化外部GPIO引脚 + ** + ** \return 无 + ******************************************************************************/ +static void App_GpioInit(void) +{ + stc_gpio_cfg_t GpioInitStruct; + DDL_ZERO_STRUCT(GpioInitStruct); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //开GPIO时钟 + + GpioInitStruct.enDrv = GpioDrvH; + GpioInitStruct.enDir = GpioDirOut; + Gpio_Init(GpioPort0,GpioPin3,&GpioInitStruct); + Gpio_SetAfMode(GpioPort0,GpioPin3,GpioAf7); //P03作为VC0_OUT + + Gpio_Init(STK_LED_PORT, STK_LED_PIN, &GpioInitStruct); //控制板上蓝色LED + Gpio_SetAnalogMode(GpioPort3,GpioPin4); //模拟输入 + +} + +/** + ****************************************************************************** + ** \brief 初始化VC0 + ** + ** \return 无 + ******************************************************************************/ +static void App_VC0Init(void) +{ + stc_vc_channel_cfg_t VcInitStruct; + DDL_ZERO_STRUCT(VcInitStruct); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralVcLvd, TRUE); //开LVD时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdcBgr, TRUE);//开adc时钟 + + Bgr_BgrEnable(); //BGR必须使能 + + VcInitStruct.enVcChannel = VcChannel0; + VcInitStruct.enVcCmpDly = VcDelay10mv; //VC0迟滞电压约为10mV + VcInitStruct.enVcBiasCurrent = VcBias10ua; //VC0功耗为10uA + VcInitStruct.enVcFilterTime = VcFilter28us; //VC输出滤波时间约为28us + VcInitStruct.enVcInPin_P = VcInPCh4; //VC0_CH的P端连接P34 + VcInitStruct.enVcInPin_N = AiBg1p2; //VC0_CH的N端连接内核1.2V + VcInitStruct.enVcOutCfg = VcOutDisable; //不输出给配置寄存器所定义的外设 + VcInitStruct.bFlten = TRUE; //是能滤波 + Vc_Init(&VcInitStruct); + + ///< VC0 中断配置 + Vc_CfgItType(VcChannel0, VcIrqFall); //配置VC0为上升沿中断 + Vc_ClearItStatus(Vc0_Intf); + Vc_ItCfg(VcChannel0, TRUE); + EnableNvic(VC0_IRQn, IrqLevel3, TRUE); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/EWARM/vc_vref_rising_irq.ewp b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/EWARM/vc_vref_rising_irq.ewp new file mode 100644 index 0000000..25c90cf --- /dev/null +++ b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/EWARM/vc_vref_rising_irq.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\vc.c + + + $PROJ_DIR$\..\..\..\..\driver\src\gpio.c + + + $PROJ_DIR$\..\..\..\..\driver\src\bgr.c + + + + + source + + $PROJ_DIR$\..\source\main.c + + + Release + + ICCARM + + 31 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + README + + $PROJ_DIR$\..\readme.txt + + + + + diff --git a/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/EWARM/vc_vref_rising_irq.eww b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/EWARM/vc_vref_rising_irq.eww new file mode 100644 index 0000000..579eb39 --- /dev/null +++ b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/EWARM/vc_vref_rising_irq.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\vc_vref_rising_irq.ewp + + + + + diff --git a/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/MDK/vc_vref_rising_irq.uvprojx b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/MDK/vc_vref_rising_irq.uvprojx new file mode 100644 index 0000000..5fe065a --- /dev/null +++ b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/MDK/vc_vref_rising_irq.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + vc_vref_rising_irq_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + vc_vref_rising_irq + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + vc_vref_rising_irq.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +vc.c +1..\..\..\..\driver\src\vc.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + +bgr.c +1..\..\..\..\driver\src\bgr.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/source/ddl_device.h b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/source/main.c b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/source/main.c new file mode 100644 index 0000000..8b50edd --- /dev/null +++ b/src/hc32f005_ddl/example/vc/vc_vref_rising_irq/source/main.c @@ -0,0 +1,190 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2017-05-28 LiuHL First Version + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ +#include "vc.h" +#include "gpio.h" +#include "bgr.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') + ******************************************************************************/ +static void App_GpioInit(void); +static void App_VC0Init(void); + +/** +****************************************************************************** + ** \brief 主函数 + ** + ** @param 无 + ** \retval 无 + ** +******************************************************************************/ +int main(void) +{ + ///< GPIO初始化 + App_GpioInit(); + ///< VC0 初始化 + App_VC0Init(); + + Vc_Cmd(VcChannel0, TRUE); + + while (1) + { + ; + } +} + + +/** + ****************************************************************************** + ** \brief LPTIMER0中断服务函数 + ** + ** \return 无 + ******************************************************************************/ +void Vc0_IRQHandler(void) +{ + if(Vc_GetItStatus(Vc0_Intf) == TRUE) + { + Vc_ClearItStatus(Vc0_Intf); + + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); //输出低,熄灭LED + delay1ms(500); + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); //输出高,点亮LED + delay1ms(500); + } +} + +/** + ****************************************************************************** + ** \brief 初始化外部GPIO引脚 + ** + ** \return 无 + ******************************************************************************/ +static void App_GpioInit(void) +{ + stc_gpio_cfg_t GpioInitStruct; + DDL_ZERO_STRUCT(GpioInitStruct); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); //开GPIO时钟 + + GpioInitStruct.enDrv = GpioDrvH; + GpioInitStruct.enDir = GpioDirOut; + Gpio_Init(GpioPort0,GpioPin3,&GpioInitStruct); + Gpio_SetAfMode(GpioPort0,GpioPin3,GpioAf7); //P03作为VC0_OUT + + Gpio_Init(STK_LED_PORT, STK_LED_PIN, &GpioInitStruct); //控制板上蓝色LED + Gpio_SetAnalogMode(GpioPort3,GpioPin4); //模拟输入 + +} + +/** + ****************************************************************************** + ** \brief 初始化VC0 + ** + ** \return 无 + ******************************************************************************/ +static void App_VC0Init(void) +{ + stc_vc_channel_cfg_t VcInitStruct; + DDL_ZERO_STRUCT(VcInitStruct); + + Sysctrl_SetPeripheralGate(SysctrlPeripheralVcLvd, TRUE); //开LVD时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralAdcBgr, TRUE);//开adc时钟 + + Bgr_BgrEnable(); //BGR必须使能 + + VcInitStruct.enVcChannel = VcChannel0; + VcInitStruct.enVcCmpDly = VcDelay10mv; //VC0迟滞电压约为10mV + VcInitStruct.enVcBiasCurrent = VcBias10ua; //VC0功耗为10uA + VcInitStruct.enVcFilterTime = VcFilter28us; //VC输出滤波时间约为28us + VcInitStruct.enVcInPin_P = VcInPCh4; //VC0_CH的P端连接P34 + VcInitStruct.enVcInPin_N = AiBg1p2; //VC0_CH的N端连接内核1.2V + VcInitStruct.enVcOutCfg = VcOutDisable; //不输出给配置寄存器所定义的外设 + VcInitStruct.bFlten = TRUE; //是能滤波 + Vc_Init(&VcInitStruct); + + ///< VC0 中断配置 + Vc_CfgItType(VcChannel0, VcIrqRise); //配置VC0为下降沿中断 + Vc_ClearItStatus(Vc0_Intf); + Vc_ItCfg(VcChannel0, TRUE); + EnableNvic(VC0_IRQn, IrqLevel3, TRUE); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/wdt/wdt_int/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/wdt/wdt_int/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/wdt/wdt_int/EWARM/wdt_int.ewp b/src/hc32f005_ddl/example/wdt/wdt_int/EWARM/wdt_int.ewp new file mode 100644 index 0000000..947abae --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int/EWARM/wdt_int.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\wdt.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lpm.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/src/hc32f005_ddl/example/wdt/wdt_int/EWARM/wdt_int.eww b/src/hc32f005_ddl/example/wdt/wdt_int/EWARM/wdt_int.eww new file mode 100644 index 0000000..ad24edd --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int/EWARM/wdt_int.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\wdt_int.ewp + + + + + diff --git a/src/hc32f005_ddl/example/wdt/wdt_int/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/wdt/wdt_int/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/wdt/wdt_int/MDK/wdt_int.uvprojx b/src/hc32f005_ddl/example/wdt/wdt_int/MDK/wdt_int.uvprojx new file mode 100644 index 0000000..7dab062 --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int/MDK/wdt_int.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + wdt_int_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + wdt_int + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + wdt_int.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +wdt.c +1..\..\..\..\driver\src\wdt.c + +lpm.c +1..\..\..\..\driver\src\lpm.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/wdt/wdt_int/source/ddl_device.h b/src/hc32f005_ddl/example/wdt/wdt_int/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/wdt/wdt_int/source/main.c b/src/hc32f005_ddl/example/wdt/wdt_int/source/main.c new file mode 100644 index 0000000..34bdbc4 --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int/source/main.c @@ -0,0 +1,175 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2017-05-17 1.0 CJ First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ + +#include "wdt.h" +#include "lpm.h" +#include "gpio.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') + ******************************************************************************/ + +uint8_t u32CountWdt; +uint8_t u8Flag=0xFF; + +static void App_GpioInit(void); +static void App_WdtInit(void); + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + ///< LED 端口初始化 + App_GpioInit(); + + ///< WDT 初始化 + App_WdtInit(); + + ///< 启动 WDT + Wdt_Start(); + + while (1) + { + ///< 开启喂狗后,将不会产生中断 + delay1ms(800); + //Wdt_Feed(); + } +} + + +///< WDT 中断服务程序 +void Wdt_IRQHandler(void) +{ + if(Wdt_GetIrqStatus()) + { + Wdt_IrqClr(); ///<清除 wdt 中断标记 + + u8Flag = ~u8Flag; + if(u8Flag) + { + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); + } + else + { + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); + } + + u32CountWdt++; + } + +} + +static void App_WdtInit(void) +{ + ///< 开启WDT外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralWdt,TRUE); + ///< WDT 初始化 + Wdt_Init(WdtIntEn, WdtT820ms); + ///< 开启NVIC中断 + EnableNvic(WDT_IRQn, IrqLevel3, TRUE); +} + + +static void App_GpioInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + DDL_ZERO_STRUCT(stcGpioCfg); + + ///< 开启GPIO外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); + + ///< LED 初始化 + stcGpioCfg.enDir = GpioDirOut; + Gpio_WriteOutputIO(STK_LED_PORT,STK_LED_PIN,TRUE); + Gpio_Init(STK_LED_PORT,STK_LED_PIN,&stcGpioCfg); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/EWARM/wdt_int_lpm_wakeup.ewp b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/EWARM/wdt_int_lpm_wakeup.ewp new file mode 100644 index 0000000..bb5d3b3 --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/EWARM/wdt_int_lpm_wakeup.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\wdt.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lpm.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/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/EWARM/wdt_int_lpm_wakeup.eww b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/EWARM/wdt_int_lpm_wakeup.eww new file mode 100644 index 0000000..bc0f931 --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/EWARM/wdt_int_lpm_wakeup.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\wdt_int_lpm_wakeup.ewp + + + + + diff --git a/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/MDK/wdt_int_lpm_wakeup.uvprojx b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/MDK/wdt_int_lpm_wakeup.uvprojx new file mode 100644 index 0000000..3086bcb --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/MDK/wdt_int_lpm_wakeup.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + wdt_int_lpm_wakeup_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + wdt_int_lpm_wakeup + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + wdt_int_lpm_wakeup.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +wdt.c +1..\..\..\..\driver\src\wdt.c + +lpm.c +1..\..\..\..\driver\src\lpm.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/source/ddl_device.h b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/source/main.c b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/source/main.c new file mode 100644 index 0000000..f2b4aec --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_int_lpm_wakeup/source/main.c @@ -0,0 +1,230 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2017-05-17 1.0 CJ First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ + +#include "wdt.h" +#include "lpm.h" +#include "gpio.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') + ******************************************************************************/ + +uint8_t u32CountWdt; +uint8_t u8Flag=0xFF; + +static void App_GpioInit(void); +static void App_WdtInit(void); + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + ///< =============================================== + ///< ============ 警告,警告,警告!!!============= + ///< =============================================== + ///< 本样例程序会进入深度休眠模式,因此以下两行代码起防护作用(防止进入深度 + ///< 休眠后芯片调试功能不能再次使用), + ///< 在使用本样例时,禁止在没有唤醒机制的情况下删除以下两行代码。 + delay1ms(2000); + + ///< GPIO 初始化 + App_GpioInit(); + while(TRUE == Gpio_GetInputIO(STK_USER_PORT, STK_USER_PIN)); + + ///< WDT 初始化 + App_WdtInit(); + + ///< 启动 WDT + Wdt_Start(); + + ///< 进入深度休眠模式——使能唤醒后自动休眠特性 + Lpm_GotoDeepSleep(TRUE); + + while (1) + { + ; + } +} + + +///< WDT 中断服务程序 +void Wdt_IRQHandler(void) +{ + if(Wdt_GetIrqStatus()) + { + Wdt_IrqClr(); ///<清除 wdt 中断标记 + + u8Flag = ~u8Flag; + if(u8Flag) + { + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, TRUE); + } + else + { + Gpio_WriteOutputIO(STK_LED_PORT, STK_LED_PIN, FALSE); + } + + u32CountWdt++; + } + +} + +static void App_WdtInit(void) +{ + ///< 开启WDT外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralWdt,TRUE); + ///< WDT 初始化 + Wdt_Init(WdtIntEn, WdtT820ms); + ///< 开启NVIC中断 + EnableNvic(WDT_IRQn, IrqLevel3, TRUE); +} + + + +static void _LowPowerModeGpioSet(void) +{ + ///< 开启GPIO外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); + + //swd as gpio + Sysctrl_SetFunc(SysctrlSWDUseIOEn, TRUE); + + ///< 配置为数字端口 + M0P_GPIO->P0ADS = 0; + M0P_GPIO->P1ADS = 0; + M0P_GPIO->P2ADS = 0; + M0P_GPIO->P3ADS = 0; + + ///< 配置为端口输入(除LED端口外) + M0P_GPIO->P0DIR = 0XFFF7; + M0P_GPIO->P1DIR = 0XFFFF; + M0P_GPIO->P2DIR = 0XFFFF; + M0P_GPIO->P3DIR = 0XFFFF; + + ///< 输入下拉(除KEY端口以外) + M0P_GPIO->P0PD = 0xFFF7; + M0P_GPIO->P1PD = 0xFFFF; + M0P_GPIO->P2PD = 0xFFFF; + M0P_GPIO->P3PD = 0xFFF7; + +} + +static void App_GpioInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + DDL_ZERO_STRUCT(stcGpioCfg); + + ///< 开启GPIO外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); + + _LowPowerModeGpioSet(); + + ///< LED 初始化 + stcGpioCfg.enDir = GpioDirOut; + Gpio_WriteOutputIO(STK_LED_PORT,STK_LED_PIN,TRUE); + Gpio_Init(STK_LED_PORT,STK_LED_PIN,&stcGpioCfg); + + ///< 端口方向配置->输出 + stcGpioCfg.enDir = GpioDirIn; + ///< 端口驱动能力配置->低驱动能力 + stcGpioCfg.enDrv = GpioDrvL; + ///< 端口上下拉配置->上拉 + stcGpioCfg.enPu = GpioPuEnable; + stcGpioCfg.enPd = GpioPdDisable; + ///< 端口开漏输出配置->开漏输出关闭 + stcGpioCfg.enOD = GpioOdDisable; + + ///< GPIO IO USER KEY初始化 + Gpio_Init(STK_USER_PORT, STK_USER_PIN, &stcGpioCfg); + +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/example/wdt/wdt_reset/EWARM/startup_hc32f005.s b/src/hc32f005_ddl/example/wdt/wdt_reset/EWARM/startup_hc32f005.s new file mode 100644 index 0000000..d60d45d --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_reset/EWARM/startup_hc32f005.s @@ -0,0 +1,310 @@ +;******************************************************************************* +; Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +; +; This software is owned and published by: +; Huada Semiconductor Co.,Ltd ("HDSC"). +; +; BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +; BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +; +; This software contains source code for use with HDSC +; components. This software is licensed by HDSC to be adapted only +; for use in systems utilizing HDSC components. HDSC shall not be +; responsible for misuse or illegal use of this software for devices not +; supported herein. HDSC is providing this software "AS IS" and will +; not be responsible for issues arising from incorrect user implementation +; of the software. +; +; Disclaimer: +; HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +; REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +; ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +; WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +; WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +; WARRANTY OF NONINFRINGEMENT. +; HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +; NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +; LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +; LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +; INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +; INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +; SAVINGS OR PROFITS, +; EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +; YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +; INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +; FROM, THE SOFTWARE. +; +; This software may be replicated in part or whole for the licensed use, +; with the restriction that this Disclaimer and Copyright notice must be +; included with each copy of this software, whether used in part or whole, +; at all times. +;/ +;/*****************************************************************************/ +;/* Startup for IAR */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* 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) ; 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 + +; Numbered IRQ handler vectors + +; Note: renaming to device dependent ISR function names are done in + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD Dummy_Handler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + + 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 PORT0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT0_IRQHandler + B PORT0_IRQHandler + + + PUBWEAK PORT1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT1_IRQHandler + B PORT1_IRQHandler + + + PUBWEAK PORT2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT2_IRQHandler + B PORT2_IRQHandler + + + PUBWEAK PORT3_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PORT3_IRQHandler + B PORT3_IRQHandler + + + PUBWEAK Dummy_Handler + SECTION .text:CODE:NOROOT:REORDER(1) +Dummy_Handler + B Dummy_Handler + + + PUBWEAK UART0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART0_IRQHandler + B UART0_IRQHandler + + + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +UART1_IRQHandler + B UART1_IRQHandler + + + + + PUBWEAK SPI_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +SPI_IRQHandler + B SPI_IRQHandler + + + PUBWEAK I2C_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +I2C_IRQHandler + B I2C_IRQHandler + + + PUBWEAK TIM0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM0_IRQHandler + B TIM0_IRQHandler + + + PUBWEAK TIM1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM1_IRQHandler + B TIM1_IRQHandler + + + PUBWEAK TIM2_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM2_IRQHandler + B TIM2_IRQHandler + + + + + PUBWEAK TIM4_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM4_IRQHandler + B TIM4_IRQHandler + + + PUBWEAK TIM5_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM5_IRQHandler + B TIM5_IRQHandler + + + PUBWEAK TIM6_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +TIM6_IRQHandler + B TIM6_IRQHandler + + + PUBWEAK PCA_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +PCA_IRQHandler + B PCA_IRQHandler + + + PUBWEAK WDT_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +WDT_IRQHandler + B WDT_IRQHandler + + + + + PUBWEAK ADC_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +ADC_IRQHandler + B ADC_IRQHandler + + + PUBWEAK VC0_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC0_IRQHandler + B VC0_IRQHandler + + + PUBWEAK VC1_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +VC1_IRQHandler + B VC1_IRQHandler + + + PUBWEAK LVD_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +LVD_IRQHandler + B LVD_IRQHandler + + + PUBWEAK FLASH_RAM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +FLASH_RAM_IRQHandler + B FLASH_RAM_IRQHandler + + + PUBWEAK CLKTRIM_IRQHandler + SECTION .text:CODE:NOROOT:REORDER(1) +CLKTRIM_IRQHandler + B CLKTRIM_IRQHandler + + + END diff --git a/src/hc32f005_ddl/example/wdt/wdt_reset/EWARM/wdt_reset.ewp b/src/hc32f005_ddl/example/wdt/wdt_reset/EWARM/wdt_reset.ewp new file mode 100644 index 0000000..7acccae --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_reset/EWARM/wdt_reset.ewp @@ -0,0 +1,2219 @@ + + + + 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_hc32f005.c + + + $PROJ_DIR$\..\..\..\..\mcu\common\interrupts_hc32f005.c + + + $PROJ_DIR$\startup_hc32f005.s + + + $PROJ_DIR$\..\..\..\..\driver\src\ddl.c + + + + driver + + $PROJ_DIR$\..\..\..\..\driver\src\sysctrl.c + + + $PROJ_DIR$\..\..\..\..\driver\src\wdt.c + + + $PROJ_DIR$\..\..\..\..\driver\src\lpm.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/src/hc32f005_ddl/example/wdt/wdt_reset/EWARM/wdt_reset.eww b/src/hc32f005_ddl/example/wdt/wdt_reset/EWARM/wdt_reset.eww new file mode 100644 index 0000000..fb2ca6f --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_reset/EWARM/wdt_reset.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\wdt_reset.ewp + + + + + diff --git a/src/hc32f005_ddl/example/wdt/wdt_reset/MDK/startup_hc32f005.s b/src/hc32f005_ddl/example/wdt/wdt_reset/MDK/startup_hc32f005.s new file mode 100644 index 0000000..8b56703 --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_reset/MDK/startup_hc32f005.s @@ -0,0 +1,292 @@ +;/****************************************************************************** +;* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +;* +;* This software is owned and published by: +;* Huada Semiconductor Co.,Ltd ("HDSC"). +;* +;* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +;* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +;* +;* This software contains source code for use with HDSC +;* components. This software is licensed by HDSC to be adapted only +;* for use in systems utilizing HDSC components. HDSC shall not be +;* responsible for misuse or illegal use of this software for devices not +;* supported herein. HDSC is providing this software "AS IS" and will +;* not be responsible for issues arising from incorrect user implementation +;* of the software. +;* +;* Disclaimer: +;* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +;* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +;* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +;* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +;* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +;* WARRANTY OF NONINFRINGEMENT. +;* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +;* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +;* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +;* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +;* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +;* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +;* SAVINGS OR PROFITS, +;* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +;* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +;* FROM, THE SOFTWARE. +;* +;* This software may be replicated in part or whole for the licensed use, +;* with the restriction that this Disclaimer and Copyright notice must be +;* included with each copy of this software, whether used in part or whole, +;* at all times. +;*/ +;/*****************************************************************************/ + +;/*****************************************************************************/ +;/* Startup for ARM */ +;/* Version V1.0 */ +;/* Date 2019-03-01 */ +;/* Target-mcu {MCU_PN_H} */ +;/*****************************************************************************/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Stack_Size EQU 0x00000200 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors + DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset + DCD NMI_Handler ; NMI + DCD HardFault_Handler ; Hard Fault + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV + DCD SysTick_Handler ; SysTick + + DCD PORT0_IRQHandler ; + DCD PORT1_IRQHandler ; + DCD PORT2_IRQHandler ; + DCD PORT3_IRQHandler ; + DCD Dummy_Handler ; + DCD Dummy_Handler ; + DCD UART0_IRQHandler ; + DCD UART1_IRQHandler ; + DCD LPUART_IRQHandler ; + DCD Dummy_Handler ; + DCD SPI_IRQHandler ; + DCD Dummy_Handler ; + DCD I2C_IRQHandler ; + DCD Dummy_Handler ; + DCD TIM0_IRQHandler ; + DCD TIM1_IRQHandler ; + DCD TIM2_IRQHandler ; + DCD LPTIM_IRQHandler ; + DCD TIM4_IRQHandler ; + DCD TIM5_IRQHandler ; + DCD TIM6_IRQHandler ; + DCD PCA_IRQHandler ; + DCD WDT_IRQHandler ; + DCD RTC_IRQHandler ; + DCD ADC_IRQHandler ; + DCD Dummy_Handler ; + DCD VC0_IRQHandler ; + DCD VC1_IRQHandler ; + DCD LVD_IRQHandler ; + DCD Dummy_Handler ; + DCD FLASH_RAM_IRQHandler ; + DCD CLKTRIM_IRQHandler ; + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + ;reset NVIC if in rom debug + LDR R0, =0x20000000 + LDR R2, =0x0 + MOVS R1, #0 ; for warning, + ADD R1, PC,#0 ; for A1609W, + CMP R1, R0 + BLS RAMCODE + + ; ram code base address. + ADD R2, R0,R2 +RAMCODE + ; reset Vector table address. + LDR R0, =0xE000ED08 + 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 PORT0_IRQHandler [WEAK] + EXPORT PORT1_IRQHandler [WEAK] + EXPORT PORT2_IRQHandler [WEAK] + EXPORT PORT3_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LPUART_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT SPI_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT TIM0_IRQHandler [WEAK] + EXPORT TIM1_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT LPTIM_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT PCA_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT VC0_IRQHandler [WEAK] + EXPORT VC1_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT Dummy_Handler [WEAK] + EXPORT FLASH_RAM_IRQHandler [WEAK] + EXPORT CLKTRIM_IRQHandler [WEAK] + + +PORT0_IRQHandler +PORT1_IRQHandler +PORT2_IRQHandler +PORT3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LPUART_IRQHandler +SPI_IRQHandler +I2C_IRQHandler +TIM0_IRQHandler +TIM1_IRQHandler +TIM2_IRQHandler +LPTIM_IRQHandler +TIM4_IRQHandler +TIM5_IRQHandler +TIM6_IRQHandler +PCA_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +ADC_IRQHandler +VC0_IRQHandler +VC1_IRQHandler +LVD_IRQHandler +FLASH_RAM_IRQHandler +CLKTRIM_IRQHandler +Dummy_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/src/hc32f005_ddl/example/wdt/wdt_reset/MDK/wdt_reset.uvprojx b/src/hc32f005_ddl/example/wdt/wdt_reset/MDK/wdt_reset.uvprojx new file mode 100644 index 0000000..57b9d57 --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_reset/MDK/wdt_reset.uvprojx @@ -0,0 +1,467 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + wdt_reset_Release + 0x4 + ARM-ADS + 6100001::V6.10.1::.\ARMCLANG + 1 + + + ARMCM0P + ARM + ARM.CMSIS.5.4.0 + http://www.keil.com/pack/ + IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM)) + 0 + $$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h + + + + + + + + + + ./../../../..\mcu\MDK\HC32F005.sfr + 1 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\output\release\ + wdt_reset + 1 + 0 + 1 + 1 + 1 + .\output\release\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 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 + 0x1000 + + + 1 + 0x0 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x1000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 7 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + ..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + wdt_reset.sct + + + --keep=*Handler + + + + + + + + common + + + startup_hc32f005.s + 2 + .\startup_hc32f005.s + + + system_hc32f005.c + 1 + ..\..\..\..\mcu\common\system_hc32f005.c + + + interrupts_hc32f005.c + 1 + ..\..\..\..\mcu\common\interrupts_hc32f005.c + + + + + source + + + main.c + 1 + ..\source\main.c + + + + + driver + + + ddl.c + 1 + ..\..\..\..\driver\src\ddl.c + + + sysctrl.c + 1 + ..\..\..\..\driver\src\sysctrl.c + + +wdt.c +1..\..\..\..\driver\src\wdt.c + +lpm.c +1..\..\..\..\driver\src\lpm.c + +gpio.c +1..\..\..\..\driver\src\gpio.c + + + + + ::CMSIS + + + README + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/hc32f005_ddl/example/wdt/wdt_reset/source/ddl_device.h b/src/hc32f005_ddl/example/wdt/wdt_reset/source/ddl_device.h new file mode 100644 index 0000000..6c47316 --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_reset/source/ddl_device.h @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file ddl_device.h + ** + ** Device define + ** @link SampleGroup Some description @endlink + ** + ** - 2018-04-15 + ** + *****************************************************************************/ + +#ifndef __DDL_DEVICE_H__ +#define __DDL_DEVICE_H__ + +/** + ******************************************************************************* + ** \brief Global device series definition + ** + ** \note + ******************************************************************************/ +#define DDL_MCU_SERIES DDL_DEVICE_SERIES_HC32F005 + + +/** + ******************************************************************************* + ** \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/src/hc32f005_ddl/example/wdt/wdt_reset/source/main.c b/src/hc32f005_ddl/example/wdt/wdt_reset/source/main.c new file mode 100644 index 0000000..7da7ab6 --- /dev/null +++ b/src/hc32f005_ddl/example/wdt/wdt_reset/source/main.c @@ -0,0 +1,148 @@ +/****************************************************************************** +* 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 main.c + ** + ** A detailed description is available at + ** @link Sample Group Some description @endlink + ** + ** - 2017-05-17 1.0 CJ First version for Device Driver Library of Module. + ** + ******************************************************************************/ + +/****************************************************************************** + * Include files + ******************************************************************************/ + +#include "wdt.h" +#include "lpm.h" +#include "gpio.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') + ******************************************************************************/ +static void App_GpioInit(void); +static void App_WdtInit(void); + +/** + ****************************************************************************** + ** \brief Main function of project + ** + ** \return uint32_t return value, if needed + ** + ** This sample + ** + ******************************************************************************/ +int32_t main(void) +{ + ///< LED 端口初始化 + App_GpioInit(); + + ///< WDT 初始化 + App_WdtInit(); + + ///< 启动 WDT + Wdt_Start(); + + while (1) + { + ///< 开启喂狗后,将不会产生复位 + delay1ms(800); + //Wdt_Feed(); // 喂狗 + Gpio_WriteOutputIO(STK_LED_PORT,STK_LED_PIN,FALSE); + } +} + + +static void App_WdtInit(void) +{ + ///< 开启WDT外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralWdt,TRUE); + ///< WDT 初始化 + Wdt_Init(WdtResetEn, WdtT820ms); +} + + +static void App_GpioInit(void) +{ + stc_gpio_cfg_t stcGpioCfg; + + DDL_ZERO_STRUCT(stcGpioCfg); + + ///< 开启GPIO外设时钟 + Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); + + ///< LED 初始化 + stcGpioCfg.enDir = GpioDirOut; + Gpio_WriteOutputIO(STK_LED_PORT,STK_LED_PIN,TRUE); + Gpio_Init(STK_LED_PORT,STK_LED_PIN,&stcGpioCfg); +} + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ + + diff --git a/src/hc32f005_ddl/hc32f005_example_list.pdf b/src/hc32f005_ddl/hc32f005_example_list.pdf new file mode 100644 index 0000000..074f819 Binary files /dev/null and b/src/hc32f005_ddl/hc32f005_example_list.pdf differ diff --git a/src/hc32f005_ddl/mcu/EWARM/HC32F005.svd b/src/hc32f005_ddl/mcu/EWARM/HC32F005.svd new file mode 100644 index 0000000..414b424 --- /dev/null +++ b/src/hc32f005_ddl/mcu/EWARM/HC32F005.svd @@ -0,0 +1,9997 @@ + + + HDSC Co.Ltd + HDSC + HDSC_HC32F005 + 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 + + + + + + + ADTIM4 + desc ADTIM + 0x40003000 + + 0x0 + 0x400 + + + + CNTER + desc CNTER + 0x0 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PERAR + desc PERAR + 0x4 + 32 + read-write + 0xFFFF + 0xFFFF + + + PERA + desc PERA + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PERBR + desc PERBR + 0x8 + 32 + read-write + 0xFFFF + 0xFFFF + + + PERB + desc PERB + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + GCMAR + desc GCMAR + 0x10 + 32 + read-write + 0xFFFF + 0xFFFF + + + GCMA + desc GCMA + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + GCMBR + desc GCMBR + 0x14 + 32 + read-write + 0xFFFF + 0xFFFF + + + GCMB + desc GCMB + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + GCMCR + desc GCMCR + 0x18 + 32 + read-write + 0xFFFF + 0xFFFF + + + GCMC + desc GCMC + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + GCMDR + desc GCMDR + 0x1C + 32 + read-write + 0xFFFF + 0xFFFF + + + GCMD + desc GCMD + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DTUAR + desc DTUAR + 0x40 + 32 + read-write + 0xFFFF + 0xFFFF + + + DTUA + desc DTUA + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DTDAR + desc DTDAR + 0x44 + 32 + read-write + 0xFFFF + 0xFFFF + + + DTDA + desc DTDA + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + GCONR + desc GCONR + 0x50 + 32 + read-write + 0x100 + 0xF017F + + + START + desc START + 0 + 0 + read-write + + + MODE + desc MODE + 3 + 1 + read-write + + + CKDIV + desc CKDIV + 6 + 4 + read-write + + + DIR + desc DIR + 8 + 8 + read-write + + + ZMSKREV + desc ZMSKREV + 16 + 16 + read-write + + + ZMSKPOS + desc ZMSKPOS + 17 + 17 + read-write + + + ZMSK + desc ZMSK + 19 + 18 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICONR + desc ICONR + 0x54 + 32 + read-write + 0x0 + 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 + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PCONR + desc PCONR + 0x58 + 32 + read-write + 0x0 + 0x1FFF1FFF + + + CAPCA + desc CAPCA + 0 + 0 + read-write + + + STACA + desc STACA + 1 + 1 + read-write + + + STPCA + desc STPCA + 2 + 2 + read-write + + + STASTPSA + desc STASTPSA + 3 + 3 + read-write + + + CMPCA + desc CMPCA + 5 + 4 + read-write + + + PERCA + desc PERCA + 7 + 6 + read-write + + + OUTENA + desc OUTENA + 8 + 8 + read-write + + + DISSELA + desc DISSELA + 10 + 9 + read-write + + + DISVALA + desc DISVALA + 12 + 11 + read-write + + + CAPCB + desc CAPCB + 16 + 16 + read-write + + + STACB + desc STACB + 17 + 17 + read-write + + + STPCB + desc STPCB + 18 + 18 + read-write + + + STASTPSB + desc STASTPSB + 19 + 19 + read-write + + + CMPCB + desc CMPCB + 21 + 20 + read-write + + + PERCB + desc PERCB + 23 + 22 + read-write + + + OUTENB + desc OUTENB + 24 + 24 + read-write + + + DISSELB + desc DISSELB + 26 + 25 + read-write + + + DISVALB + desc DISVALB + 28 + 27 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + BCONR + desc BCONR + 0x5C + 32 + read-write + 0x0 + 0x105 + + + BENA + desc BENA + 0 + 0 + read-write + + + BENB + desc BENB + 2 + 2 + read-write + + + BENP + desc BENP + 8 + 8 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DCONR + desc DCONR + 0x60 + 32 + read-write + 0x0 + 0x101 + + + DTCEN + desc DTCEN + 0 + 0 + read-write + + + SEPA + desc SEPA + 8 + 8 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + FCONR + desc FCONR + 0x68 + 32 + read-write + 0x0 + 0x77770077 + + + NOFIENGA + desc NOFIENGA + 0 + 0 + read-write + + + NOFICKGA + desc NOFICKGA + 2 + 1 + read-write + + + NOFIENGB + desc NOFIENGB + 4 + 4 + read-write + + + NOFICKGB + desc NOFICKGB + 6 + 5 + read-write + + + NOFIENTA + desc NOFIENTA + 16 + 16 + read-write + + + NOFICKTA + desc NOFICKTA + 18 + 17 + read-write + + + NOFIENTB + desc NOFIENTB + 20 + 20 + read-write + + + NOFICKTB + desc NOFICKTB + 22 + 21 + read-write + + + NOFIENTC + desc NOFIENTC + 24 + 24 + read-write + + + NOFICKTC + desc NOFICKTC + 26 + 25 + read-write + + + NOFIENTD + desc NOFIENTD + 28 + 28 + read-write + + + NOFICKTD + desc NOFICKTD + 30 + 29 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + VPERR + desc VPERR + 0x6C + 32 + read-write + 0x0 + 0x1F000F + + + GEPERIA + desc GEPERIA + 0 + 0 + read-write + + + GEPERIB + desc GEPERIB + 1 + 1 + read-write + + + GEPERIC + desc GEPERIC + 2 + 2 + read-write + + + GEPERID + desc GEPERID + 3 + 3 + read-write + + + PCNTE + desc PCNTE + 17 + 16 + read-write + + + PCNTS + desc PCNTS + 20 + 18 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + STFLR + desc STFLR + 0x70 + 32 + read-write + 0x0 + 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 + + + RSV + desc RSV + 31 + 31 + read-write + + + + + HCPBR + desc HCPBR + 0x84 + 32 + read-write + 0x0 + 0xFFFF + + + HCPB0 + desc HCPB0 + 0 + 0 + read-write + + + HCPB1 + desc HCPB1 + 1 + 1 + read-write + + + HCPB2 + desc HCPB2 + 2 + 2 + read-write + + + HCPB3 + desc HCPB3 + 3 + 3 + read-write + + + HCPB4 + desc HCPB4 + 4 + 4 + read-write + + + HCPB5 + desc HCPB5 + 5 + 5 + read-write + + + HCPB6 + desc HCPB6 + 6 + 6 + read-write + + + HCPB7 + desc HCPB7 + 7 + 7 + read-write + + + HCPB8 + desc HCPB8 + 8 + 8 + read-write + + + HCPB9 + desc HCPB9 + 9 + 9 + read-write + + + HCPB10 + desc HCPB10 + 10 + 10 + read-write + + + HCPB11 + desc HCPB11 + 11 + 11 + read-write + + + HCPB12 + desc HCPB12 + 12 + 12 + read-write + + + HCPB13 + desc HCPB13 + 13 + 13 + read-write + + + HCPB14 + desc HCPB14 + 14 + 14 + read-write + + + HCPB15 + desc HCPB15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + HCUPR + desc HCUPR + 0x88 + 32 + read-write + 0x0 + 0xFFFFF + + + HCUP0 + desc HCUP0 + 0 + 0 + read-write + + + HCUP1 + desc HCUP1 + 1 + 1 + read-write + + + HCUP2 + desc HCUP2 + 2 + 2 + read-write + + + HCUP3 + desc HCUP3 + 3 + 3 + read-write + + + HCUP4 + desc HCUP4 + 4 + 4 + read-write + + + HCUP5 + desc HCUP5 + 5 + 5 + read-write + + + HCUP6 + desc HCUP6 + 6 + 6 + read-write + + + HCUP7 + desc HCUP7 + 7 + 7 + read-write + + + HCUP8 + desc HCUP8 + 8 + 8 + read-write + + + HCUP9 + desc HCUP9 + 9 + 9 + read-write + + + HCUP10 + desc HCUP10 + 10 + 10 + read-write + + + HCUP11 + desc HCUP11 + 11 + 11 + read-write + + + HCUP12 + desc HCUP12 + 12 + 12 + read-write + + + HCUP13 + desc HCUP13 + 13 + 13 + read-write + + + HCUP14 + desc HCUP14 + 14 + 14 + read-write + + + HCUP15 + desc HCUP15 + 15 + 15 + read-write + + + HCUP16 + desc HCUP16 + 16 + 16 + read-write + + + HCUP17 + desc HCUP17 + 17 + 17 + read-write + + + HCUP18 + desc HCUP18 + 18 + 18 + read-write + + + HCUP19 + desc HCUP19 + 19 + 19 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + HCDOR + desc HCDOR + 0x8C + 32 + read-write + 0x0 + 0xFFFFF + + + HCDO0 + desc HCDO0 + 0 + 0 + read-write + + + HCDO1 + desc HCDO1 + 1 + 1 + read-write + + + HCDO2 + desc HCDO2 + 2 + 2 + read-write + + + HCDO3 + desc HCDO3 + 3 + 3 + read-write + + + HCDO4 + desc HCDO4 + 4 + 4 + read-write + + + HCDO5 + desc HCDO5 + 5 + 5 + read-write + + + HCDO6 + desc HCDO6 + 6 + 6 + read-write + + + HCDO7 + desc HCDO7 + 7 + 7 + read-write + + + HCDO8 + desc HCDO8 + 8 + 8 + read-write + + + HCDO9 + desc HCDO9 + 9 + 9 + read-write + + + HCDO10 + desc HCDO10 + 10 + 10 + read-write + + + HCDO11 + desc HCDO11 + 11 + 11 + read-write + + + HCDO12 + desc HCDO12 + 12 + 12 + read-write + + + HCDO13 + desc HCDO13 + 13 + 13 + read-write + + + HCDO14 + desc HCDO14 + 14 + 14 + read-write + + + HCDO15 + desc HCDO15 + 15 + 15 + read-write + + + HCDO16 + desc HCDO16 + 16 + 16 + read-write + + + HCDO17 + desc HCDO17 + 17 + 17 + read-write + + + HCDO18 + desc HCDO18 + 18 + 18 + read-write + + + HCDO19 + desc HCDO19 + 19 + 19 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x100 + 32 + read-only + 0x0 + 0xC1CF + + + CMAF + desc CMAF + 0 + 0 + read-only + + + CMBF + desc CMBF + 1 + 1 + read-only + + + CMCF + desc CMCF + 2 + 2 + read-only + + + CMDF + desc CMDF + 3 + 3 + read-only + + + OVFF + desc OVFF + 6 + 6 + read-only + + + UDFF + desc UDFF + 7 + 7 + read-only + + + DTEF + desc DTEF + 8 + 8 + read-only + + + SAMLF + desc SAMLF + 14 + 14 + read-only + + + SAMHF + desc SAMHF + 15 + 15 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x104 + 32 + write-only + 0x0 + 0xC1CF + + + CMAC + desc CMAC + 0 + 0 + write-only + + + CMBC + desc CMBC + 1 + 1 + write-only + + + CMCC + desc CMCC + 2 + 2 + write-only + + + CMDC + desc CMDC + 3 + 3 + write-only + + + OVFC + desc OVFC + 6 + 6 + write-only + + + UDFC + desc UDFC + 7 + 7 + write-only + + + DTEC + desc DTEC + 8 + 8 + write-only + + + SAMLC + desc SAMLC + 14 + 14 + write-only + + + SAMHC + desc SAMHC + 15 + 15 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CR + desc CR + 0x108 + 32 + read-write + 0x300 + 0x79FFCF + + + CMAE + desc CMAE + 0 + 0 + read-write + + + CMBE + desc CMBE + 1 + 1 + read-write + + + CMCE + desc CMCE + 2 + 2 + read-write + + + CMDE + desc CMDE + 3 + 3 + read-write + + + OVFE + desc OVFE + 6 + 6 + read-write + + + UDFE + desc UDFE + 7 + 7 + read-write + + + DITENA + desc DITENA + 8 + 8 + read-write + + + DITENB + desc DITENB + 9 + 9 + read-write + + + DITENS + desc DITENS + 10 + 10 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + AOSSR + desc AOSSR + 0x110 + 32 + read-write + 0x0 + 0x3F9F + + + FBRAKE + desc FBRAKE + 0 + 0 + read-only + + + FSAME + desc FSAME + 1 + 1 + read-only + + + BFILTS + desc BFILTS + 3 + 2 + read-write + + + BFILTEN + desc BFILTEN + 4 + 4 + read-write + + + SOFTBK + desc SOFTBK + 7 + 7 + read-write + + + SML0 + desc SML0 + 8 + 8 + read-write + + + SML1 + desc SML1 + 9 + 9 + read-write + + + SML2 + desc SML2 + 10 + 10 + read-write + + + SMH0 + desc SMH0 + 11 + 11 + read-write + + + SMH1 + desc SMH1 + 12 + 12 + read-write + + + SMH2 + desc SMH2 + 13 + 13 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + AOSCL + desc AOSCL + 0x114 + 32 + write-only + 0x0 + 0x3 + + + FBRAKE + desc FBRAKE + 0 + 0 + write-only + + + FSAME + desc FSAME + 1 + 1 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PTBKS + desc PTBKS + 0x118 + 32 + read-write + 0x0 + 0xFFFF + + + EN0 + desc EN0 + 0 + 0 + read-write + + + EN1 + desc EN1 + 1 + 1 + read-write + + + EN2 + desc EN2 + 2 + 2 + read-write + + + EN3 + desc EN3 + 3 + 3 + read-write + + + EN4 + desc EN4 + 4 + 4 + read-write + + + EN5 + desc EN5 + 5 + 5 + read-write + + + EN6 + desc EN6 + 6 + 6 + read-write + + + EN7 + desc EN7 + 7 + 7 + read-write + + + EN8 + desc EN8 + 8 + 8 + read-write + + + EN9 + desc EN9 + 9 + 9 + read-write + + + EN10 + desc EN10 + 10 + 10 + read-write + + + EN11 + desc EN11 + 11 + 11 + read-write + + + EN12 + desc EN12 + 12 + 12 + read-write + + + EN13 + desc EN13 + 13 + 13 + read-write + + + EN14 + desc EN14 + 14 + 14 + read-write + + + EN15 + desc EN15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + TTRIG + desc TTRIG + 0x11C + 32 + read-write + 0x0 + 0xFFFF + + + TRIGAS + desc TRIGAS + 3 + 0 + read-write + + + TRIGBS + desc TRIGBS + 7 + 4 + read-write + + + TRIGCS + desc TRIGCS + 11 + 8 + read-write + + + TRIGDS + desc TRIGDS + 15 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ITRIG + desc ITRIG + 0x120 + 32 + read-write + 0x0 + 0xFFFF + + + IAOS0S + desc IAOS0S + 3 + 0 + read-write + + + IAOS1S + desc IAOS1S + 7 + 4 + read-write + + + IAOS2S + desc IAOS2S + 11 + 8 + read-write + + + IAOS3S + desc IAOS3S + 15 + 12 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PTBKP + desc PTBKP + 0x124 + 32 + read-write + 0x0 + 0xFFFF + + + POL0 + desc POL0 + 0 + 0 + read-write + + + POL1 + desc POL1 + 1 + 1 + read-write + + + POL2 + desc POL2 + 2 + 2 + read-write + + + POL3 + desc POL3 + 3 + 3 + read-write + + + POL4 + desc POL4 + 4 + 4 + read-write + + + POL5 + desc POL5 + 5 + 5 + read-write + + + POL6 + desc POL6 + 6 + 6 + read-write + + + POL7 + desc POL7 + 7 + 7 + read-write + + + POL8 + desc POL8 + 8 + 8 + read-write + + + POL9 + desc POL9 + 9 + 9 + read-write + + + POL10 + desc POL10 + 10 + 10 + read-write + + + POL11 + desc POL11 + 11 + 11 + read-write + + + POL12 + desc POL12 + 12 + 12 + read-write + + + POL13 + desc POL13 + 13 + 13 + read-write + + + POL14 + desc POL14 + 14 + 14 + read-write + + + POL15 + desc POL15 + 15 + 15 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SSTAR + desc SSTAR + 0x3F4 + 32 + read-write + 0x0 + 0x7 + + + SSTA0 + desc SSTA0 + 0 + 0 + read-write + + + SSTA1 + desc SSTA1 + 1 + 1 + read-write + + + SSTA2 + desc SSTA2 + 2 + 2 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SSTPR + desc SSTPR + 0x3F8 + 32 + read-write + 0x0 + 0x7 + + + SSTP0 + desc SSTP0 + 0 + 0 + read-write + + + SSTP1 + desc SSTP1 + 1 + 1 + read-write + + + SSTP2 + desc SSTP2 + 2 + 2 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SCLRR + desc SCLRR + 0x3FC + 32 + read-write + 0x0 + 0x7 + + + SCLR0 + desc SCLR0 + 0 + 0 + read-write + + + SCLR1 + desc SCLR1 + 1 + 1 + read-write + + + SCLR2 + desc SCLR2 + 2 + 2 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + ADTIM5 + desc ADTIM + 0x40003400 + + 0x0 + 0x400 + + + + ADTIM6 + desc ADTIM + 0x40003800 + + 0x0 + 0x400 + + + + BGR + desc BGR + 0x40002400 + ADC + + 0x0 + 0x4 + + + + CR + desc CR + 0x0 + 32 + read-write + 0x0 + 0x3 + + + BGR_EN + desc BGR_EN + 0 + 0 + read-write + + + TS_EN + desc TS_EN + 1 + 1 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + CLK_TRIM + desc CLK_TRIM + 0x40001800 + + 0x0 + 0x1C + + + + CR + desc CR + 0x0 + 32 + read-write + 0x0 + 0xFF + + + TRIM_START + desc TRIM_START + 0 + 0 + read-write + + + REFCLK_SEL + desc REFCLK_SEL + 3 + 1 + read-write + + + CALCLK_SEL + desc CALCLK_SEL + 5 + 4 + read-write + + + MON_EN + desc MON_EN + 6 + 6 + read-write + + + IE + desc IE + 7 + 7 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + REFCON + desc REFCON + 0x4 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + RCNTVAL + desc RCNTVAL + 31 + 0 + read-write + + + + + REFCNT + desc REFCNT + 0x8 + 32 + read-only + 0x0 + 0xFFFFFFFF + + + REFCNT + desc REFCNT + 31 + 0 + read-only + + + + + CALCNT + desc CALCNT + 0xC + 32 + read-only + 0x0 + 0xFFFFFFFF + + + CALCNT + desc CALCNT + 31 + 0 + read-only + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0xF + + + STOP + desc STOP + 0 + 0 + read-only + + + CALCNT_OF + desc CALCNT_OF + 1 + 1 + read-only + + + XTH_FAULT + desc XTH_FAULT + 3 + 3 + read-only + + + RSV + desc RSV + 31 + 31 + read-only + + + + + ICLR + desc ICLR + 0x14 + 32 + read-write + 0xC + 0xC + + + XTH_FAULT_CLR + desc XTH_FAULT_CLR + 3 + 3 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CALCON + desc CALCON + 0x18 + 32 + read-write + 0xFFFFFFFF + 0xFFFFFFFF + + + CCNTVAL + desc CCNTVAL + 31 + 0 + read-write + + + + + + + CRC + desc CRC + 0x40020900 + + 0x0 + 0x100 + + + + 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 + + + + + + + DEBUG_ACTIVE + desc DEBUG_ACTIVE + 0x40002038 + + 0x0 + 0x4 + + + + DEBUG_ACTIVE + desc DEBUG_ACTIVE + 0x0 + 32 + read-write + 0xFFF + 0xFFF + + + TIM0 + desc TIM0 + 0 + 0 + read-write + + + TIM1 + desc TIM1 + 1 + 1 + read-write + + + TIM2 + desc TIM2 + 2 + 2 + read-write + + + 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 + + + TIM3 + desc TIM3 + 11 + 11 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + FLASH + desc FLASH + 0x40020000 + + 0x0 + 0x34 + + + + TNVS + desc TNVS + 0x0 + 32 + read-write + 0x20 + 0x1FF + + + TNVS + desc TNVS + 8 + 0 + read-write + + + RSV + desc RSV + 31 + 9 + read-write + + + + + TPGS + desc TPGS + 0x4 + 32 + read-write + 0x17 + 0xFF + + + TPGS + desc TPGS + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 8 + read-write + + + + + TPROG + desc TPROG + 0x8 + 32 + read-write + 0x1B + 0xFF + + + TPROG + desc TPROG + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 9 + read-write + + + + + TSERASE + desc TSERASE + 0xC + 32 + read-write + 0x4650 + 0x3FFFF + + + TSERASE + desc TSERASE + 17 + 0 + read-write + + + RSV + desc RSV + 31 + 18 + read-write + + + + + TMERASE + desc TMERASE + 0x10 + 32 + read-write + 0x222E0 + 0x1FFFFF + + + TMERASE + desc TMERASE + 20 + 0 + read-write + + + RSV + desc RSV + 31 + 21 + read-write + + + + + TPRCV + desc TPRCV + 0x14 + 32 + read-write + 0x18 + 0xFFF + + + TPRCV + desc TPRCV + 11 + 0 + read-write + + + RSV + desc RSV + 31 + 12 + read-write + + + + + TSRCV + desc TSRCV + 0x18 + 32 + read-write + 0xF0 + 0xFFF + + + TSRCV + desc TSRCV + 11 + 0 + read-write + + + RSV + desc RSV + 31 + 12 + read-write + + + + + TMRCV + desc TMRCV + 0x1C + 32 + read-write + 0x3E8 + 0x1FFF + + + TMRCV + desc TMRCV + 12 + 0 + read-write + + + RSV + desc RSV + 31 + 14 + read-write + + + + + CR + desc CR + 0x20 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + OP + desc OP + 1 + 0 + read-write + + + WAIT + desc WAIT + 2 + 2 + read-write + + + BUSY + desc BUSY + 4 + 4 + read-only + + + IE + desc IE + 6 + 5 + read-write + + + RSV + desc RSV + 31 + 10 + read-write + + + + + IFR + desc IFR + 0x24 + 32 + read-only + 0x0 + 0x3 + + + IF0 + desc IF0 + 0 + 0 + read-only + + + IF1 + desc IF1 + 1 + 1 + read-only + + + RSV + desc RSV + 31 + 2 + read-write + + + + + ICLR + desc ICLR + 0x28 + 32 + write-only + 0x3 + 0xFFFFFFFF + + + ICLR0 + desc ICLR0 + 0 + 0 + write-only + + + ICLR1 + desc ICLR1 + 1 + 1 + write-only + + + RSV + desc RSV + 31 + 2 + read-write + + + + + BYPASS + desc BYPASS + 0x2C + 32 + write-only + 0x0 + 0xFFFF + + + BYSEQ + desc BYSEQ + 15 + 0 + write-only + + + RSV + desc RSV + 31 + 16 + read-write + + + + + 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 + + + RSV + desc RSV + 31 + 31 + read-write + + + + + TM + desc TM + 0x4 + 32 + read-write + 0x0 + 0xFF + + + TM + desc TM + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CR + desc CR + 0x8 + 32 + read-write + 0x0 + 0x7D + + + H1M + desc H1M + 0 + 0 + read-write + + + AA + desc AA + 2 + 2 + read-write + + + SI + desc SI + 3 + 3 + read-write + + + STO + desc STO + 4 + 4 + read-write + + + STA + desc STA + 5 + 5 + read-write + + + ENS + desc ENS + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DATA + desc DATA + 0xC + 32 + read-write + 0x0 + 0xFF + + + DAT + desc DAT + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ADDR + desc ADDR + 0x10 + 32 + read-write + 0x0 + 0xFF + + + GC + desc GC + 0 + 0 + read-write + + + ADR + desc ADR + 7 + 1 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + STAT + desc STAT + 0x14 + 32 + read-only + 0x0 + 0xFF + + + STA + desc STA + 7 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + 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 + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x2C + 32 + read-write + 0x0 + 0x1 + + + INTF + desc INTF + 0 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + 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 + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CMOD + desc CMOD + 0x4 + 32 + read-write + 0x0 + 0xCF + + + CFIE + desc CFIE + 0 + 0 + read-write + + + CPS + desc CPS + 3 + 1 + read-write + + + WDTE + desc WDTE + 6 + 6 + read-write + + + CIDL + desc CIDL + 7 + 7 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT + desc CNT + 0x8 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0xC + 32 + write-only + 0x9F + 0x9F + + + CCF0 + desc CCF0 + 0 + 0 + write-only + + + CCF1 + desc CCF1 + 1 + 1 + write-only + + + CCF2 + desc CCF2 + 2 + 2 + write-only + + + CCF3 + desc CCF3 + 3 + 3 + write-only + + + CCF4 + desc CCF4 + 4 + 4 + write-only + + + CF + desc CF + 7 + 7 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAPM0 + desc CCAPM0 + 0x10 + 32 + read-write + 0x0 + 0x7F + + + CCIE + desc CCIE + 0 + 0 + read-write + + + PWM + desc PWM + 1 + 1 + read-write + + + TOG + desc TOG + 2 + 2 + read-write + + + MAT + desc MAT + 3 + 3 + read-write + + + CAPN + desc CAPN + 4 + 4 + read-write + + + CAPP + desc CAPP + 5 + 5 + read-write + + + ECOM + desc ECOM + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAPM1 + desc CCAPM1 + 0x14 + 32 + read-write + 0x0 + 0x7F + + + CCIE + desc CCIE + 0 + 0 + read-write + + + PWM + desc PWM + 1 + 1 + read-write + + + TOG + desc TOG + 2 + 2 + read-write + + + MAT + desc MAT + 3 + 3 + read-write + + + CAPN + desc CAPN + 4 + 4 + read-write + + + CAPP + desc CAPP + 5 + 5 + read-write + + + ECOM + desc ECOM + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAPM2 + desc CCAPM2 + 0x18 + 32 + read-write + 0x0 + 0x7F + + + CCIE + desc CCIE + 0 + 0 + read-write + + + PWM + desc PWM + 1 + 1 + read-write + + + TOG + desc TOG + 2 + 2 + read-write + + + MAT + desc MAT + 3 + 3 + read-write + + + CAPN + desc CAPN + 4 + 4 + read-write + + + CAPP + desc CAPP + 5 + 5 + read-write + + + ECOM + desc ECOM + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAPM3 + desc CCAPM3 + 0x1C + 32 + read-write + 0x0 + 0x7F + + + CCIE + desc CCIE + 0 + 0 + read-write + + + PWM + desc PWM + 1 + 1 + read-write + + + TOG + desc TOG + 2 + 2 + read-write + + + MAT + desc MAT + 3 + 3 + read-write + + + CAPN + desc CAPN + 4 + 4 + read-write + + + CAPP + desc CAPP + 5 + 5 + read-write + + + ECOM + desc ECOM + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAPM4 + desc CCAPM4 + 0x20 + 32 + read-write + 0x0 + 0x7F + + + CCIE + desc CCIE + 0 + 0 + read-write + + + PWM + desc PWM + 1 + 1 + read-write + + + TOG + desc TOG + 2 + 2 + read-write + + + MAT + desc MAT + 3 + 3 + read-write + + + CAPN + desc CAPN + 4 + 4 + read-write + + + CAPP + desc CAPP + 5 + 5 + read-write + + + ECOM + desc ECOM + 6 + 6 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP0H + desc CCAP0H + 0x24 + 32 + read-write + 0x0 + 0xFF + + + CCAP0 + desc CCAP0 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP0L + desc CCAP0L + 0x28 + 32 + read-write + 0x0 + 0xFF + + + CCAP0 + desc CCAP0 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP1H + desc CCAP1H + 0x2C + 32 + read-write + 0x0 + 0xFF + + + CCAP1 + desc CCAP1 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP1L + desc CCAP1L + 0x30 + 32 + read-write + 0x0 + 0xFF + + + CCAP1 + desc CCAP1 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP2H + desc CCAP2H + 0x34 + 32 + read-write + 0x0 + 0xFF + + + CCAP2 + desc CCAP2 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP2L + desc CCAP2L + 0x38 + 32 + read-write + 0x0 + 0xFF + + + CCAP2 + desc CCAP2 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP3H + desc CCAP3H + 0x3C + 32 + read-write + 0x0 + 0xFF + + + CCAP3 + desc CCAP3 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP3L + desc CCAP3L + 0x40 + 32 + read-write + 0x0 + 0xFF + + + CCAP3 + desc CCAP3 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP4H + desc CCAP4H + 0x44 + 32 + read-write + 0x0 + 0xFF + + + CCAP4 + desc CCAP4 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP4L + desc CCAP4L + 0x48 + 32 + read-write + 0x0 + 0xFF + + + CCAP4 + desc CCAP4 + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAPO + desc CCAPO + 0x4C + 32 + read-write + 0x0 + 0x1F + + + CCAPO0 + desc CCAPO0 + 0 + 0 + read-write + + + CCAPO1 + desc CCAPO1 + 1 + 1 + read-write + + + CCAPO2 + desc CCAPO2 + 2 + 2 + read-write + + + CCAPO3 + desc CCAPO3 + 3 + 3 + read-write + + + CCAPO4 + desc CCAPO4 + 4 + 4 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP0 + desc CCAP0 + 0x50 + 32 + read-write + 0x0 + 0xFFFF + + + CCAP0 + desc CCAP0 + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP1 + desc CCAP1 + 0x54 + 32 + read-write + 0x0 + 0xFFFF + + + CCAP1 + desc CCAP1 + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP2 + desc CCAP2 + 0x58 + 32 + read-write + 0x0 + 0xFFFF + + + CCAP2 + desc CCAP2 + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP3 + desc CCAP3 + 0x5C + 32 + read-write + 0x0 + 0xFFFF + + + CCAP3 + desc CCAP3 + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CCAP4 + desc CCAP4 + 0x60 + 32 + read-write + 0x0 + 0xFFFF + + + CCAP4 + desc CCAP4 + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + 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 + + + + + PERI_RESET + desc PERI_RESET + 0xC + 32 + read-write + 0xFFFFFFFF + 0xBFFF7FFF + + + 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 + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SSN + desc SSN + 0x4 + 32 + read-write + 0x1 + 0x1 + + + SSN + desc SSN + 0 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + STAT + desc STAT + 0x8 + 32 + read-only + 0x0 + 0xBE + + + 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 + + + RSV + desc RSV + 31 + 31 + read-write + + + + + DATA + desc DATA + 0xC + 32 + read-write + 0x0 + 0xFF + + + DAT + desc DAT + 7 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + SYSCTRL + desc SYSCTRL + 0x40002000 + + 0x0 + 0x54 + + + + SYSCTRL0 + desc SYSCTRL0 + 0x0 + 32 + read-write + 0x1 + 0x9FFF + + + RCH_EN + desc RCH_EN + 0 + 0 + read-write + + + XTH_EN + desc XTH_EN + 1 + 1 + read-write + + + RCL_EN + desc RCL_EN + 2 + 2 + read-write + + + CLKSW + desc CLKSW + 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 + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SYSCTRL1 + desc SYSCTRL1 + 0x4 + 32 + read-write + 0x8 + 0xF7E + + + EXTH_EN + desc EXTH_EN + 1 + 1 + read-write + + + EXTL_EN + desc EXTL_EN + 2 + 2 + read-write + + + XTL_ALWAYS_ON + desc XTL_ALWAYS_ON + 3 + 3 + read-write + + + CLOCK_FT_EN + desc CLOCK_FT_EN + 4 + 4 + read-write + + + RTC_LPW + desc RTC_LPW + 5 + 5 + read-write + + + LOCKUP_EN + desc LOCKUP_EN + 6 + 6 + read-write + + + RES_UIO + desc RES_UIO + 7 + 7 + read-write + + + SWD_USE_IO + desc SWD_USE_IO + 8 + 8 + read-write + + + RTC_FREQ_ADJUST + desc RTC_FREQ_ADJUST + 11 + 9 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + SYSCTRL2 + desc SYSCTRL2 + 0x8 + 32 + write-only + 0x0 + 0xFFFF + + + SYSCTRL2 + desc SYSCTRL2 + 15 + 0 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + RCH_CR + desc RCH_CR + 0xC + 32 + read-write + 0x126 + 0xFFF + + + TRIM + desc TRIM + 10 + 0 + read-write + + + STABLE + desc STABLE + 11 + 11 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + XTH_CR + desc XTH_CR + 0x10 + 32 + read-write + 0x22 + 0x7F + + + DRIVER + desc DRIVER + 1 + 0 + read-write + + + XTH_FSEL + desc XTH_FSEL + 3 + 2 + read-write + + + STARTUP + desc STARTUP + 5 + 4 + read-write + + + STABLE + desc STABLE + 6 + 6 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + RCL_CR + desc RCL_CR + 0x14 + 32 + read-write + 0x33F + 0x1FFF + + + TRIM + desc TRIM + 9 + 0 + read-write + + + STARTUP + desc STARTUP + 11 + 10 + read-write + + + STABLE + desc STABLE + 12 + 12 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + XTL_CR + desc XTL_CR + 0x18 + 32 + read-write + 0x21 + 0x7F + + + DRIVER + desc DRIVER + 1 + 0 + read-write + + + AMP_SEL + desc AMP_SEL + 3 + 2 + read-write + + + STARTUP + desc STARTUP + 5 + 4 + read-write + + + STABLE + desc STABLE + 6 + 6 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + PERI_CLKEN + desc PERI_CLKEN + 0x20 + 32 + read-write + 0x0 + 0x9733C777 + + + 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 + + + + + + + TIM0 + desc TIM + 0x40000C00 + + 0x0 + 0x18 + + + + ARR + desc ARR + 0x0 + 32 + read-write + 0x0 + 0xFFFF + + + ARR + desc ARR + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT + desc CNT + 0x4 + 32 + read-write + 0x0 + 0xFFFF + + + CNT + desc CNT + 15 + 0 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CNT32 + desc CNT32 + 0x8 + 32 + read-write + 0x0 + 0xFFFFFFFF + + + CNT32 + desc CNT32 + 31 + 0 + read-write + + + + + CR + desc CR + 0xC + 32 + read-write + 0x8 + 0x77F + + + CTEN + desc CTEN + 0 + 0 + read-write + + + MD + desc MD + 1 + 1 + read-write + + + CT + desc CT + 2 + 2 + read-write + + + TOGEN + desc TOGEN + 3 + 3 + read-write + + + PRS + desc PRS + 6 + 4 + read-write + + + GATE + desc GATE + 8 + 8 + read-write + + + GATEP + desc GATEP + 9 + 9 + read-write + + + UIE + desc UIE + 10 + 10 + read-write + + + RSV + desc RSV + 31 + 31 + read-write + + + + + IFR + desc IFR + 0x10 + 32 + read-only + 0x0 + 0x1 + + + UIF + desc UIF + 0 + 0 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + ICLR + desc ICLR + 0x14 + 32 + write-only + 0xFFFF + 0x1 + + + UIF + desc UIF + 0 + 0 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + TIM1 + desc TIM + 0x40000C20 + + 0x0 + 0x18 + + + + TIM2 + desc TIM + 0x40000C40 + + 0x0 + 0x18 + + + + 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 + + + RSV + desc RSV + 31 + 31 + read-write + + + + + VC0_CR + desc VC0_CR + 0x14 + 32 + read-write + 0x0 + 0x1FFFF + + + 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 + + + RSV + desc RSV + 31 + 31 + read-write + + + + + VC1_CR + desc VC1_CR + 0x18 + 32 + read-write + 0x0 + 0x1FFFF + + + 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 + + + RSV + desc RSV + 31 + 31 + read-write + + + + + VC0_OUT_CFG + desc VC0_OUT_CFG + 0x1C + 32 + read-write + 0x0 + 0xFE3F + + + INV_TIMER + desc INV_TIMER + 0 + 0 + read-write + + + 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 + + + RSV + desc RSV + 31 + 31 + read-write + + + + + VC1_OUT_CFG + desc VC1_OUT_CFG + 0x20 + 32 + read-write + 0x0 + 0xFEFF + + + INV_TIMER + desc INV_TIMER + 0 + 0 + read-write + + + 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 + + + RSV + desc RSV + 31 + 31 + 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 + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + WDT + desc WDT + 0x40000C00 + TIM0 + + 0x0 + 0x86 + + + + RST + desc RST + 0x80 + 32 + write-only + 0x0 + 0xFF + + + RST + desc RST + 7 + 0 + write-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + CON + desc CON + 0x84 + 32 + read-write + 0xF + 0xFFBF + + + WOV + desc WOV + 3 + 0 + read-write + + + R + desc R + 4 + 4 + read-only + + + WINT_EN + desc WINT_EN + 5 + 5 + read-write + + + INT + desc INT + 7 + 7 + read-only + + + WCNTL + desc WCNTL + 15 + 8 + read-only + + + RSV + desc RSV + 31 + 31 + read-write + + + + + + + diff --git a/src/hc32f005_ddl/mcu/common/base_types.h b/src/hc32f005_ddl/mcu/common/base_types.h new file mode 100644 index 0000000..ab32088 --- /dev/null +++ b/src/hc32f005_ddl/mcu/common/base_types.h @@ -0,0 +1,147 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file base_types.h + ** + ** base type common define. + ** @link SampleGroup Some description @endlink + ** + ** - 2019-03-01 1.0 Lux First version. + ** + ******************************************************************************/ + +#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 + +/** Returns the minimum value out of two values */ +#define MINIMUM( X, Y ) ((X) < (Y) ? (X) : (Y)) + +/** Returns the maximum value out of two values */ +#define MAXIMUM( X, Y ) ((X) > (Y) ? (X) : (Y)) + +/** Returns the dimension of an array */ +#define ARRAY_SZ( X ) (sizeof(X) / sizeof((X)[0])) + +#ifdef __DEBUG_ASSERT + #define ASSERT(x) do{ assert((x)> 0u) ; }while(0); +#else + #define ASSERT(x) {} +#endif +/****************************************************************************** + * Global type definitions + ******************************************************************************/ + +/** logical datatype (only values are TRUE and FALSE) */ +typedef uint8_t boolean_t; + +/** single precision floating point number (4 byte) */ +typedef float float32_t; + +/** double precision floating point number (8 byte) */ +typedef double float64_t; + +/** ASCII character for string generation (8 bit) */ +typedef char char_t; + +/** function pointer type to void/void function */ +typedef void (*func_ptr_t)(void); + +/** function pointer type to void/uint8_t function */ +typedef void (*func_ptr_arg1_t)(uint8_t u8Param); + +/** generic error codes */ +typedef enum en_result +{ + Ok = 0u, ///< No error + Error = 1u, ///< Non-specific error code + ErrorAddressAlignment = 2u, ///< Address alignment does not match + ErrorAccessRights = 3u, ///< Wrong mode (e.g. user/system) mode is set + ErrorInvalidParameter = 4u, ///< Provided parameter is not valid + ErrorOperationInProgress = 5u, ///< A conflicting or requested operation is still in progress + ErrorInvalidMode = 6u, ///< Operation not allowed in current mode + ErrorUninitialized = 7u, ///< Module (or part of it) was not initialized properly + ErrorBufferFull = 8u, ///< Circular buffer can not be written because the buffer is full + ErrorTimeout = 9u, ///< Time Out error occurred (e.g. I2C arbitration lost, Flash time-out, etc.) + ErrorNotReady = 10u, ///< A requested final state is not reached + OperationInProgress = 11u ///< Indicator for operation in progress +} en_result_t; + + +/*****************************************************************************/ +/* Global variable declarations ('extern', definition in C source) */ +/*****************************************************************************/ + +/*****************************************************************************/ +/* Global function prototypes ('extern', definition in C source) */ +/*****************************************************************************/ + +#endif /* __BASE_TYPES_H__ */ + +/******************************************************************************/ +/* EOF (not truncated) */ +/******************************************************************************/ + + + diff --git a/src/hc32f005_ddl/mcu/common/board_stkhc32f005.h b/src/hc32f005_ddl/mcu/common/board_stkhc32f005.h new file mode 100644 index 0000000..b60271b --- /dev/null +++ b/src/hc32f005_ddl/mcu/common/board_stkhc32f005.h @@ -0,0 +1,87 @@ +/****************************************************************************** +* 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 stkhc32l13x.h + ** + ** stk board common define. + ** @link SampleGroup Some description @endlink + ** + ** - 2018-03-09 1.0 Lux First version. + ** + ******************************************************************************/ +#ifndef __BOARD_STKHC32F005_H__ +#define __BOARD_STKHC32F005_H__ + +///< STK GPIO DEFINE +///< USER KEY +#define STK_USER_PORT GpioPort3 +#define STK_USER_PIN GpioPin3 + +///< LED +#define STK_LED_PORT GpioPort0 +#define STK_LED_PIN GpioPin3 + +///< XTH +#define SYSTEM_XTH (32*1000*1000u) ///< 32MHz + +#define STK_XTHI_PORT GpioPort0 +#define STK_XTHI_PIN GpioPin1 +#define STK_XTHO_PORT GpioPort0 +#define STK_XTHO_PIN GpioPin2 + +///< I2C EEPROM +#define EVB_I2C_EEPROM_SCL_PORT GpioPort2 +#define EVB_I2C_EEPROM_SCL_PIN GpioPin6 +#define EVB_I2C_EEPROM_SDA_PORT GpioPort2 +#define EVB_I2C_EEPROM_SDA_PIN GpioPin5 + +///< SPI +#define EVB_SPI_CS_PORT GpioPort0 +#define EVB_SPI_CS_PIN GpioPin3 +#define EVB_SPI_SCK_PORT GpioPort2 +#define EVB_SPI_SCK_PIN GpioPin5 +#define EVB_SPI_MISO_PORT GpioPort2 +#define EVB_SPI_MISO_PIN GpioPin3 +#define EVB_SPI_MOSI_PORT GpioPort2 +#define EVB_SPI_MOSI_PIN GpioPin4 + +#endif \ No newline at end of file diff --git a/src/hc32f005_ddl/mcu/common/hc32f005.h b/src/hc32f005_ddl/mcu/common/hc32f005.h new file mode 100644 index 0000000..8d4fd68 --- /dev/null +++ b/src/hc32f005_ddl/mcu/common/hc32f005.h @@ -0,0 +1,3584 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \\file HC32F005.h +** +** Auto generate. +** Headerfile for HC32F005 series MCU +** +** History: +** +** - 2019-06-30 0.1 Lux First version. +** +******************************************************************************/ + +#ifndef __HC32F005_H__ +#define __HC32F005_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, + ADTIM4_IRQn = 18, + ADTIM5_IRQn = 19, + ADTIM6_IRQn = 20, + PCA_IRQn = 21, + WDT_IRQn = 22, + ADC_IRQn = 24, + VC0_IRQn = 26, + VC1_IRQn = 27, + LVD_IRQn = 28, + FLASH_RAM_IRQn = 30, + CLKTRIM_IRQn = 31, + + +} IRQn_Type; + + +#include +#include + +#define SUCCESS (0) +#define ERROR (-1) + +#ifndef NULL +#define NULL (0) +#endif + + +/******************************************************************************/ +/* Device Specific Peripheral Registers structures */ +/******************************************************************************/ + +#if defined ( __CC_ARM ) +#pragma anon_unions +#endif + +typedef struct +{ + __IO uint32_t 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; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_cnter_field_t; + +typedef struct +{ + __IO uint32_t PERA :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_perar_field_t; + +typedef struct +{ + __IO uint32_t PERB :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_perbr_field_t; + +typedef struct +{ + __IO uint32_t GCMA :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_gcmar_field_t; + +typedef struct +{ + __IO uint32_t GCMB :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_gcmbr_field_t; + +typedef struct +{ + __IO uint32_t GCMC :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_gcmcr_field_t; + +typedef struct +{ + __IO uint32_t GCMD :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_gcmdr_field_t; + +typedef struct +{ + __IO uint32_t DTUA :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_dtuar_field_t; + +typedef struct +{ + __IO uint32_t DTDA :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_dtdar_field_t; + +typedef struct +{ + __IO uint32_t START : 1; + __IO uint32_t MODE : 3; + __IO uint32_t CKDIV : 3; + uint32_t RESERVED7 : 1; + __IO uint32_t DIR : 1; + uint32_t RESERVED9 : 7; + __IO uint32_t ZMSKREV : 1; + __IO uint32_t ZMSKPOS : 1; + __IO uint32_t ZMSK : 2; + uint32_t RESERVED20 :11; + __IO uint32_t RSV : 1; +} stc_adtim_gconr_field_t; + +typedef struct +{ + __IO uint32_t INTENA : 1; + __IO uint32_t INTENB : 1; + __IO uint32_t INTENC : 1; + __IO uint32_t INTEND : 1; + uint32_t RESERVED4 : 2; + __IO uint32_t INTENOVF : 1; + __IO uint32_t INTENUDF : 1; + __IO uint32_t INTENDE : 1; + uint32_t RESERVED9 :22; + __IO uint32_t RSV : 1; +} stc_adtim_iconr_field_t; + +typedef struct +{ + __IO uint32_t CAPCA : 1; + __IO uint32_t STACA : 1; + __IO uint32_t STPCA : 1; + __IO uint32_t STASTPSA : 1; + __IO uint32_t CMPCA : 2; + __IO uint32_t PERCA : 2; + __IO uint32_t OUTENA : 1; + __IO uint32_t DISSELA : 2; + __IO uint32_t DISVALA : 2; + uint32_t RESERVED13 : 3; + __IO uint32_t CAPCB : 1; + __IO uint32_t STACB : 1; + __IO uint32_t STPCB : 1; + __IO uint32_t STASTPSB : 1; + __IO uint32_t CMPCB : 2; + __IO uint32_t PERCB : 2; + __IO uint32_t OUTENB : 1; + __IO uint32_t DISSELB : 2; + __IO uint32_t DISVALB : 2; + uint32_t RESERVED29 : 2; + __IO uint32_t RSV : 1; +} stc_adtim_pconr_field_t; + +typedef struct +{ + __IO uint32_t BENA : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t BENB : 1; + uint32_t RESERVED3 : 5; + __IO uint32_t BENP : 1; + uint32_t RESERVED9 :22; + __IO uint32_t RSV : 1; +} stc_adtim_bconr_field_t; + +typedef struct +{ + __IO uint32_t DTCEN : 1; + uint32_t RESERVED1 : 7; + __IO uint32_t SEPA : 1; + uint32_t RESERVED9 :22; + __IO uint32_t RSV : 1; +} stc_adtim_dconr_field_t; + +typedef struct +{ + __IO uint32_t NOFIENGA : 1; + __IO uint32_t NOFICKGA : 2; + uint32_t RESERVED3 : 1; + __IO uint32_t NOFIENGB : 1; + __IO uint32_t NOFICKGB : 2; + uint32_t RESERVED7 : 9; + __IO uint32_t NOFIENTA : 1; + __IO uint32_t NOFICKTA : 2; + uint32_t RESERVED19 : 1; + __IO uint32_t NOFIENTB : 1; + __IO uint32_t NOFICKTB : 2; + uint32_t RESERVED23 : 1; + __IO uint32_t NOFIENTC : 1; + __IO uint32_t NOFICKTC : 2; + uint32_t RESERVED27 : 1; + __IO uint32_t NOFIENTD : 1; + __IO uint32_t NOFICKTD : 2; + __IO uint32_t RSV : 1; +} stc_adtim_fconr_field_t; + +typedef struct +{ + __IO uint32_t GEPERIA : 1; + __IO uint32_t GEPERIB : 1; + __IO uint32_t GEPERIC : 1; + __IO uint32_t GEPERID : 1; + uint32_t RESERVED4 :12; + __IO uint32_t PCNTE : 2; + __IO uint32_t PCNTS : 3; + uint32_t RESERVED21 :10; + __IO uint32_t RSV : 1; +} stc_adtim_vperr_field_t; + +typedef struct +{ + __IO uint32_t CMAF : 1; + __IO uint32_t CMBF : 1; + __IO uint32_t CMCF : 1; + __IO uint32_t CMDF : 1; + uint32_t RESERVED4 : 2; + __IO uint32_t OVFF : 1; + __IO uint32_t UDFF : 1; + __IO uint32_t DTEF : 1; + uint32_t RESERVED9 :12; + __IO uint32_t VPERNUM : 3; + uint32_t RESERVED24 : 7; + __IO uint32_t DIRF : 1; +} stc_adtim_stflr_field_t; + +typedef struct +{ + __IO uint32_t HSTA0 : 1; + __IO uint32_t HSTA1 : 1; + __IO uint32_t HSTA2 : 1; + __IO uint32_t HSTA3 : 1; + __IO uint32_t HSTA4 : 1; + __IO uint32_t HSTA5 : 1; + __IO uint32_t HSTA6 : 1; + __IO uint32_t HSTA7 : 1; + __IO uint32_t HSTA8 : 1; + __IO uint32_t HSTA9 : 1; + __IO uint32_t HSTA10 : 1; + __IO uint32_t HSTA11 : 1; + __IO uint32_t HSTA12 : 1; + __IO uint32_t HSTA13 : 1; + __IO uint32_t HSTA14 : 1; + __IO uint32_t HSTA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t STARTS : 1; +} stc_adtim_hstar_field_t; + +typedef struct +{ + __IO uint32_t HSTP0 : 1; + __IO uint32_t HSTP1 : 1; + __IO uint32_t HSTP2 : 1; + __IO uint32_t HSTP3 : 1; + __IO uint32_t HSTP4 : 1; + __IO uint32_t HSTP5 : 1; + __IO uint32_t HSTP6 : 1; + __IO uint32_t HSTP7 : 1; + __IO uint32_t HSTP8 : 1; + __IO uint32_t HSTP9 : 1; + __IO uint32_t HSTP10 : 1; + __IO uint32_t HSTP11 : 1; + __IO uint32_t HSTP12 : 1; + __IO uint32_t HSTP13 : 1; + __IO uint32_t HSTP14 : 1; + __IO uint32_t HSTP15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t STOPS : 1; +} stc_adtim_hstpr_field_t; + +typedef struct +{ + __IO uint32_t HCEL0 : 1; + __IO uint32_t HCEL1 : 1; + __IO uint32_t HCEL2 : 1; + __IO uint32_t HCEL3 : 1; + __IO uint32_t HCEL4 : 1; + __IO uint32_t HCEL5 : 1; + __IO uint32_t HCEL6 : 1; + __IO uint32_t HCEL7 : 1; + __IO uint32_t HCEL8 : 1; + __IO uint32_t HCEL9 : 1; + __IO uint32_t HCEL10 : 1; + __IO uint32_t HCEL11 : 1; + __IO uint32_t HCEL12 : 1; + __IO uint32_t HCEL13 : 1; + __IO uint32_t HCEL14 : 1; + __IO uint32_t HCEL15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t CLEARS : 1; +} stc_adtim_hcelr_field_t; + +typedef struct +{ + __IO uint32_t HCPA0 : 1; + __IO uint32_t HCPA1 : 1; + __IO uint32_t HCPA2 : 1; + __IO uint32_t HCPA3 : 1; + __IO uint32_t HCPA4 : 1; + __IO uint32_t HCPA5 : 1; + __IO uint32_t HCPA6 : 1; + __IO uint32_t HCPA7 : 1; + __IO uint32_t HCPA8 : 1; + __IO uint32_t HCPA9 : 1; + __IO uint32_t HCPA10 : 1; + __IO uint32_t HCPA11 : 1; + __IO uint32_t HCPA12 : 1; + __IO uint32_t HCPA13 : 1; + __IO uint32_t HCPA14 : 1; + __IO uint32_t HCPA15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_hcpar_field_t; + +typedef struct +{ + __IO uint32_t HCPB0 : 1; + __IO uint32_t HCPB1 : 1; + __IO uint32_t HCPB2 : 1; + __IO uint32_t HCPB3 : 1; + __IO uint32_t HCPB4 : 1; + __IO uint32_t HCPB5 : 1; + __IO uint32_t HCPB6 : 1; + __IO uint32_t HCPB7 : 1; + __IO uint32_t HCPB8 : 1; + __IO uint32_t HCPB9 : 1; + __IO uint32_t HCPB10 : 1; + __IO uint32_t HCPB11 : 1; + __IO uint32_t HCPB12 : 1; + __IO uint32_t HCPB13 : 1; + __IO uint32_t HCPB14 : 1; + __IO uint32_t HCPB15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_hcpbr_field_t; + +typedef struct +{ + __IO uint32_t HCUP0 : 1; + __IO uint32_t HCUP1 : 1; + __IO uint32_t HCUP2 : 1; + __IO uint32_t HCUP3 : 1; + __IO uint32_t HCUP4 : 1; + __IO uint32_t HCUP5 : 1; + __IO uint32_t HCUP6 : 1; + __IO uint32_t HCUP7 : 1; + __IO uint32_t HCUP8 : 1; + __IO uint32_t HCUP9 : 1; + __IO uint32_t HCUP10 : 1; + __IO uint32_t HCUP11 : 1; + __IO uint32_t HCUP12 : 1; + __IO uint32_t HCUP13 : 1; + __IO uint32_t HCUP14 : 1; + __IO uint32_t HCUP15 : 1; + __IO uint32_t HCUP16 : 1; + __IO uint32_t HCUP17 : 1; + __IO uint32_t HCUP18 : 1; + __IO uint32_t HCUP19 : 1; + uint32_t RESERVED20 :11; + __IO uint32_t RSV : 1; +} stc_adtim_hcupr_field_t; + +typedef struct +{ + __IO uint32_t HCDO0 : 1; + __IO uint32_t HCDO1 : 1; + __IO uint32_t HCDO2 : 1; + __IO uint32_t HCDO3 : 1; + __IO uint32_t HCDO4 : 1; + __IO uint32_t HCDO5 : 1; + __IO uint32_t HCDO6 : 1; + __IO uint32_t HCDO7 : 1; + __IO uint32_t HCDO8 : 1; + __IO uint32_t HCDO9 : 1; + __IO uint32_t HCDO10 : 1; + __IO uint32_t HCDO11 : 1; + __IO uint32_t HCDO12 : 1; + __IO uint32_t HCDO13 : 1; + __IO uint32_t HCDO14 : 1; + __IO uint32_t HCDO15 : 1; + __IO uint32_t HCDO16 : 1; + __IO uint32_t HCDO17 : 1; + __IO uint32_t HCDO18 : 1; + __IO uint32_t HCDO19 : 1; + uint32_t RESERVED20 :11; + __IO uint32_t RSV : 1; +} stc_adtim_hcdor_field_t; + +typedef struct +{ + __IO uint32_t CMAF : 1; + __IO uint32_t CMBF : 1; + __IO uint32_t CMCF : 1; + __IO uint32_t CMDF : 1; + uint32_t RESERVED4 : 2; + __IO uint32_t OVFF : 1; + __IO uint32_t UDFF : 1; + __IO uint32_t DTEF : 1; + uint32_t RESERVED9 : 5; + __IO uint32_t SAMLF : 1; + __IO uint32_t SAMHF : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_ifr_field_t; + +typedef struct +{ + __IO uint32_t CMAC : 1; + __IO uint32_t CMBC : 1; + __IO uint32_t CMCC : 1; + __IO uint32_t CMDC : 1; + uint32_t RESERVED4 : 2; + __IO uint32_t OVFC : 1; + __IO uint32_t UDFC : 1; + __IO uint32_t DTEC : 1; + uint32_t RESERVED9 : 5; + __IO uint32_t SAMLC : 1; + __IO uint32_t SAMHC : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_iclr_field_t; + +typedef struct +{ + __IO uint32_t CMAE : 1; + __IO uint32_t CMBE : 1; + __IO uint32_t CMCE : 1; + __IO uint32_t CMDE : 1; + uint32_t RESERVED4 : 2; + __IO uint32_t OVFE : 1; + __IO uint32_t UDFE : 1; + __IO uint32_t DITENA : 1; + __IO uint32_t DITENB : 1; + __IO uint32_t DITENS : 1; + uint32_t RESERVED11 :20; + __IO uint32_t RSV : 1; +} stc_adtim_cr_field_t; + +typedef struct +{ + __IO uint32_t FBRAKE : 1; + __IO uint32_t FSAME : 1; + __IO uint32_t BFILTS : 2; + __IO uint32_t BFILTEN : 1; + uint32_t RESERVED5 : 2; + __IO uint32_t SOFTBK : 1; + __IO uint32_t SML0 : 1; + __IO uint32_t SML1 : 1; + __IO uint32_t SML2 : 1; + __IO uint32_t SMH0 : 1; + __IO uint32_t SMH1 : 1; + __IO uint32_t SMH2 : 1; + uint32_t RESERVED14 :17; + __IO uint32_t RSV : 1; +} stc_adtim_aossr_field_t; + +typedef struct +{ + __IO uint32_t FBRAKE : 1; + __IO uint32_t FSAME : 1; + uint32_t RESERVED2 :29; + __IO uint32_t RSV : 1; +} stc_adtim_aoscl_field_t; + +typedef struct +{ + __IO uint32_t EN0 : 1; + __IO uint32_t EN1 : 1; + __IO uint32_t EN2 : 1; + __IO uint32_t EN3 : 1; + __IO uint32_t EN4 : 1; + __IO uint32_t EN5 : 1; + __IO uint32_t EN6 : 1; + __IO uint32_t EN7 : 1; + __IO uint32_t EN8 : 1; + __IO uint32_t EN9 : 1; + __IO uint32_t EN10 : 1; + __IO uint32_t EN11 : 1; + __IO uint32_t EN12 : 1; + __IO uint32_t EN13 : 1; + __IO uint32_t EN14 : 1; + __IO uint32_t EN15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_ptbks_field_t; + +typedef struct +{ + __IO uint32_t TRIGAS : 4; + __IO uint32_t TRIGBS : 4; + __IO uint32_t TRIGCS : 4; + __IO uint32_t TRIGDS : 4; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_ttrig_field_t; + +typedef struct +{ + __IO uint32_t IAOS0S : 4; + __IO uint32_t IAOS1S : 4; + __IO uint32_t IAOS2S : 4; + __IO uint32_t IAOS3S : 4; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_itrig_field_t; + +typedef struct +{ + __IO uint32_t POL0 : 1; + __IO uint32_t POL1 : 1; + __IO uint32_t POL2 : 1; + __IO uint32_t POL3 : 1; + __IO uint32_t POL4 : 1; + __IO uint32_t POL5 : 1; + __IO uint32_t POL6 : 1; + __IO uint32_t POL7 : 1; + __IO uint32_t POL8 : 1; + __IO uint32_t POL9 : 1; + __IO uint32_t POL10 : 1; + __IO uint32_t POL11 : 1; + __IO uint32_t POL12 : 1; + __IO uint32_t POL13 : 1; + __IO uint32_t POL14 : 1; + __IO uint32_t POL15 : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_adtim_ptbkp_field_t; + +typedef struct +{ + __IO uint32_t SSTA0 : 1; + __IO uint32_t SSTA1 : 1; + __IO uint32_t SSTA2 : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_adtim_sstar_field_t; + +typedef struct +{ + __IO uint32_t SSTP0 : 1; + __IO uint32_t SSTP1 : 1; + __IO uint32_t SSTP2 : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_adtim_sstpr_field_t; + +typedef struct +{ + __IO uint32_t SCLR0 : 1; + __IO uint32_t SCLR1 : 1; + __IO uint32_t SCLR2 : 1; + uint32_t RESERVED3 :28; + __IO uint32_t RSV : 1; +} stc_adtim_sclrr_field_t; + +typedef struct +{ + __IO uint32_t BGR_EN : 1; + __IO uint32_t TS_EN : 1; + uint32_t RESERVED2 :29; + __IO uint32_t RSV : 1; +} stc_bgr_cr_field_t; + +typedef struct +{ + __IO uint32_t TRIM_START : 1; + __IO uint32_t REFCLK_SEL : 3; + __IO uint32_t CALCLK_SEL : 2; + __IO uint32_t MON_EN : 1; + __IO uint32_t IE : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_clk_trim_cr_field_t; + +typedef struct +{ + __IO uint32_t RCNTVAL :32; +} stc_clk_trim_refcon_field_t; + +typedef struct +{ + __IO uint32_t REFCNT :32; +} stc_clk_trim_refcnt_field_t; + +typedef struct +{ + __IO uint32_t CALCNT :32; +} stc_clk_trim_calcnt_field_t; + +typedef struct +{ + __IO uint32_t STOP : 1; + __IO uint32_t CALCNT_OF : 1; + uint32_t RESERVED2 : 1; + __IO uint32_t XTH_FAULT : 1; + uint32_t RESERVED4 :27; + __IO uint32_t RSV : 1; +} stc_clk_trim_ifr_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 3; + __IO uint32_t XTH_FAULT_CLR : 1; + uint32_t RESERVED4 :27; + __IO uint32_t RSV : 1; +} stc_clk_trim_iclr_field_t; + +typedef struct +{ + __IO uint32_t CCNTVAL :32; +} stc_clk_trim_calcon_field_t; + +typedef struct +{ + __IO uint32_t 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 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 : 2; + __IO uint32_t TIM3 : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_debug_active_field_t; + +typedef struct +{ + __IO uint32_t TNVS : 9; + __IO uint32_t RSV :23; +} stc_flash_tnvs_field_t; + +typedef struct +{ + __IO uint32_t TPGS : 8; + __IO uint32_t RSV :24; +} stc_flash_tpgs_field_t; + +typedef struct +{ + __IO uint32_t TPROG : 8; + uint32_t RESERVED8 : 1; + __IO uint32_t RSV :23; +} stc_flash_tprog_field_t; + +typedef struct +{ + __IO uint32_t TSERASE :18; + __IO uint32_t RSV :14; +} stc_flash_tserase_field_t; + +typedef struct +{ + __IO uint32_t TMERASE :21; + __IO uint32_t RSV :11; +} stc_flash_tmerase_field_t; + +typedef struct +{ + __IO uint32_t TPRCV :12; + __IO uint32_t RSV :20; +} stc_flash_tprcv_field_t; + +typedef struct +{ + __IO uint32_t TSRCV :12; + __IO uint32_t RSV :20; +} stc_flash_tsrcv_field_t; + +typedef struct +{ + __IO uint32_t TMRCV :13; + uint32_t RESERVED13 : 1; + __IO uint32_t RSV :18; +} 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; + uint32_t RESERVED7 : 3; + __IO uint32_t RSV :22; +} stc_flash_cr_field_t; + +typedef struct +{ + __IO uint32_t IF0 : 1; + __IO uint32_t IF1 : 1; + __IO uint32_t RSV :30; +} stc_flash_ifr_field_t; + +typedef struct +{ + __IO uint32_t ICLR0 : 1; + __IO uint32_t ICLR1 : 1; + __IO uint32_t RSV :30; +} stc_flash_iclr_field_t; + +typedef struct +{ + __IO uint32_t BYSEQ :16; + __IO uint32_t RSV :16; +} stc_flash_bypass_field_t; + +typedef struct +{ + __IO uint32_t SLOCK :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; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_i2c_tmrun_field_t; + +typedef struct +{ + __IO uint32_t TM : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_i2c_tm_field_t; + +typedef struct +{ + __IO uint32_t H1M : 1; + uint32_t RESERVED1 : 1; + __IO uint32_t AA : 1; + __IO uint32_t SI : 1; + __IO uint32_t STO : 1; + __IO uint32_t STA : 1; + __IO uint32_t ENS : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_i2c_cr_field_t; + +typedef struct +{ + __IO uint32_t DAT : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_i2c_data_field_t; + +typedef struct +{ + __IO uint32_t GC : 1; + __IO uint32_t ADR : 7; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_i2c_addr_field_t; + +typedef struct +{ + __IO uint32_t STA : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_i2c_stat_field_t; + +typedef struct +{ + __IO uint32_t LVDEN : 1; + __IO uint32_t ACT : 1; + __IO uint32_t SOURCE_SEL : 2; + __IO uint32_t VTDS : 4; + __IO uint32_t FLTEN : 1; + __IO uint32_t DEBOUNCE_TIME : 3; + __IO uint32_t FTEN : 1; + __IO uint32_t RTEN : 1; + __IO uint32_t HTEN : 1; + __IO uint32_t IE : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_lvd_cr_field_t; + +typedef struct +{ + __IO uint32_t INTF : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 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; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccon_field_t; + +typedef struct +{ + __IO uint32_t CFIE : 1; + __IO uint32_t CPS : 3; + uint32_t RESERVED4 : 2; + __IO uint32_t WDTE : 1; + __IO uint32_t CIDL : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_cmod_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pca_cnt_field_t; + +typedef struct +{ + __IO uint32_t CCF0 : 1; + __IO uint32_t CCF1 : 1; + __IO uint32_t CCF2 : 1; + __IO uint32_t CCF3 : 1; + __IO uint32_t CCF4 : 1; + uint32_t RESERVED5 : 2; + __IO uint32_t CF : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_iclr_field_t; + +typedef struct +{ + __IO uint32_t CCIE : 1; + __IO uint32_t PWM : 1; + __IO uint32_t TOG : 1; + __IO uint32_t MAT : 1; + __IO uint32_t CAPN : 1; + __IO uint32_t CAPP : 1; + __IO uint32_t ECOM : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_pca_ccapm0_field_t; + +typedef struct +{ + __IO uint32_t CCIE : 1; + __IO uint32_t PWM : 1; + __IO uint32_t TOG : 1; + __IO uint32_t MAT : 1; + __IO uint32_t CAPN : 1; + __IO uint32_t CAPP : 1; + __IO uint32_t ECOM : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_pca_ccapm1_field_t; + +typedef struct +{ + __IO uint32_t CCIE : 1; + __IO uint32_t PWM : 1; + __IO uint32_t TOG : 1; + __IO uint32_t MAT : 1; + __IO uint32_t CAPN : 1; + __IO uint32_t CAPP : 1; + __IO uint32_t ECOM : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_pca_ccapm2_field_t; + +typedef struct +{ + __IO uint32_t CCIE : 1; + __IO uint32_t PWM : 1; + __IO uint32_t TOG : 1; + __IO uint32_t MAT : 1; + __IO uint32_t CAPN : 1; + __IO uint32_t CAPP : 1; + __IO uint32_t ECOM : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_pca_ccapm3_field_t; + +typedef struct +{ + __IO uint32_t CCIE : 1; + __IO uint32_t PWM : 1; + __IO uint32_t TOG : 1; + __IO uint32_t MAT : 1; + __IO uint32_t CAPN : 1; + __IO uint32_t CAPP : 1; + __IO uint32_t ECOM : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_pca_ccapm4_field_t; + +typedef struct +{ + __IO uint32_t CCAP0 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap0h_field_t; + +typedef struct +{ + __IO uint32_t CCAP0 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap0l_field_t; + +typedef struct +{ + __IO uint32_t CCAP1 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap1h_field_t; + +typedef struct +{ + __IO uint32_t CCAP1 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap1l_field_t; + +typedef struct +{ + __IO uint32_t CCAP2 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap2h_field_t; + +typedef struct +{ + __IO uint32_t CCAP2 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap2l_field_t; + +typedef struct +{ + __IO uint32_t CCAP3 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap3h_field_t; + +typedef struct +{ + __IO uint32_t CCAP3 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap3l_field_t; + +typedef struct +{ + __IO uint32_t CCAP4 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap4h_field_t; + +typedef struct +{ + __IO uint32_t CCAP4 : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_pca_ccap4l_field_t; + +typedef struct +{ + __IO uint32_t CCAPO0 : 1; + __IO uint32_t CCAPO1 : 1; + __IO uint32_t CCAPO2 : 1; + __IO uint32_t CCAPO3 : 1; + __IO uint32_t CCAPO4 : 1; + uint32_t RESERVED5 :26; + __IO uint32_t RSV : 1; +} stc_pca_ccapo_field_t; + +typedef struct +{ + __IO uint32_t CCAP0 :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pca_ccap0_field_t; + +typedef struct +{ + __IO uint32_t CCAP1 :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pca_ccap1_field_t; + +typedef struct +{ + __IO uint32_t CCAP2 :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pca_ccap2_field_t; + +typedef struct +{ + __IO uint32_t CCAP3 :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pca_ccap3_field_t; + +typedef struct +{ + __IO uint32_t CCAP4 :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_pca_ccap4_field_t; + +typedef struct +{ + __IO uint32_t 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_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_peri_field_t; + +typedef struct +{ + __IO uint32_t SPR0 : 1; + __IO uint32_t SPR1 : 1; + __IO uint32_t CPHA : 1; + __IO uint32_t CPOL : 1; + __IO uint32_t MSTR : 1; + uint32_t RESERVED5 : 1; + __IO uint32_t SPEN : 1; + __IO uint32_t SPR2 : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_spi_cr_field_t; + +typedef struct +{ + __IO uint32_t SSN : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_spi_ssn_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 4; + __IO uint32_t MDF : 1; + __IO uint32_t SSERR : 1; + __IO uint32_t WCOL : 1; + __IO uint32_t SPIF : 1; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_spi_stat_field_t; + +typedef struct +{ + __IO uint32_t DAT : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_spi_data_field_t; + +typedef struct +{ + __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 CLKSW : 2; + __IO uint32_t HCLK_PRS : 3; + __IO uint32_t PCLK_PRS : 2; + uint32_t RESERVED11 : 4; + __IO uint32_t WAKEUP_BYRCH : 1; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_sysctrl_sysctrl0_field_t; + +typedef struct +{ + uint32_t RESERVED0 : 1; + __IO uint32_t EXTH_EN : 1; + __IO uint32_t EXTL_EN : 1; + __IO uint32_t XTL_ALWAYS_ON : 1; + __IO uint32_t CLOCK_FT_EN : 1; + __IO uint32_t RTC_LPW : 1; + __IO uint32_t LOCKUP_EN : 1; + __IO uint32_t RES_UIO : 1; + __IO uint32_t SWD_USE_IO : 1; + __IO uint32_t RTC_FREQ_ADJUST : 3; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_sysctrl_sysctrl1_field_t; + +typedef struct +{ + __IO uint32_t SYSCTRL2 :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_sysctrl_sysctrl2_field_t; + +typedef struct +{ + __IO uint32_t TRIM :11; + __IO uint32_t STABLE : 1; + uint32_t RESERVED12 :19; + __IO uint32_t RSV : 1; +} stc_sysctrl_rch_cr_field_t; + +typedef struct +{ + __IO uint32_t DRIVER : 2; + __IO uint32_t XTH_FSEL : 2; + __IO uint32_t STARTUP : 2; + __IO uint32_t STABLE : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_sysctrl_xth_cr_field_t; + +typedef struct +{ + __IO uint32_t TRIM :10; + __IO uint32_t STARTUP : 2; + __IO uint32_t STABLE : 1; + uint32_t RESERVED13 :18; + __IO uint32_t RSV : 1; +} stc_sysctrl_rcl_cr_field_t; + +typedef struct +{ + __IO uint32_t DRIVER : 2; + __IO uint32_t AMP_SEL : 2; + __IO uint32_t STARTUP : 2; + __IO uint32_t STABLE : 1; + uint32_t RESERVED7 :24; + __IO uint32_t RSV : 1; +} stc_sysctrl_xtl_cr_field_t; + +typedef struct +{ + __IO uint32_t UART0 : 1; + __IO uint32_t UART1 : 1; + 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_sysctrl_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_sysctrl_systick_cr_field_t; + +typedef struct +{ + __IO uint32_t ARR :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim_arr_field_t; + +typedef struct +{ + __IO uint32_t CNT :16; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_tim_cnt_field_t; + +typedef struct +{ + __IO uint32_t CNT32 :32; +} stc_tim_cnt32_field_t; + +typedef struct +{ + __IO uint32_t CTEN : 1; + __IO uint32_t MD : 1; + __IO uint32_t CT : 1; + __IO uint32_t TOGEN : 1; + __IO uint32_t PRS : 3; + uint32_t RESERVED7 : 1; + __IO uint32_t GATE : 1; + __IO uint32_t GATEP : 1; + __IO uint32_t UIE : 1; + uint32_t RESERVED11 :20; + __IO uint32_t RSV : 1; +} stc_tim_cr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_tim_ifr_field_t; + +typedef struct +{ + __IO uint32_t UIF : 1; + uint32_t RESERVED1 :30; + __IO uint32_t RSV : 1; +} stc_tim_iclr_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; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} 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; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 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; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 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; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_vc_vc0_out_cfg_field_t; + +typedef struct +{ + __IO uint32_t INV_TIMER : 1; + __IO uint32_t 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; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_vc_vc1_out_cfg_field_t; + +typedef struct +{ + __IO uint32_t VC0_INTF : 1; + __IO uint32_t VC1_INTF : 1; + __IO uint32_t VC0_FILTER : 1; + __IO uint32_t VC1_FILTER : 1; + uint32_t RESERVED4 :27; + __IO uint32_t RSV : 1; +} stc_vc_ifr_field_t; + +typedef struct +{ + __IO uint32_t RST : 8; + uint32_t RESERVED8 :23; + __IO uint32_t RSV : 1; +} stc_wdt_rst_field_t; + +typedef struct +{ + __IO uint32_t WOV : 4; + __IO uint32_t R : 1; + __IO uint32_t WINT_EN : 1; + uint32_t RESERVED6 : 1; + __IO uint32_t INT : 1; + __IO uint32_t WCNTL : 8; + uint32_t RESERVED16 :15; + __IO uint32_t RSV : 1; +} stc_wdt_con_field_t; + + +typedef struct +{ + uint8_t RESERVED0[4]; + union + { + __IO uint32_t CR0; + stc_adc_cr0_field_t CR0_f; + }; + union + { + __IO uint32_t CR1; + stc_adc_cr1_field_t CR1_f; + }; + 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_adtim_cnter_field_t CNTER_f; + }; + union + { + __IO uint32_t PERAR; + stc_adtim_perar_field_t PERAR_f; + }; + union + { + __IO uint32_t PERBR; + stc_adtim_perbr_field_t PERBR_f; + }; + uint8_t RESERVED3[4]; + union + { + __IO uint32_t GCMAR; + stc_adtim_gcmar_field_t GCMAR_f; + }; + union + { + __IO uint32_t GCMBR; + stc_adtim_gcmbr_field_t GCMBR_f; + }; + union + { + __IO uint32_t GCMCR; + stc_adtim_gcmcr_field_t GCMCR_f; + }; + union + { + __IO uint32_t GCMDR; + stc_adtim_gcmdr_field_t GCMDR_f; + }; + uint8_t RESERVED7[32]; + union + { + __IO uint32_t DTUAR; + stc_adtim_dtuar_field_t DTUAR_f; + }; + union + { + __IO uint32_t DTDAR; + stc_adtim_dtdar_field_t DTDAR_f; + }; + uint8_t RESERVED9[8]; + union + { + __IO uint32_t GCONR; + stc_adtim_gconr_field_t GCONR_f; + }; + union + { + __IO uint32_t ICONR; + stc_adtim_iconr_field_t ICONR_f; + }; + union + { + __IO uint32_t PCONR; + stc_adtim_pconr_field_t PCONR_f; + }; + union + { + __IO uint32_t BCONR; + stc_adtim_bconr_field_t BCONR_f; + }; + union + { + __IO uint32_t DCONR; + stc_adtim_dconr_field_t DCONR_f; + }; + uint8_t RESERVED14[4]; + union + { + __IO uint32_t FCONR; + stc_adtim_fconr_field_t FCONR_f; + }; + union + { + __IO uint32_t VPERR; + stc_adtim_vperr_field_t VPERR_f; + }; + union + { + __IO uint32_t STFLR; + stc_adtim_stflr_field_t STFLR_f; + }; + union + { + __IO uint32_t HSTAR; + stc_adtim_hstar_field_t HSTAR_f; + }; + union + { + __IO uint32_t HSTPR; + stc_adtim_hstpr_field_t HSTPR_f; + }; + union + { + __IO uint32_t HCELR; + stc_adtim_hcelr_field_t HCELR_f; + }; + union + { + __IO uint32_t HCPAR; + stc_adtim_hcpar_field_t HCPAR_f; + }; + union + { + __IO uint32_t HCPBR; + stc_adtim_hcpbr_field_t HCPBR_f; + }; + union + { + __IO uint32_t HCUPR; + stc_adtim_hcupr_field_t HCUPR_f; + }; + union + { + __IO uint32_t HCDOR; + stc_adtim_hcdor_field_t HCDOR_f; + }; + uint8_t RESERVED24[112]; + union + { + __IO uint32_t IFR; + stc_adtim_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_adtim_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t CR; + stc_adtim_cr_field_t CR_f; + }; + uint8_t RESERVED27[4]; + union + { + __IO uint32_t AOSSR; + stc_adtim_aossr_field_t AOSSR_f; + }; + union + { + __IO uint32_t AOSCL; + stc_adtim_aoscl_field_t AOSCL_f; + }; + union + { + __IO uint32_t PTBKS; + stc_adtim_ptbks_field_t PTBKS_f; + }; + union + { + __IO uint32_t TTRIG; + stc_adtim_ttrig_field_t TTRIG_f; + }; + union + { + __IO uint32_t ITRIG; + stc_adtim_itrig_field_t ITRIG_f; + }; + union + { + __IO uint32_t PTBKP; + stc_adtim_ptbkp_field_t PTBKP_f; + }; + uint8_t RESERVED33[716]; + union + { + __IO uint32_t SSTAR; + stc_adtim_sstar_field_t SSTAR_f; + }; + union + { + __IO uint32_t SSTPR; + stc_adtim_sstpr_field_t SSTPR_f; + }; + union + { + __IO uint32_t SCLRR; + stc_adtim_sclrr_field_t SCLRR_f; + }; +}M0P_ADTIM_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CR; + stc_bgr_cr_field_t CR_f; + }; +}M0P_BGR_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t CR; + stc_clk_trim_cr_field_t CR_f; + }; + union + { + __IO uint32_t REFCON; + stc_clk_trim_refcon_field_t REFCON_f; + }; + union + { + __IO uint32_t REFCNT; + stc_clk_trim_refcnt_field_t REFCNT_f; + }; + union + { + __IO uint32_t CALCNT; + stc_clk_trim_calcnt_field_t CALCNT_f; + }; + union + { + __IO uint32_t IFR; + stc_clk_trim_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_clk_trim_iclr_field_t ICLR_f; + }; + union + { + __IO uint32_t CALCON; + stc_clk_trim_calcon_field_t CALCON_f; + }; +}M0P_CLK_TRIM_TypeDef; + +typedef struct +{ + 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 DEBUG_ACTIVE; + stc_debug_active_field_t DEBUG_ACTIVE_f; + }; +}M0P_DEBUG_ACTIVE_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_flag_field_t RESET_FLAG_f; + }; + uint8_t RESERVED1[8]; + union + { + __IO uint32_t PERI_RESET; + stc_reset_peri_field_t PERI_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 SYSCTRL0; + stc_sysctrl_sysctrl0_field_t SYSCTRL0_f; + }; + union + { + __IO uint32_t SYSCTRL1; + stc_sysctrl_sysctrl1_field_t SYSCTRL1_f; + }; + union + { + __IO uint32_t SYSCTRL2; + stc_sysctrl_sysctrl2_field_t SYSCTRL2_f; + }; + union + { + __IO uint32_t RCH_CR; + stc_sysctrl_rch_cr_field_t RCH_CR_f; + }; + union + { + __IO uint32_t XTH_CR; + stc_sysctrl_xth_cr_field_t XTH_CR_f; + }; + union + { + __IO uint32_t RCL_CR; + stc_sysctrl_rcl_cr_field_t RCL_CR_f; + }; + union + { + __IO uint32_t XTL_CR; + stc_sysctrl_xtl_cr_field_t XTL_CR_f; + }; + uint8_t RESERVED7[4]; + union + { + __IO uint32_t PERI_CLKEN; + stc_sysctrl_peri_clken_field_t PERI_CLKEN_f; + }; + uint8_t RESERVED8[16]; + union + { + __IO uint32_t SYSTICK_CR; + stc_sysctrl_systick_cr_field_t SYSTICK_CR_f; + }; +}M0P_SYSCTRL_TypeDef; + +typedef struct +{ + union + { + __IO uint32_t ARR; + stc_tim_arr_field_t ARR_f; + }; + union + { + __IO uint32_t CNT; + stc_tim_cnt_field_t CNT_f; + }; + union + { + __IO uint32_t CNT32; + stc_tim_cnt32_field_t CNT32_f; + }; + union + { + __IO uint32_t CR; + stc_tim_cr_field_t CR_f; + }; + union + { + __IO uint32_t IFR; + stc_tim_ifr_field_t IFR_f; + }; + union + { + __IO uint32_t ICLR; + stc_tim_iclr_field_t ICLR_f; + }; +}M0P_TIM_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_PERIPH_BASE (0x40000000UL) +#define M0P_ADC_BASE (M0P_PERIPH_BASE + 0x00002400UL) +#define M0P_ADTIM4_BASE (M0P_PERIPH_BASE + 0x00003000UL) +#define M0P_ADTIM5_BASE (M0P_PERIPH_BASE + 0x00003400UL) +#define M0P_ADTIM6_BASE (M0P_PERIPH_BASE + 0x00003800UL) +#define M0P_BGR_BASE (M0P_PERIPH_BASE + 0x00002400UL) +#define M0P_CLK_TRIM_BASE (M0P_PERIPH_BASE + 0x00001800UL) +#define M0P_CRC_BASE (M0P_PERIPH_BASE + 0x00020900UL) +#define M0P_DEBUG_ACTIVE_BASE (M0P_PERIPH_BASE + 0x00002038UL) +#define M0P_FLASH_BASE (M0P_PERIPH_BASE + 0x00020000UL) +#define M0P_GPIO_BASE (M0P_PERIPH_BASE + 0x00020C00UL) +#define M0P_I2C_BASE (M0P_PERIPH_BASE + 0x00000400UL) +#define M0P_LVD_BASE (M0P_PERIPH_BASE + 0x00002400UL) +#define M0P_PCA_BASE (M0P_PERIPH_BASE + 0x00001000UL) +#define M0P_RAM_BASE (M0P_PERIPH_BASE + 0x00020400UL) +#define M0P_RESET_BASE (M0P_PERIPH_BASE + 0x0000201CUL) +#define M0P_SPI_BASE (M0P_PERIPH_BASE + 0x00000800UL) +#define M0P_SYSCTRL_BASE (M0P_PERIPH_BASE + 0x00002000UL) +#define M0P_TIM0_BASE (M0P_PERIPH_BASE + 0x00000C00UL) +#define M0P_TIM1_BASE (M0P_PERIPH_BASE + 0x00000C20UL) +#define M0P_TIM2_BASE (M0P_PERIPH_BASE + 0x00000C40UL) +#define M0P_UART0_BASE (M0P_PERIPH_BASE + 0x00000000UL) +#define M0P_UART1_BASE (M0P_PERIPH_BASE + 0x00000100UL) +#define M0P_VC_BASE (M0P_PERIPH_BASE + 0x00002400UL) +#define M0P_WDT_BASE (M0P_PERIPH_BASE + 0x00000C00UL) + + +#define M0P_ADC ((M0P_ADC_TypeDef *)0x40002400UL) +#define M0P_ADTIM4 ((M0P_ADTIM_TypeDef *)0x40003000UL) +#define M0P_ADTIM5 ((M0P_ADTIM_TypeDef *)0x40003400UL) +#define M0P_ADTIM6 ((M0P_ADTIM_TypeDef *)0x40003800UL) +#define M0P_BGR ((M0P_BGR_TypeDef *)0x40002400UL) +#define M0P_CLK_TRIM ((M0P_CLK_TRIM_TypeDef *)0x40001800UL) +#define M0P_CRC ((M0P_CRC_TypeDef *)0x40020900UL) +#define M0P_DEBUG_ACTIVE ((M0P_DEBUG_ACTIVE_TypeDef *)0x40002038UL) +#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_SYSCTRL ((M0P_SYSCTRL_TypeDef *)0x40002000UL) +#define M0P_TIM0 ((M0P_TIM_TypeDef *)0x40000C00UL) +#define M0P_TIM1 ((M0P_TIM_TypeDef *)0x40000C20UL) +#define M0P_TIM2 ((M0P_TIM_TypeDef *)0x40000C40UL) +#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 /* __HC32F005_H__ */ + diff --git a/src/hc32f005_ddl/mcu/common/interrupts_hc32f005.c b/src/hc32f005_ddl/mcu/common/interrupts_hc32f005.c new file mode 100644 index 0000000..bb32a26 --- /dev/null +++ b/src/hc32f005_ddl/mcu/common/interrupts_hc32f005.c @@ -0,0 +1,477 @@ +/****************************************************************************** +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file interrupts_hc32f005.c + ** + ** Interrupt management + ** @link Driver Group Some description @endlink + ** + ** - 2018-04-15 1.0 Lux First version. + ** + ** + ******************************************************************************/ + +/******************************************************************************* + * Include files + ******************************************************************************/ +#include "ddl.h" + +/******************************************************************************* + * IRQ WEAK DEFINE + ******************************************************************************/ +__WEAK void SysTick_IRQHandler(void); + + +__WEAK void Port0_IRQHandler(void); +__WEAK void Port1_IRQHandler(void); +__WEAK void Port2_IRQHandler(void); +__WEAK void Port3_IRQHandler(void); +__WEAK void Dmac_IRQHandler(void); +__WEAK void Tim3_IRQHandler(void); +__WEAK void Uart0_IRQHandler(void); +__WEAK void Uart1_IRQHandler(void); +__WEAK void Spi_IRQHandler(void); +__WEAK void I2c_IRQHandler(void); +__WEAK void Tim0_IRQHandler(void); +__WEAK void Tim1_IRQHandler(void); +__WEAK void Tim2_IRQHandler(void); +__WEAK void Tim4_IRQHandler(void); +__WEAK void Tim5_IRQHandler(void); +__WEAK void Tim6_IRQHandler(void); +__WEAK void Pca_IRQHandler(void); +__WEAK void Wdt_IRQHandler(void); +__WEAK void Adc_IRQHandler(void); +__WEAK void Dac_IRQHandler(void); +__WEAK void Pcnt_IRQHandler(void); +__WEAK void Vc0_IRQHandler(void); +__WEAK void Vc1_IRQHandler(void); +__WEAK void Lvd_IRQHandler(void); +__WEAK void Flash_IRQHandler(void); +__WEAK void Ram_IRQHandler(void); +__WEAK void ClkTrim_IRQHandler(void); + +/** + ******************************************************************************* + ** \brief NVIC 中断使能 + ** + ** \param [in] enIrq 中断号枚举类型 + ** \param [in] enLevel 中断优先级枚举类型 + ** \param [in] bEn 中断开关 + ** \retval Ok 设置成功 + ** 其他值 设置失败 + ******************************************************************************/ +void EnableNvic(IRQn_Type enIrq, en_irq_level_t enLevel, boolean_t bEn) +{ + NVIC_ClearPendingIRQ(enIrq); + NVIC_SetPriority(enIrq, enLevel); + if (TRUE == bEn) + { + NVIC_EnableIRQ(enIrq); + } + else + { + NVIC_DisableIRQ(enIrq); + } +} + +/** + ******************************************************************************* + ** \brief NVIC hardware fault 中断实现 + ** + ** + ** \retval + ******************************************************************************/ +void HardFault_Handler(void) +{ + volatile int a = 0; + + while( 0 == a) + { + ; + } + +} + + +/** + ******************************************************************************* + ** \brief NVIC SysTick 中断实现 + ** + ** \retval + ******************************************************************************/ +void SysTick_Handler(void) +{ + SysTick_IRQHandler(); +} + +/** + ******************************************************************************* + ** \brief GPIO Port0 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void PORT0_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_PORT0) + Port0_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief GPIO Port1 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void PORT1_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_PORT1) + Port1_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief GPIO Port2 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void PORT2_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_PORT2) + Port2_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief GPIO Port3 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void PORT3_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_PORT3) + Port3_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief DMAC 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void DMAC_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_DMAC) + Dmac_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM3 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void TIM3_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM3) + Tim3_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief UART0 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void UART0_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_UART0) + Uart0_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief UART1 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void UART1_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_UART1) + Uart1_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief SPI 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void SPI_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_SPI) + Spi_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief I2C 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void I2C_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_I2C) + I2c_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM0 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void TIM0_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM0) + Tim0_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM1 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void TIM1_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM1) + Tim1_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM2 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void TIM2_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM2) + Tim2_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM4 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void TIM4_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM4) + Tim4_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM5 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void TIM5_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM5) + Tim5_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief TIM6 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void TIM6_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_TIM6) + Tim6_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief PCA 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void PCA_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_PCA) + Pca_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief WDT 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void WDT_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_WDT) + Wdt_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief ADC 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void ADC_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_ADC) + Adc_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief PCNT 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void PCNT_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_PCNT) + Pcnt_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief VC0 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void VC0_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_VC0) + Vc0_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief VC1 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void VC1_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_VC1) + Vc1_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief LVD 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void LVD_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_LVD) + Lvd_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief FLASH/RAM 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void FLASH_RAM_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_FLASH) + Flash_IRQHandler(); +#endif + +#if (INT_CALLBACK_ON == INT_CALLBACK_RAM) + Ram_IRQHandler(); +#endif +} + +/** + ******************************************************************************* + ** \brief CLKTRIM 中断处理函数 + ** + ** \retval + ******************************************************************************/ +void CLKTRIM_IRQHandler(void) +{ +#if (INT_CALLBACK_ON == INT_CALLBACK_CLKTRIM) + ClkTrim_IRQHandler(); +#endif +} + +/******************************************************************************/ +/* EOF (not truncated) */ +/******************************************************************************/ diff --git a/src/hc32f005_ddl/mcu/common/interrupts_hc32f005.h b/src/hc32f005_ddl/mcu/common/interrupts_hc32f005.h new file mode 100644 index 0000000..7cf9f79 --- /dev/null +++ b/src/hc32f005_ddl/mcu/common/interrupts_hc32f005.h @@ -0,0 +1,136 @@ +/******************************************************************************* +* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file interrupts_hc32l13x.h + ** + ** Interrupt common define. + ** @link IRQGroup Some description @endlink + ** + ** - 2019-03-01 1.0 Lux First version. + ** + ******************************************************************************/ +#ifndef __INTERRUPTS_HC32F005_H__ +#define __INTERRUPTS_HC32F005_H__ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "ddl.h" + +/* C binding of definitions if building with C++ compiler */ +#ifdef __cplusplus +extern "C" +{ +#endif + +/******************************************************************************/ +/* Global pre-processor symbols/macros ('#define') */ +/******************************************************************************/ +#define DDL_IRQ_LEVEL_DEFAULT 3u + +//<<此选项会打开interrupt_hc32xxx.c中的中断回调函数,用户如果需要实现中断服务函数, +//<<可在源码文件中定义该文件中用"__WEAK"声明的同名中断服务函数即可。 +#define INT_CALLBACK_ON 1u //<<(默认值) +//<<此选项会关闭interrupt_hc32xxx.c中的中断回调函数,此时用户可在该文件中自行定义中断服务函数的实现。 +#define INT_CALLBACK_OFF 0u +/****************************************************************************** + * Global type definitions + ******************************************************************************/ +#define INT_CALLBACK_PORT0 INT_CALLBACK_ON +#define INT_CALLBACK_PORT1 INT_CALLBACK_ON +#define INT_CALLBACK_PORT2 INT_CALLBACK_ON +#define INT_CALLBACK_PORT3 INT_CALLBACK_ON +#define INT_CALLBACK_DMAC INT_CALLBACK_ON +#define INT_CALLBACK_TIM3 INT_CALLBACK_ON +#define INT_CALLBACK_UART0 INT_CALLBACK_ON +#define INT_CALLBACK_UART1 INT_CALLBACK_ON +#define INT_CALLBACK_SPI INT_CALLBACK_ON +#define INT_CALLBACK_I2C INT_CALLBACK_ON +#define INT_CALLBACK_TIM0 INT_CALLBACK_ON +#define INT_CALLBACK_TIM1 INT_CALLBACK_ON +#define INT_CALLBACK_TIM2 INT_CALLBACK_ON +#define INT_CALLBACK_TIM4 INT_CALLBACK_ON +#define INT_CALLBACK_TIM5 INT_CALLBACK_ON +#define INT_CALLBACK_TIM6 INT_CALLBACK_ON +#define INT_CALLBACK_PCA INT_CALLBACK_ON +#define INT_CALLBACK_WDT INT_CALLBACK_ON +#define INT_CALLBACK_ADC INT_CALLBACK_ON +#define INT_CALLBACK_PCNT INT_CALLBACK_ON +#define INT_CALLBACK_VC0 INT_CALLBACK_ON +#define INT_CALLBACK_VC1 INT_CALLBACK_ON +#define INT_CALLBACK_LVD INT_CALLBACK_ON +#define INT_CALLBACK_FLASH INT_CALLBACK_ON +#define INT_CALLBACK_RAM INT_CALLBACK_ON +#define INT_CALLBACK_CLKTRIM INT_CALLBACK_ON + + +/** + ******************************************************************************* + ** \brief 中断优先级数据类型定义 + ** \note + ******************************************************************************/ +typedef enum en_irq_level +{ + IrqLevel0 = 0u, ///< 优先级0 + IrqLevel1 = 1u, ///< 优先级1 + IrqLevel2 = 2u, ///< 优先级2 + IrqLevel3 = 3u, ///< 优先级3 +} en_irq_level_t; + + +/****************************************************************************** + * Global function prototypes (definition in C source) + ******************************************************************************/ +///< 系统中断使能开关 +extern void EnableNvic(IRQn_Type enIrq, en_irq_level_t enLevel, boolean_t bEn); + + +#ifdef __cplusplus +} +#endif + + +#endif /* __INTERRUPTS_HC32L13X_H__ */ + +/****************************************************************************** + * EOF (not truncated) + ******************************************************************************/ diff --git a/src/hc32f005_ddl/mcu/common/system_hc32f005.c b/src/hc32f005_ddl/mcu/common/system_hc32f005.c new file mode 100644 index 0000000..6a0546e --- /dev/null +++ b/src/hc32f005_ddl/mcu/common/system_hc32f005.c @@ -0,0 +1,91 @@ +/******************************************************************************* +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file system_hc32f005.c + ** + ** System clock initialization. + ** @link SampleGroup Some description @endlink + ** + ** - 2019-03-01 1.0 Lux First version. + ** + ******************************************************************************/ + +/******************************************************************************/ +/* Include files */ +/******************************************************************************/ +#include "base_types.h" +#include "hc32f005.h" +#include "system_hc32f005.h" +#include "sysctrl.h" + +/** + ****************************************************************************** + ** System Clock Frequency (Core Clock) Variable according CMSIS + ******************************************************************************/ +uint32_t SystemCoreClock = 4000000; + + +//add clock source. +void SystemCoreClockUpdate (void) // Update SystemCoreClock variable +{ + SystemCoreClock = Sysctrl_GetHClkFreq(); +} + +/** + ****************************************************************************** + ** \brief Setup the microcontroller system. Initialize the System and update + ** the SystemCoreClock variable. + ** + ** \param none + ** \return none + ******************************************************************************/ +void SystemInit(void) +{ + SystemCoreClockUpdate(); + +} + + + + + + diff --git a/src/hc32f005_ddl/mcu/common/system_hc32f005.h b/src/hc32f005_ddl/mcu/common/system_hc32f005.h new file mode 100644 index 0000000..5914507 --- /dev/null +++ b/src/hc32f005_ddl/mcu/common/system_hc32f005.h @@ -0,0 +1,111 @@ +/******************************************************************************* +* Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved. +* +* This software is owned and published by: +* Huada Semiconductor Co.,Ltd ("HDSC"). +* +* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND +* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. +* +* This software contains source code for use with HDSC +* components. This software is licensed by HDSC to be adapted only +* for use in systems utilizing HDSC components. HDSC shall not be +* responsible for misuse or illegal use of this software for devices not +* supported herein. HDSC is providing this software "AS IS" and will +* not be responsible for issues arising from incorrect user implementation +* of the software. +* +* Disclaimer: +* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, +* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), +* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, +* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED +* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED +* WARRANTY OF NONINFRINGEMENT. +* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, +* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT +* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, +* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR +* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, +* SAVINGS OR PROFITS, +* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR +* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED +* FROM, THE SOFTWARE. +* +* This software may be replicated in part or whole for the licensed use, +* with the restriction that this Disclaimer and Copyright notice must be +* included with each copy of this software, whether used in part or whole, +* at all times. +*/ +/******************************************************************************/ +/** \file system_hc3f005.h + ** + ** A detailed description is available at + ** @link SampleGroup Some description @endlink + ** + ** - 2019-03-01 1.0 Lux First version. + ** + ******************************************************************************/ + +#ifndef __SYSTEM_HC32F005_H__ +#define __SYSTEM_HC32F005_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_HC32F005_H__ */ + + + + + + +