mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-22 17:12:55 +08:00
554 lines
12 KiB
C
554 lines
12 KiB
C
|
/********************************** (C) COPYRIGHT *******************************
|
|||
|
* File Name : CH57x_timer.h
|
|||
|
* Author : WCH
|
|||
|
* Version : V1.2
|
|||
|
* Date : 2021/11/17
|
|||
|
* Description
|
|||
|
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
|||
|
* SPDX-License-Identifier: Apache-2.0
|
|||
|
*******************************************************************************/
|
|||
|
|
|||
|
#ifndef __CH58x_TIMER_H__
|
|||
|
#define __CH58x_TIMER_H__
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
extern "C" {
|
|||
|
#endif
|
|||
|
|
|||
|
#define DataBit_25 (1 << 25)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief TMR0 interrupt bit define
|
|||
|
*/
|
|||
|
|
|||
|
#define TMR0_3_IT_CYC_END 0x01 // <20><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD>-<2D><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ-<2D><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD>PWM-<2D><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>
|
|||
|
#define TMR0_3_IT_DATA_ACT 0x02 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>־<EFBFBD><D6BE><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>PWM-<2D><>Ч<EFBFBD><D0A7>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>
|
|||
|
#define TMR0_3_IT_FIFO_HF 0x04 // FIFO ʹ<>ù<EFBFBD><C3B9>룺<EFBFBD><EBA3BA>- FIFO>=4<><34> PWM- FIFO<4
|
|||
|
#define TMR1_2_IT_DMA_END 0x08 // DMA <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>TMR1<52><31>TMR2
|
|||
|
#define TMR0_3_IT_FIFO_OV 0x10 // FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>- FIFO<46><4F><EFBFBD><EFBFBD> PWM- FIFO<46><4F>
|
|||
|
|
|||
|
/**
|
|||
|
* @brief Configuration PWM effective level repeat times
|
|||
|
*/
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
PWM_Times_1 = 0, // PWM <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>
|
|||
|
PWM_Times_4, // PWM <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>4<EFBFBD><34><EFBFBD><EFBFBD>
|
|||
|
PWM_Times_8, // PWM <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>8<EFBFBD><38><EFBFBD><EFBFBD>
|
|||
|
PWM_Times_16, // PWM <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>16<31><36><EFBFBD><EFBFBD>
|
|||
|
} PWM_RepeatTsTypeDef;
|
|||
|
|
|||
|
/**
|
|||
|
* @brief Configuration Cap mode
|
|||
|
*/
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
CAP_NULL = 0, // <20><><EFBFBD><EFBFBD> & <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
Edge_To_Edge, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE> & <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
FallEdge_To_FallEdge, // <20>½<EFBFBD><C2BD>ص<EFBFBD><D8B5>½<EFBFBD><C2BD><EFBFBD> & <20><><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD><EFBFBD>
|
|||
|
RiseEdge_To_RiseEdge, // <20><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> & <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
} CapModeTypeDef;
|
|||
|
|
|||
|
/**
|
|||
|
* @brief Configuration DMA mode
|
|||
|
*/
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
Mode_Single = 0, // <20><><EFBFBD><EFBFBD>ģʽ
|
|||
|
Mode_LOOP, // ѭ<><D1AD>ģʽ
|
|||
|
} DMAModeTypeDef;
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param t - <EFBFBD><EFBFBD>ʱʱ<EFBFBD>䣬<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ǰϵͳʱ<EFBFBD><EFBFBD>Tsys, <EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 67108864
|
|||
|
*/
|
|||
|
void TMR0_TimerInit(uint32_t t);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ֵ
|
|||
|
*/
|
|||
|
#define TMR0_GetCurrentTimer() R32_TMR0_COUNT
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param cap - <EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void TMR0_EXTSingleCounterInit(CapModeTypeDef cap);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
|
|||
|
*
|
|||
|
* @param cyc - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|||
|
*/
|
|||
|
#define TMR0_CountOverflowCfg(cyc) (R32_TMR0_CNT_END = (cyc + 2))
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
*/
|
|||
|
#define TMR0_GetCurrentCount() R32_TMR0_COUNT
|
|||
|
|
|||
|
/**
|
|||
|
* @brief PWM0 ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
|
|||
|
*
|
|||
|
* @param cyc - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR0_PWMCycleCfg(cyc) (R32_TMR0_CNT_END = cyc)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief PWM <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
|||
|
* @param ts - set pwm repeat times, refer to PWM_RepeatTsTypeDef
|
|||
|
*/
|
|||
|
void TMR0_PWMInit(PWMX_PolarTypeDef pr, PWM_RepeatTsTypeDef ts);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief PWM0 <EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
|
|||
|
*
|
|||
|
* @param d - <EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR0_PWMActDataWidth(d) (R32_TMR0_FIFO = d)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief CAP0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>33554432
|
|||
|
*
|
|||
|
* @param cyc - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD>ʱ
|
|||
|
*/
|
|||
|
#define TMR0_CAPTimeoutCfg(cyc) (R32_TMR0_CNT_END = cyc)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD>ⲿ<EFBFBD>źŲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param cap - select capture mode, refer to CapModeTypeDef
|
|||
|
*/
|
|||
|
void TMR0_CapInit(CapModeTypeDef cap);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR0_CAPGetData() R32_TMR0_FIFO
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD>Ѳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD>Ѳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR0_CAPDataCounter() R8_TMR0_FIFO_COUNT
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD>ر<EFBFBD> TMR0
|
|||
|
*/
|
|||
|
#define TMR0_Disable() (R8_TMR0_CTRL_MOD &= ~RB_TMR_COUNT_EN)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD> TMR0
|
|||
|
*/
|
|||
|
#define TMR0_Enable() (R8_TMR0_CTRL_MOD |= RB_TMR_COUNT_EN)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param s - ʹ<EFBFBD><EFBFBD>/<EFBFBD>ر<EFBFBD>
|
|||
|
* @param f - refer to TMR interrupt bit define
|
|||
|
*/
|
|||
|
#define TMR0_ITCfg(s, f) ((s) ? (R8_TMR0_INTER_EN |= f) : (R8_TMR0_INTER_EN &= ~f))
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϱ<EFBFBD>־
|
|||
|
*
|
|||
|
* @param f - refer to TMR interrupt bit define
|
|||
|
*/
|
|||
|
#define TMR0_ClearITFlag(f) (R8_TMR0_INT_FLAG = f)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ѯ<EFBFBD>жϱ<EFBFBD>־״̬
|
|||
|
*
|
|||
|
* @param f - refer to TMR interrupt bit define
|
|||
|
*/
|
|||
|
#define TMR0_GetITFlag(f) (R8_TMR0_INT_FLAG & f)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param t - <EFBFBD><EFBFBD>ʱʱ<EFBFBD>䣬<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ǰϵͳʱ<EFBFBD><EFBFBD>Tsys, <EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 67108864
|
|||
|
*/
|
|||
|
void TMR1_TimerInit(uint32_t t);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ֵ
|
|||
|
*/
|
|||
|
#define TMR1_GetCurrentTimer() R32_TMR1_COUNT
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param cap - <EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void TMR1_EXTSingleCounterInit(CapModeTypeDef cap);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
|
|||
|
*
|
|||
|
* @param cyc - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|||
|
*/
|
|||
|
#define TMR1_CountOverflowCfg(cyc) (R32_TMR1_CNT_END = (cyc + 2))
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
*/
|
|||
|
#define TMR1_GetCurrentCount() R32_TMR1_COUNT
|
|||
|
|
|||
|
/**
|
|||
|
* @brief PWM1 ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
|
|||
|
*
|
|||
|
* @param cyc - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR1_PWMCycleCfg(cyc) (R32_TMR1_CNT_END = cyc)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief PWM <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
|||
|
* @param ts - set pwm repeat times, refer to PWM_RepeatTsTypeDef
|
|||
|
*/
|
|||
|
void TMR1_PWMInit(PWMX_PolarTypeDef pr, PWM_RepeatTsTypeDef ts);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief PWM1 <EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
|
|||
|
*
|
|||
|
* @param d - <EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR1_PWMActDataWidth(d) (R32_TMR1_FIFO = d)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief CAP1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>33554432
|
|||
|
*
|
|||
|
* @param cyc - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD>ʱ
|
|||
|
*/
|
|||
|
#define TMR1_CAPTimeoutCfg(cyc) (R32_TMR1_CNT_END = cyc)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD>ⲿ<EFBFBD>źŲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param cap - select capture mode, refer to CapModeTypeDef
|
|||
|
*/
|
|||
|
void TMR1_CapInit(CapModeTypeDef cap);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR1_CAPGetData() R32_TMR1_FIFO
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD>Ѳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD>Ѳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR1_CAPDataCounter() R8_TMR1_FIFO_COUNT
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>DMA<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param s - <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DMA<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param startAddr - DMA <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ
|
|||
|
* @param endAddr - DMA <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
* @param m - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>DMAģʽ
|
|||
|
*/
|
|||
|
void TMR1_DMACfg(uint8_t s, uint16_t startAddr, uint16_t endAddr, DMAModeTypeDef m);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD>ر<EFBFBD> TMR1
|
|||
|
*/
|
|||
|
#define TMR1_Disable() (R8_TMR1_CTRL_MOD &= ~RB_TMR_COUNT_EN)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD> TMR1
|
|||
|
*/
|
|||
|
#define TMR1_Enable() (R8_TMR1_CTRL_MOD |= RB_TMR_COUNT_EN)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param s - ʹ<EFBFBD><EFBFBD>/<EFBFBD>ر<EFBFBD>
|
|||
|
* @param f - refer to TMR interrupt bit define
|
|||
|
*/
|
|||
|
#define TMR1_ITCfg(s, f) ((s) ? (R8_TMR1_INTER_EN |= f) : (R8_TMR1_INTER_EN &= ~f))
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϱ<EFBFBD>־
|
|||
|
*
|
|||
|
* @param f - refer to TMR interrupt bit define
|
|||
|
*/
|
|||
|
#define TMR1_ClearITFlag(f) (R8_TMR1_INT_FLAG = f)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ѯ<EFBFBD>жϱ<EFBFBD>־״̬
|
|||
|
*
|
|||
|
* @param f - refer to TMR interrupt bit define
|
|||
|
*/
|
|||
|
#define TMR1_GetITFlag(f) (R8_TMR1_INT_FLAG & f)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param t - <EFBFBD><EFBFBD>ʱʱ<EFBFBD>䣬<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ǰϵͳʱ<EFBFBD><EFBFBD>Tsys, <EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 67108864
|
|||
|
*/
|
|||
|
void TMR2_TimerInit(uint32_t t);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ֵ
|
|||
|
*/
|
|||
|
#define TMR2_GetCurrentTimer() R32_TMR2_COUNT
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param cap - <EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void TMR2_EXTSingleCounterInit(CapModeTypeDef cap);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
|
|||
|
*
|
|||
|
* @param cyc - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|||
|
*/
|
|||
|
#define TMR2_CountOverflowCfg(cyc) (R32_TMR2_CNT_END = (cyc + 2))
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
*/
|
|||
|
#define TMR2_GetCurrentCount() R32_TMR2_COUNT
|
|||
|
|
|||
|
/**
|
|||
|
* @brief PWM2 ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
|
|||
|
*
|
|||
|
* @param cyc - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR2_PWMCycleCfg(cyc) (R32_TMR2_CNT_END = cyc)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief PWM <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
|||
|
* @param ts - set pwm repeat times, refer to PWM_RepeatTsTypeDef
|
|||
|
*/
|
|||
|
void TMR2_PWMInit(PWMX_PolarTypeDef pr, PWM_RepeatTsTypeDef ts);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief PWM2 <EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
|
|||
|
*
|
|||
|
* @param d - <EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR2_PWMActDataWidth(d) (R32_TMR2_FIFO = d)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief CAP2 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>33554432
|
|||
|
*
|
|||
|
* @param cyc - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD>ʱ
|
|||
|
*/
|
|||
|
#define TMR2_CAPTimeoutCfg(cyc) (R32_TMR2_CNT_END = cyc)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD>ⲿ<EFBFBD>źŲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param cap - select capture mode, refer to CapModeTypeDef
|
|||
|
*/
|
|||
|
void TMR2_CapInit(CapModeTypeDef cap);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR2_CAPGetData() R32_TMR2_FIFO
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD>Ѳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD>Ѳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR2_CAPDataCounter() R8_TMR2_FIFO_COUNT
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>DMA<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param s - <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DMA<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param startAddr - DMA <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ
|
|||
|
* @param endAddr - DMA <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
* @param m - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>DMAģʽ
|
|||
|
*/
|
|||
|
void TMR2_DMACfg(uint8_t s, uint16_t startAddr, uint16_t endAddr, DMAModeTypeDef m);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD>ر<EFBFBD> TMR2
|
|||
|
*/
|
|||
|
#define TMR2_Disable() (R8_TMR2_CTRL_MOD &= ~RB_TMR_COUNT_EN)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD> TMR2
|
|||
|
*/
|
|||
|
#define TMR2_Enable() (R8_TMR2_CTRL_MOD |= RB_TMR_COUNT_EN)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param s - ʹ<EFBFBD><EFBFBD>/<EFBFBD>ر<EFBFBD>
|
|||
|
* @param f - refer to TMR interrupt bit define
|
|||
|
*/
|
|||
|
#define TMR2_ITCfg(s, f) ((s) ? (R8_TMR2_INTER_EN |= f) : (R8_TMR2_INTER_EN &= ~f))
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϱ<EFBFBD>־
|
|||
|
*
|
|||
|
* @param f - refer to TMR interrupt bit define
|
|||
|
*/
|
|||
|
#define TMR2_ClearITFlag(f) (R8_TMR2_INT_FLAG = f)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ѯ<EFBFBD>жϱ<EFBFBD>־״̬
|
|||
|
*
|
|||
|
* @param f - refer to TMR interrupt bit define
|
|||
|
*/
|
|||
|
#define TMR2_GetITFlag(f) (R8_TMR2_INT_FLAG & f)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param t - <EFBFBD><EFBFBD>ʱʱ<EFBFBD>䣬<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ǰϵͳʱ<EFBFBD><EFBFBD>Tsys, <EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 67108864
|
|||
|
*/
|
|||
|
void TMR3_TimerInit(uint32_t t);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ֵ
|
|||
|
*/
|
|||
|
#define TMR3_GetCurrentTimer() R32_TMR3_COUNT
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param cap - <EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void TMR3_EXTSingleCounterInit(CapModeTypeDef cap);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
|
|||
|
*
|
|||
|
* @param cyc - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|||
|
*/
|
|||
|
#define TMR3_CountOverflowCfg(cyc) (R32_TMR3_CNT_END = (cyc + 2))
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
*/
|
|||
|
#define TMR3_GetCurrentCount() R32_TMR3_COUNT
|
|||
|
|
|||
|
/**
|
|||
|
* @brief PWM3 ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
|
|||
|
*
|
|||
|
* @param cyc - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR3_PWMCycleCfg(cyc) (R32_TMR3_CNT_END = cyc)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief PWM <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
|||
|
* @param ts - set pwm repeat times, refer to PWM_RepeatTsTypeDef
|
|||
|
*/
|
|||
|
void TMR3_PWMInit(PWMX_PolarTypeDef pr, PWM_RepeatTsTypeDef ts);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief PWM3 <EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
|
|||
|
*
|
|||
|
* @param d - <EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR3_PWMActDataWidth(d) (R32_TMR3_FIFO = d)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief CAP3 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>33554432
|
|||
|
*
|
|||
|
* @param cyc - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD>ʱ
|
|||
|
*/
|
|||
|
#define TMR3_CAPTimeoutCfg(cyc) (R32_TMR3_CNT_END = cyc)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD>ⲿ<EFBFBD>źŲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param cap - select capture mode, refer to CapModeTypeDef
|
|||
|
*/
|
|||
|
void TMR3_CapInit(CapModeTypeDef cap);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR3_CAPGetData() R32_TMR3_FIFO
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD>Ѳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD>Ѳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define TMR3_CAPDataCounter() R8_TMR3_FIFO_COUNT
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD>ر<EFBFBD> TMR3
|
|||
|
*/
|
|||
|
#define TMR3_Disable() (R8_TMR3_CTRL_MOD &= ~RB_TMR_COUNT_EN)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD> TMR3
|
|||
|
*/
|
|||
|
#define TMR3_Enable() (R8_TMR3_CTRL_MOD |= RB_TMR_COUNT_EN)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param s - ʹ<EFBFBD><EFBFBD>/<EFBFBD>ر<EFBFBD>
|
|||
|
* @param f - refer to TMR interrupt bit define
|
|||
|
*/
|
|||
|
#define TMR3_ITCfg(s, f) ((s) ? (R8_TMR3_INTER_EN |= f) : (R8_TMR3_INTER_EN &= ~f))
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϱ<EFBFBD>־
|
|||
|
*
|
|||
|
* @param f - refer to TMR interrupt bit define
|
|||
|
*/
|
|||
|
#define TMR3_ClearITFlag(f) (R8_TMR3_INT_FLAG = f)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ѯ<EFBFBD>жϱ<EFBFBD>־״̬
|
|||
|
*
|
|||
|
* @param f - refer to TMR interrupt bit define
|
|||
|
*/
|
|||
|
#define TMR3_GetITFlag(f) (R8_TMR3_INT_FLAG & f)
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
#endif // __CH58x_TIMER_H__
|