add dll
This commit is contained in:
1 parent
13f000fae8
commit
d29c75c209
380 files changed
+195420
-1
No files matched your search
@@ -29,4 +29,4 @@ jobs:
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: gcc_template
|
||||
path: src/gcc_template
|
||||
path: src/gcc_template/build
|
||||
@@ -0,0 +1,21 @@
|
||||
.pio/
|
||||
.vscode/
|
||||
*.bin
|
||||
*.out
|
||||
*.o
|
||||
~$*
|
||||
*.dep
|
||||
*.log
|
||||
*.ewt
|
||||
*.ewd
|
||||
*.sfr
|
||||
*.icf
|
||||
*uvgui*
|
||||
*uvopt*
|
||||
*.txt
|
||||
*.ini
|
||||
RTE
|
||||
output
|
||||
config
|
||||
settings
|
||||
flashloader
|
||||
@@ -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, /*!<AVDD*/
|
||||
|
||||
}en_adc_ref_vol_sel_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADC采样通道选择
|
||||
*****************************************************************************/
|
||||
typedef enum en_adc_samp_ch_sel
|
||||
{
|
||||
AdcExInputCH0 = 0, /*!<使用通道0输入P2.4*/
|
||||
AdcExInputCH1 = 1, /*!<使用通道1输入P2.6*/
|
||||
AdcExInputCH2 = 2, /*!<使用通道2输入P3.2*/
|
||||
AdcExInputCH3 = 3, /*!<使用通道3输入P3.3*/
|
||||
AdcExInputCH4 = 4, /*!<使用通道4输入P3.4*/
|
||||
AdcExInputCH5 = 5, /*!<使用通道5输入P3.5*/
|
||||
AdcExInputCH6 = 6, /*!<使用通道6输入P3.6*/
|
||||
AdcExInputCH7 = 7, /*!<使用通道7输入P0.1*/
|
||||
AdcExInputCH8 = 8, /*!<使用通道8输入P0.2*/
|
||||
AdcAVccDiV3Input = 9, /*!<使用1/3 AVCC(必须使用输入增益)*/
|
||||
AdcAiTsInput = 10, /*!<使用AI_TS(必须使用输入增益)*/
|
||||
AdcVref1P2Input = 11, /*!<使用Vref1P2(必须使用输入增益)*/
|
||||
|
||||
}en_adc_samp_ch_sel_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADC采样周期数选择
|
||||
*****************************************************************************/
|
||||
typedef enum en_adc_samp_time_sel
|
||||
{
|
||||
AdcSampTime4Clk = 0, /*!<4个采样时钟*/
|
||||
AdcSampTime6Clk = 1, /*!<6个采样时钟*/
|
||||
AdcSampTime8Clk = 2, /*!<8个采样时钟*/
|
||||
AdcSampTime12Clk = 3, /*!<12个采样时钟*/
|
||||
|
||||
}en_adc_samp_time_sel_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADC周边模块反射源选择
|
||||
*****************************************************************************/
|
||||
typedef enum en_adc_trig_sel
|
||||
{
|
||||
AdcTrigDisable = 0, /*!<禁用周边模块反射源*/
|
||||
AdcTrigTimer0 = 1, /*!<选择timer0中断源,自动触发ADC采样*/
|
||||
AdcTrigTimer1 = 2, /*!<选择timer1中断源,自动触发ADC采样*/
|
||||
AdcTrigTimer2 = 3, /*!<选择timer2中断源,自动触发ADC采样*/
|
||||
AdcTrigLptimer = 4, /*!<选择lptimer中断源,自动触发ADC采样*/
|
||||
AdcTrigTimer4 = 5, /*!<选择timer4中断源,自动触发ADC采样*/
|
||||
AdcTrigTimer5 = 6, /*!<选择timer5中断源,自动触发ADC采样*/
|
||||
AdcTrigTimer6 = 7, /*!<选择timer6中断源,自动触发ADC采样*/
|
||||
AdcTrigUart0 = 8, /*!<选择uart0中断源,自动触发ADC采样*/
|
||||
AdcTrigUart1 = 9, /*!<选择uart1中断源,自动触发ADC采样*/
|
||||
AdcTrigLpuart = 10, /*!<选择lpuart中断源,自动触发ADC采样*/
|
||||
AdcTrigVC1 = 11, /*!<选择VC1中断源,自动触发ADC采样*/
|
||||
AdcTrigVC2 = 12, /*!<选择VC2中断源,自动触发ADC采样*/
|
||||
AdcTrigRTC = 13, /*!<选择RTC中断源,自动触发ADC采样*/
|
||||
AdcTrigPCA = 14, /*!<选择PCA中断源,自动触发ADC采样*/
|
||||
AdcTrigSPI = 15, /*!<选择SPI中断源,自动触发ADC采样*/
|
||||
AdcTrigP01 = 16, /*!<选择P01中断源,自动触发ADC采样*/
|
||||
AdcTrigP02 = 17, /*!<选择P02中断源,自动触发ADC采样*/
|
||||
AdcTrigP03 = 18, /*!<选择P03中断源,自动触发ADC采样*/
|
||||
AdcTrigP14 = 19, /*!<选择P14中断源,自动触发ADC采样*/
|
||||
AdcTrigP15 = 20, /*!<选择P15中断源,自动触发ADC采样*/
|
||||
AdcTrigP23 = 21, /*!<选择P23中断源,自动触发ADC采样*/
|
||||
AdcTrigP24 = 22, /*!<选择P24中断源,自动触发ADC采样*/
|
||||
AdcTrigP25 = 23, /*!<选择P25中断源,自动触发ADC采样*/
|
||||
AdcTrigP26 = 24, /*!<选择P26中断源,自动触发ADC采样*/
|
||||
AdcTrigP27 = 25, /*!<选择P27中断源,自动触发ADC采样*/
|
||||
AdcTrigP31 = 26, /*!<选择P31中断源,自动触发ADC采样*/
|
||||
AdcTrigP32 = 27, /*!<选择P32中断源,自动触发ADC采样*/
|
||||
AdcTrigP33 = 28, /*!<选择P33中断源,自动触发ADC采样*/
|
||||
AdcTrigP34 = 29, /*!<选择P34中断源,自动触发ADC采样*/
|
||||
AdcTrigP35 = 30, /*!<选择P35中断源,自动触发ADC采样*/
|
||||
AdcTrigP36 = 31, /*!<选择P36中断源,自动触发ADC采样*/
|
||||
|
||||
}en_adc_trig_sel_t;
|
||||
|
||||
/******************************************************************************
|
||||
* Extern type definitions ('typedef') *
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADC配置
|
||||
*****************************************************************************/
|
||||
typedef struct stc_adc_cfg
|
||||
{
|
||||
/*! ADC操作模式*/
|
||||
en_adc_op_mode_t enAdcOpMode;
|
||||
|
||||
/*! ADC时钟选择*/
|
||||
en_adc_clk_sel_t enAdcClkSel;
|
||||
|
||||
/*! ADC采样时间*/
|
||||
en_adc_samp_time_sel_t enAdcSampTimeSel;
|
||||
|
||||
/*! ADC参考电压*/
|
||||
en_adc_ref_vol_sel_t enAdcRefVolSel;
|
||||
|
||||
/*! ADC输入增益使能*/
|
||||
boolean_t bAdcInBufEn;
|
||||
|
||||
/*!ADC区间模式上限值*/
|
||||
uint32_t u32AdcRegHighThd;
|
||||
|
||||
/*!ADC区间模式下限值*/
|
||||
uint32_t u32AdcRegLowThd;
|
||||
|
||||
/*! ADC触发0选择*/
|
||||
en_adc_trig_sel_t enAdcTrig0Sel;
|
||||
|
||||
/*! ADC触发1选择*/
|
||||
en_adc_trig_sel_t enAdcTrig1Sel;
|
||||
|
||||
}stc_adc_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADC单次采样模式配置
|
||||
*****************************************************************************/
|
||||
typedef struct stc_adc_norm_cfg
|
||||
{
|
||||
/*! ADC通道选择*/
|
||||
en_adc_samp_ch_sel_t enAdcNormModeCh;
|
||||
/*! ADC结果累加使能*/
|
||||
boolean_t bAdcResultAccEn;
|
||||
|
||||
}stc_adc_norm_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADC单通道连续采样模式配置
|
||||
*****************************************************************************/
|
||||
typedef struct stc_adc_cont_cfg
|
||||
{
|
||||
/*! ADC通道选择*/
|
||||
en_adc_samp_ch_sel_t enAdcContModeCh;
|
||||
/*! ADC采样次数*/
|
||||
uint8_t u8AdcSampCnt;
|
||||
/*! ADC结果累加使能*/
|
||||
boolean_t bAdcResultAccEn;
|
||||
|
||||
}stc_adc_cont_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADC扫描采样模式配置
|
||||
*****************************************************************************/
|
||||
typedef struct stc_adc_scan_cfg
|
||||
{
|
||||
/*! ADC通道选择*/
|
||||
uint8_t u8AdcScanModeCh;
|
||||
/*! ADC采样次数*/
|
||||
uint8_t u8AdcSampCnt;
|
||||
|
||||
}stc_adc_scan_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADC中断配置
|
||||
*****************************************************************************/
|
||||
typedef struct stc_adc_irq
|
||||
{
|
||||
/*!<ADC连续采样中断*/
|
||||
boolean_t bAdcIrq;
|
||||
/*!ADC区间*/
|
||||
boolean_t bAdcRegCmp;
|
||||
/*!ADC上超出区间*/
|
||||
boolean_t bAdcHhtCmp;
|
||||
/*!ADC下超出区间*/
|
||||
boolean_t bAdcLltCmp;
|
||||
|
||||
}stc_adc_irq_t;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable definitions ('extern')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
******************************************************************************/
|
||||
//ADC initialization
|
||||
en_result_t Adc_Init(stc_adc_cfg_t* pstcAdcConfig);
|
||||
//ADC de-init
|
||||
void Adc_DeInit(void);
|
||||
|
||||
//ADC conversion start
|
||||
void Adc_Start(void);
|
||||
//ADC conversion stop
|
||||
void Adc_Stop(void);
|
||||
|
||||
//ADC conversion enable
|
||||
void Adc_Enable(void);
|
||||
//ADC conversion disable
|
||||
void Adc_Disable(void);
|
||||
|
||||
//ADC normal mode configuration
|
||||
en_result_t Adc_ConfigNormMode(stc_adc_cfg_t* pstcAdcConfig, stc_adc_norm_cfg_t* pstcAdcNormCfg);
|
||||
//ADC continuous mode configuration
|
||||
en_result_t Adc_ConfigContMode(stc_adc_cfg_t* pstcAdcConfig, stc_adc_cont_cfg_t* pstcAdcContCfg);
|
||||
//ADC scan mode configuration
|
||||
en_result_t Adc_ConfigScanMode(stc_adc_cfg_t* pstcAdcConfig, stc_adc_scan_cfg_t* pstcAdcScanCfg);
|
||||
|
||||
//ADC enable IRQ
|
||||
void Adc_EnableIrq(void);
|
||||
//ADC disable IRQ
|
||||
void Adc_DisableIrq(void);
|
||||
//ADC enable compare
|
||||
void Adc_CmpCfg(stc_adc_irq_t* pstcAdcIrqCfg);
|
||||
//ADC get IRQ state
|
||||
void Adc_GetIrqState(stc_adc_irq_t* pstcAdcIrqState);
|
||||
//ADC clear IRQ states
|
||||
void Adc_ClrContIrqState(void);
|
||||
void Adc_ClrRegIrqState(void);
|
||||
void Adc_ClrHhtIrqState(void);
|
||||
void Adc_ClrIrqLltState(void);
|
||||
|
||||
//查询ADC转换状态
|
||||
boolean_t Adc_PollBusyState(void);
|
||||
//获取采样值
|
||||
en_result_t Adc_GetResult(uint16_t* pu16AdcResult);
|
||||
//获取累加采样值
|
||||
en_result_t Adc_GetAccResult(uint32_t* pu32AdcAccResult);
|
||||
//clear ADC accumulated result
|
||||
void Adc_ClrAccResult(void);
|
||||
//get ADC scan channel result
|
||||
en_result_t Adc_GetScanResult(uint8_t u8Channel, uint16_t* pu16AdcResult);
|
||||
//获取通道8采样值
|
||||
en_result_t Adc_GetCH8Result(uint16_t* pu16AdcResult);
|
||||
|
||||
en_result_t Adc_SetVref(en_adc_ref_vol_sel_t enAdcRefVolSel);
|
||||
|
||||
//@}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ADC_H__ */
|
||||
/******************************************************************************/
|
||||
/* EOF (not truncated) */
|
||||
/******************************************************************************/
|
||||
@@ -0,0 +1,859 @@
|
||||
/*******************************************************************************
|
||||
* 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 adt.h
|
||||
**
|
||||
** Headerfile for Advance Timer functions
|
||||
** @link ADT Group Some description @endlink
|
||||
**
|
||||
** - 2018-04-19 Husj First Version
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __ADT_H__
|
||||
#define __ADT_H__
|
||||
|
||||
/******************************************************************************
|
||||
* Include files
|
||||
******************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
|
||||
/* C binding of definitions if building with C++ compiler */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \defgroup AdtGroup Advance Timer (ADT)
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT CHx通道定义
|
||||
*****************************************************************************/
|
||||
typedef enum en_adt_CHxX_port
|
||||
{
|
||||
AdtCHxA = 0u, ///< CHx A通道
|
||||
AdtCHxB = 1u, ///< CHx B通道
|
||||
}en_adt_CHxX_port_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT TRIG端口定义
|
||||
*****************************************************************************/
|
||||
typedef enum en_adt_trig_port
|
||||
{
|
||||
AdtTrigA = 0u, ///< TIMx 触发A端口
|
||||
AdtTrigB = 1u, ///< TIMx 触发B端口
|
||||
AdtTrigC = 2u, ///< TIMx 触发C端口
|
||||
AdtTrigD = 3u, ///< TIMx 触发D端口
|
||||
}en_adt_trig_port_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT通用控制 - Z相输入屏蔽周期数
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_gconr_zmsk
|
||||
{
|
||||
AdtZMaskDis = 0u, ///< Z相输入屏蔽功能无效
|
||||
AdtZMask4Cyl = 1u, ///< 位置计数上溢后或下溢后的4个计数周期内的Z相输入被屏蔽
|
||||
AdtZMask8Cyl = 2u, ///< 位置计数上溢后或下溢后的8个计数周期内的Z相输入被屏蔽
|
||||
AdtZMask16Cyl = 3u, ///< 位置计数上溢后或下溢后的16个计数周期内的Z相输入被屏蔽
|
||||
}en_adt_gconr_zmsk_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT通用控制 - 计数时钟选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_cnt_ckdiv
|
||||
{
|
||||
AdtClkPClk0 = 0u, ///< PCLK0
|
||||
AdtClkPClk0Div2 = 1u, ///< PCLK0/2
|
||||
AdtClkPClk0Div4 = 2u, ///< PCLK0/4
|
||||
AdtClkPClk0Div8 = 3u, ///< PCLK0/8
|
||||
AdtClkPClk0Div16 = 4u, ///< PCLK0/16
|
||||
AdtClkPClk0Div64 = 5u, ///< PCLK0/64
|
||||
AdtClkPClk0Div256 = 6u, ///< PCLK0/256
|
||||
AdtClkPClk0Div1024 = 7u, ///< PCLK0/1024
|
||||
}en_adt_cnt_ckdiv_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT计数模式
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_cnt_mode
|
||||
{
|
||||
AdtSawtoothMode = 0u, ///< 锯齿波模式
|
||||
AdtTriangleModeA = 4u, ///< 三角波A模式
|
||||
AdtTriangleModeB = 5u, ///< 三角波B模式
|
||||
}en_adt_cnt_mode_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT计数方向
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_cnt_dir
|
||||
{
|
||||
AdtCntDown = 0u, ///< 递减计数
|
||||
AdtCntUp = 1u, ///< 递加计数
|
||||
}en_adt_cnt_dir_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT通用比较基准
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_compare
|
||||
{
|
||||
AdtCompareA = 0u, ///< 通用比较基准A
|
||||
AdtCompareB = 1u, ///< 通用比较基准B
|
||||
AdtCompareC = 2u, ///< 通用比较基准C
|
||||
AdtCompareD = 3u, ///< 通用比较基准D
|
||||
}en_adt_compare_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT专用比较基准
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_special_compare
|
||||
{
|
||||
AdtSpclCompA = 0u, ///< 专用比较基准A
|
||||
AdtSpclCompB = 1u, ///< 专用比较基准B
|
||||
}en_adt_special_compare_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT端口控制 - TIMx输出状态控制
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_pconr_disval
|
||||
{
|
||||
AdtTIMxDisValNorm = 0u, ///< 强制输出无效条件0~3中被选择的条件成立时,CHx端口正常输出
|
||||
AdtTIMxDisValHiZ = 1u, ///< 强制输出无效条件0~3中被选择的条件成立时,CHx端口输出高阻态
|
||||
AdtTIMxDisValLow = 2u, ///< 强制输出无效条件0~3中被选择的条件成立时,CHx端口输出低电平
|
||||
AdtTIMxDisValHigh = 3u, ///< 强制输出无效条件0~3中被选择的条件成立时,CHx端口输出高电平
|
||||
}en_adt_pconr_disval_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT端口控制 - CHx强制输出无效条件选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_pconr_dissel
|
||||
{
|
||||
AdtCHxDisSel0 = 0u, ///< 选择强制输出无效条件0
|
||||
AdtCHxDisSel1 = 1u, ///< 选择强制输出无效条件1
|
||||
AdtCHxDisSel2 = 2u, ///< 选择强制输出无效条件2
|
||||
AdtCHxDisSel3 = 3u, ///< 选择强制输出无效条件3
|
||||
}en_adt_pconr_dissel_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT端口控制 - CHx周期值匹配时端口状态设定
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_pconr_perc
|
||||
{
|
||||
AdtCHxPeriodLow = 0u, ///< 计数器计数值与周期值相等时,CHx端口输出保持为低电平
|
||||
AdtCHxPeriodHigh = 1u, ///< 计数器计数值与周期值相等时,CHx端口输出设定为高电平
|
||||
AdtCHxPeriodKeep = 2u, ///< 计数器计数值与周期值相等时,CHx端口输出设定为先前状态
|
||||
AdtCHxPeriodInv = 3u, ///< 计数器计数值与周期值相等时,CHx端口输出设定为反转电平
|
||||
}en_adt_pconr_perc_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT端口控制 - CHx比较值匹配时端口状态设定
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_pconr_cmpc
|
||||
{
|
||||
AdtCHxCompareLow = 0u, ///< 计数器计数值与GCMxR相等时,CHx端口输出保持为低电平
|
||||
AdtCHxCompareHigh = 1u, ///< 计数器计数值与GCMxR相等时,CHx端口输出设定为高电平
|
||||
AdtCHxCompareKeep = 2u, ///< 计数器计数值与GCMxR相等时,CHx端口输出设定为先前状态
|
||||
AdtCHxCompareInv = 3u, ///< 计数器计数值与GCMxR相等时,CHx端口输出设定为反转电平
|
||||
}en_adt_pconr_cmpc_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT端口控制 - CHx端口输出
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_pconr_port_out
|
||||
{
|
||||
AdtCHxPortOutLow = 0u, ///< CHx端口输出设定为低电平
|
||||
AdtCHxPortOutHigh = 1u, ///< CHx端口输出设定为高电平
|
||||
}en_adt_pconr_port_out_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT端口控制 - CHx端口功能模式选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_pconr_capc
|
||||
{
|
||||
AdtCHxCompareOutput = 0u, ///< CHx端口设定为比较输出功能
|
||||
AdtCHxCompareInput = 1u, ///< CHx端口设定为捕获输入功能
|
||||
}en_adt_pconr_capc_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT端口控制 - CHx计数开始停止端口状态选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_pconr_stastps
|
||||
{
|
||||
AdtCHxStateSelSS = 0u, ///< 计数开始或停止时,CHx端口输出由STACB、STPCB决定
|
||||
AdtCHxStateSelKeep = 1u, ///< 计数开始或停止时,CHx端口输出设定为先前状态
|
||||
}en_adt_pconr_stastps_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT死区控制 - CHx死区分离设定
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_dconr_sepa
|
||||
{
|
||||
AdtCHxDtSeperate = 0u, ///< DTUAR和DTDAR分别设定
|
||||
AdtCHxDtEqual = 1u, ///< DTDAR的值和DTUAR的值自动相等
|
||||
}en_adt_dconr_sepa_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT滤波控制 - TRIx/TIMxIx端口滤波采样基准时钟选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_fconr_nofick
|
||||
{
|
||||
AdtFltClkPclk0 = 0u, ///< PCLK0
|
||||
AdtFltClkPclk0Div4 = 1u, ///< PCLK0/4
|
||||
AdtFltClkPclk0Div16 = 2u, ///< PCLK0/16
|
||||
AdtFltClkPclk0Div64 = 3u, ///< PCLK0/64
|
||||
}en_adt_fconr_nofick_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT有效周期 - TIMx有效周期选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_vperr_pcnts
|
||||
{
|
||||
AdtPeriodCnts0 = 0u, ///< 有效周期选择功能无效
|
||||
AdtPeriodCnts1 = 1u, ///< 每隔1个周期有效一次
|
||||
AdtPeriodCnts2 = 2u, ///< 每隔2个周期有效一次
|
||||
AdtPeriodCnts3 = 3u, ///< 每隔3个周期有效一次
|
||||
AdtPeriodCnts4 = 4u, ///< 每隔4个周期有效一次
|
||||
AdtPeriodCnts5 = 5u, ///< 每隔5个周期有效一次
|
||||
AdtPeriodCnts6 = 6u, ///< 每隔6个周期有效一次
|
||||
AdtPeriodCnts7 = 7u, ///< 每隔7个周期有效一次
|
||||
}en_adt_vperr_pcnts_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT有效周期 - 计数条件选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_vperr_pcnte
|
||||
{
|
||||
AdtPeriodCnteDisable = 0u, ///< 有效周期选择功能无效
|
||||
AdtPeriodCnteMin = 1u, ///< 锯齿波计数上、下溢点或三角波波谷做为计数条件
|
||||
AdtPeriodCnteMax = 2u, ///< 锯齿波计数上、下溢点或三角波波峰做为计数条件
|
||||
AdtPeriodCnteBoth = 3u, ///< 锯齿波计数上、下溢点或三角波波峰,波谷做为计数条件
|
||||
}en_adt_vperr_pcnte_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT端口触发控制 - 触发源选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_ttrig_trigxs
|
||||
{
|
||||
AdtTrigxSelP01 = 0u, ///< P01
|
||||
AdtTrigxSelP02 = 1u, ///< P02
|
||||
AdtTrigxSelP03 = 2u, ///< P03
|
||||
AdtTrigxSelP14 = 3u, ///< P14
|
||||
AdtTrigxSelP15 = 4u, ///< P15
|
||||
AdtTrigxSelP23 = 5u, ///< P23
|
||||
AdtTrigxSelP24 = 6u, ///< P24
|
||||
AdtTrigxSelP25 = 7u, ///< P25
|
||||
AdtTrigxSelP26 = 8u, ///< P26
|
||||
AdtTrigxSelP27 = 9u, ///< P27
|
||||
AdtTrigxSelP31 = 10u, ///< P31
|
||||
AdtTrigxSelP32 = 11u, ///< P32
|
||||
AdtTrigxSelP33 = 12u, ///< P33
|
||||
AdtTrigxSelP34 = 13u, ///< P34
|
||||
AdtTrigxSelP35 = 14u, ///< P35
|
||||
AdtTrigxSelP36 = 15u, ///< P36
|
||||
}en_adt_ttrig_trigxs_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT AOS触发控制 - AOSx触发源选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_itrig_iaosxs
|
||||
{
|
||||
AdtAosxTrigSelTim0Int = 0u, ///< TIM0_INT
|
||||
AdtAosxTrigSelTim1Int = 1u, ///< TIM1_INT
|
||||
AdtAosxTrigSelTim2Int = 2u, ///< TIM2_INT
|
||||
AdtAosxTrigSelLpTimInt = 3u, ///< LPTIMER_INT
|
||||
AdtAosxTrigSelTim4Int = 4u, ///< TIM4_INT
|
||||
AdtAosxTrigSelTim5Int = 5u, ///< TIM5_INT
|
||||
AdtAosxTrigSelTim6Int = 6u, ///< TIM6_INT
|
||||
AdtAosxTrigSelUart0Int = 7u, ///< UART0_INT
|
||||
AdtAosxTrigSelUart1Int = 8u, ///< UART1_INT
|
||||
AdtAosxTrigSelLpUartInt = 9u, ///< LPUART_INT
|
||||
AdtAosxTrigSelVc0Int = 10u, ///< VC0_INT
|
||||
AdtAosxTrigSelVc1Int = 11u, ///< VC1_INT
|
||||
AdtAosxTrigSelRtcInt = 12u, ///< RTC_INT
|
||||
AdtAosxTrigSelPcaInt = 13u, ///< PCA_INT
|
||||
AdtAosxTrigSelSpiInt = 14u, ///< SPI_INT
|
||||
AdtAosxTrigSelAdcInt = 15u, ///< ADC_INT
|
||||
}en_adt_itrig_iaosxs_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT硬件(启动/停止/清零/捕获)事件触发选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
|
||||
typedef enum en_adt_hw_trig
|
||||
{
|
||||
AdtHwTrigAos0 = 0u, ///< 从AOS来的事件触发0有效
|
||||
AdtHwTrigAos1 = 1u, ///< 从AOS来的事件触发1有效
|
||||
AdtHwTrigAos2 = 2u, ///< 从AOS来的事件触发2有效
|
||||
AdtHwTrigAos3 = 3u, ///< 从AOS来的事件触发3有效
|
||||
AdtHwTrigCHxARise = 4u, ///< CHxA端口上采样到上升沿
|
||||
AdtHwTrigCHxAFall = 5u, ///< CHxA端口上采样到下降沿
|
||||
AdtHwTrigCHxBRise = 6u, ///< CHxB端口上采样到上升沿
|
||||
AdtHwTrigCHxBFall = 7u, ///< CHxB端口上采样到下降沿
|
||||
AdtHwTrigTimTriARise = 8u, ///< TIMTRIA端口上采样到上升沿
|
||||
AdtHwTrigTimTriAFall = 9u, ///< TIMTRIA端口上采样到下降沿
|
||||
AdtHwTrigTimTriBRise = 10u, ///< TIMTRIB端口上采样到上升沿
|
||||
AdtHwTrigTimTriBFall = 11u, ///< TIMTRIB端口上采样到下降沿
|
||||
AdtHwTrigTimTriCRise = 12u, ///< TIMTRIC端口上采样到上升沿
|
||||
AdtHwTrigTimTriCFall = 13u, ///< TIMTRIC端口上采样到下降沿
|
||||
AdtHwTrigTimTriDRise = 14u, ///< TIMTRID端口上采样到上升沿
|
||||
AdtHwTrigTimTriDFall = 15u, ///< TIMTRID端口上采样到下降沿
|
||||
AdtHwTrigEnd = 16u,
|
||||
}en_adt_hw_trig_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT硬件(递加/递减)事件触发选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
|
||||
typedef enum en_adt_hw_cnt
|
||||
{
|
||||
AdtHwCntCHxALowCHxBRise = 0u, ///< CHxA端口为低电平时,CHxB端口上采样到上升沿
|
||||
AdtHwCntCHxALowCHxBFall = 1u, ///< CHxA端口为低电平时,CHxB端口上采样到下降沿
|
||||
AdtHwCntCHxAHighCHxBRise = 2u, ///< CHxA端口为高电平时,CHxB端口上采样到上升沿
|
||||
AdtHwCntCHxAHighCHxBFall = 3u, ///< CHxA端口为高电平时,CHxB端口上采样到下降沿
|
||||
AdtHwCntCHxBLowCHxARise = 4u, ///< CHxB端口为低电平时,CHxA端口上采样到上升沿
|
||||
AdtHwCntCHxBLowCHxAFall = 5u, ///< CHxB端口为低电平时,CHxA端口上采样到下降沿
|
||||
AdtHwCntCHxBHighChxARise = 6u, ///< CHxB端口为高电平时,CHxA端口上采样到上升沿
|
||||
AdtHwCntCHxBHighCHxAFall = 7u, ///< CHxB端口为高电平时,CHxA端口上采样到下降沿
|
||||
AdtHwCntTimTriARise = 8u, ///< TIMTRIA端口上采样到上升沿
|
||||
AdtHwCntTimTriAFall = 9u, ///< TIMTRIA端口上采样到下降沿
|
||||
AdtHwCntTimTriBRise = 10u, ///< TIMTRIB端口上采样到上升沿
|
||||
AdtHwCntTimTriBFall = 11u, ///< TIMTRIB端口上采样到下降沿
|
||||
AdtHwCntTimTriCRise = 12u, ///< TIMTRIC端口上采样到上升沿
|
||||
AdtHwCntTimTriCFall = 13u, ///< TIMTRIC端口上采样到下降沿
|
||||
AdtHwCntTimTriDRise = 14u, ///< TIMTRID端口上采样到上升沿
|
||||
AdtHwCntTimTriDFall = 15u, ///< TIMTRID端口上采样到下降沿
|
||||
AdtHwCntAos0 = 16u, ///< 从AOS来的事件触发0有效
|
||||
AdtHwCntAos1 = 17u, ///< 从AOS来的事件触发1有效
|
||||
AdtHwCntAos2 = 18u, ///< 从AOS来的事件触发2有效
|
||||
AdtHwCntAos3 = 19u, ///< 从AOS来的事件触发3有效
|
||||
AdtHwCntMax = 20u,
|
||||
}en_adt_hw_cnt_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT端口刹车极性控制
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_ptbrk_polarity
|
||||
{
|
||||
AdtPtBrkHigh = 0u, ///< 端口刹车极性高电平有效
|
||||
AdtPtBrkLow = 1u, ///< 端口刹车极性低电平有效
|
||||
}en_adt_ptbrk_polarity_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT PWM展频计数选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_adt_pwm_dither_type
|
||||
{
|
||||
AdtPwmDitherUnderFlow = 0u, ///< PWM展频计数下溢出
|
||||
AdtPwmDitherOverFlow = 1u, ///< PWM展频计数上溢出
|
||||
}en_adt_pwm_dither_type_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT中断类型
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
|
||||
typedef enum en_adt_irq_type
|
||||
{
|
||||
AdtCMAIrq = 0u, ///< 计数匹配A(或捕获输入)中断
|
||||
AdtCMBIrq = 1u, ///< 计数匹配B(或捕获输入)中断
|
||||
AdtCMCIrq = 2u, ///< 计数匹配C中断
|
||||
AdtCMDIrq = 3u, ///< 计数匹配D中断
|
||||
AdtOVFIrq = 6u, ///< 上溢匹配中断
|
||||
AdtUDFIrq = 7u, ///< 下溢匹配中断
|
||||
AdtDTEIrq = 8u, ///< 死区时间错误中断
|
||||
}en_adt_irq_type_t;
|
||||
|
||||
|
||||
typedef enum en_adt_state_type
|
||||
{
|
||||
AdtCMAF = 0, ///< 计数匹配A标志
|
||||
AdtCMBF = 1, ///< 计数匹配B标志
|
||||
AdtCMCF = 2, ///< 计数匹配C标志
|
||||
AdtCMDF = 3, ///< 计数匹配D标志
|
||||
AdtOVFF = 6, ///< 上溢匹配标志
|
||||
AdtUDFF = 7, ///< 下溢匹配标志
|
||||
AdtDTEF = 8, ///< 死区时间错误标志
|
||||
AdtCntDir = 31, ///< 计数方向
|
||||
}en_adt_state_type_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT软件同步配置
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_adt_sw_sync
|
||||
{
|
||||
boolean_t bAdTim4; ///< Timer 4
|
||||
boolean_t bAdTim5; ///< Timer 5
|
||||
boolean_t bAdTim6; ///< Timer 6
|
||||
|
||||
}stc_adt_sw_sync_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT AOS触发配置
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_adt_aos_trig_cfg
|
||||
{
|
||||
en_adt_itrig_iaosxs_t enAos0TrigSrc; ///< AOS0触发源选择
|
||||
en_adt_itrig_iaosxs_t enAos1TrigSrc; ///< AOS1触发源选择
|
||||
en_adt_itrig_iaosxs_t enAos2TrigSrc; ///< AOS2触发源选择
|
||||
en_adt_itrig_iaosxs_t enAos3TrigSrc; ///< AOS3触发源选择
|
||||
}stc_adt_aos_trig_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT 中断触发配置
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_adt_irq_trig_cfg
|
||||
{
|
||||
boolean_t bAdtUnderFlowTrigEn; ///< 下溢匹配使能触发ADC
|
||||
boolean_t bAdtOverFlowTrigEn; ///< 上溢匹配使能触发ADC
|
||||
boolean_t bAdtCntMatchDTrigEn; ///< 计数匹配D使能触发ADC
|
||||
boolean_t bAdtCntMatchCTrigEn; ///< 计数匹配C使能触发ADC
|
||||
boolean_t bAdtCntMatchBTrigEn; ///< 计数匹配B使能触发ADC
|
||||
boolean_t bAdtCntMatchATrigEn; ///< 计数匹配A使能触发ADC
|
||||
}stc_adt_irq_trig_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT Trig端口配置
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_adt_port_trig_cfg
|
||||
{
|
||||
en_adt_ttrig_trigxs_t enTrigSrc; ///< 触发源选择
|
||||
boolean_t bFltEn; ///< 触发源捕获输入滤波使能
|
||||
en_adt_fconr_nofick_t enFltClk; ///< 滤波采样基准时钟
|
||||
}stc_adt_port_trig_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT Z相输入屏蔽功能配置
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_adt_zmask_cfg
|
||||
{
|
||||
en_adt_gconr_zmsk_t enZMaskCycle; ///< Z相输入屏蔽计数周期选择
|
||||
boolean_t bFltPosCntMaksEn; ///< Z相输入时的屏蔽周期内,位置计数器的清零功能不屏蔽(FALSE)或屏蔽(TRUE)
|
||||
boolean_t bFltRevCntMaksEn; ///< Z相输入时的屏蔽周期内,公转计数器的计数功能不屏蔽(FALSE)或屏蔽(TRUE)
|
||||
}stc_adt_zmask_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT TIMxX端口配置
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_adt_TIMxX_port_cfg
|
||||
{
|
||||
en_adt_pconr_capc_t enCap; ///< 端口功能模式
|
||||
boolean_t bOutEn; ///< 输出使能
|
||||
en_adt_pconr_perc_t enPerc; ///< 周期值匹配时端口状态
|
||||
en_adt_pconr_cmpc_t enCmpc; ///< 比较值匹配时端口状态
|
||||
en_adt_pconr_stastps_t enStaStp; ///< 计数开始停止端口状态选择
|
||||
en_adt_pconr_port_out_t enStaOut; ///< 计数开始端口输出状态
|
||||
en_adt_pconr_port_out_t enStpOut; ///< 计数停止端口输出状态
|
||||
en_adt_pconr_disval_t enDisVal; ///< 强制输出无效时输出状态控制
|
||||
en_adt_pconr_dissel_t enDisSel; ///< 强制输出无效条件选择
|
||||
boolean_t bFltEn; ///< 端口捕获输入滤波使能
|
||||
en_adt_fconr_nofick_t enFltClk; ///< 端口滤波采样基准时钟
|
||||
}stc_adt_CHxX_port_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT刹车端口配置
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_adt_break_port_cfg
|
||||
{
|
||||
boolean_t bPortEn; ///< 端口使能
|
||||
en_adt_ptbrk_polarity_t enPol; ///< 极性选择
|
||||
}stc_adt_break_port_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT无效条件3配置
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_adt_disable_3_cfg
|
||||
{
|
||||
stc_adt_break_port_cfg_t stcBrkPtCfg[16]; ///< 刹车端口配置
|
||||
boolean_t bFltEn; ///< 刹车端口滤波使能
|
||||
en_adt_fconr_nofick_t enFltClk; ///< 滤波采样基准时钟
|
||||
}stc_adt_disable_3_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT无效条件1配置
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_adt_disable_1_cfg
|
||||
{
|
||||
boolean_t bTim6OutSH; ///< TIM6输出同高
|
||||
boolean_t bTim5OutSH; ///< TIM5输出同高
|
||||
boolean_t bTim4OutSH; ///< TIM4输出同高
|
||||
boolean_t bTim6OutSL; ///< TIM6输出同低
|
||||
boolean_t bTim5OutSL; ///< TIM5输出同低
|
||||
boolean_t bTim4OutSL; ///< TIM4输出同低
|
||||
}stc_adt_disable_1_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT PWM展频计数配置
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_adt_pwm_dither_cfg
|
||||
{
|
||||
en_adt_pwm_dither_type_t enAdtPDType; ///< PWM展频计数选择
|
||||
boolean_t bTimxBPDEn; ///< PWM通道B展频使能
|
||||
boolean_t bTimxAPDEn; ///< PWM通道A展频使能
|
||||
}stc_adt_pwm_dither_cfg_t;
|
||||
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT基本计数配置
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_adt_basecnt_cfg
|
||||
{
|
||||
en_adt_cnt_mode_t enCntMode; ///< 计数模式
|
||||
en_adt_cnt_dir_t enCntDir; ///< 计数方向
|
||||
en_adt_cnt_ckdiv_t enCntClkDiv; ///< 计数时钟选择
|
||||
}stc_adt_basecnt_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT计数状态
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_adt_cntstate_cfg
|
||||
{
|
||||
uint16_t u16Counter; ///< 当前计数器的计数值
|
||||
boolean_t enCntDir; ///< 计数方向
|
||||
uint8_t u8ValidPeriod; ///< 有效周期计数
|
||||
boolean_t bDTEF; ///< 死区时间错误标志
|
||||
boolean_t bUDFF; ///< 下溢匹配标志
|
||||
boolean_t bOVFF; ///< 上溢匹配标志
|
||||
boolean_t bCMDF; ///< 计数匹配D标志
|
||||
boolean_t bCMCF; ///< 计数匹配C标志
|
||||
boolean_t bCMBF; ///< 计数匹配B标志
|
||||
boolean_t bCMAF; ///< 计数匹配A标志
|
||||
}stc_adt_cntstate_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief ADT有效计数周期
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_adt_validper_cfg
|
||||
{
|
||||
en_adt_vperr_pcnts_t enValidCnt; ///< 有效周期选择
|
||||
en_adt_vperr_pcnte_t enValidCdt; ///< 有效周期计数条件
|
||||
boolean_t bPeriodD; ///< 通用信号有效周期选择D
|
||||
boolean_t bPeriodC; ///< 通用信号有效周期选择C
|
||||
boolean_t bPeriodB; ///< 通用信号有效周期选择B
|
||||
boolean_t bPeriodA; ///< 通用信号有效周期选择A
|
||||
}stc_adt_validper_cfg_t;
|
||||
|
||||
/******************************************************************************
|
||||
* Global definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Local type definitions ('typedef')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable definitions ('extern')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
******************************************************************************/
|
||||
//配置硬件递加事件
|
||||
en_result_t Adt_CfgHwCntUp(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_cnt_t enAdtHwCntUp);
|
||||
//清除硬件递加事件
|
||||
en_result_t Adt_ClearHwCntUp(M0P_ADTIM_TypeDef *ADTx);
|
||||
//配置硬件递减事件
|
||||
en_result_t Adt_CfgHwCntDwn(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_cnt_t enAdtHwCntDwn);
|
||||
//清除硬件递减事件
|
||||
en_result_t Adt_ClearHwCntDwn(M0P_ADTIM_TypeDef *ADTx);
|
||||
//配置硬件启动事件
|
||||
en_result_t Adt_CfgHwStart(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwStart);
|
||||
//清除硬件启动事件
|
||||
en_result_t Adt_ClearHwStart(M0P_ADTIM_TypeDef *ADTx);
|
||||
//使能硬件启动事件
|
||||
en_result_t Adt_EnableHwStart(M0P_ADTIM_TypeDef *ADTx);
|
||||
//禁止硬件启动事件
|
||||
en_result_t Adt_DisableHwStart(M0P_ADTIM_TypeDef *ADTx);
|
||||
//配置硬件停止事件
|
||||
en_result_t Adt_CfgHwStop(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwStop);
|
||||
//清除硬件停止事件
|
||||
en_result_t Adt_ClearHwStop(M0P_ADTIM_TypeDef *ADTx);
|
||||
//使能硬件停止事件
|
||||
en_result_t Adt_EnableHwStop(M0P_ADTIM_TypeDef *ADTx);
|
||||
//禁止硬件停止事件
|
||||
en_result_t Adt_DisableHwStop(M0P_ADTIM_TypeDef *ADTx);
|
||||
//配置硬件清零事件
|
||||
en_result_t Adt_CfgHwClear(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwClear);
|
||||
//清除硬件清零事件
|
||||
en_result_t Adt_ClearHwClear(M0P_ADTIM_TypeDef *ADTx);
|
||||
//使能硬件清零事件
|
||||
en_result_t Adt_EnableHwClear(M0P_ADTIM_TypeDef *ADTx);
|
||||
//禁止硬件清零事件
|
||||
en_result_t Adt_DisableHwClear(M0P_ADTIM_TypeDef *ADTx);
|
||||
//配置A通道硬件捕获事件
|
||||
en_result_t Adt_CfgHwCaptureA(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwCaptureA);
|
||||
//清除A通道硬件捕获事件
|
||||
en_result_t Adt_ClearHwCaptureA(M0P_ADTIM_TypeDef *ADTx);
|
||||
//配置B通道硬件捕获事件
|
||||
en_result_t Adt_CfgHwCaptureB(M0P_ADTIM_TypeDef *ADTx, en_adt_hw_trig_t enAdtHwCaptureB);
|
||||
//清除B通道硬件捕获事件
|
||||
en_result_t Adt_ClearHwCaptureB(M0P_ADTIM_TypeDef *ADTx);
|
||||
//软件同步启动
|
||||
en_result_t Adt_SwSyncStart(stc_adt_sw_sync_t* pstcAdtSwSyncStart);
|
||||
//软件同步停止
|
||||
en_result_t Adt_SwSyncStop(stc_adt_sw_sync_t* pstcAdtSwSyncStop);
|
||||
//软件同步清零
|
||||
en_result_t Adt_SwSyncClear(stc_adt_sw_sync_t* pstcAdtSwSyncClear);
|
||||
//获取软件同步状态
|
||||
en_result_t Adt_GetSwSyncState(stc_adt_sw_sync_t* pstcAdtSwSyncState);
|
||||
//AOS触发配置
|
||||
en_result_t Adt_AosTrigCfg(stc_adt_aos_trig_cfg_t* pstcAdtAosTrigCfg);
|
||||
//中断触发配置
|
||||
en_result_t Adt_IrqTrigCfg(M0P_ADTIM_TypeDef *ADTx,
|
||||
stc_adt_irq_trig_cfg_t* pstcAdtIrqTrigCfg);
|
||||
//端口触发配置
|
||||
en_result_t Adt_PortTrigCfg(en_adt_trig_port_t enAdtTrigPort,
|
||||
stc_adt_port_trig_cfg_t* pstcAdtPortTrigCfg);
|
||||
//CHxX端口配置
|
||||
en_result_t Adt_CHxXPortCfg(M0P_ADTIM_TypeDef *ADTx,
|
||||
en_adt_CHxX_port_t enAdtCHxXPort,
|
||||
stc_adt_CHxX_port_cfg_t* pstcAdtCHxXCfg);
|
||||
//使能端口刹车
|
||||
en_result_t Adt_EnableBrakePort(uint8_t port, stc_adt_break_port_cfg_t* pstcAdtBrkPtCfg);
|
||||
//清除端口刹车
|
||||
void Adt_ClearBrakePort(void);
|
||||
//无效条件3配置(端口刹车)
|
||||
en_result_t Adt_Disable3Cfg(stc_adt_disable_3_cfg_t* pstcAdtDisable3);
|
||||
//软件刹车 Enable/Disable(仅适用于无效条件3使能的情况下)
|
||||
en_result_t Adt_SwBrake(boolean_t bSwBrk);
|
||||
//获取端口刹车标志
|
||||
boolean_t Adt_GetPortBrakeFlag(void);
|
||||
//清除端口刹车标志
|
||||
void Adt_ClearPortBrakeFlag(void);
|
||||
//无效条件1配置(同高同低刹车)
|
||||
en_result_t Adt_Disable1Cfg(stc_adt_disable_1_cfg_t* pstcAdtDisable1);
|
||||
//获取同高同低刹车标志
|
||||
boolean_t Adt_GetSameBrakeFlag(void);
|
||||
//清除同高同低刹车标志
|
||||
void Adt_ClearSameBrakeFlag(void);
|
||||
//PWM展频配置
|
||||
en_result_t Adt_PwmDitherCfg(M0P_ADTIM_TypeDef *ADTx, stc_adt_pwm_dither_cfg_t* pstcAdtPwmDitherCfg);
|
||||
//AdvTimer初始化
|
||||
en_result_t Adt_Init(M0P_ADTIM_TypeDef *ADTx, stc_adt_basecnt_cfg_t* pstcAdtBaseCntCfg);
|
||||
//AdvTimer去初始化
|
||||
en_result_t Adt_DeInit(M0P_ADTIM_TypeDef *ADTx);
|
||||
//AdvTimert启动
|
||||
en_result_t Adt_StartCount(M0P_ADTIM_TypeDef *ADTx);
|
||||
//AdvTimert停止
|
||||
en_result_t Adt_StopCount(M0P_ADTIM_TypeDef *ADTx);
|
||||
//设置计数值
|
||||
en_result_t Adt_SetCount(M0P_ADTIM_TypeDef *ADTx, uint16_t u16Value);
|
||||
//获取计数值
|
||||
uint16_t Adt_GetCount(M0P_ADTIM_TypeDef *ADTx);
|
||||
//清除计数值
|
||||
en_result_t Adt_ClearCount(M0P_ADTIM_TypeDef *ADTx);
|
||||
//获取有效周期计数值
|
||||
uint8_t Adt_GetVperNum(M0P_ADTIM_TypeDef *ADTx);
|
||||
//获取状态标志
|
||||
boolean_t Adt_GetState(M0P_ADTIM_TypeDef *ADTx, en_adt_state_type_t enstate);
|
||||
//配置计数周期
|
||||
en_result_t Adt_SetPeriod(M0P_ADTIM_TypeDef *ADTx, uint16_t u16Period);
|
||||
//配置计数周期缓冲
|
||||
en_result_t Adt_SetPeriodBuf(M0P_ADTIM_TypeDef *ADTx, uint16_t u16PeriodBuf);
|
||||
//清除计数周期缓冲
|
||||
en_result_t Adt_ClearPeriodBuf(M0P_ADTIM_TypeDef *ADTx);
|
||||
//配置有效计数周期
|
||||
en_result_t Adt_SetValidPeriod(M0P_ADTIM_TypeDef *ADTx,
|
||||
stc_adt_validper_cfg_t* pstcAdtValidPerCfg);
|
||||
//配置比较输出计数基准值
|
||||
en_result_t Adt_SetCompareValue(M0P_ADTIM_TypeDef *ADTx,
|
||||
en_adt_compare_t enAdtCompare,
|
||||
uint16_t u16Compare);
|
||||
//配置通用比较值/捕获值的缓存传送
|
||||
en_result_t Adt_EnableValueBuf(M0P_ADTIM_TypeDef *ADTx,
|
||||
en_adt_CHxX_port_t enAdtCHxXPort,
|
||||
boolean_t bCompareBufEn);
|
||||
//清除比较输出计数值/捕获值缓存
|
||||
en_result_t Adt_ClearValueBuf(M0P_ADTIM_TypeDef *ADTx,
|
||||
en_adt_CHxX_port_t enAdtCHxXPort);
|
||||
//获取捕获值
|
||||
en_result_t Adt_GetCaptureValue(M0P_ADTIM_TypeDef *ADTx,
|
||||
en_adt_CHxX_port_t enAdtCHxXPort,
|
||||
uint16_t* pu16Capture);
|
||||
//获取捕获缓存值
|
||||
en_result_t Adt_GetCaptureBuf(M0P_ADTIM_TypeDef *ADTx,
|
||||
en_adt_CHxX_port_t enAdtCHxXPort,
|
||||
uint16_t* pu16CaptureBuf);
|
||||
//设置死区时间上基准值
|
||||
en_result_t Adt_SetDTUA(M0P_ADTIM_TypeDef *ADTx,
|
||||
uint16_t u16Value);
|
||||
//设置死区时间下基准值
|
||||
en_result_t Adt_SetDTDA(M0P_ADTIM_TypeDef *ADTx,
|
||||
uint16_t u16Value);
|
||||
//配置死区时间功能
|
||||
en_result_t Adt_CfgDT(M0P_ADTIM_TypeDef *ADTx,
|
||||
boolean_t bDTEn,
|
||||
boolean_t bEqual);
|
||||
//配置中断
|
||||
en_result_t Adt_CfgIrq(M0P_ADTIM_TypeDef *ADTx,
|
||||
en_adt_irq_type_t enAdtIrq,
|
||||
boolean_t bEn);
|
||||
//获取中断标志
|
||||
boolean_t Adt_GetIrqFlag(M0P_ADTIM_TypeDef *ADTx,
|
||||
en_adt_irq_type_t enAdtIrq);
|
||||
//清除中断标志
|
||||
en_result_t Adt_ClearIrqFlag(M0P_ADTIM_TypeDef *ADTx,
|
||||
en_adt_irq_type_t enAdtIrq);
|
||||
//清除所有中断标志
|
||||
en_result_t Adt_ClearAllIrqFlag(M0P_ADTIM_TypeDef *ADTx);
|
||||
//Z相输入屏蔽设置
|
||||
en_result_t Adt_CfgZMask(M0P_ADTIM_TypeDef *ADTx,
|
||||
stc_adt_zmask_cfg_t* pstcAdtZMaskCfg);
|
||||
|
||||
//@} // ADT Group
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ADT_H__ */
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
******************************************************************************/
|
||||
@@ -0,0 +1,109 @@
|
||||
/******************************************************************************
|
||||
* 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.h
|
||||
**
|
||||
** BGR 数据结构及API声明.
|
||||
**
|
||||
** - 2018-04-21 LuX V1.0.
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __CRC_H__
|
||||
#define __CRC_H__
|
||||
|
||||
/******************************************************************************
|
||||
* Include files
|
||||
******************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
/* C binding of definitions if building with C++ compiler */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \defgroup BGR
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Global definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Local type definitions ('typedef')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable definitions ('extern')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
******************************************************************************/
|
||||
///<内部温度传感器使能/关闭
|
||||
void Bgr_TempSensorEnable(void);
|
||||
void Bgr_TempSensorDisable(void);
|
||||
///<BGR使能/关闭
|
||||
void Bgr_BgrEnable(void);
|
||||
void Bgr_BgrDisable(void);
|
||||
|
||||
//@} // BGR Group
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BGR_H__ */
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
******************************************************************************/
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
/******************************************************************************
|
||||
* 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.h
|
||||
**
|
||||
** 基本定时器数据结构及API声明
|
||||
** @link BT Group Some description @endlink
|
||||
**
|
||||
** History:
|
||||
** - 2017-05-10 Lux V1.0
|
||||
**
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __BT_H__
|
||||
#define __BT_H__
|
||||
|
||||
/*****************************************************************************
|
||||
* Include files
|
||||
*****************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \defgroup BtGroup Base Timer (BT)
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************/
|
||||
/* Global pre-processor symbols/macros ('#define') */
|
||||
/******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief 定时器选择数据类型重定义
|
||||
*****************************************************************************/
|
||||
typedef enum en_bt_unit
|
||||
{
|
||||
TIM0 = 0u, ///< Timer 0
|
||||
TIM1 = 1u, ///< Timer 1
|
||||
TIM2 = 2u, ///< Timer 2
|
||||
}en_bt_unit_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief 极性控制数据类型重定义 (GATE_P)
|
||||
*****************************************************************************/
|
||||
typedef enum en_bt_gatep
|
||||
{
|
||||
BtPositive = 0u, ///< 高电平有效
|
||||
BtOpposite = 1u, ///< 低电平有效
|
||||
}en_bt_gatep_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief 定时器门控数据类型重定义 (GATE)
|
||||
*****************************************************************************/
|
||||
typedef enum en_bt_gate
|
||||
{
|
||||
BtGateDisable = 0u, ///< 无门控
|
||||
BtGateEnable = 1u, ///< 门控使能
|
||||
}en_bt_gate_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief TIM 预除频选择 (PRS)
|
||||
*****************************************************************************/
|
||||
typedef enum en_bt_timclkdiv
|
||||
{
|
||||
BtPCLKDiv1 = 0u, ///< Div 1
|
||||
BtPCLKDiv2 = 1u, ///< Div 2
|
||||
BtPCLKDiv4 = 2u, ///< Div 4
|
||||
BtPCLKDiv8 = 3u, ///< Div 8
|
||||
BtPCLKDiv16 = 4u, ///< Div 16
|
||||
BtPCLKDiv32 = 5u, ///< Div 32
|
||||
BtPCLKDiv64 = 6u, ///< Div 64
|
||||
BtPCLKDiv256 = 7u, ///< Div 256
|
||||
}en_bt_timclkdiv_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief 翻转输出使能数据类型重定义 (TOG_EN)
|
||||
*****************************************************************************/
|
||||
typedef enum en_bt_toggle
|
||||
{
|
||||
BtTogDisable = 0u, ///< 翻转输出禁止
|
||||
BtTogEnable = 1u, ///< 翻转输出使能
|
||||
}en_bt_toggle_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief 计数/定时器功能选择数据类型重定义 (CT)
|
||||
*****************************************************************************/
|
||||
typedef enum en_bt_function
|
||||
{
|
||||
BtTimer = 0u, ///< 定时器功能
|
||||
BtCounter = 1u, ///< 计数器功能
|
||||
}en_bt_function_t;
|
||||
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief 定时器工作模式数据类型重定义 (MD)
|
||||
*****************************************************************************/
|
||||
typedef enum en_bt_mode
|
||||
{
|
||||
BtMode1 = 0u, ///< 32位计数器/定时器
|
||||
BtMode2 = 1u, ///< 自动重装载16位计数器/定时器
|
||||
}en_bt_mode_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief 定时器运行控制数据类型重定义 (TR)
|
||||
*****************************************************************************/
|
||||
typedef enum en_bt_start
|
||||
{
|
||||
BtTRDisable = 0u, ///< 停止
|
||||
BtTREnable = 1u, ///< 运行
|
||||
}en_bt_start_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief Timer 配置结构体定义
|
||||
*****************************************************************************/
|
||||
typedef struct stc_bt_config
|
||||
{
|
||||
en_bt_gatep_t enGateP; ///< 门控极性控制
|
||||
en_bt_gate_t enGate; ///< 门控使能
|
||||
en_bt_timclkdiv_t enPRS; ///< 预除频配置
|
||||
en_bt_toggle_t enTog; ///< 反转输出使能
|
||||
en_bt_function_t enCT; ///< 定时/计数功能选择
|
||||
en_bt_mode_t enMD; ///< 计数模式配置
|
||||
|
||||
}stc_bt_cfg_t;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable declarations ('extern', definition in C source)
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
*****************************************************************************/
|
||||
//中断相关函数
|
||||
//中断标志获取
|
||||
boolean_t Bt_GetIntFlag(en_bt_unit_t enUnit);
|
||||
//中断标志清除
|
||||
en_result_t Bt_ClearIntFlag(en_bt_unit_t enUnit);
|
||||
//中断使能/禁止
|
||||
en_result_t Bt_EnableIrq (en_bt_unit_t enUnit);
|
||||
en_result_t Bt_DisableIrq(en_bt_unit_t enUnit);
|
||||
|
||||
//初始化及相关功能操作
|
||||
//timer配置及初始化
|
||||
en_result_t Bt_Init(en_bt_unit_t enUnit, stc_bt_cfg_t* pstcCfg);
|
||||
//Lptimer 启动/停止
|
||||
en_result_t Bt_Run(en_bt_unit_t enUnit);
|
||||
en_result_t Bt_Stop(en_bt_unit_t enUnit);
|
||||
//重载值设置
|
||||
en_result_t Bt_ARRSet(en_bt_unit_t enUnit, uint16_t u16Data);
|
||||
//16位计数值设置/获取
|
||||
en_result_t Bt_Cnt16Set(en_bt_unit_t enUnit, uint16_t u16Data);
|
||||
uint16_t Bt_Cnt16Get(en_bt_unit_t enUnit);
|
||||
//32位计数值设置/获取
|
||||
en_result_t Bt_Cnt32Set(en_bt_unit_t enUnit, uint32_t u32Data);
|
||||
uint32_t Bt_Cnt32Get(en_bt_unit_t enUnit);
|
||||
|
||||
//@} // BtGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __BT_H__ */
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2016, Huada Semiconductor Co.,Ltd All rights reserved.
|
||||
*
|
||||
* This software is owned and published by:
|
||||
* Huada Semiconductor Co.,Ltd ("HDSC").
|
||||
*
|
||||
* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
|
||||
* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
|
||||
*
|
||||
* This software contains source code for use with HDSC
|
||||
* components. This software is licensed by HDSC to be adapted only
|
||||
* for use in systems utilizing HDSC components. HDSC shall not be
|
||||
* responsible for misuse or illegal use of this software for devices not
|
||||
* supported herein. HDSC is providing this software "AS IS" and will
|
||||
* not be responsible for issues arising from incorrect user implementation
|
||||
* of the software.
|
||||
*
|
||||
* Disclaimer:
|
||||
* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
|
||||
* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
|
||||
* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
|
||||
* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
|
||||
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
|
||||
* WARRANTY OF NONINFRINGEMENT.
|
||||
* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
|
||||
* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
|
||||
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
|
||||
* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
|
||||
* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
|
||||
* SAVINGS OR PROFITS,
|
||||
* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
|
||||
* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
|
||||
* FROM, THE SOFTWARE.
|
||||
*
|
||||
* This software may be replicated in part or whole for the licensed use,
|
||||
* with the restriction that this Disclaimer and Copyright notice must be
|
||||
* included with each copy of this software, whether used in part or whole,
|
||||
* at all times.
|
||||
*/
|
||||
/******************************************************************************/
|
||||
/** \file crc.h
|
||||
**
|
||||
** CRC 数据结构及API声明.
|
||||
**
|
||||
** - 2016-05-04 LuX V1.0.
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __CRC_H__
|
||||
#define __CRC_H__
|
||||
|
||||
/******************************************************************************
|
||||
* Include files
|
||||
******************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
/* C binding of definitions if building with C++ compiler */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \defgroup CrcGroup Cyclic Redundancy Check (CRC)
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Global definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Local type definitions ('typedef')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable definitions ('extern')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
******************************************************************************/
|
||||
//CRC16 编码值获取
|
||||
uint16_t CRC16_Get8(uint8_t* pu8Data, uint32_t u32Len);
|
||||
uint16_t CRC16_Get16(uint16_t* pu16Data, uint32_t u32Len);
|
||||
uint16_t CRC16_Get32(uint32_t* pu32Data, uint32_t u32Len);
|
||||
//CRC16 校验
|
||||
en_result_t CRC16_Check8(uint8_t* pu8Data, uint32_t u32Len, uint16_t u16CRC);
|
||||
en_result_t CRC16_Check16(uint16_t* pu16Data, uint32_t u32Len, uint16_t u16CRC);
|
||||
en_result_t CRC16_Check32(uint32_t* pu32Data, uint32_t u32Len, uint16_t u16CRC);
|
||||
|
||||
//@} // CRC Group
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CRC_H__ */
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
******************************************************************************/
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
/*******************************************************************************
|
||||
* 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.h
|
||||
**
|
||||
** DDL common define.
|
||||
** @link SampleGroup Some description @endlink
|
||||
**
|
||||
** - 2019-03-03 1.0 Lux First version.
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __DDL_H__
|
||||
#define __DDL_H__
|
||||
|
||||
/******************************************************************************/
|
||||
/* Include files */
|
||||
/******************************************************************************/
|
||||
#include "base_types.h"
|
||||
#include "board_stkhc32f005.h"
|
||||
#include "hc32f005.h"
|
||||
#include "system_hc32f005.h"
|
||||
#include "sysctrl.h"
|
||||
#include "interrupts_hc32f005.h"
|
||||
|
||||
/* C binding of definitions if building with C++ compiler */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
/* Global pre-processor symbols/macros ('#define') */
|
||||
/* Macro for initializing local structures to zero */
|
||||
/******************************************************************************/
|
||||
#define DDL_ZERO_STRUCT(x) ddl_memclr((uint8_t*)&(x), (uint32_t)(sizeof(x)))
|
||||
|
||||
#define DEC2BCD(x) ((((x)/10)<<4) + ((x)%10))
|
||||
#define BCD2DEC(x) ((((x)>>4)*10) + ((x)&0x0F))
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** 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) */
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
///<Flash 初始化配置(编程时间参数置)
|
||||
en_result_t Flash_Init(uint8_t u8FreqCfg);
|
||||
|
||||
///<Flash 页/全片擦除
|
||||
en_result_t Flash_SectorErase(uint32_t u32SectorAddr);
|
||||
en_result_t Flash_ChipErase(void);
|
||||
|
||||
///<Flash 字节/半字/字写
|
||||
en_result_t Flash_WriteByte(uint32_t u32Addr, uint8_t u8Data);
|
||||
en_result_t Flash_WriteHalfWord(uint32_t u32Addr, uint16_t u16Data);
|
||||
en_result_t Flash_WriteWord(uint32_t u32Addr, uint32_t u32Data);
|
||||
|
||||
///<Flash 编程保护加锁/解锁
|
||||
void Flash_LockAll(void);
|
||||
void Flash_UnlockAll(void);
|
||||
en_result_t Flash_LockSet(uint32_t u32LockValue);
|
||||
|
||||
|
||||
///<Flash 读等待周期设定
|
||||
en_result_t Flash_WaitCycle(en_flash_waitcycle_t enWaitCycle);
|
||||
|
||||
///<中断相关函数
|
||||
///<中断使能/禁止
|
||||
en_result_t Flash_EnableIrq(en_flash_int_type_t enFlashIntType);
|
||||
en_result_t Flash_DisableIrq(en_flash_int_type_t enFlashIntType);
|
||||
///<中断标志获取
|
||||
boolean_t Flash_GetIntFlag(en_flash_int_type_t enFlashIntType);
|
||||
///<中断标志清除
|
||||
en_result_t Flash_ClearIntFlag(en_flash_int_type_t enFlashIntType);
|
||||
|
||||
//@} // FlashGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __FLASH_H__ */
|
||||
/******************************************************************************/
|
||||
/* EOF (not truncated) */
|
||||
/******************************************************************************/
|
||||
@@ -0,0 +1,427 @@
|
||||
/*******************************************************************************
|
||||
* 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.h
|
||||
**
|
||||
** GPIO driver
|
||||
** @link GPIO Group Some description @endlink
|
||||
**
|
||||
** - 2018-04-18
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __GPIO_H__
|
||||
#define __GPIO_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* Include files
|
||||
******************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
|
||||
/* C binding of definitions if building with C++ compiler */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \defgroup GpioGroup General Purpose I/O (GPIO)
|
||||
**
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
#define GPIO_GPSZ (0x40u)
|
||||
|
||||
/*******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO PORT类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_port
|
||||
{
|
||||
GpioPort0 = 0x00u, ///< GPIO PORT 0
|
||||
GpioPort1 = 0x40u, ///< GPIO PORT 1
|
||||
GpioPort2 = 0x80u, ///< GPIO PORT 2
|
||||
GpioPort3 = 0xc0u, ///< GPIO PORT 3
|
||||
}en_gpio_port_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO PIN类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_pin
|
||||
{
|
||||
GpioPin0 = 0u, ///< GPIO PIN0
|
||||
GpioPin1 = 1u, ///< GPIO PIN1
|
||||
GpioPin2 = 2u, ///< GPIO PIN2
|
||||
GpioPin3 = 3u, ///< GPIO PIN3
|
||||
GpioPin4 = 4u, ///< GPIO PIN4
|
||||
GpioPin5 = 5u, ///< GPIO PIN5
|
||||
GpioPin6 = 6u, ///< GPIO PIN6
|
||||
GpioPin7 = 7u, ///< GPIO PIN7
|
||||
}en_gpio_pin_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 端口复用功能(AF-Alternate function)类型定义
|
||||
** \note 具体功能及含义请参考用户手册GPIO复用表
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_af
|
||||
{
|
||||
GpioAf0 = 0u, ///< GPIO功能
|
||||
GpioAf1 = 1u, ///< GPIO AF1:复用功能1
|
||||
GpioAf2 = 2u, ///< GPIO AF2:复用功能2
|
||||
GpioAf3 = 3u, ///< GPIO AF3:复用功能3
|
||||
GpioAf4 = 4u, ///< GPIO AF4:复用功能4
|
||||
GpioAf5 = 5u, ///< GPIO AF5:复用功能5
|
||||
GpioAf6 = 6u, ///< GPIO AF6:复用功能6
|
||||
GpioAf7 = 7u, ///< GPIO AF7:复用功能7
|
||||
}en_gpio_af_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO输入输出配置数据类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_dir
|
||||
{
|
||||
GpioDirOut = 0u, ///< GPIO 输出
|
||||
GpioDirIn = 1u, ///< GPIO 输入
|
||||
}en_gpio_dir_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO端口上拉配置数据类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_pu
|
||||
{
|
||||
GpioPuDisable = 0u, ///< GPIO无上拉
|
||||
GpioPuEnable = 1u, ///< GPIO上拉
|
||||
}en_gpio_pu_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO端口下拉配置数据类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_pd
|
||||
{
|
||||
GpioPdDisable = 0u, ///< GPIO无下拉
|
||||
GpioPdEnable = 1u, ///< GPIO下拉
|
||||
}en_gpio_pd_t;
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO端口输出驱动能力配置数据类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_drv
|
||||
{
|
||||
GpioDrvH = 0u, ///< GPIO高驱动能力
|
||||
GpioDrvL = 1u, ///< GPIO低驱动能力
|
||||
}en_gpio_drv_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO端口开漏输出控制数据类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_od
|
||||
{
|
||||
GpioOdDisable = 0u, ///< GPIO开漏输出关闭
|
||||
GpioOdEnable = 1u, ///< GPIO开漏输出使能
|
||||
}en_gpio_od_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO中断触发方式类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_irqtype
|
||||
{
|
||||
GpioIrqHigh = 0u, ///< GPIO高电平触发
|
||||
GpioIrqLow = 1u, ///< GPIO低电平触发
|
||||
GpioIrqRising = 2u, ///< GPIO上升沿触发
|
||||
GpioIrqFalling = 3u, ///< GPIO下降沿触发
|
||||
}en_gpio_irqtype_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 辅助功能(SF-Secondary Function)端口中断模式类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_sf_irqmode
|
||||
{
|
||||
GpioSfIrqDpslpMode = 1u, ///< Deep Sleep模式
|
||||
GpioSfIrqActSlpMode = 0u, ///< Active/Sleep模式
|
||||
}en_gpio_sf_irqmode_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 辅助功能(SF-Secondary Function)HCLK输出门控类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_sf_hclkout_g
|
||||
{
|
||||
GpioSfHclkOutDisable = 0u, ///< HCLK输出门控关闭
|
||||
GpioSfHclkOutEnable = 1u, ///< HCLK输出门控使能
|
||||
}en_gpio_sf_hclkout_g_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 辅助功能(SF-Secondary Function)HCLK输出分频选择类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_sf_hclkout_div
|
||||
{
|
||||
GpioSfHclkOutDiv1 = 0u, ///< HCLK
|
||||
GpioSfHclkOutDiv2 = 1u, ///< HCLK/2
|
||||
GpioSfHclkOutDiv4 = 2u, ///< HCLK/4
|
||||
GpioSfHclkOutDiv8 = 3u, ///< HCLK/8
|
||||
}en_gpio_sf_hclkout_div_t;
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 辅助功能(SF-Secondary Function)PCLK输出门控类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_sf_pclkout_g
|
||||
{
|
||||
GpioSfPclkOutDisable = 0u, ///< PCLK输出门控关闭
|
||||
GpioSfPclkOutEnable = 1u, ///< PCLK输出门控使能
|
||||
}en_gpio_sf_pclkout_g_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 辅助功能(SF-Secondary Function)PCLK输出分频选择类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_sf_pclkout_div
|
||||
{
|
||||
GpioSfPclkOutDiv1 = 0u, ///< PCLK
|
||||
GpioSfPclkOutDiv2 = 1u, ///< PCLK/2
|
||||
GpioSfPclkOutDiv4 = 2u, ///< PCLK/4
|
||||
GpioSfPclkOutDiv8 = 3u, ///< PCLK/8
|
||||
}en_gpio_sf_pclkout_div_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 辅助功能(SF-Secondary Function)IR输出极性选择类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_sf_irpol
|
||||
{
|
||||
GpioSfIrP = 0u, ///< IR正向输出
|
||||
GpioSfIrN = 1u, ///< IR反向输出
|
||||
}en_gpio_sf_irpol_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 辅助功能(SF-Secondary Function)SSN与外部时钟输入信号源选择类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_sf_ssn_extclk
|
||||
{
|
||||
GpioSfSsnExtClkH = 0u, ///< 高电平
|
||||
GpioSfSsnExtClkP35 = 1u, ///< P35
|
||||
GpioSfSsnExtClkP36 = 2u, ///< P36
|
||||
GpioSfSsnExtClkP01 = 3u, ///< P01
|
||||
GpioSfSsnExtClkP02 = 4u, ///< P02
|
||||
GpioSfSsnExtClkP03 = 5u, ///< P03
|
||||
GpioSfSsnExtClkP15 = 6u, ///< P15
|
||||
GpioSfSsnExtClkP14 = 7u, ///< P14
|
||||
GpioSfSsnExtClkP23 = 8u, ///< P23
|
||||
GpioSfSsnExtClkP24 = 9u, ///< P24
|
||||
GpioSfSsnExtClkP25 = 10u, ///< P25
|
||||
GpioSfSsnExtClkP26 = 11u, ///< P26
|
||||
GpioSfSsnExtClkP27 = 12u, ///< P27
|
||||
GpioSfSsnExtClkP31 = 13u, ///< P31
|
||||
GpioSfSsnExtClkP32 = 14u, ///< P32
|
||||
GpioSfSsnExtClkP33 = 15u, ///< P33
|
||||
}en_gpio_sf_ssn_extclk_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 辅助功能(SF-Secondary Function)定时器互联功能选择类型定义
|
||||
** \note 具体功能及含义请参考用户手册GPIO辅助寄存器描述
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_sf
|
||||
{
|
||||
GpioSf0 = 0u, ///< SF0:PX_SEL的配置功能
|
||||
GpioSf1 = 1u, ///< SF1:辅助功能1
|
||||
GpioSf2 = 2u, ///< SF2:辅助功能2
|
||||
GpioSf3 = 3u, ///< SF3:辅助功能3
|
||||
GpioSf4 = 4u, ///< SF4:辅助功能4
|
||||
GpioSf5 = 5u, ///< SF5:辅助功能5
|
||||
GpioSf6 = 6u, ///< SF6:辅助功能6
|
||||
GpioSf7 = 7u, ///< SF7:辅助功能7
|
||||
}en_gpio_sf_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 辅助功能(SF-Secondary Function)定时器门控类型选择数据类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_sf_tim_g
|
||||
{
|
||||
GpioSfTim0G = 0u, ///<Tim0定时器GATE输入选择
|
||||
GpioSfTim1G = 2u, ///<Tim1定时器GATE输入选择
|
||||
GpioSfTim2G = 4u, ///<Tim2定时器GATE输入选择
|
||||
GpioSfTim3G = 6u, ///<Tim3定时器GATE输入选择
|
||||
}en_gpio_sf_tim_g_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 辅助功能(SF-Secondary Function)定时器ETR类型选择数据类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_sf_tim_e
|
||||
{
|
||||
GpioSfTim0E = 0u, ///<Tim0定时器ETR输入选择
|
||||
GpioSfTim1E = 3u, ///<Tim1定时器ETR输入选择
|
||||
GpioSfTim2E = 6u, ///<Tim2定时器ETR输入选择
|
||||
GpioSfTim3E = 9u, ///<Tim3定时器ETR输入选择
|
||||
GpioSfLpTimE = 12u, ///<LPTim定时器ETR输入选择
|
||||
}en_gpio_sf_tim_e_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 辅助功能(SF-Secondary Function)定时器捕获输入类型选择数据类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_sf_tim_c
|
||||
{
|
||||
GpioSfTim4CB = 0u, ///<Tim4定时器CHB输入选择
|
||||
GpioSfTim5CB = 2u, ///<Tim5定时器CHB输入选择
|
||||
GpioSfTim6CB = 4u, ///<Tim6定时器CHB输入选择
|
||||
GpioSfTim4CA = 6u, ///<Tim4定时器CHA输入选择
|
||||
GpioSfTim5CA = 8u, ///<Tim5定时器CHA输入选择
|
||||
GpioSfTim6CA = 10u, ///<Tim6定时器CHA输入选择
|
||||
}en_gpio_sf_tim_c_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 辅助功能(SF-Secondary Function)PCA捕获选择数据类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_gpio_sf_pca
|
||||
{
|
||||
GpioSfPcaCapCH0 = 0u, ///<PCA捕获通道0信号来源选择
|
||||
GpioSfPcaCapCH1 = 2u, ///<PCA捕获通道1信号来源选择
|
||||
GpioSfPcaCapCH2 = 4u, ///<PCA捕获通道2信号来源选择
|
||||
GpioSfPcaCapCH3 = 6u, ///<PCA捕获通道3信号来源选择
|
||||
GpioSfPcaCapCH4 = 8u, ///<PCA捕获通道4信号来源选择
|
||||
}en_gpio_sf_pca_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 端口配置结构体定义
|
||||
******************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
en_gpio_dir_t enDir; ///< 端口方向配置
|
||||
en_gpio_drv_t enDrv; ///< 端口驱动能力配置
|
||||
en_gpio_pu_t enPu; ///< 端口上拉配置
|
||||
en_gpio_pd_t enPd; ///< 端口下拉配置
|
||||
en_gpio_od_t enOD; ///< 端口开漏输出配置
|
||||
}stc_gpio_cfg_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* Global definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Local type definitions ('typedef')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable definitions ('extern')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
Global function prototypes (definition in C source)
|
||||
*******************************************************************************/
|
||||
///< GPIO IO初始化/去初始化
|
||||
en_result_t Gpio_Init(en_gpio_port_t enPort, en_gpio_pin_t enPin, stc_gpio_cfg_t *pstcGpioCfg);
|
||||
|
||||
///< GPIO 获取端口输入电平
|
||||
boolean_t Gpio_GetInputIO(en_gpio_port_t enPort, en_gpio_pin_t enPin);
|
||||
uint16_t Gpio_GetInputData(en_gpio_port_t enPort);
|
||||
|
||||
///< GPIO 设置端口输出
|
||||
///< GPIO 端口输出电平配置及获取
|
||||
en_result_t Gpio_WriteOutputIO(en_gpio_port_t enPort, en_gpio_pin_t enPin, boolean_t bVal);
|
||||
boolean_t Gpio_ReadOutputIO(en_gpio_port_t enPort, en_gpio_pin_t enPin);
|
||||
|
||||
///< GPIO 设置端口为模拟功能
|
||||
en_result_t Gpio_SetAnalogMode(en_gpio_port_t enPort, en_gpio_pin_t enPin);
|
||||
|
||||
///< GPIO 设置端口为端口复用功能
|
||||
en_result_t Gpio_SetAfMode(en_gpio_port_t enPort, en_gpio_pin_t enPin, en_gpio_af_t enAf);
|
||||
|
||||
///< GPIO 端口中断控制功能使能/关闭
|
||||
en_result_t Gpio_EnableIrq(en_gpio_port_t enPort, en_gpio_pin_t enPin, en_gpio_irqtype_t enType);
|
||||
en_result_t Gpio_DisableIrq(en_gpio_port_t enPort, en_gpio_pin_t enPin, en_gpio_irqtype_t enType);
|
||||
///< GPIO 中断状态获取
|
||||
boolean_t Gpio_GetIrqStatus(en_gpio_port_t enPort, en_gpio_pin_t enPin);
|
||||
///< GPIO 中断标志清除
|
||||
en_result_t Gpio_ClearIrq(en_gpio_port_t enPort, en_gpio_pin_t enPin);
|
||||
|
||||
///< GPIO 端口辅助功能配置
|
||||
///< GPIO 中断模式配置
|
||||
en_result_t Gpio_SfIrqModeCfg(en_gpio_sf_irqmode_t enIrqMode);
|
||||
///< GPIO IR输出极性配置
|
||||
en_result_t Gpio_SfIrPolCfg(en_gpio_sf_irpol_t enIrPolMode);
|
||||
///< GPIO HCLK输出配置
|
||||
en_result_t Gpio_SfHClkOutputCfg(en_gpio_sf_hclkout_g_t enGate, en_gpio_sf_hclkout_div_t enDiv);
|
||||
///< GPIO PCLK输出配置
|
||||
en_result_t Gpio_SfPClkOutputCfg(en_gpio_sf_pclkout_g_t enGate, en_gpio_sf_pclkout_div_t enDiv);
|
||||
///< GPIO 外部时钟输入配置
|
||||
en_result_t Gpio_SfExtClkCfg(en_gpio_sf_ssn_extclk_t enExtClk);
|
||||
///< GPIO SPI SSN输入配置
|
||||
en_result_t Gpio_SfSsnCfg(en_gpio_sf_ssn_extclk_t enSsn);
|
||||
///< GPIO Timer 门控输入配置
|
||||
en_result_t Gpio_SfTimGCfg(en_gpio_sf_tim_g_t enTimG, en_gpio_sf_t enSf);
|
||||
///< GPIO Timer ETR选择配置
|
||||
en_result_t Gpio_SfTimECfg(en_gpio_sf_tim_e_t enTimE, en_gpio_sf_t enSf);
|
||||
///< GPIO Timer 捕获输入配置
|
||||
en_result_t Gpio_SfTimCCfg(en_gpio_sf_tim_c_t enTimC, en_gpio_sf_t enSf);
|
||||
///< GPIO PCA捕获选择配置
|
||||
en_result_t Gpio_SfPcaCfg(en_gpio_sf_pca_t enPca, en_gpio_sf_t enSf);
|
||||
|
||||
|
||||
//@} // GpioGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GPIO_H__ */
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
******************************************************************************/
|
||||
@@ -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 i2c.h
|
||||
**
|
||||
** Headerfile for I2C functions
|
||||
**
|
||||
**
|
||||
** History:
|
||||
** - 2018-03-1 CJ First Version
|
||||
**
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __I2C_H__
|
||||
#define __I2C_H__
|
||||
|
||||
#include "ddl.h"
|
||||
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \defgroup I2cGroup Inter-Integrated Circuit (I2C)
|
||||
**
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************/
|
||||
/* Global pre-processor symbols/macros ('#define') */
|
||||
/******************************************************************************/
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief I2C功能配置
|
||||
*****************************************************************************/
|
||||
typedef enum en_i2c_func
|
||||
{
|
||||
I2cModule_En = 6u, ///<I2C模块使能
|
||||
I2cStart_En = 5u, ///<开始信号
|
||||
I2cStop_En = 4u, ///<结束信号
|
||||
I2cAck_En = 2u, ///<应答信号
|
||||
I2cHlm_En = 0u, ///<高速使能
|
||||
}en_i2c_func_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief I2C模式配置
|
||||
*****************************************************************************/
|
||||
typedef enum en_i2c_mode
|
||||
{
|
||||
I2cMasterMode = 0x40u, ///<I2C主机模式
|
||||
I2cSlaveMode = 0x44u, ///<I2C从机模式
|
||||
}en_i2c_mode_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief I2C初始化配置结构
|
||||
*****************************************************************************/
|
||||
typedef struct stc_i2c_cfg
|
||||
{
|
||||
uint32_t u32Pclk; ///<Pclk 设置(Hz)
|
||||
uint32_t u32Baud; ///<I2C通信波特率(Hz)
|
||||
en_i2c_mode_t enMode; ///<I2C主从模式配置
|
||||
uint8_t u8SlaveAddr; ///<从机地址配置(如果需要)
|
||||
boolean_t bGc; ///<广播地址使能(如果需要)
|
||||
}stc_i2c_cfg_t;
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable declarations ('extern', definition in C source)
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
*****************************************************************************/
|
||||
//I2C初始化函数
|
||||
en_result_t I2C_Init(M0P_I2C_TypeDef* I2Cx,stc_i2c_cfg_t *pstcI2CCfg);
|
||||
//设置波特率配置寄存器
|
||||
en_result_t I2C_SetBaud(M0P_I2C_TypeDef* I2Cx,uint8_t u8Tm);
|
||||
//I2C功能设置函数
|
||||
en_result_t I2C_SetFunc(M0P_I2C_TypeDef* I2Cx,en_i2c_func_t enFunc);
|
||||
//I2C功能清除函数
|
||||
en_result_t I2C_ClearFunc(M0P_I2C_TypeDef* I2Cx,en_i2c_func_t enFunc);
|
||||
//获取中断标记SI
|
||||
boolean_t I2C_GetIrq(M0P_I2C_TypeDef* I2Cx);
|
||||
//清除中断标记SI
|
||||
en_result_t I2C_ClearIrq(M0P_I2C_TypeDef* I2Cx);
|
||||
//获取状态
|
||||
uint8_t I2C_GetState(M0P_I2C_TypeDef* I2Cx);
|
||||
|
||||
//字节写函数
|
||||
en_result_t I2C_WriteByte(M0P_I2C_TypeDef* I2Cx,uint8_t u8Data);
|
||||
|
||||
//字节读函数
|
||||
uint8_t I2C_ReadByte(M0P_I2C_TypeDef* I2Cx);
|
||||
|
||||
//@} // I2cGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
#endif
|
||||
|
||||
#endif /* __I2C_H__ */
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/******************************************************************************
|
||||
* 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.h
|
||||
**
|
||||
** Lpm 数据结构及API声明
|
||||
**
|
||||
**
|
||||
** History:
|
||||
** - 2017-06-06 Lux V1.0
|
||||
**
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __LPM_H__
|
||||
#define __LPM_H__
|
||||
|
||||
/*****************************************************************************
|
||||
* Include files
|
||||
*****************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \defgroup LpmGroup Low Power Management (LPM)
|
||||
**
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************
|
||||
** Global pre-processor symbols/macros ('#define')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable declarations ('extern', definition in C source)
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
*****************************************************************************/
|
||||
///<功能配置及操作函数
|
||||
///<进入普通休眠模式
|
||||
void Lpm_GotoSleep(boolean_t bOnExit);
|
||||
///<进入深度休眠模式
|
||||
void Lpm_GotoDeepSleep(boolean_t bOnExit);
|
||||
|
||||
//@} // LpmGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __LPM_H__ */
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved.
|
||||
*
|
||||
* This software is owned and published by:
|
||||
* Huada Semiconductor Co.,Ltd ("HDSC").
|
||||
*
|
||||
* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
|
||||
* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
|
||||
*
|
||||
* This software contains source code for use with HDSC
|
||||
* components. This software is licensed by HDSC to be adapted only
|
||||
* for use in systems utilizing HDSC components. HDSC shall not be
|
||||
* responsible for misuse or illegal use of this software for devices not
|
||||
* supported herein. HDSC is providing this software "AS IS" and will
|
||||
* not be responsible for issues arising from incorrect user implementation
|
||||
* of the software.
|
||||
*
|
||||
* Disclaimer:
|
||||
* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
|
||||
* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
|
||||
* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
|
||||
* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
|
||||
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
|
||||
* WARRANTY OF NONINFRINGEMENT.
|
||||
* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
|
||||
* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
|
||||
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
|
||||
* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
|
||||
* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
|
||||
* SAVINGS OR PROFITS,
|
||||
* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
|
||||
* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
|
||||
* FROM, THE SOFTWARE.
|
||||
*
|
||||
* This software may be replicated in part or whole for the licensed use,
|
||||
* with the restriction that this Disclaimer and Copyright notice must be
|
||||
* included with each copy of this software, whether used in part or whole,
|
||||
* at all times.
|
||||
*/
|
||||
/******************************************************************************/
|
||||
/** \file lvd.h
|
||||
**
|
||||
** Headerfile for Low Voltage Detector functions
|
||||
**
|
||||
** - 2017-06-28 Alex First Version
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __LVD_H__
|
||||
#define __LVD_H__
|
||||
|
||||
/******************************************************************************
|
||||
* Include files
|
||||
******************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
|
||||
/* C binding of definitions if building with C++ compiler */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \defgroup LvdGroup Low Voltage Detector (LVD)
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief LVD监测电压源选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_lvd_input_src
|
||||
{
|
||||
LvdInputSrcMskVCC = 0u<<2, ///< Vcc
|
||||
LvdInputSrcMskP03 = 1u<<2, ///< P03
|
||||
LvdInputSrcMskP23 = 2u<<2, ///< P23
|
||||
LvdInputSrcMskP25 = 3u<<2, ///< P25
|
||||
}en_lvd_input_src_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief LVD阈值电压选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_lvd_threshold
|
||||
{
|
||||
LvdMskTH1_8V = 0u<<4, ///< 1.8V
|
||||
LvdMskTH1_9V = 1u<<4, ///< 1.9V
|
||||
LvdMskTH2_0V = 2u<<4, ///< 2.0V
|
||||
LvdMskTH2_1V = 3u<<4, ///< 2.1V
|
||||
LvdMskTH2_2V = 4u<<4, ///< 2.2V
|
||||
LvdMskTH2_3V = 5u<<4, ///< 2.3V
|
||||
LvdMskTH2_4V = 6u<<4, ///< 2.4V
|
||||
LvdMskTH2_5V = 7u<<4, ///< 2.5V
|
||||
LvdMskTH2_6V = 8u<<4, ///< 2.6V
|
||||
LvdMskTH2_7V = 9u<<4, ///< 2.7V
|
||||
LvdMskTH2_8V = 10u<<4, ///< 2.8V
|
||||
LvdMskTH2_9V = 11u<<4, ///< 2.9V
|
||||
LvdMskTH3_0V = 12u<<4, ///< 3.0V
|
||||
LvdMskTH3_1V = 13u<<4, ///< 3.1V
|
||||
LvdMskTH3_2V = 14u<<4, ///< 3.2V
|
||||
LvdMskTH3_3V = 15u<<4, ///< 3.3V
|
||||
}en_lvd_threshold_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief LVD输出滤波时间
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_lvd_filter_time
|
||||
{
|
||||
LvdFilterMsk7us = 0u<<9, ///< 7us
|
||||
LvdFilterMsk14us = 1u<<9, ///< 14us
|
||||
LvdFilterMsk28us = 2u<<9, ///< 28us
|
||||
LvdFilterMsk112us = 3u<<9, ///< 112us
|
||||
LvdFilterMsk450us = 4u<<9, ///< 450us
|
||||
LvdFilterMsk1_8ms = 5u<<9, ///< 1.8ms
|
||||
LvdFilterMsk7_2ms = 6u<<9, ///< 7.3ms
|
||||
LvdFilterMsk28_8ms = 7u<<9, ///< 28.8ms
|
||||
}en_lvd_filter_time_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief LVD中断触发方式
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_lvd_irq_type
|
||||
{
|
||||
LvdIrqMskRiseFall = 3u<<12, ///< 上升/下降沿触发
|
||||
LvdIrqMskHigh = 1u<<14, ///< 高电平触发
|
||||
LvdIrqMskRise = 1u<<13, ///< 上升沿触发
|
||||
LvdIrqMskFall = 1u<<12, ///< 下降沿触发
|
||||
}en_lvd_irq_type_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief LVD触发动作选择
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_lvd_act
|
||||
{
|
||||
LvdActMskReset = 1u<<1, ///< 系统复位
|
||||
LvdActMskInt = 0u, ///< NVIC中断
|
||||
}en_lvd_act_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief LVD数字滤波使能配置
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_lvd_filter
|
||||
{
|
||||
LvdFilterMskEnable = 1u<<8, ///< 数字滤波使能
|
||||
LvdFilterMskDisable = 0u, ///< 数字滤波禁止
|
||||
}en_lvd_filter_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief LVD配置
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct stc_lvd_cfg
|
||||
{
|
||||
en_lvd_act_t enAct; ///< LVD触发动作
|
||||
en_lvd_input_src_t enInputSrc; ///< LVD输入电压源
|
||||
en_lvd_threshold_t enThreshold; ///< LVD监测电压
|
||||
en_lvd_filter_t enFilter; ///< 是否使用输出滤波
|
||||
en_lvd_filter_time_t enFilterTime; ///< 输出滤波时间
|
||||
en_lvd_irq_type_t enIrqType; ///< 中断触发方式
|
||||
}stc_lvd_cfg_t;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Global definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Local type definitions ('typedef')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable definitions ('extern')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
******************************************************************************/
|
||||
//irq enable/disable
|
||||
void Lvd_EnableIrq(void);
|
||||
void Lvd_DisableIrq(void);
|
||||
|
||||
// irq function
|
||||
void Lvd_ClearIrq(void);
|
||||
boolean_t Lvd_GetIrqStat(void);
|
||||
|
||||
//init/deinit function
|
||||
void Lvd_Init(stc_lvd_cfg_t *pstcCfg);
|
||||
|
||||
//LVD function enable/disable
|
||||
void Lvd_Enable(void);
|
||||
void Lvd_Disable(void);
|
||||
|
||||
//@} // LvdGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LVD_H__ */
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
******************************************************************************/
|
||||
@@ -0,0 +1,259 @@
|
||||
/******************************************************************************
|
||||
* 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.h
|
||||
**
|
||||
** PCA(可编程计数阵列)数据结构及API声明
|
||||
**
|
||||
**
|
||||
** History:
|
||||
** - 2019-04-09 First version
|
||||
**
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __PCA_H__
|
||||
#define __PCA_H__
|
||||
|
||||
/*****************************************************************************
|
||||
* Include files
|
||||
*****************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \defgroup PcaGroup Programmable Counter Array (PCA)
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************/
|
||||
/* Global pre-processor symbols/macros ('#define') */
|
||||
/******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief PCA 模块选择
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
PcaModule0 = 0, // PCA_0
|
||||
PcaModule1 = 1, // PCA_1
|
||||
PcaModule2 = 2, // PCA_2
|
||||
PcaModule3 = 3, // PCA_3
|
||||
PcaModule4 = 4 // PCA_4
|
||||
}en_pca_module_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief PCA 中断标志位 中断清除位
|
||||
** \note PCA_CCON中的CCF0-CCF4与CF; PCA_ICLR中的CCF0-CCF4与CF
|
||||
******************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
PcaCcf0 = 0,
|
||||
PcaCcf1 = 1,
|
||||
PcaCcf2 = 2,
|
||||
PcaCcf3 = 3,
|
||||
PcaCcf4 = 4,
|
||||
PcaCf = 7
|
||||
}en_pca_ccficlr_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief PCA 时钟分频选择及时钟源选择
|
||||
** \note PCA_CMOD CPS[2:0]
|
||||
******************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
PcaPclkdiv32 = 0, // PCLK/32
|
||||
PcaPclkdiv16 = 1, // PCLK/16
|
||||
PcaPclkdiv8 = 2, // PCLK/8
|
||||
PcaPclkdiv4 = 3, // PCLK/4
|
||||
PcaPclkdiv2 = 4, // PCLK/2
|
||||
PcaTim0ovf = 5, // timer0 overflow
|
||||
PcaTim1ovf = 6, // timer1 overflow
|
||||
PcaEci = 7 // ECI外部时钟
|
||||
}en_pca_clksrc_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief PCA 允许比较器功能控制
|
||||
** \note PCA_CCAPMx ECOM
|
||||
******************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
PcaEcomDisable = 0,
|
||||
PcaEcomEnable = 1
|
||||
}en_pca_ecom_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief PCA 正沿捕获控制位
|
||||
** \note PCA_CCAPMx CAPP
|
||||
******************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
PcaCappDisable = 0,
|
||||
PcaCappEnable = 1
|
||||
}en_pca_capp_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief PCA 负沿捕获控制位
|
||||
** \note PCA_CCAPMx CAPN
|
||||
******************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
PcaCapnDisable = 0,
|
||||
PcaCapnEnable = 1
|
||||
}en_pca_capn_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief PCA 匹配控制位
|
||||
** \note PCA_CCAPMx MAT
|
||||
******************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
PcaMatDisable = 0,
|
||||
PcaMatEnable = 1
|
||||
}en_pca_mat_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief PCA 翻转控制位
|
||||
** \note PCA_CCAPMx TOG
|
||||
******************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
PcaTogDisable = 0,
|
||||
PcaTogEnable = 1
|
||||
}en_pca_tog_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief PCA PWM控制位
|
||||
** \note PCA_CCAPMx PWM
|
||||
******************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
PcaPwm8bitDisable = 0,
|
||||
PcaPwm8bitEnable = 1
|
||||
}en_pca_pwm8bit_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief PCA EPWM控制位
|
||||
** \note PCA_EPWM EPWM
|
||||
******************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
PcaEpwmDisable = 0,
|
||||
PcaEpwmEnable = 1
|
||||
}en_pca_epwm_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief PCA 初始化配置的结构体
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
en_pca_clksrc_t pca_clksrc; // PCA_CMOD CPS[2:0]
|
||||
boolean_t pca_cidl; // PCA_CMOD CIDL
|
||||
en_pca_ecom_t pca_ecom; // PCA_CCAPMx ECOM
|
||||
en_pca_capp_t pca_capp; // PCA_CCAPMx CAPP
|
||||
en_pca_capn_t pca_capn; // PCA_CCAPMx CAPN
|
||||
en_pca_mat_t pca_mat; // PCA_CCAPMx MAT
|
||||
en_pca_tog_t pca_tog; // PCA_CCAPMx TOG
|
||||
en_pca_pwm8bit_t pca_pwm; // PCA_CCAPMx PWM
|
||||
|
||||
uint16_t pca_ccap; // PCA_CCAP
|
||||
uint8_t pca_ccapl; // PCA_CCAPL PCA_CCAP的低字节
|
||||
uint8_t pca_ccaph; // PCA_CCAPH PCA_CCAP的高字节
|
||||
|
||||
}stc_pcacfg_t;
|
||||
/******************************************************************************
|
||||
* Global variable declarations ('extern', definition in C source)
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
*****************************************************************************/
|
||||
extern boolean_t Pca_GetItStatus(en_pca_ccficlr_t It_Src);
|
||||
extern void Pca_ClrItStatus(en_pca_ccficlr_t It_Src);
|
||||
extern void Pca_StartPca(boolean_t NewStatus);
|
||||
extern void Pca_SetCidl(boolean_t NewStatus);
|
||||
extern void Pca_Set4Wdte(boolean_t NewStatus);
|
||||
extern void Pca_ConfPcaIt(boolean_t NewStatus);
|
||||
extern void Pca_ConfModulexIt(en_pca_module_t Modulex, boolean_t NewStatus);
|
||||
extern void Pca_M0Init(stc_pcacfg_t* InitStruct);
|
||||
extern void Pca_M1Init(stc_pcacfg_t* InitStruct);
|
||||
extern void Pca_M2Init(stc_pcacfg_t* InitStruct);
|
||||
extern void Pca_M3Init(stc_pcacfg_t* InitStruct);
|
||||
extern void Pca_M4Init(stc_pcacfg_t* InitStruct);
|
||||
extern uint16_t Pca_GetCnt(void);
|
||||
extern void Pca_SetCnt(uint16_t cnt);
|
||||
extern boolean_t Pca_GetOut(en_pca_module_t Modulex);
|
||||
extern void Pca_SetCcap(en_pca_module_t Modulex, uint16_t Value);
|
||||
extern uint16_t Pca_GetCcap(en_pca_module_t Modulex);
|
||||
extern void Pca_SetCcapHL(en_pca_module_t Modulex, uint8_t ValueH, uint8_t ValueL);
|
||||
extern void Pca_GetCcapHL(en_pca_module_t Modulex, uint8_t *ValueH, uint8_t *ValueL);
|
||||
|
||||
//@} // PcaGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
#endif
|
||||
|
||||
#endif /* __PCA_H__ */
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
*****************************************************************************/
|
||||
@@ -0,0 +1,119 @@
|
||||
/*************************************************************************************
|
||||
* 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 ram.h
|
||||
**
|
||||
** RAM 数据结构及API声明.
|
||||
**
|
||||
** - 2019-04-02 LuX V1.0
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __RAM_H__
|
||||
#define __RAM_H__
|
||||
|
||||
/******************************************************************************/
|
||||
/* Include files */
|
||||
/******************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
/* C binding of definitions if building with C++ compiler */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \defgroup RamGroup Ram Controller (Ram)
|
||||
**
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief Redefinition of RAM register structure
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Local type definitions ('typedef')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable definitions ('extern')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
///<中断相关函数
|
||||
///<中断使能/禁止
|
||||
en_result_t Ram_EnableIrq(void);
|
||||
en_result_t Ram_DisableIrq(void);
|
||||
///<中断标志获取
|
||||
boolean_t Ram_GetIntFlag(void);
|
||||
///<中断标志清除
|
||||
en_result_t Ram_ClearIntFlag(void);
|
||||
///<奇偶校验出错地址获取
|
||||
uint32_t Ram_ErrAddrGet(void);
|
||||
|
||||
//@} // RamGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __RAM_H__ */
|
||||
/******************************************************************************/
|
||||
/* EOF (not truncated) */
|
||||
/******************************************************************************/
|
||||
@@ -0,0 +1,153 @@
|
||||
/******************************************************************************
|
||||
* 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 reset.h
|
||||
**
|
||||
** Headerfile for reset functions
|
||||
**
|
||||
**
|
||||
** History:
|
||||
** - 2018-04-21 Lux First Version
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __RESET_H__
|
||||
#define __RESET_H__
|
||||
|
||||
/******************************************************************************
|
||||
* Include files
|
||||
******************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \defgroup ResetGroup Reset (RST)
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** function prototypes.
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Global definitions
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief 外设复位控制类型定义
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_sysctrl_peripheral
|
||||
{
|
||||
ResetMskUart0 = 1u<<0u, ///< 串口0
|
||||
ResetMskUart1 = 1u<<1u, ///< 串口1
|
||||
ResetMskI2c = 1u<<4u, ///< I2C
|
||||
ResetMskSpi = 1u<<6u, ///< SPI
|
||||
ResetMskBaseTim = 1u<<8u, ///< 基础定时器TIM0/1/2
|
||||
ResetMskAdvTim = 1u<<10u, ///< 高级定时器TIM4/5/6
|
||||
ResetMskPca = 1u<<14u, ///< 可编程计数阵列
|
||||
ResetMskAdcBgr = 1u<<16u, ///< ADC&BGR
|
||||
ResetMskVcLvd = 1u<<17u, ///< VC和LVD
|
||||
ResetMskTrim = 1u<<21u, ///< 时钟校准
|
||||
ResetMskTick = 1u<<24u, ///< 系统定时器
|
||||
ResetMskCrc = 1u<<26u, ///< CRC
|
||||
ResetMskGpio = 1u<<28u, ///< GPIO
|
||||
}en_reset_peripheral_t;
|
||||
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief 复位源(标识)显示
|
||||
**
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_reset_flag
|
||||
{
|
||||
ResetFlagMskPor5V = 1u<<0u, ///< 5V启动复位
|
||||
ResetFlagMskPor1_5V = 1u<<1u, ///< 1.5V启动复位
|
||||
ResetFlagMskLvd = 1u<<2u, ///< 低电压检测复位
|
||||
ResetFlagMskWdt = 1u<<3u, ///< 看门狗复位
|
||||
ResetFlagMskPca = 1u<<4u, ///< PCA复位
|
||||
ResetFlagMskLockup = 1u<<5u, ///< 系统异常复位
|
||||
ResetFlagMskSysreq = 1u<<6u, ///< 软件复位
|
||||
ResetFlagMskRstb = 1u<<7u, ///< RESET脚 复位
|
||||
}en_reset_flag_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* Global variable declarations ('extern', definition in C source)
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
******************************************************************************/
|
||||
///< 获得复位源状态
|
||||
boolean_t Reset_GetFlag(en_reset_flag_t enRstFlg);
|
||||
///< 清除复位源状态
|
||||
void Reset_ClearFlag(en_reset_flag_t enRstFlg);
|
||||
void Reset_ClearFlagAll(void);
|
||||
|
||||
///< 外设模块复位
|
||||
void Reset_RstPeripheralAll(void);
|
||||
void Reset_RstPeripheral(en_reset_peripheral_t enPeri);
|
||||
|
||||
//@} // ResetGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __RESET_H__ */
|
||||
/*******************************************************************************
|
||||
* EOF (not truncated)
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
/******************************************************************************
|
||||
* 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 spi.h
|
||||
**
|
||||
** Headerfile for SPI functions
|
||||
**
|
||||
**
|
||||
** History:
|
||||
** - 2017-05-17 1.0 Devi First Version
|
||||
**
|
||||
*****************************************************************************/
|
||||
#ifndef __SPI_H__
|
||||
#define __SPI_H__
|
||||
|
||||
/******************************************************************************
|
||||
* Include files
|
||||
*****************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
|
||||
/* C binding of definitions if building with C++ compiler */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//@{
|
||||
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
*****************************************************************************/
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief SPI 功能通道选择设置
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief SPI 功能使能设置
|
||||
******************************************************************************/
|
||||
typedef enum en_spi_en
|
||||
{
|
||||
SpiMskEnable = 0x4u, ///< SPI模块使能
|
||||
SpiMskDisable = 0u, ///< SPI模块禁止
|
||||
}en_spi_en_t;
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief SPI 模式配置
|
||||
******************************************************************************/
|
||||
typedef enum en_spi_mode
|
||||
{
|
||||
SpiMskMaster = 0x10u, ///<主机
|
||||
SpiMskSlave = 0x00u, ///<从机
|
||||
}en_spi_mode_t;
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief SPI 时钟极性设置
|
||||
******************************************************************************/
|
||||
typedef enum en_spi_cpol
|
||||
{
|
||||
SpiMskcpollow = 0u, ///<极性为低
|
||||
SpiMskcpolhigh = 0x08u, ///<极性为高
|
||||
}en_spi_cpol_t;
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief SPI 时钟相位设置
|
||||
******************************************************************************/
|
||||
typedef enum en_spi_cpha
|
||||
{
|
||||
SpiMskCphafirst = 0u, ///<第一边沿采样
|
||||
SpiMskCphasecond = 0x4u, ///<第二边沿采样
|
||||
}en_spi_cpha_t;
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief SPI 时钟分频配置
|
||||
*****************************************************************************/
|
||||
typedef enum en_spi_clk_div
|
||||
{
|
||||
SpiClkMskDiv2 = 0x00u, ///<2分频
|
||||
SpiClkMskDiv4 = 0x01u, ///<4分频
|
||||
SpiClkMskDiv8 = 0x02u, ///<8分频
|
||||
SpiClkMskDiv16 = 0x03u, ///<16分频
|
||||
SpiClkMskDiv32 = 0x80u, ///<32分频
|
||||
SpiClkMskDiv64 = 0x81u, ///<64分频
|
||||
SpiClkMskDiv128 = 0x82u, ///<128分频
|
||||
}en_spi_clk_div_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief SPI 片选脚电平选择
|
||||
*****************************************************************************/
|
||||
typedef enum en_spi_cspin
|
||||
{
|
||||
SpiCsLow = 0u, ///<片选低电平
|
||||
SpiCsHigh = 1u, ///<片选高电平
|
||||
}en_spi_cspin_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief SPI 状态
|
||||
*****************************************************************************/
|
||||
typedef enum en_spi_status
|
||||
{
|
||||
SpiIf = 0x80, ///<传输结束中断标志
|
||||
SpiWcol = 0x40, ///<写冲突标志
|
||||
SpiSserr = 0x20, ///<从机模式错误标志
|
||||
SpiMdf = 0x10, ///<主机模式错误标志
|
||||
}en_spi_status_t;
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief SPI 总体配置结构体
|
||||
*****************************************************************************/
|
||||
typedef struct stc_spi_cfg
|
||||
{
|
||||
en_spi_mode_t enSpiMode; ///< 主从模式选择
|
||||
en_spi_clk_div_t enPclkDiv; ///< PCLK分频系数(波特率分频)
|
||||
en_spi_cpol_t enCPOL; ///< 时钟极性选择
|
||||
en_spi_cpha_t enCPHA; ///< 时钟相位选择
|
||||
}stc_spi_cfg_t;
|
||||
|
||||
//SPI 状态获取
|
||||
boolean_t Spi_GetStatus(M0P_SPI_TypeDef* SPIx,en_spi_status_t enStatus);
|
||||
|
||||
///<SPI 中断使能/禁止
|
||||
en_result_t Spi_IrqEnable(M0P_SPI_TypeDef* SPIx);
|
||||
en_result_t Spi_IrqDisable(M0P_SPI_TypeDef* SPIx);
|
||||
//SPI初始化函数
|
||||
en_result_t Spi_Init(M0P_SPI_TypeDef* SPIx,stc_spi_cfg_t* pstcSpiCfg);
|
||||
//SPI关闭函数
|
||||
en_result_t Spi_DeInit(M0P_SPI_TypeDef* SPIx);
|
||||
//SPI 配置主发送的电平
|
||||
void Spi_SetCS(M0P_SPI_TypeDef* SPIx,boolean_t bFlag);
|
||||
//SPI 数据发送
|
||||
en_result_t Spi_SendData(M0P_SPI_TypeDef* SPIx, uint8_t u8Data);
|
||||
//SPI 数据接收
|
||||
uint8_t Spi_ReceiveData(M0P_SPI_TypeDef* SPIx);
|
||||
|
||||
//@} // Spi Group
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SPI_H__ */
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
*****************************************************************************/
|
||||
|
||||
@@ -0,0 +1,307 @@
|
||||
/*******************************************************************************
|
||||
* 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.h
|
||||
**
|
||||
** Headerfile for SYSCTRL functions
|
||||
** @link SYSCTRL Group Some description @endlink
|
||||
**
|
||||
** History:
|
||||
** - 2018-04-15 Lux First Version
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __SYSCTRL_H__
|
||||
#define __SYSCTRL_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* Include files
|
||||
******************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \defgroup SysCtrlGroup (SYSCTRL)
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** function prototypes.
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief 系统时钟输入源类型定义
|
||||
** \note
|
||||
******************************************************************************/
|
||||
typedef enum en_sysctrl_clk_source
|
||||
{
|
||||
SysctrlClkRCH = 0u, ///< 内部高速时钟
|
||||
SysctrlClkXTH = 1u, ///< 外部高速时钟
|
||||
SysctrlClkRCL = 2u, ///< 内部低速时钟
|
||||
SysctrlClkXTL = 3u, ///< 外部低速时钟
|
||||
}en_sysctrl_clk_source_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief RCH频率值枚举类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_sysctrl_rch_freq
|
||||
{
|
||||
SysctrlRchFreq4MHz = 4u, ///< 4MHz
|
||||
SysctrlRchFreq8MHz = 3u, ///< 8MHz
|
||||
SysctrlRchFreq16MHz = 2u, ///< 16MHz
|
||||
SysctrlRchFreq22_12MHz = 1u, ///< 22.12MHz
|
||||
SysctrlRchFreq24MHz = 0u, ///< 24MHz
|
||||
}en_sysctrl_rch_freq_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief XTAL驱动能力类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_sysctrl_xtal_driver
|
||||
{
|
||||
SysctrlXtalDriver0 = 0u, ///< 最弱驱动能力
|
||||
SysctrlXtalDriver1 = 1u, ///< 弱驱动能力
|
||||
SysctrlXtalDriver2 = 2u, ///< 一般驱动能力
|
||||
SysctrlXtalDriver3 = 3u, ///< 最强驱动能力
|
||||
}en_sysctrl_xtal_driver_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief XTH频率值范围选择类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_sysctrl_xth_freq
|
||||
{
|
||||
SysctrlXthFreq4_6MHz = 0u, ///< 4~6MHz
|
||||
SysctrlXthFreq6_12MHz = 1u, ///< 6~12MHz
|
||||
SysctrlXthFreq12_20MHz = 2u, ///< 12~20MHz
|
||||
SysctrlXthFreq20_32MHz = 3u, ///< 20~32MHz
|
||||
}en_sysctrl_xth_freq_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief XTH时钟稳定周期数类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_sysctrl_xth_cycle
|
||||
{
|
||||
SysctrlXthStableCycle256 = 0u, ///< 256 个周期数
|
||||
SysctrlXthStableCycle1024 = 1u, ///< 1024 个周期数
|
||||
SysctrlXthStableCycle4096 = 2u, ///< 4096 个周期数
|
||||
SysctrlXthStableCycle16384 = 3u, ///< 16384 个周期数
|
||||
}en_sysctrl_xth_cycle_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief RCL频率值枚举类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_sysctrl_rcl_freq
|
||||
{
|
||||
SysctrlRclFreq32768 = 0x11u, ///< 32.768KHz
|
||||
SysctrlRclFreq38400 = 0x10u, ///< 38.4KHz
|
||||
}en_sysctrl_rcl_freq_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief RCL时钟稳定周期数类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_sysctrl_rcl_cycle
|
||||
{
|
||||
SysctrlRclStableCycle4 = 0u, ///< 4 个周期数
|
||||
SysctrlRclStableCycle16 = 1u, ///< 16 个周期数
|
||||
SysctrlRclStableCycle64 = 2u, ///< 64 个周期数
|
||||
SysctrlRclStableCycle256 = 3u, ///< 256 个周期数
|
||||
}en_sysctrl_rcl_cycle_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief HCLK时钟分频系数类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_sysctrl_hclk_div
|
||||
{
|
||||
SysctrlHclkDiv1 = 0u, ///< SystemClk
|
||||
SysctrlHclkDiv2 = 1u, ///< SystemClk/2
|
||||
SysctrlHclkDiv4 = 2u, ///< SystemClk/4
|
||||
SysctrlHclkDiv8 = 3u, ///< SystemClk/8
|
||||
SysctrlHclkDiv16 = 4u, ///< SystemClk/16
|
||||
SysctrlHclkDiv32 = 5u, ///< SystemClk/32
|
||||
SysctrlHclkDiv64 = 6u, ///< SystemClk/64
|
||||
SysctrlHclkDiv128 = 7u, ///< SystemClk/128
|
||||
}en_sysctrl_hclk_div_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief PCLK分频系数
|
||||
******************************************************************************/
|
||||
typedef enum en_sysctrl_pclk_div
|
||||
{
|
||||
SysctrlPclkDiv1 = 0u, ///< HCLK
|
||||
SysctrlPclkDiv2 = 1u, ///< HCLK/2
|
||||
SysctrlPclkDiv4 = 2u, ///< HCLK/4
|
||||
SysctrlPclkDiv8 = 3u, ///< HCLK/8
|
||||
}en_sysctrl_pclk_div_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief 系统控制模块其他功能数据类型定义
|
||||
******************************************************************************/
|
||||
typedef enum en_sysctrl_func
|
||||
{
|
||||
SysctrlEXTHEn = 1u, ///< 使能外部高速时钟从输入引脚输入
|
||||
SysctrlCMLockUpEn = 6u, ///< 使能后CPU执行无效指令会复位MCU
|
||||
SysctrlSWDUseIOEn = 8u, ///< SWD端口设为IO功能
|
||||
}en_sysctrl_func_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief 外设时钟门控开关类型枚举
|
||||
******************************************************************************/
|
||||
typedef enum en_sysctrl_peripheral_gate
|
||||
{
|
||||
SysctrlPeripheralUart0 = 0u, ///< 串口0
|
||||
SysctrlPeripheralUart1 = 1u, ///< 串口1
|
||||
SysctrlPeripheralI2c = 4u, ///< I2C
|
||||
SysctrlPeripheralSpi = 6u, ///< SPI
|
||||
SysctrlPeripheralBt = 8u, ///< 基础时钟
|
||||
SysctrlPeripheralAdvTim = 10u, ///< 高级时钟
|
||||
SysctrlPeripheralPca = 14u, ///< 可编程计数阵列
|
||||
SysctrlPeripheralWdt = 15u, ///< 看门狗
|
||||
SysctrlPeripheralAdcBgr = 16u, ///< ADC
|
||||
SysctrlPeripheralVcLvd = 17u, ///< 电压比较和低电压检测
|
||||
SysctrlPeripheralTrim = 21u, ///< 时钟校准
|
||||
SysctrlPeripheralTick = 24u, ///< 系统定时器
|
||||
SysctrlPeripheralCrc = 26u, ///< CRC
|
||||
SysctrlPeripheralGpio = 28u, ///< GPIO
|
||||
SysctrlPeripheralFlash = 31u, ///< Flash
|
||||
}en_sysctrl_peripheral_gate_t;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief 时钟初始化配置结构体定义
|
||||
******************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
en_sysctrl_clk_source_t enClkSrc; ///< 时钟源选择
|
||||
en_sysctrl_hclk_div_t enHClkDiv; ///< HCLK分频系数
|
||||
en_sysctrl_pclk_div_t enPClkDiv; ///< PCLK分频系数
|
||||
}stc_sysctrl_clk_cfg_t;
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable declarations ('extern', definition in C source)
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
******************************************************************************/
|
||||
///< 系统时钟初始化API:用于上电后,系统工作之前对主频及外设时钟进行初始化;
|
||||
///< 注意1:使用该初始化函数前需要根据系统,必须优先设置目标内部时钟源的TRIM值或外部时钟源的频率范围,
|
||||
///< 注意2:XTH、XTL的频率范围设定,需要根据外部晶振决定,
|
||||
///< 注意3:本驱动默认宏定义:SYSTEM_XTH=32MHz,SYSTEM_XTL=32768Hz,如使用其它外部晶振,必须修改这两个宏定义的值。
|
||||
en_result_t Sysctrl_ClkInit(stc_sysctrl_clk_cfg_t *pstcCfg);
|
||||
|
||||
///< 系统时钟去初始化API:恢复为上电默认状态->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)
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
@@ -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)
|
||||
*****************************************************************************/
|
||||
///<<功能配置及操作函数
|
||||
///<Trim 配置及初始化
|
||||
en_result_t Trim_Init(stc_trim_cfg_t* pstcCfg);
|
||||
///<校准/监测启动/停止
|
||||
void Trim_Run(void);
|
||||
void Trim_Stop(void);
|
||||
|
||||
///<参考计数器计数值获取
|
||||
uint32_t Trim_RefCntGet(void);
|
||||
///<校准计数器计数值获取
|
||||
uint32_t Trim_CalCntGet(void);
|
||||
|
||||
///<中断操作相关函数
|
||||
///中断使能/禁止
|
||||
void Trim_EnableIrq(void);
|
||||
void Trim_DisableIrq(void);
|
||||
///<中断标志获取
|
||||
boolean_t Trim_GetIntFlag(en_trim_inttype_t enIntType);
|
||||
///<中断标志清除
|
||||
en_result_t Trim_ClearIntFlag(en_trim_inttype_t enIntType);
|
||||
|
||||
//@} // TrimGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __TRIM_H__ */
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
/******************************************************************************
|
||||
* 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.h
|
||||
**
|
||||
** Headerfile for UART functions
|
||||
**
|
||||
**
|
||||
** History:
|
||||
** - 2017-05-10 Cathy First Version
|
||||
**
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __UART_H__
|
||||
#define __UART_H__
|
||||
/*****************************************************************************
|
||||
* Include files
|
||||
*****************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \defgroup UartGroup Universal Asynchronous Receiver/Transmitter (UART)
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************/
|
||||
/* Global pre-processor symbols/macros ('#define') */
|
||||
/******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief uart多主机模式地址帧/数据帧或者奇偶校验
|
||||
******************************************************************************/
|
||||
typedef enum en_uart_mmdorck
|
||||
{
|
||||
UartData = 0u, ///<多主机模式时,数据帧TB8标记
|
||||
UartAddr = 1u, ///<多主机模式时,地址帧TB8标记
|
||||
}en_uart_mmdorck_t;
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief uart奇偶校验
|
||||
******************************************************************************/
|
||||
typedef enum en_uart_check
|
||||
{
|
||||
UartEven = 0u, ///<偶校验
|
||||
UartOdd = 1u, ///<奇校验
|
||||
}en_uart_check_t;
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief uart多主机模式配置
|
||||
******************************************************************************/
|
||||
typedef enum en_uart_multimode
|
||||
{
|
||||
UartNormal = 0u, ///<正常工作模式
|
||||
UartMulti = 1u, ///<多主机工作模式
|
||||
}en_uart_multimode_t;
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief uart多主机模式及从机地址和地址掩码配置
|
||||
******************************************************************************/
|
||||
|
||||
typedef struct stc_uart_multimode
|
||||
{
|
||||
uint8_t u8SlaveAddr; ///<从机地址
|
||||
uint8_t u8SaddEn; ///<从及地址掩码
|
||||
}stc_uart_multimode_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief uart 四种工作模式选择
|
||||
******************************************************************************/
|
||||
|
||||
typedef enum en_uart_mode
|
||||
{
|
||||
UartMode0 = 0u, ///<模式0
|
||||
UartMode1 = 1u, ///<模式1
|
||||
UartMode2 = 2u, ///<模式2
|
||||
UartMode3 = 3u, ///<模式3
|
||||
} en_uart_mode_t;
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief uart 发送接收功能使能
|
||||
******************************************************************************/
|
||||
typedef enum en_uart_func
|
||||
{
|
||||
UartRenFunc = 4u, ///<0-TX; ///<1-非mode0模式代表RX&TX ,mode0模式代表RX;
|
||||
}en_uart_func_t;
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief uart发送接收中断使能
|
||||
******************************************************************************/
|
||||
typedef enum en_uart_irq_sel
|
||||
{
|
||||
UartRxIrq = 0u, ///<接收中断使能
|
||||
UartTxIrq = 1u, ///<发送中断使能
|
||||
}en_uart_irq_sel_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief uart 状态标志位
|
||||
******************************************************************************/
|
||||
typedef enum en_uart_status
|
||||
{
|
||||
UartRC = 0u, ///<接收数据完成标记
|
||||
UartTC = 1u, ///<发送数据完成标记
|
||||
UartFE = 2u, ///<帧错误标记
|
||||
|
||||
}en_uart_status_t;
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief uart 通道地址结构
|
||||
******************************************************************************/
|
||||
typedef struct stc_uart_instance_data
|
||||
{
|
||||
uint32_t u32Idx; ///< 通道号
|
||||
M0P_UART_TypeDef *pstcInstance; ///< 通道寄存器地址
|
||||
} stc_uart_instance_data_t;
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief uart 通道波特率配置
|
||||
******************************************************************************/
|
||||
typedef struct stc_uart_baud_cfg
|
||||
{
|
||||
en_uart_mode_t enMode; ///<四种工作模式
|
||||
boolean_t bDbaud; ///<是否双倍波特率
|
||||
uint32_t u32Pclk; ///< PCLK
|
||||
uint32_t u32Baud; ///<波特率
|
||||
}stc_uart_baud_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \uart 总体配置
|
||||
******************************************************************************/
|
||||
typedef struct stc_uart_cfg
|
||||
{
|
||||
en_uart_mode_t enRunMode; ///<四种模式配置
|
||||
} stc_uart_cfg_t;
|
||||
|
||||
//UART初始化
|
||||
en_result_t Uart_Init(M0P_UART_TypeDef* UARTx, stc_uart_cfg_t* pstcCfg);
|
||||
|
||||
///<中断相关设置函数
|
||||
en_result_t Uart_EnableIrq(M0P_UART_TypeDef* UARTx, en_uart_irq_sel_t enIrqSel);
|
||||
en_result_t Uart_DisableIrq(M0P_UART_TypeDef* UARTx, en_uart_irq_sel_t enIrqSel);
|
||||
|
||||
// 初始化处理
|
||||
en_result_t Uart_Init(M0P_UART_TypeDef* UARTx, stc_uart_cfg_t* pstcCfg);
|
||||
|
||||
// 波特率设置
|
||||
uint16_t Uart_SetBaudRate(M0P_UART_TypeDef* UARTx,stc_uart_baud_cfg_t* pstcBaud);
|
||||
|
||||
///<UART模块多机模式设置函数
|
||||
en_result_t Uart_SetMultiMode(M0P_UART_TypeDef* UARTx, stc_uart_multimode_t* pstcMultiCfg);
|
||||
|
||||
///< 发送或接收使能和禁止
|
||||
en_result_t Uart_EnableFunc(M0P_UART_TypeDef* UARTx, en_uart_func_t enFunc);
|
||||
en_result_t Uart_DisableFunc(M0P_UART_TypeDef* UARTx, en_uart_func_t enFunc);
|
||||
|
||||
///< 状态位的获取和清除
|
||||
uint8_t Uart_GetIsr(M0P_UART_TypeDef* UARTx);
|
||||
boolean_t Uart_GetStatus(M0P_UART_TypeDef* UARTx,en_uart_status_t enStatus);
|
||||
en_result_t Uart_ClrIsr(M0P_UART_TypeDef* UARTx);
|
||||
en_result_t Uart_ClrStatus(M0P_UART_TypeDef* UARTx,en_uart_status_t enStatus);
|
||||
|
||||
//数据收发操作
|
||||
///< 数据查询模式发送
|
||||
en_result_t Uart_SendDataPoll(M0P_UART_TypeDef* UARTx, uint8_t u8Data);
|
||||
///< 数据中断模式发送
|
||||
en_result_t Uart_SendDataIt(M0P_UART_TypeDef* UARTx, uint8_t u8Data);
|
||||
uint8_t Uart_ReceiveData(M0P_UART_TypeDef* UARTx);
|
||||
///< 奇偶校验检查
|
||||
en_result_t Uart_CheckEvenOrOdd(M0P_UART_TypeDef* UARTx, en_uart_check_t enCheck, uint8_t u8Recv);
|
||||
///< 获取Rb8位
|
||||
boolean_t Uart_GetRb8(M0P_UART_TypeDef* UARTx);
|
||||
//< 设置TB8
|
||||
en_result_t Uart_SetTb8(M0P_UART_TypeDef* UARTx, en_uart_check_t enCheck, uint8_t u8Data);
|
||||
|
||||
|
||||
//@} // UartGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
#endif
|
||||
|
||||
#endif /* __UART_H__ */
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
/******************************************************************************
|
||||
* 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.h
|
||||
**
|
||||
** Headerfile for Voltage Comparator functions
|
||||
** @link VC Group Some description @endlink
|
||||
**
|
||||
** - 2019-04-10 First Version
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __VC_H__
|
||||
#define __VC_H__
|
||||
|
||||
/******************************************************************************
|
||||
* Include files
|
||||
******************************************************************************/
|
||||
#include "ddl.h"
|
||||
|
||||
/* C binding of definitions if building with C++ compiler */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \defgroup VcGroup Voltage Comparator (VC)
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief VC通道
|
||||
*****************************************************************************/
|
||||
typedef enum en_vc_channel
|
||||
{
|
||||
VcChannel0 = 0u, // 通道0
|
||||
VcChannel1 = 1u, // 通道1
|
||||
|
||||
}en_vc_channel_t;
|
||||
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief VC迟滞
|
||||
*****************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
VcDelayoff = 0u, // 迟滞关闭
|
||||
VcDelay10mv = 1u, // 迟滞10mv
|
||||
VcDelay20mv = 2u, // 迟滞20mv
|
||||
VcDelay30mv = 3u, // 迟滞30mv
|
||||
}en_vc_cmp_delay_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief VC偏置电流
|
||||
*****************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
VcBias300na = 0u, // 偏置电流300nA
|
||||
VcBias1200na = 1u, // 偏置电流1.2uA
|
||||
VcBias10ua = 2u, // 偏置电流10uA
|
||||
VcBias20ua = 3u, // 偏置电流20uA
|
||||
}en_vc_bias_current_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief VC输出滤波时间
|
||||
*****************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
VcFilter7us = 0u, // 输出滤波时间7us
|
||||
VcFilter14us = 1u, // 输出滤波时间14us
|
||||
VcFilter28us = 2u, // 输出滤波时间28us
|
||||
VcFilter112us = 3u, // 输出滤波时间112us
|
||||
VcFilter450us = 4u, // 输出滤波时间450us
|
||||
VcFilter1800us = 5u, // 输出滤波时间1.8ms
|
||||
VcFilter7200us = 6u, // 输出滤波时间7.2ms
|
||||
VcFilter28800us = 7u, // 输出滤波时间28.8ms
|
||||
}en_vc_resp_filter_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief VC P端输入
|
||||
*****************************************************************************/
|
||||
typedef enum en_vc_input_p_src
|
||||
{
|
||||
VcInPCh0, ///< 输入通道0 P2.3
|
||||
VcInPCh1, ///< 输入通道1 P2.5
|
||||
VcInPCh2, ///< 输入通道2 P3.2
|
||||
VcInPCh3, ///< 输入通道3 P3.3
|
||||
VcInPCh4, ///< 输入通道4 P3.4
|
||||
VcInPCh5, ///< 输入通道5 P3.5
|
||||
VcInPCh6, ///< 输入通道6 P3.6
|
||||
VcInPCh7, ///< 输入通道7 P0.1
|
||||
}en_vc_input_p_src_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief VC N端输入
|
||||
*****************************************************************************/
|
||||
typedef enum en_vc_input_n_src
|
||||
{
|
||||
VcInNCh0, ///< 输入通道0 P2.3
|
||||
VcInNCh1, ///< 输入通道1 P2.5
|
||||
VcInNCh2, ///< 输入通道2 P3.2
|
||||
VcInNCh3, ///< 输入通道3 P3.3
|
||||
VcInNCh4, ///< 输入通道4 P3.4
|
||||
VcInNCh5, ///< 输入通道5 P3.5
|
||||
VcInNCh6, ///< 输入通道6 P3.6
|
||||
VcInNCh7, ///< 输入通道7 P0.1
|
||||
ResDivOut, ///< Vcc分压
|
||||
AiTs, ///< 温度传感器
|
||||
AiBg1p2, ///< BGR 1.2V
|
||||
AiVcRef2p5, ///< REF 2.5V
|
||||
AiLdo, ///< LDO
|
||||
}en_vc_input_n_src_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief VC中断触发方式
|
||||
*****************************************************************************/
|
||||
typedef enum en_vc_irq_sel
|
||||
{
|
||||
VcIrqNone = 0u, ///< 无中断
|
||||
VcIrqRise = 1u, ///< 上升沿触发
|
||||
VcIrqFall = 2u, ///< 下降沿触发
|
||||
VcIrqHigh = 3u, ///< 高电平触发
|
||||
|
||||
}en_vc_irq_sel_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief VC状态 VC_IFR
|
||||
*****************************************************************************/
|
||||
typedef enum en_vc_stat
|
||||
{
|
||||
Vc0_Intf = 0u, // VC0中断标志
|
||||
Vc1_Intf = 1u, // VC1中断标志
|
||||
Vc0_Filter = 2u, // VC0 Filter 后的状态
|
||||
Vc1_Filter = 3u, // VC1 Filter 后的状态
|
||||
|
||||
}en_vc_ifr_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief VC输出配置
|
||||
*****************************************************************************/
|
||||
typedef enum en_vc_output_cfg
|
||||
{
|
||||
VcOutInvTimer, ///< 结果输出负向到各Timer0,1,2,3
|
||||
VcOutTm0Gate, ///< 结果使能输出到TM0 Gate
|
||||
VcOutTm1Gate, ///< 结果使能输出到TM1 Gate
|
||||
VcOutTm2Gate, ///< 结果使能输出到TM2 Gate
|
||||
VcOutTm3Gate, ///< 结果使能输出到LPTIMER3 Gate
|
||||
VcOutTm3ExtClk, ///< 结果使能输出到LPTIMER 外部时钟
|
||||
VcOutInvPca, ///< 结果输出负向到PCA
|
||||
VcOutPcaCap0, ///< 结果使能输出到PCA 捕获模式0
|
||||
VcOutPcaExtClk, ///< 结果使能输出到PCA 外部时钟
|
||||
VcOutInvTm4, ///< 结果输出负向到Timer4
|
||||
VcOutTm4, ///< 结果使能输出到TM4 捕获模式
|
||||
VcOutInvTm5, ///< 结果输出负向到Timer5
|
||||
VcOutTm5, ///< 结果使能输出到TM5 捕获模式
|
||||
VcOutInvTm6, ///< 结果输出负向到Timer6
|
||||
VcOutTm6, ///< 结果使能输出到TM6 捕获模式
|
||||
VcOutBrake, ///< 刹车控制
|
||||
VcOutDisable, ///< 结果输出除能
|
||||
}en_vc_output_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief VC DIV参考电压Vref选择
|
||||
*****************************************************************************/
|
||||
typedef enum en_vc_div_vref
|
||||
{
|
||||
VcDivVrefAvcc = 0u, ///< AVCC
|
||||
VcDivVrefAdc = 1u, ///< ADC_CR0 SREF选择参考电压
|
||||
}en_vc_div_vref_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief VC模块配置
|
||||
*****************************************************************************/
|
||||
typedef struct stc_vc_dac_cfg
|
||||
{
|
||||
boolean_t bDivEn; // VC_CR: VC_DIV_EN
|
||||
uint8_t u8DivVal; // VC_CR: VC_DIV 范围:0-63
|
||||
en_vc_div_vref_t enDivVref; // VC_CR: VC_REF2P5_SEL
|
||||
}stc_vc_dac_cfg_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief VC通道配置
|
||||
*****************************************************************************/
|
||||
typedef struct stc_vc_channel_cfg
|
||||
{
|
||||
en_vc_channel_t enVcChannel; // VC通道选择
|
||||
en_vc_cmp_delay_t enVcCmpDly; // VC迟滞
|
||||
en_vc_bias_current_t enVcBiasCurrent; // VC功耗选择
|
||||
en_vc_resp_filter_t enVcFilterTime; // 输出滤波时间
|
||||
en_vc_input_p_src_t enVcInPin_P; // P端输入
|
||||
en_vc_input_n_src_t enVcInPin_N; // N端输入
|
||||
en_vc_output_cfg_t enVcOutCfg; // 输出配置
|
||||
boolean_t bFlten; // 滤波输出使能
|
||||
}stc_vc_channel_cfg_t;
|
||||
|
||||
/******************************************************************************
|
||||
* Global definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Local type definitions ('typedef')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable definitions ('extern')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
******************************************************************************/
|
||||
extern void Vc_CfgItType(en_vc_channel_t Channelx, en_vc_irq_sel_t ItType);
|
||||
extern void Vc_ItCfg(en_vc_channel_t Channelx, boolean_t NewStatus);
|
||||
extern boolean_t Vc_GetItStatus(en_vc_ifr_t Result);
|
||||
extern void Vc_ClearItStatus(en_vc_ifr_t NewStatus);
|
||||
extern en_result_t Vc_DacInit(stc_vc_dac_cfg_t *pstcDacCfg);
|
||||
extern void Vc_Init(stc_vc_channel_cfg_t *pstcChannelCfg);
|
||||
extern void Vc_Cmd(en_vc_channel_t enChannel, boolean_t NewStatus);
|
||||
|
||||
|
||||
//@} // VcGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __VC_H__ */
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
******************************************************************************/
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/******************************************************************************
|
||||
* 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.h
|
||||
**
|
||||
** Headerfile for WDT functions
|
||||
**
|
||||
**
|
||||
** History:
|
||||
** - 2017-05-10 Cathy First Version
|
||||
**
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __WDT_H__
|
||||
#define __WDT_H__
|
||||
|
||||
#include "ddl.h"
|
||||
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \defgroup WdtGroup Watchdog Timer (WDT)
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************/
|
||||
/* Global pre-processor symbols/macros ('#define') */
|
||||
/******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global type definitions
|
||||
******************************************************************************/
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief wdt溢出后复位或中断配置
|
||||
*****************************************************************************/
|
||||
typedef enum en_wdt_func
|
||||
{
|
||||
WdtResetEn = 0, ///<复位使能
|
||||
WdtIntEn = 1, ///<中断使能
|
||||
}en_wdt_func_t;
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief wdt当前运行时间配置数据类型定义
|
||||
*****************************************************************************/
|
||||
|
||||
typedef enum en_wdt_time
|
||||
{
|
||||
WdtT1ms6 = 0u, ///<1.6ms
|
||||
WdtT3ms2 = 1u, ///<3.2ms
|
||||
WdtT6ms4 = 2u, ///<6.4ms
|
||||
WdtT13ms = 3u, ///<13ms
|
||||
WdtT26ms = 4u, ///<26ms
|
||||
WdtT51ms = 5u, ///<51ms
|
||||
WdtT102ms = 6u, ///<102ms
|
||||
WdtT205ms = 7u, ///<205ms
|
||||
WdtT500ms = 8u, ///<500ms
|
||||
WdtT820ms = 9u, ///<820ms
|
||||
WdtT1s64 = 10u, ///<1.64s
|
||||
WdtT3s28 = 11u, ///<3.28s
|
||||
WdtT6s55 = 12u, ///<6.55s
|
||||
WdtT13s1 = 13u, ///<13.1s
|
||||
WdtT26s2 = 14u, ///<26.2s
|
||||
WdtT52s4 = 15u, ///<52.4s
|
||||
}en_wdt_time_t;
|
||||
|
||||
|
||||
//wdt初始化
|
||||
en_result_t Wdt_Init(en_wdt_func_t enFunc, en_wdt_time_t enTime);
|
||||
|
||||
//wdt开始和停止
|
||||
void Wdt_Start(void);
|
||||
//喂狗处理
|
||||
void Wdt_Feed(void);
|
||||
//喂狗处理
|
||||
void Wdt_IrqClr(void);
|
||||
//wdt溢出时间设置
|
||||
void Wdt_WriteWdtLoad(uint8_t u8LoadValue);
|
||||
///< 当前计数时间获取
|
||||
uint8_t Wdt_ReadWdtValue(void);
|
||||
//< 中断状态获取
|
||||
boolean_t Wdt_GetIrqStatus(void);
|
||||
///< 运行状态获取
|
||||
boolean_t Wdt_ReadwdtStatus(void);
|
||||
|
||||
//@} // WdtGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
#endif
|
||||
|
||||
#endif /* __WDT_H__ */
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,592 @@
|
||||
/******************************************************************************
|
||||
* 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.c
|
||||
**
|
||||
** ADC driver API.
|
||||
**
|
||||
** - 2017-06-28 Alex First Version
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Include files
|
||||
******************************************************************************/
|
||||
#include "adc.h"
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \addtogroup AdcGroup
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************
|
||||
* Local pre-processor symbols/macros ('#define')
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable definitions (declared in header file with 'extern')
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Local type definitions ('typedef')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Local function prototypes ('static')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Local variable definitions ('static')
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Function implementation - global ('extern') and local ('static')
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* 获取ADC中断状态
|
||||
*
|
||||
* \param [in] pstcAdcIrqState ADC中断状态指针
|
||||
*
|
||||
* \retval 无
|
||||
*/
|
||||
void Adc_GetIrqState(stc_adc_irq_t* pstcAdcIrqState)
|
||||
{
|
||||
pstcAdcIrqState->bAdcIrq = M0P_ADC->IFR_f.CONT_INTF;
|
||||
pstcAdcIrqState->bAdcRegCmp = M0P_ADC->IFR_f.REG_INTF;
|
||||
pstcAdcIrqState->bAdcHhtCmp = M0P_ADC->IFR_f.HHT_INTF;
|
||||
pstcAdcIrqState->bAdcLltCmp = M0P_ADC->IFR_f.LLT_INTF;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* 清除ADC CONT中断状态
|
||||
*
|
||||
* \param 无
|
||||
*
|
||||
* \retval 无
|
||||
*/
|
||||
void Adc_ClrContIrqState(void)
|
||||
{
|
||||
M0P_ADC->ICLR = ~(1<<3);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* 清除ADC REG中断状态
|
||||
*
|
||||
* \param 无
|
||||
*
|
||||
* \retval 无
|
||||
*/
|
||||
void Adc_ClrRegIrqState(void)
|
||||
{
|
||||
M0P_ADC->ICLR = ~(1<<2);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* 清除ADC HHT中断状态
|
||||
*
|
||||
* \param 无
|
||||
*
|
||||
* \retval 无
|
||||
*/
|
||||
void Adc_ClrHhtIrqState(void)
|
||||
{
|
||||
M0P_ADC->ICLR = ~(1<<1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* 清除ADC LLT中断状态
|
||||
*
|
||||
* \param 无
|
||||
*
|
||||
* \retval 无
|
||||
*/
|
||||
void Adc_ClrIrqLltState(void)
|
||||
{
|
||||
M0P_ADC->ICLR = ~1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* ADC中断使能
|
||||
*
|
||||
* \param 无
|
||||
*
|
||||
* \retval 无
|
||||
*/
|
||||
void Adc_EnableIrq(void)
|
||||
{
|
||||
M0P_ADC->CR0_f.IE = 1u;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* ADC比较使能
|
||||
*
|
||||
* \param [in] pstcAdcIrqCfg ADC比较配置
|
||||
*
|
||||
* \retval 无
|
||||
*/
|
||||
void Adc_CmpCfg(stc_adc_irq_t* pstcAdcIrqCfg)
|
||||
{
|
||||
if (TRUE == pstcAdcIrqCfg->bAdcRegCmp)
|
||||
{
|
||||
M0P_ADC->CR1_f.REGCMP = 1u;
|
||||
}
|
||||
else
|
||||
{
|
||||
M0P_ADC->CR1_f.REGCMP = 0u;
|
||||
}
|
||||
|
||||
if (TRUE == pstcAdcIrqCfg->bAdcHhtCmp)
|
||||
{
|
||||
M0P_ADC->CR1_f.HTCMP = 1u;
|
||||
}
|
||||
else
|
||||
{
|
||||
M0P_ADC->CR1_f.HTCMP = 0u;
|
||||
}
|
||||
|
||||
if (TRUE == pstcAdcIrqCfg->bAdcLltCmp)
|
||||
{
|
||||
M0P_ADC->CR1_f.LTCMP = 1u;
|
||||
}
|
||||
else
|
||||
{
|
||||
M0P_ADC->CR1_f.LTCMP = 0u;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* \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<<pstcAdcContCfg->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)
|
||||
******************************************************************************/
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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;u32Index<u32Len;u32Index++)
|
||||
{
|
||||
*((volatile uint8_t*)(&(M0P_CRC->DATA))) = 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; u32Index<u32Len; u32Index++)
|
||||
{
|
||||
*((volatile uint16_t*)(&(M0P_CRC->DATA))) = 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; u32Index<u32Len; u32Index++)
|
||||
{
|
||||
M0P_CRC->DATA_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; u32Index<u32Len; u32Index++)
|
||||
{
|
||||
*((volatile uint8_t*)(&(M0P_CRC->DATA))) = 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; u32Index<u32Len; u32Index++)
|
||||
{
|
||||
*((volatile uint16_t*)(&(M0P_CRC->DATA))) = 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; u32Index<u32Len; u32Index++)
|
||||
{
|
||||
*((volatile uint32_t*)(&(M0P_CRC->DATA))) = pu32Data[u32Index];
|
||||
}
|
||||
|
||||
*((volatile uint16_t*)(&(M0P_CRC->DATA))) = u16CRC;
|
||||
|
||||
enResult = M0P_CRC->RESULT_f.FLAG ? Ok : Error;
|
||||
|
||||
return (enResult);
|
||||
}
|
||||
|
||||
|
||||
//@} // CrcGroup
|
||||
|
||||
/*******************************************************************************
|
||||
* EOF (not truncated)
|
||||
******************************************************************************/
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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<<enTimG));
|
||||
M0P_GPIO->CTRL4 |= (uint32_t)(enSf<<enTimG);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 端口辅助功能配置——Timer 捕获输入选择配置
|
||||
**
|
||||
** \param [in] enTimC Timer类型选择枚举
|
||||
** \param [in] enSf Timer互联功能选择枚举
|
||||
**
|
||||
** \retval Ok 设置成功
|
||||
******************************************************************************/
|
||||
en_result_t Gpio_SfTimCCfg(en_gpio_sf_tim_c_t enTimC, en_gpio_sf_t enSf)
|
||||
{
|
||||
M0P_GPIO->CTRL3 &= (uint32_t)(~(0x03u<<enTimC));
|
||||
M0P_GPIO->CTRL3 |= (uint32_t)(enSf<<enTimC);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief GPIO 端口辅助功能配置——PCA 捕获输入选择配置
|
||||
**
|
||||
** \param [in] enPca PCA类型选择枚举
|
||||
** \param [in] enSf PCA互联功能选择枚举
|
||||
**
|
||||
** \retval Ok 设置成功
|
||||
******************************************************************************/
|
||||
en_result_t Gpio_SfPcaCfg(en_gpio_sf_pca_t enPca, en_gpio_sf_t enSf)
|
||||
{
|
||||
M0P_GPIO->CTRL2 &= (uint32_t)(~(0x03u<<enPca));
|
||||
M0P_GPIO->CTRL2 |= (uint32_t)(enSf<<enPca);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
//@} // GpioGroup
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* EOF (not truncated)
|
||||
******************************************************************************/
|
||||
|
||||
@@ -0,0 +1,259 @@
|
||||
/*************************************************************************************
|
||||
* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved.
|
||||
*
|
||||
* This software is owned and published by:
|
||||
* Huada Semiconductor Co.,Ltd ("HDSC").
|
||||
*
|
||||
* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
|
||||
* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
|
||||
*
|
||||
* This software contains source code for use with HDSC
|
||||
* components. This software is licensed by HDSC to be adapted only
|
||||
* for use in systems utilizing HDSC components. HDSC shall not be
|
||||
* responsible for misuse or illegal use of this software for devices not
|
||||
* supported herein. HDSC is providing this software "AS IS" and will
|
||||
* not be responsible for issues arising from incorrect user implementation
|
||||
* of the software.
|
||||
*
|
||||
* Disclaimer:
|
||||
* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
|
||||
* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
|
||||
* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
|
||||
* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
|
||||
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
|
||||
* WARRANTY OF NONINFRINGEMENT.
|
||||
* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
|
||||
* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
|
||||
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
|
||||
* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
|
||||
* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
|
||||
* SAVINGS OR PROFITS,
|
||||
* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
|
||||
* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
|
||||
* FROM, THE SOFTWARE.
|
||||
*
|
||||
* This software may be replicated in part or whole for the licensed use,
|
||||
* with the restriction that this Disclaimer and Copyright notice must be
|
||||
* included with each copy of this software, whether used in part or whole,
|
||||
* at all times.
|
||||
*/
|
||||
/******************************************************************************/
|
||||
/** \file I2C.c
|
||||
**
|
||||
** WDT function driver API.
|
||||
** @link SampleGroup Some description @endlink
|
||||
**
|
||||
** - 2018-03-13 1.0 CJ First version for Device Driver Library of Module.
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
/* Include files */
|
||||
/******************************************************************************/
|
||||
#include "i2c.h"
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \addtogroup I2cGroup
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************/
|
||||
/* Local function prototypes ('static') */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief I2C设置波特率配置寄存器
|
||||
**
|
||||
** \param [in] u8Tm 波特率配置值
|
||||
**
|
||||
** \retval enRet 成功或失败
|
||||
**
|
||||
******************************************************************************/
|
||||
en_result_t I2C_SetBaud(M0P_I2C_TypeDef* I2Cx, uint8_t u8Tm)
|
||||
{
|
||||
en_result_t enRet = Error;
|
||||
|
||||
I2Cx->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
|
||||
@@ -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<<bOnExit;
|
||||
__WFI();
|
||||
}
|
||||
|
||||
/**
|
||||
*****************************************************************************
|
||||
** \brief 进入普通睡眠模式
|
||||
**
|
||||
** \input bOnExit - TRUE:当退出异常处理后,自动再次进入休眠;
|
||||
** FALSE:唤醒后不再自动进入休眠
|
||||
**
|
||||
** \retval NULL
|
||||
*****************************************************************************/
|
||||
void Lpm_GotoSleep(boolean_t bOnExit)
|
||||
{
|
||||
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
|
||||
SCB->SCR |= 1u<<bOnExit;
|
||||
__WFI();
|
||||
}
|
||||
|
||||
//@} // LpmGroup
|
||||
|
||||
/*******************************************************************************
|
||||
* EOF (not truncated)
|
||||
******************************************************************************/
|
||||
@@ -0,0 +1,205 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved.
|
||||
*
|
||||
* This software is owned and published by:
|
||||
* Huada Semiconductor Co.,Ltd ("HDSC").
|
||||
*
|
||||
* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
|
||||
* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
|
||||
*
|
||||
* This software contains source code for use with HDSC
|
||||
* components. This software is licensed by HDSC to be adapted only
|
||||
* for use in systems utilizing HDSC components. HDSC shall not be
|
||||
* responsible for misuse or illegal use of this software for devices not
|
||||
* supported herein. HDSC is providing this software "AS IS" and will
|
||||
* not be responsible for issues arising from incorrect user implementation
|
||||
* of the software.
|
||||
*
|
||||
* Disclaimer:
|
||||
* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
|
||||
* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
|
||||
* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
|
||||
* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
|
||||
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
|
||||
* WARRANTY OF NONINFRINGEMENT.
|
||||
* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
|
||||
* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
|
||||
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
|
||||
* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
|
||||
* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
|
||||
* SAVINGS OR PROFITS,
|
||||
* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
|
||||
* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
|
||||
* FROM, THE SOFTWARE.
|
||||
*
|
||||
* This software may be replicated in part or whole for the licensed use,
|
||||
* with the restriction that this Disclaimer and Copyright notice must be
|
||||
* included with each copy of this software, whether used in part or whole,
|
||||
* at all times.
|
||||
*/
|
||||
/******************************************************************************/
|
||||
/** \file lvd.c
|
||||
**
|
||||
** Low Voltage Detect driver API.
|
||||
** @link Lvd Group Some description @endlink
|
||||
**
|
||||
** - 2017-06-28 Alex First Version
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Include files
|
||||
******************************************************************************/
|
||||
#include "lvd.h"
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \addtogroup LvdGroup
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/******************************************************************************
|
||||
* Local pre-processor symbols/macros ('#define')
|
||||
******************************************************************************/
|
||||
|
||||
#define IS_VALID_INPUT(x) ( (x) <= LvdInputP25 )
|
||||
|
||||
#define IS_VALID_THRESHOLD(x) ( (x) <= LvdTH3p3V )
|
||||
|
||||
#define IS_VALID_FILTER(x) ( (x) <= LvdFilter29ms )
|
||||
|
||||
#define IS_VALID_IRQTYPE(x) ( (x) <= LvdIrqFall )
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Global variable definitions (declared in header file with 'extern') *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Local type definitions ('typedef')
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Local function prototypes ('static')
|
||||
******************************************************************************/
|
||||
// static void LvdEnableNvic(void);
|
||||
// static void LvdDisableNvic(void);
|
||||
// static en_result_t LvdEnable(en_lvd_type_t enType, boolean_t bFlag);
|
||||
|
||||
/******************************************************************************
|
||||
* Local variable definitions ('static')
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Function implementation - global ('extern') and local ('static')
|
||||
*****************************************************************************/
|
||||
/**
|
||||
* \brief
|
||||
* 使能LVD中断
|
||||
*
|
||||
* \param [in] enType LVD中断类型
|
||||
*
|
||||
* \retval en_result_t Ok: 设置成功
|
||||
* \retval en_result_t ErrorInvalidParameter: 无效类型
|
||||
*/
|
||||
void Lvd_EnableIrq(void)
|
||||
{
|
||||
M0P_LVD->CR_f.IE = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* 除能LVD中断
|
||||
*
|
||||
* \param 无
|
||||
*
|
||||
* \retval 无
|
||||
*/
|
||||
void Lvd_DisableIrq(void)
|
||||
{
|
||||
M0P_LVD->CR_f.IE = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* LVD初始化
|
||||
*
|
||||
* \param [in] pstcCfg LVD配置指针
|
||||
*
|
||||
* \retval 无
|
||||
*/
|
||||
void Lvd_Init(stc_lvd_cfg_t *pstcCfg)
|
||||
{
|
||||
M0P_LVD->CR = 0;
|
||||
|
||||
M0P_LVD->CR = (uint32_t)pstcCfg->enAct |
|
||||
(uint32_t)pstcCfg->enFilter |
|
||||
(uint32_t)pstcCfg->enFilterTime |
|
||||
(uint32_t)pstcCfg->enInputSrc |
|
||||
(uint32_t)pstcCfg->enIrqType |
|
||||
(uint32_t)pstcCfg->enThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* 使能LVD
|
||||
*
|
||||
* \param 无
|
||||
*
|
||||
* \retval 无
|
||||
*
|
||||
*/
|
||||
void Lvd_Enable(void)
|
||||
{
|
||||
M0P_LVD->CR_f.LVDEN = 1u;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* 除能LVD
|
||||
*
|
||||
* \param 无
|
||||
*
|
||||
* \retval 无
|
||||
*/
|
||||
void Lvd_Disable(void)
|
||||
{
|
||||
M0P_LVD->CR_f.LVDEN = 0u;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* 获取LVD中断标志
|
||||
*
|
||||
* \param 无
|
||||
*
|
||||
* \retval boolean_t 中断标志
|
||||
*/
|
||||
boolean_t Lvd_GetIrqStat(void)
|
||||
{
|
||||
return M0P_LVD->IFR_f.INTF;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* 清除LVD中断标志
|
||||
*
|
||||
* \param 无
|
||||
*
|
||||
* \retval 无
|
||||
*/
|
||||
void Lvd_ClearIrq(void)
|
||||
{
|
||||
M0P_LVD->IFR_f.INTF = 0u;
|
||||
}
|
||||
|
||||
|
||||
//@} // LvdGroup
|
||||
|
||||
/******************************************************************************
|
||||
* EOF (not truncated)
|
||||
******************************************************************************/
|
||||
|
||||
@@ -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<<It_Src);
|
||||
}
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
** \brief PCA 计数器运行控制 PCA_CCON CR控制位
|
||||
** @param NewStatus : TRUE 或 FALSE
|
||||
** \retval 无
|
||||
**
|
||||
******************************************************************************/
|
||||
void Pca_StartPca(boolean_t NewStatus)
|
||||
{
|
||||
SetBit((uint32_t)(&(M0P_PCA->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)
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
@@ -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)
|
||||
*****************************************************************************/
|
||||
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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
|
||||
@@ -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<<pstcChannelCfg->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<<pstcChannelCfg->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)
|
||||
******************************************************************************/
|
||||
|
||||
@@ -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
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\adc_norm_polling.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,467 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>adc_norm_polling_Release</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>6100001::V6.10.1::.\ARMCLANG</pCCUsed>
|
||||
<uAC6>1</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>ARMCM0P</Device>
|
||||
<Vendor>ARM</Vendor>
|
||||
<PackID>ARM.CMSIS.5.4.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM))</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h</RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>./../../../..\mcu\MDK\HC32F005.sfr</SFDFile>
|
||||
<bCustSvd>1</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\output\release\</OutputDirectory>
|
||||
<OutputName>adc_norm_polling</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>1</BrowseInformation>
|
||||
<ListingPath>.\output\release\</ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments> </SimDllArguments>
|
||||
<SimDlgDll>DARMCM1.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM0+</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments> </TargetDllArguments>
|
||||
<TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM0+</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4096</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>0</AdsALst>
|
||||
<AdsACrf>0</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>0</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>0</AdsLsun>
|
||||
<AdsLven>0</AdsLven>
|
||||
<AdsLsxf>0</AdsLsxf>
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M0+"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>1</useUlib>
|
||||
<EndSel>1</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>3</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>1</Ir1Chk>
|
||||
<Ir2Chk>0</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>1</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>7</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>4</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>5</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>0</vShortEn>
|
||||
<vShortWch>0</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>1</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x00000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile>adc_norm_polling.sct</ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc>--keep=*Handler</Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>common</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>startup_hc32f005.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>.\startup_hc32f005.s</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>system_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\system_hc32f005.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>interrupts_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\interrupts_hc32f005.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>source</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\source\main.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>driver</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ddl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\ddl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sysctrl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\sysctrl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adc.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\adc.c</FilePath></File>
|
||||
<File>
|
||||
<FileName>gpio.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\gpio.c</FilePath></File>
|
||||
<File>
|
||||
<FileName>bgr.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\bgr.c</FilePath></File>
|
||||
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>README</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>readme.txt</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\readme.txt</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis/>
|
||||
<components>
|
||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.1.0" condition="CMSIS Core">
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.3.0"/>
|
||||
<targetInfos>
|
||||
<targetInfo name="adc_norm_polling_Release"/>
|
||||
</targetInfos>
|
||||
</component>
|
||||
</components>
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
</Project>
|
||||
@@ -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
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\adc_scan_mul_irq.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,467 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>adc_scan_mul_irq_Release</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>6100001::V6.10.1::.\ARMCLANG</pCCUsed>
|
||||
<uAC6>1</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>ARMCM0P</Device>
|
||||
<Vendor>ARM</Vendor>
|
||||
<PackID>ARM.CMSIS.5.4.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM))</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h</RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>./../../../..\mcu\MDK\HC32F005.sfr</SFDFile>
|
||||
<bCustSvd>1</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\output\release\</OutputDirectory>
|
||||
<OutputName>adc_scan_mul_irq</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>1</BrowseInformation>
|
||||
<ListingPath>.\output\release\</ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments> </SimDllArguments>
|
||||
<SimDlgDll>DARMCM1.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM0+</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments> </TargetDllArguments>
|
||||
<TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM0+</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4096</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>0</AdsALst>
|
||||
<AdsACrf>0</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>0</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>0</AdsLsun>
|
||||
<AdsLven>0</AdsLven>
|
||||
<AdsLsxf>0</AdsLsxf>
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M0+"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>1</useUlib>
|
||||
<EndSel>1</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>3</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>1</Ir1Chk>
|
||||
<Ir2Chk>0</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>1</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>7</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>4</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>5</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>0</vShortEn>
|
||||
<vShortWch>0</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>1</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x00000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile>adc_scan_mul_irq.sct</ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc>--keep=*Handler</Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>common</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>startup_hc32f005.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>.\startup_hc32f005.s</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>system_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\system_hc32f005.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>interrupts_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\interrupts_hc32f005.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>source</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\source\main.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>driver</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ddl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\ddl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sysctrl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\sysctrl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adc.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\adc.c</FilePath></File>
|
||||
<File>
|
||||
<FileName>gpio.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\gpio.c</FilePath></File>
|
||||
<File>
|
||||
<FileName>bgr.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\bgr.c</FilePath></File>
|
||||
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>README</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>readme.txt</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\readme.txt</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis/>
|
||||
<components>
|
||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.1.0" condition="CMSIS Core">
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.3.0"/>
|
||||
<targetInfos>
|
||||
<targetInfo name="adc_scan_mul_irq_Release"/>
|
||||
</targetInfos>
|
||||
</component>
|
||||
</components>
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
</Project>
|
||||
@@ -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
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\adc_scan_sqr_acc.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,467 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>adc_scan_sqr_acc_Release</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>6100001::V6.10.1::.\ARMCLANG</pCCUsed>
|
||||
<uAC6>1</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>ARMCM0P</Device>
|
||||
<Vendor>ARM</Vendor>
|
||||
<PackID>ARM.CMSIS.5.4.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM))</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h</RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>./../../../..\mcu\MDK\HC32F005.sfr</SFDFile>
|
||||
<bCustSvd>1</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\output\release\</OutputDirectory>
|
||||
<OutputName>adc_scan_sqr_acc</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>1</BrowseInformation>
|
||||
<ListingPath>.\output\release\</ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments> </SimDllArguments>
|
||||
<SimDlgDll>DARMCM1.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM0+</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments> </TargetDllArguments>
|
||||
<TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM0+</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4096</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>0</AdsALst>
|
||||
<AdsACrf>0</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>0</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>0</AdsLsun>
|
||||
<AdsLven>0</AdsLven>
|
||||
<AdsLsxf>0</AdsLsxf>
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M0+"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>1</useUlib>
|
||||
<EndSel>1</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>3</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>1</Ir1Chk>
|
||||
<Ir2Chk>0</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>1</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>7</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>4</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>5</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>0</vShortEn>
|
||||
<vShortWch>0</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>1</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x00000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile>adc_scan_sqr_acc.sct</ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc>--keep=*Handler</Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>common</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>startup_hc32f005.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>.\startup_hc32f005.s</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>system_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\system_hc32f005.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>interrupts_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\interrupts_hc32f005.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>source</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\source\main.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>driver</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ddl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\ddl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sysctrl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\sysctrl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adc.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\adc.c</FilePath></File>
|
||||
<File>
|
||||
<FileName>gpio.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\gpio.c</FilePath></File>
|
||||
<File>
|
||||
<FileName>bgr.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\bgr.c</FilePath></File>
|
||||
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>README</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>readme.txt</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\readme.txt</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis/>
|
||||
<components>
|
||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.1.0" condition="CMSIS Core">
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.3.0"/>
|
||||
<targetInfos>
|
||||
<targetInfo name="adc_scan_sqr_acc_Release"/>
|
||||
</targetInfos>
|
||||
</component>
|
||||
</components>
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
</Project>
|
||||
@@ -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
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\CaptureInput.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,464 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>CaptureInput_Release</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>6100001::V6.10.1::.\ARMCLANG</pCCUsed>
|
||||
<uAC6>1</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>ARMCM0P</Device>
|
||||
<Vendor>ARM</Vendor>
|
||||
<PackID>ARM.CMSIS.5.4.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM))</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h</RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>./../../../..\mcu\MDK\HC32F005.sfr</SFDFile>
|
||||
<bCustSvd>1</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\output\release\</OutputDirectory>
|
||||
<OutputName>CaptureInput</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>1</BrowseInformation>
|
||||
<ListingPath>.\output\release\</ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments> </SimDllArguments>
|
||||
<SimDlgDll>DARMCM1.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM0+</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments> </TargetDllArguments>
|
||||
<TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM0+</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4096</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>0</AdsALst>
|
||||
<AdsACrf>0</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>0</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>0</AdsLsun>
|
||||
<AdsLven>0</AdsLven>
|
||||
<AdsLsxf>0</AdsLsxf>
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M0+"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>1</useUlib>
|
||||
<EndSel>1</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>3</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>1</Ir1Chk>
|
||||
<Ir2Chk>0</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>1</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>7</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>4</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>5</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>0</vShortEn>
|
||||
<vShortWch>0</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>1</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x00000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile>CaptureInput.sct</ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc>--keep=*Handler</Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>common</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>startup_hc32f005.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>.\startup_hc32f005.s</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>system_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\system_hc32f005.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>interrupts_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\interrupts_hc32f005.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>source</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\source\main.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>driver</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ddl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\ddl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sysctrl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\sysctrl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adt.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\adt.c</FilePath></File>
|
||||
<File>
|
||||
<FileName>gpio.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\gpio.c</FilePath></File>
|
||||
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>README</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>readme.txt</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\readme.txt</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis/>
|
||||
<components>
|
||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.1.0" condition="CMSIS Core">
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.3.0"/>
|
||||
<targetInfos>
|
||||
<targetInfo name="CaptureInput_Release"/>
|
||||
</targetInfos>
|
||||
</component>
|
||||
</components>
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
</Project>
|
||||
@@ -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
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\CaptureInputBuf.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,464 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>CaptureInputBuf_Release</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>6100001::V6.10.1::.\ARMCLANG</pCCUsed>
|
||||
<uAC6>1</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>ARMCM0P</Device>
|
||||
<Vendor>ARM</Vendor>
|
||||
<PackID>ARM.CMSIS.5.4.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM))</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h</RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>./../../../..\mcu\MDK\HC32F005.sfr</SFDFile>
|
||||
<bCustSvd>1</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\output\release\</OutputDirectory>
|
||||
<OutputName>CaptureInputBuf</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>1</BrowseInformation>
|
||||
<ListingPath>.\output\release\</ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments> </SimDllArguments>
|
||||
<SimDlgDll>DARMCM1.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM0+</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments> </TargetDllArguments>
|
||||
<TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM0+</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4096</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>0</AdsALst>
|
||||
<AdsACrf>0</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>0</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>0</AdsLsun>
|
||||
<AdsLven>0</AdsLven>
|
||||
<AdsLsxf>0</AdsLsxf>
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M0+"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>1</useUlib>
|
||||
<EndSel>1</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>3</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>1</Ir1Chk>
|
||||
<Ir2Chk>0</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>1</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>7</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>4</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>5</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>0</vShortEn>
|
||||
<vShortWch>0</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>1</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x00000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile>CaptureInputBuf.sct</ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc>--keep=*Handler</Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>common</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>startup_hc32f005.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>.\startup_hc32f005.s</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>system_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\system_hc32f005.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>interrupts_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\interrupts_hc32f005.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>source</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\source\main.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>driver</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ddl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\ddl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sysctrl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\sysctrl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adt.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\adt.c</FilePath></File>
|
||||
<File>
|
||||
<FileName>gpio.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\gpio.c</FilePath></File>
|
||||
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>README</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>readme.txt</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\readme.txt</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis/>
|
||||
<components>
|
||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.1.0" condition="CMSIS Core">
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.3.0"/>
|
||||
<targetInfos>
|
||||
<targetInfo name="CaptureInputBuf_Release"/>
|
||||
</targetInfos>
|
||||
</component>
|
||||
</components>
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
</Project>
|
||||
@@ -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
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\CompareOutput.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,467 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>CompareOutput_Release</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>6100001::V6.10.1::.\ARMCLANG</pCCUsed>
|
||||
<uAC6>1</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>ARMCM0P</Device>
|
||||
<Vendor>ARM</Vendor>
|
||||
<PackID>ARM.CMSIS.5.4.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM))</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h</RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>./../../../..\mcu\MDK\HC32F005.sfr</SFDFile>
|
||||
<bCustSvd>1</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\output\release\</OutputDirectory>
|
||||
<OutputName>CompareOutput</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>1</BrowseInformation>
|
||||
<ListingPath>.\output\release\</ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments> </SimDllArguments>
|
||||
<SimDlgDll>DARMCM1.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM0+</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments> </TargetDllArguments>
|
||||
<TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM0+</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4096</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>0</AdsALst>
|
||||
<AdsACrf>0</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>0</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>0</AdsLsun>
|
||||
<AdsLven>0</AdsLven>
|
||||
<AdsLsxf>0</AdsLsxf>
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M0+"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>1</useUlib>
|
||||
<EndSel>1</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>3</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>1</Ir1Chk>
|
||||
<Ir2Chk>0</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>1</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>7</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>4</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>5</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>0</vShortEn>
|
||||
<vShortWch>0</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>1</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x00000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile>CompareOutput.sct</ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc>--keep=*Handler</Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>common</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>startup_hc32f005.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>.\startup_hc32f005.s</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>system_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\system_hc32f005.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>interrupts_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\interrupts_hc32f005.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>source</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\source\main.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>driver</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ddl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\ddl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sysctrl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\sysctrl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adt.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\adt.c</FilePath></File>
|
||||
<File>
|
||||
<FileName>gpio.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\gpio.c</FilePath></File>
|
||||
<File>
|
||||
<FileName>flash.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\flash.c</FilePath></File>
|
||||
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>README</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>readme.txt</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\readme.txt</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis/>
|
||||
<components>
|
||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.1.0" condition="CMSIS Core">
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.3.0"/>
|
||||
<targetInfos>
|
||||
<targetInfo name="CompareOutput_Release"/>
|
||||
</targetInfos>
|
||||
</component>
|
||||
</components>
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
</Project>
|
||||
@@ -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
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\CompareOutputBuf.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,467 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>CompareOutputBuf_Release</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>6100001::V6.10.1::.\ARMCLANG</pCCUsed>
|
||||
<uAC6>1</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>ARMCM0P</Device>
|
||||
<Vendor>ARM</Vendor>
|
||||
<PackID>ARM.CMSIS.5.4.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM))</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h</RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>./../../../..\mcu\MDK\HC32F005.sfr</SFDFile>
|
||||
<bCustSvd>1</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\output\release\</OutputDirectory>
|
||||
<OutputName>CompareOutputBuf</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>1</BrowseInformation>
|
||||
<ListingPath>.\output\release\</ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments> </SimDllArguments>
|
||||
<SimDlgDll>DARMCM1.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM0+</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments> </TargetDllArguments>
|
||||
<TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM0+</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4096</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>0</AdsALst>
|
||||
<AdsACrf>0</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>0</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>0</AdsLsun>
|
||||
<AdsLven>0</AdsLven>
|
||||
<AdsLsxf>0</AdsLsxf>
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M0+"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>1</useUlib>
|
||||
<EndSel>1</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>3</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>1</Ir1Chk>
|
||||
<Ir2Chk>0</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>1</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>7</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>4</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>5</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>0</vShortEn>
|
||||
<vShortWch>0</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>1</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x00000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile>CompareOutputBuf.sct</ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc>--keep=*Handler</Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>common</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>startup_hc32f005.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>.\startup_hc32f005.s</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>system_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\system_hc32f005.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>interrupts_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\interrupts_hc32f005.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>source</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\source\main.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>driver</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ddl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\ddl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sysctrl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\sysctrl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adt.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\adt.c</FilePath></File>
|
||||
<File>
|
||||
<FileName>gpio.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\gpio.c</FilePath></File>
|
||||
<File>
|
||||
<FileName>flash.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\flash.c</FilePath></File>
|
||||
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>README</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>readme.txt</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\readme.txt</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis/>
|
||||
<components>
|
||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.1.0" condition="CMSIS Core">
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.3.0"/>
|
||||
<targetInfos>
|
||||
<targetInfo name="CompareOutputBuf_Release"/>
|
||||
</targetInfos>
|
||||
</component>
|
||||
</components>
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
</Project>
|
||||
@@ -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
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\Irq.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,464 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>Irq_Release</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>6100001::V6.10.1::.\ARMCLANG</pCCUsed>
|
||||
<uAC6>1</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>ARMCM0P</Device>
|
||||
<Vendor>ARM</Vendor>
|
||||
<PackID>ARM.CMSIS.5.4.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IROM(0x00000000,0x8000) IRAM(0x20000000,0x1000) CPUTYPE("Cortex-M0+") CLOCK(32000000) ESEL ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0P$Device\ARM\Flash\NEW_DEVICE.FLM))</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:ARMCM0P$Device\ARM\ARMCM0plus\Include\ARMCM0plus.h</RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>./../../../..\mcu\MDK\HC32F005.sfr</SFDFile>
|
||||
<bCustSvd>1</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\output\release\</OutputDirectory>
|
||||
<OutputName>Irq</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>1</BrowseInformation>
|
||||
<ListingPath>.\output\release\</ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments> </SimDllArguments>
|
||||
<SimDlgDll>DARMCM1.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM0+</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments> </TargetDllArguments>
|
||||
<TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM0+</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4096</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>0</AdsALst>
|
||||
<AdsACrf>0</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>0</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>0</AdsLsun>
|
||||
<AdsLven>0</AdsLven>
|
||||
<AdsLsxf>0</AdsLsxf>
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M0+"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>1</useUlib>
|
||||
<EndSel>1</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>3</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>1</Ir1Chk>
|
||||
<Ir2Chk>0</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>1</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x1000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>7</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>4</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>5</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>0</vShortEn>
|
||||
<vShortWch>0</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\..\..\mcu\common;..\source;..\..\..\..\driver\inc</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>1</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x00000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile>Irq.sct</ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc>--keep=*Handler</Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>common</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>startup_hc32f005.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>.\startup_hc32f005.s</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>system_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\system_hc32f005.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>interrupts_hc32f005.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\mcu\common\interrupts_hc32f005.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>source</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\source\main.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>driver</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ddl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\ddl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sysctrl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\driver\src\sysctrl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adt.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\adt.c</FilePath></File>
|
||||
<File>
|
||||
<FileName>gpio.c</FileName>
|
||||
<FileType>1</FileType><FilePath>..\..\..\..\driver\src\gpio.c</FilePath></File>
|
||||
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>README</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>readme.txt</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\readme.txt</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis/>
|
||||
<components>
|
||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.1.0" condition="CMSIS Core">
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.3.0"/>
|
||||
<targetInfos>
|
||||
<targetInfo name="Irq_Release"/>
|
||||
</targetInfos>
|
||||
</component>
|
||||
</components>
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
</Project>
|
||||
@@ -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
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
@@ -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)
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\LpBreak.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
Loaded 100 of 380 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user