/*********************************************************************************************************//**
* @file ht32f5xxxx_tm.c
* @version $Rev:: 4431 $
* @date $Date:: 2019-12-19 #$
* @brief This file provides all the TM firmware functions.
*************************************************************************************************************
* @attention
*
* Firmware Disclaimer Information
*
* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the
* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the
* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and
* other intellectual property laws.
*
* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the
* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties
* other than HOLTEK and the customer.
*
* 3. The program technical documentation, including the code, is provided "as is" and for customer reference
* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including
* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including
* the warranties of merchantability, satisfactory quality and fitness for a particular purpose.
*
* <h2><center>Copyright (C) Holtek Semiconductor Inc. All rights reserved</center></h2>
************************************************************************************************************/
/* Includes ------------------------------------------------------------------------------------------------*/
#include "ht32f5xxxx_tm.h"
/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver
* @{
*/
/** @defgroup TM TM
* @brief TM driver modules
* @{
*/
/* Private constants ---------------------------------------------------------------------------------------*/
/** @defgroup TM_Private_Define TM private definitions
* @{
*/
#define CNTCFR_UEVDIS 0x00000001ul
#define CNTCFR_UGDIS 0x00000002ul
#define CNTCFR_DIR 0x01000000ul
#define CNTCFR_CMSEL_MASK ~0x00030000ul
#define CNTCFR_CKDIV_MASK ~0x00000300ul
#define MDCFR_SPMSET 0x01000000ul
#define MDCFR_TSE 0x00000001ul
#define MDCFR_SMSEL_MASK ~0x00000700ul
#define MDCFR_MMSEL_MASK ~0x00070000ul
#define TRCFR_ECME 0x01000000ul
#define TRCFR_ETI_POL 0x00010000ul
#define TRCFR_ETI_PSC_MASK ~0x00003000ul
#define TRCFR_ETIF_MASK ~0x00000F00ul
#define TRCFR_TRSEL_MASK ~0x0000000Ful
#define TRCFR_ETI_CONF_MASK ~0x00013F00ul
#define CTR_TME 0x00000001ul
#define CTR_CRBE 0x00000002ul
#define CTR_CHCCDS 0x00010000ul
#define CH0ICFR_CH0SRC 0x80000000ul
#define CHICFR_CHF_MASK ~0x0000000Ful
#define CHICFR_CHCCS_MASK ~0x00030000ul
#define CHICFR_CHPSC_MASK ~0x000C0000ul
#define CHOCFR_REFCE 0x00000008ul
#define CHOCFR_CHPRE 0x00000010ul
#define CHOCFR_IMAE 0x00000020ul
#define CHOCFR_CHOM_MASK ~0x00000107ul
#define CHPOLR_CH0P 0x00000001ul
#define CHPOLR_CH1P 0x00000004ul
/**
* @}
*/
/* Private function prototypes -----------------------------------------------------------------------------*/
static void _TM_CHx_Config(HT_TM_TypeDef* TMx, TM_CH_Enum Ch, TM_CHP_Enum Pol, TM_CHCCS_Enum Sel, u8 Filter);
/* Global functions ----------------------------------------------------------------------------------------*/
/** @defgroup TM_Exported_Functions TM exported functions
* @{
*/
/*********************************************************************************************************//**
* @brief Deinitialize the TMx peripheral registers to their default reset values.
* @param TMx: where TMx is the selected TM from the TM peripheral.
* @retval None
************************************************************************************************************/
void TM_DeInit(HT_TM_TypeDef* TMx)
{
RSTCU_PeripReset_TypeDef RSTCUReset = {{0}};
/* Check the parameters */
Assert_Param(IS_TM(TMx));
if (TMx == HT_GPTM0)
{
RSTCUReset.Bit.GPTM0 = 1;
}
#if (LIBCFG_GPTM1)
else if (TMx == HT_GPTM1)
{
RSTCUReset.Bit.GPTM1 = 1;
}
#endif
#if (LIBCFG_MCTM0)
else if (TMx == HT_MCTM0)
{
RSTCUReset.Bit.MCTM0 = 1;
}
#endif
#if (LIBCFG_NO_SCTM)
#else
else if (TMx == HT_SCTM0)
{
RSTCUReset.Bit.SCTM0 = 1;
}
else if (TMx == HT_SCTM1)
{
RSTCUReset.Bit.SCTM1 = 1;
}
#if (LIBCFG_SCTM2)
else if (TMx == HT_SCTM2)
{
RSTCUReset.Bit.SCTM2 = 1;
}
#endif
#if (LIBCFG_SCTM3)
else if (TMx == HT_SCTM3)
{
RSTCUReset.Bit.SCTM3 = 1;
}
#endif
#endif
#if (LIBCFG_PWM0)
else if (TMx == HT_PWM0)
{
RSTCUReset.Bit.PWM0 = 1;
}
#endif
#if (LIBCFG_PWM1)
else if (TMx == HT_PWM1)
{
RSTCUReset.Bit.PWM1 = 1;
}
#endif
RSTCU_PeripReset(RSTCUReset, ENABLE);
}
/*********************************************************************************************************//**
* @brief Initialize the TMx counter to reload, prescaler, counter mode and repetition counter.
* @param TMx: where TMx is the selected TM from the TM peripheral.
* @param TimeBaseInit: Point to a \ref TM_TimeBaseInitTypeDef that contains the configuration information.
* @retval None
************************************************************************************************************/
void TM_TimeBaseInit(HT_TM_TypeDef* TMx, TM_TimeBaseInitTypeDef* TimeBaseInit)
{
/* Check the parameters */
Assert_Param(IS_TM(TMx));
Assert_Param(IS_TM_CNT_MODE(TimeBaseInit->CounterMode));
Assert_Param(IS_TM_PSC_RLD(TimeBaseInit->PSCReloadTime));
/* Set the counter reload value */
TMx->CRR = TimeBaseInit->CounterReload;
/* Set the Prescaler value */
TMx->PSCR = TimeBaseInit->Prescaler;
/* Select the Counter Mode */
TMx->CNTCFR &= CNTCFR_CMSEL_MASK; /* CNTCFR_DIR is read only when the timer configured as */
TMx->CNTCFR &= ~(u32)CNTCFR_DIR; /* Center-aligned mode. Reset mode first and then reset the */
/* CNTCFR_DIR bit (separate as two steps). */
TMx->CNTCFR |= TimeBaseInit->CounterMode;
#if (LIBCFG_MCTM0)
if (TMx == HT_MCTM0)
{
/* Set the Repetition value */
TMx->REPR = TimeBaseInit->RepetitionCounter;
}
#endif
/* To reload the Prescaler value immediatly or next update event */
TMx->EVGR = TimeBaseInit->PSCReloadTime;
}
/*********************************************************************************************************//**
* @brief Initialize the TMx channel N output.
* @param TMx: where TMx is the selected TM from the TM peripheral.
* @param OutInit: Point to a \ref TM_OutputInitTypeDef structure that contains
the configuration information.
* @retval None
************************************************************************************************************/
void TM_OutputInit(HT_TM_TypeDef* TMx, TM_OutputInitTypeDef* OutInit)
{
vu32 *pOcfr = (vu32*)&TMx->CH0OCFR + OutInit->Channel;
vu32 *pCcr = (vu32*)&TMx->CH0CCR + OutInit->Channel;
vu32 *pAcr = (vu32*)&TMx->CH0ACR + OutInit->Channel;
u8 bChPos = OutInit->Channel << 1;
u32 wTmpMask;
u
没有合适的资源?快使用搜索试试~ 我知道了~
基于HT单片机的无人送货与售货智能机器人.zip
共386个文件
h:127个
c:77个
d:54个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 186 浏览量
2024-05-14
21:35:55
上传
评论
收藏 6.58MB ZIP 举报
温馨提示
基于单片机的系统
资源推荐
资源详情
资源评论
收起资源包目录
基于HT单片机的无人送货与售货智能机器人.zip (386个子文件)
template.uvguix.15746 90KB
template.uvguix.16625 143KB
template.uvguix.Administrator 90KB
oled.h.bak 2KB
template_sct.Bak 478B
ht32f5xxxx_tm.c 79KB
ht32_usbd_core.c 44KB
ht32f5xxxx_ckcu.c 43KB
spi_flash.c 38KB
ht32f5xxxx_usart.c 33KB
ht32f5xxxx_pwrcu.c 31KB
ht32f5xxxx_i2c.c 31KB
ht32f5xxxx_usbd.c 31KB
spi_lcd.c 29KB
ht32f65230_40_adc.c 29KB
ht32f5xxxx_gpio.c 27KB
ebi_lcd.c 26KB
ht32f5xxxx_spi.c 26KB
ht32f5xxxx_adc.c 24KB
ht32f5xxxx_lcd.c 22KB
ht32f5xxxx_aes.c 21KB
system_ht32f5xxxx_01.c 19KB
ht32f5xxxx_midi.c 19KB
ht32f5xxxx_board_01.c 19KB
ht32f5xxxx_board_01.c 19KB
ht32f5xxxx_sci.c 18KB
ht32f5xxxx_exti.c 18KB
spi_flash_common.c 18KB
ht32_serial.c 18KB
ht32_serial.c 18KB
ht32_serial.c 18KB
ht32f5xxxx_flash.c 16KB
ht32_retarget_desc.c 14KB
ht32f5xxxx_rtc.c 14KB
spi_flash_auto.c 14KB
ht32f5xxxx_cmp.c 14KB
ht32f5xxxx_wdt.c 13KB
ht32f5xxxx_i2s.c 13KB
ht32f5xxxx_mctm.c 12KB
ht32f5xxxx_spi_midi.c 12KB
ht32f5xxxx_sled.c 12KB
track.c 11KB
ht32f5xxxx_dac.c 10KB
ht32f5xxxx_bftm.c 10KB
oled.c 10KB
i2c_eeprom.c 10KB
MQTT.c 10KB
printf.c 9KB
ht32_cm0plus_misc.c 9KB
pwm.c 9KB
spi_flash_SST25VF016B.c 9KB
ht32f5xxxx_pdma.c 9KB
utils_sha1.c 9KB
utils_md5.c 8KB
Cloud.c 8KB
ht32f5xxxx_ebi.c 8KB
ht32f65230_40_opa.c 8KB
MatrixKey.c 8KB
ring_buffer.c 8KB
usart.c 8KB
ht32f5xxxx_dac_dual16.c 8KB
encoder.c 7KB
ht32f5xxxx_crc.c 7KB
utils_hmac.c 6KB
ht32f5xxxx_div.c 6KB
hx711.c 6KB
spi_flash_MX25L1606E.c 6KB
ht32f5xxxx_01_it.c 6KB
ht32_retarget.c 5KB
ht32_retarget.c 5KB
ht32_retarget.c 5KB
ht32f5xxxx_rstcu.c 5KB
main.c 5KB
timdelay.c 4KB
ht32_rand.c 4KB
syscalls.c 3KB
ht32_div.c 3KB
pid.c 3KB
ht32_board.c 3KB
isd1820.c 2KB
delay.c 886B
led.c 552B
copying 18KB
main.crf 218KB
track.crf 217KB
cloud.crf 213KB
matrixkey.crf 212KB
hx711.crf 210KB
oled.crf 209KB
usart.crf 207KB
ht32_serial.crf 203KB
ht32_board.crf 200KB
ht32_retarget.crf 198KB
i2c_eeprom.crf 198KB
spi_lcd.crf 197KB
ht32_serial_1.crf 196KB
ebi_lcd.crf 194KB
encoder.crf 193KB
ht32_usbd_core.crf 192KB
ht32_retarget_1.crf 191KB
共 386 条
- 1
- 2
- 3
- 4
资源评论
我慢慢地也过来了
- 粉丝: 6705
- 资源: 4004
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功