2022-03-26 20:51:40 +08:00

554 lines
12 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/********************************** (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 <20><>ʱ<EFBFBD><CAB1><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
*
* @param t - <20><>ʱʱ<CAB1><EFBFBD><E4A3AC><EFBFBD>ڵ<EFBFBD>ǰϵͳʱ<CDB3><CAB1>Tsys, <20><EFBFBD><EEB3A4>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> 67108864
*/
void TMR0_TimerInit(uint32_t t);
/**
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>ʱ<EFBFBD><CAB1>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
*
* @return <20><>ǰ<EFBFBD><C7B0>ʱ<EFBFBD><CAB1>ֵ
*/
#define TMR0_GetCurrentTimer() R32_TMR0_COUNT
/**
* @brief <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
*
* @param cap - <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void TMR0_EXTSingleCounterInit(CapModeTypeDef cap);
/**
* @brief <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
*
* @param cyc - <20><><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
*/
#define TMR0_CountOverflowCfg(cyc) (R32_TMR0_CNT_END = (cyc + 2))
/**
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
*
* @return <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ
*/
#define TMR0_GetCurrentCount() R32_TMR0_COUNT
/**
* @brief PWM0 ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>67108864
*
* @param cyc - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#define TMR0_PWMCycleCfg(cyc) (R32_TMR0_CNT_END = cyc)
/**
* @brief PWM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
*
* @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 <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>67108864
*
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#define TMR0_PWMActDataWidth(d) (R32_TMR0_FIFO = d)
/**
* @brief CAP0 <20><>׽<EFBFBD><D7BD>ƽ<EFBFBD><C6BD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>33554432
*
* @param cyc - <20><>׽<EFBFBD><D7BD>ƽ<EFBFBD><C6BD>ʱ
*/
#define TMR0_CAPTimeoutCfg(cyc) (R32_TMR0_CNT_END = cyc)
/**
* @brief <20>ⲿ<EFBFBD>źŲ<C5BA>׽<EFBFBD><D7BD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
*
* @param cap - select capture mode, refer to CapModeTypeDef
*/
void TMR0_CapInit(CapModeTypeDef cap);
/**
* @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#define TMR0_CAPGetData() R32_TMR0_FIFO
/**
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
*
* @return <20><>ǰ<EFBFBD>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
*/
#define TMR0_CAPDataCounter() R8_TMR0_FIFO_COUNT
/**
* @brief <20>ر<EFBFBD> TMR0
*/
#define TMR0_Disable() (R8_TMR0_CTRL_MOD &= ~RB_TMR_COUNT_EN)
/**
* @brief <20><><EFBFBD><EFBFBD> TMR0
*/
#define TMR0_Enable() (R8_TMR0_CTRL_MOD |= RB_TMR_COUNT_EN)
/**
* @brief <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
*
* @param s - ʹ<><CAB9>/<2F>ر<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 <20><><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־
*
* @param f - refer to TMR interrupt bit define
*/
#define TMR0_ClearITFlag(f) (R8_TMR0_INT_FLAG = f)
/**
* @brief <20><>ѯ<EFBFBD>жϱ<D0B6>־״̬
*
* @param f - refer to TMR interrupt bit define
*/
#define TMR0_GetITFlag(f) (R8_TMR0_INT_FLAG & f)
/**
* @brief <20><>ʱ<EFBFBD><CAB1><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
*
* @param t - <20><>ʱʱ<CAB1><EFBFBD><E4A3AC><EFBFBD>ڵ<EFBFBD>ǰϵͳʱ<CDB3><CAB1>Tsys, <20><EFBFBD><EEB3A4>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> 67108864
*/
void TMR1_TimerInit(uint32_t t);
/**
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>ʱ<EFBFBD><CAB1>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
*
* @return <20><>ǰ<EFBFBD><C7B0>ʱ<EFBFBD><CAB1>ֵ
*/
#define TMR1_GetCurrentTimer() R32_TMR1_COUNT
/**
* @brief <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
*
* @param cap - <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void TMR1_EXTSingleCounterInit(CapModeTypeDef cap);
/**
* @brief <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
*
* @param cyc - <20><><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
*/
#define TMR1_CountOverflowCfg(cyc) (R32_TMR1_CNT_END = (cyc + 2))
/**
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
*
* @return <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ
*/
#define TMR1_GetCurrentCount() R32_TMR1_COUNT
/**
* @brief PWM1 ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>67108864
*
* @param cyc - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#define TMR1_PWMCycleCfg(cyc) (R32_TMR1_CNT_END = cyc)
/**
* @brief PWM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
*
* @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 <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>67108864
*
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#define TMR1_PWMActDataWidth(d) (R32_TMR1_FIFO = d)
/**
* @brief CAP1 <20><>׽<EFBFBD><D7BD>ƽ<EFBFBD><C6BD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>33554432
*
* @param cyc - <20><>׽<EFBFBD><D7BD>ƽ<EFBFBD><C6BD>ʱ
*/
#define TMR1_CAPTimeoutCfg(cyc) (R32_TMR1_CNT_END = cyc)
/**
* @brief <20>ⲿ<EFBFBD>źŲ<C5BA>׽<EFBFBD><D7BD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
*
* @param cap - select capture mode, refer to CapModeTypeDef
*/
void TMR1_CapInit(CapModeTypeDef cap);
/**
* @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#define TMR1_CAPGetData() R32_TMR1_FIFO
/**
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
*
* @return <20><>ǰ<EFBFBD>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
*/
#define TMR1_CAPDataCounter() R8_TMR1_FIFO_COUNT
/**
* @brief <20><><EFBFBD><EFBFBD>DMA<4D><41><EFBFBD><EFBFBD>
*
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>DMA<4D><41><EFBFBD><EFBFBD>
* @param startAddr - DMA <20><>ʼ<EFBFBD><CABC>ַ
* @param endAddr - DMA <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
* @param m - <20><><EFBFBD><EFBFBD>DMAģʽ
*/
void TMR1_DMACfg(uint8_t s, uint16_t startAddr, uint16_t endAddr, DMAModeTypeDef m);
/**
* @brief <20>ر<EFBFBD> TMR1
*/
#define TMR1_Disable() (R8_TMR1_CTRL_MOD &= ~RB_TMR_COUNT_EN)
/**
* @brief <20><><EFBFBD><EFBFBD> TMR1
*/
#define TMR1_Enable() (R8_TMR1_CTRL_MOD |= RB_TMR_COUNT_EN)
/**
* @brief <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
*
* @param s - ʹ<><CAB9>/<2F>ر<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 <20><><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־
*
* @param f - refer to TMR interrupt bit define
*/
#define TMR1_ClearITFlag(f) (R8_TMR1_INT_FLAG = f)
/**
* @brief <20><>ѯ<EFBFBD>жϱ<D0B6>־״̬
*
* @param f - refer to TMR interrupt bit define
*/
#define TMR1_GetITFlag(f) (R8_TMR1_INT_FLAG & f)
/**
* @brief <20><>ʱ<EFBFBD><CAB1><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
*
* @param t - <20><>ʱʱ<CAB1><EFBFBD><E4A3AC><EFBFBD>ڵ<EFBFBD>ǰϵͳʱ<CDB3><CAB1>Tsys, <20><EFBFBD><EEB3A4>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> 67108864
*/
void TMR2_TimerInit(uint32_t t);
/**
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>ʱ<EFBFBD><CAB1>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
*
* @return <20><>ǰ<EFBFBD><C7B0>ʱ<EFBFBD><CAB1>ֵ
*/
#define TMR2_GetCurrentTimer() R32_TMR2_COUNT
/**
* @brief <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
*
* @param cap - <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void TMR2_EXTSingleCounterInit(CapModeTypeDef cap);
/**
* @brief <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
*
* @param cyc - <20><><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
*/
#define TMR2_CountOverflowCfg(cyc) (R32_TMR2_CNT_END = (cyc + 2))
/**
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
*
* @return <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ
*/
#define TMR2_GetCurrentCount() R32_TMR2_COUNT
/**
* @brief PWM2 ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>67108864
*
* @param cyc - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#define TMR2_PWMCycleCfg(cyc) (R32_TMR2_CNT_END = cyc)
/**
* @brief PWM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
*
* @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 <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>67108864
*
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#define TMR2_PWMActDataWidth(d) (R32_TMR2_FIFO = d)
/**
* @brief CAP2 <20><>׽<EFBFBD><D7BD>ƽ<EFBFBD><C6BD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>33554432
*
* @param cyc - <20><>׽<EFBFBD><D7BD>ƽ<EFBFBD><C6BD>ʱ
*/
#define TMR2_CAPTimeoutCfg(cyc) (R32_TMR2_CNT_END = cyc)
/**
* @brief <20>ⲿ<EFBFBD>źŲ<C5BA>׽<EFBFBD><D7BD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
*
* @param cap - select capture mode, refer to CapModeTypeDef
*/
void TMR2_CapInit(CapModeTypeDef cap);
/**
* @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#define TMR2_CAPGetData() R32_TMR2_FIFO
/**
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
*
* @return <20><>ǰ<EFBFBD>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
*/
#define TMR2_CAPDataCounter() R8_TMR2_FIFO_COUNT
/**
* @brief <20><><EFBFBD><EFBFBD>DMA<4D><41><EFBFBD><EFBFBD>
*
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>DMA<4D><41><EFBFBD><EFBFBD>
* @param startAddr - DMA <20><>ʼ<EFBFBD><CABC>ַ
* @param endAddr - DMA <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
* @param m - <20><><EFBFBD><EFBFBD>DMAģʽ
*/
void TMR2_DMACfg(uint8_t s, uint16_t startAddr, uint16_t endAddr, DMAModeTypeDef m);
/**
* @brief <20>ر<EFBFBD> TMR2
*/
#define TMR2_Disable() (R8_TMR2_CTRL_MOD &= ~RB_TMR_COUNT_EN)
/**
* @brief <20><><EFBFBD><EFBFBD> TMR2
*/
#define TMR2_Enable() (R8_TMR2_CTRL_MOD |= RB_TMR_COUNT_EN)
/**
* @brief <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
*
* @param s - ʹ<><CAB9>/<2F>ر<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 <20><><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־
*
* @param f - refer to TMR interrupt bit define
*/
#define TMR2_ClearITFlag(f) (R8_TMR2_INT_FLAG = f)
/**
* @brief <20><>ѯ<EFBFBD>жϱ<D0B6>־״̬
*
* @param f - refer to TMR interrupt bit define
*/
#define TMR2_GetITFlag(f) (R8_TMR2_INT_FLAG & f)
/**
* @brief <20><>ʱ<EFBFBD><CAB1><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
*
* @param t - <20><>ʱʱ<CAB1><EFBFBD><E4A3AC><EFBFBD>ڵ<EFBFBD>ǰϵͳʱ<CDB3><CAB1>Tsys, <20><EFBFBD><EEB3A4>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> 67108864
*/
void TMR3_TimerInit(uint32_t t);
/**
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>ʱ<EFBFBD><CAB1>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108864
*
* @return <20><>ǰ<EFBFBD><C7B0>ʱ<EFBFBD><CAB1>ֵ
*/
#define TMR3_GetCurrentTimer() R32_TMR3_COUNT
/**
* @brief <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
*
* @param cap - <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void TMR3_EXTSingleCounterInit(CapModeTypeDef cap);
/**
* @brief <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
*
* @param cyc - <20><><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
*/
#define TMR3_CountOverflowCfg(cyc) (R32_TMR3_CNT_END = (cyc + 2))
/**
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108862
*
* @return <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ
*/
#define TMR3_GetCurrentCount() R32_TMR3_COUNT
/**
* @brief PWM3 ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>67108864
*
* @param cyc - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#define TMR3_PWMCycleCfg(cyc) (R32_TMR3_CNT_END = cyc)
/**
* @brief PWM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
*
* @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 <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>67108864
*
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#define TMR3_PWMActDataWidth(d) (R32_TMR3_FIFO = d)
/**
* @brief CAP3 <20><>׽<EFBFBD><D7BD>ƽ<EFBFBD><C6BD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>33554432
*
* @param cyc - <20><>׽<EFBFBD><D7BD>ƽ<EFBFBD><C6BD>ʱ
*/
#define TMR3_CAPTimeoutCfg(cyc) (R32_TMR3_CNT_END = cyc)
/**
* @brief <20>ⲿ<EFBFBD>źŲ<C5BA>׽<EFBFBD><D7BD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
*
* @param cap - select capture mode, refer to CapModeTypeDef
*/
void TMR3_CapInit(CapModeTypeDef cap);
/**
* @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#define TMR3_CAPGetData() R32_TMR3_FIFO
/**
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
*
* @return <20><>ǰ<EFBFBD>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
*/
#define TMR3_CAPDataCounter() R8_TMR3_FIFO_COUNT
/**
* @brief <20>ر<EFBFBD> TMR3
*/
#define TMR3_Disable() (R8_TMR3_CTRL_MOD &= ~RB_TMR_COUNT_EN)
/**
* @brief <20><><EFBFBD><EFBFBD> TMR3
*/
#define TMR3_Enable() (R8_TMR3_CTRL_MOD |= RB_TMR_COUNT_EN)
/**
* @brief <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
*
* @param s - ʹ<><CAB9>/<2F>ر<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 <20><><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־
*
* @param f - refer to TMR interrupt bit define
*/
#define TMR3_ClearITFlag(f) (R8_TMR3_INT_FLAG = f)
/**
* @brief <20><>ѯ<EFBFBD>жϱ<D0B6>־״̬
*
* @param f - refer to TMR interrupt bit define
*/
#define TMR3_GetITFlag(f) (R8_TMR3_INT_FLAG & f)
#ifdef __cplusplus
}
#endif
#endif // __CH58x_TIMER_H__