Files
2026-06-06 16:49:48 +08:00

79 lines
2.5 KiB
C

/*!
* \file xc_drv_aotimer.h
*
* \brief The header of xc_drv_aotimer.c
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
*
* _ __ _ ________ _
* | |/ /(_)___ / ____/ /_ (_)___
* | // / __ \/ / / __ \/ / __ \
* / |/ / / / / /___/ / / / / /_/ /
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
* /_/
* (C) 2022-2025 XinChip
*
* \endcode
*
* \author ( XinChip ) Alex-J
*
* \author ( XinChip )
*/
#ifndef _XC_DRV_AOTIMER_H_
#define _XC_DRV_AOTIMER_H_
/*-----------------------------------------------------------------------------------
INCLUDE HEADE FILES
------------------------------------------------------------------------------------*/
#include "xc6xxx.h"
/*------------------------------------------------------------------------------------
Macros
-------------------------------------------------------------------------------------*/
#define AOTIMER_MIN_TLC_VAL 0x04
#define AOTIMER_TCR_TIM_DISABLE (0x00UL)
#define AOTIMER_TCR_TIM_ENABLE (0x01UL)
#define AOTIMER_TCR_TES_ENABLE (0x01UL)
#define AOTIMER_TCR_TES_DISABLE (0x00UL)
#define AOTIMER_TICK_CAL(us) ((CLOCK_RC_LFCLK_IN_32K / 1000) * us / 1000)
/*------------------------------------------------------------------------------------
TypeDef
-------------------------------------------------------------------------------------*/
typedef enum
{
AOTIMER_MODE_SINGLE = 0,
AOTIMER_MODE_CYCLE = 1,
} AOTimer_ModeTypeDef;
typedef struct
{
AOTimer_ModeTypeDef aotimer_mode;
} AOTimer_InitCfg_t;
/*------------------------------------------------------------------------------------
Global Variables
-------------------------------------------------------------------------------------*/
typedef void (*aotimer_handler_callback)(void *context);
/*------------------------------------------------------------------------------------
Exported Functions
-------------------------------------------------------------------------------------*/
void xc_aotimer_init(uint8_t reg_idx, AOTimer_InitCfg_t *init_cfg);
void xc_aotimer_set_value(uint8_t reg_idx, uint32_t us);
void xc_aotimer_start(uint8_t reg_idx);
void xc_aotimer_stop(uint8_t reg_idx);
void aotimer0_callback(void *context);
void aotimer1_callback(void *context);
#endif