104 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			104 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
|  | /****************************************************************************
 | ||
|  | 
 | ||
|  | Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. | ||
|  | 
 | ||
|  | This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT | ||
|  | be copied by any method or incorporated into another program without | ||
|  | the express written consent of Aerospace C.Power. This Information or any portion | ||
|  | thereof remains the property of Aerospace C.Power. The Information contained herein | ||
|  | is believed to be accurate and Aerospace C.Power assumes no responsibility or | ||
|  | liability for its use in any way and conveys no license or title under | ||
|  | any patent or copyright and makes no representation or warranty that this | ||
|  | Information is free from patent or copyright infringement. | ||
|  | 
 | ||
|  | ****************************************************************************/ | ||
|  | #ifndef _IOT_GPTMR_API_H_
 | ||
|  | #define _IOT_GPTMR_API_H_
 | ||
|  | 
 | ||
|  | #ifdef __cplusplus
 | ||
|  | extern "C" { | ||
|  | #endif
 | ||
|  | 
 | ||
|  | /* indicate how many GP  TIMER the chip support */ | ||
|  | #define TIMER_NUM 4
 | ||
|  | 
 | ||
|  | typedef enum | ||
|  | { | ||
|  |     GP_TIMER0    = 0, | ||
|  |     GP_TIMER1    = 1, | ||
|  |     GP_TIMER2    = 2, | ||
|  |     GP_TIMER3    = 3, | ||
|  | 
 | ||
|  |     GP_TIMER_COUNT | ||
|  | }GP_TIMER_ID; | ||
|  | 
 | ||
|  | 
 | ||
|  | /* brief timer_handler_t - function callback to  handle,
 | ||
|  |                         excuted in msg queue. | ||
|  |  * @param data:         reserved data, used for customer. | ||
|  |  */ | ||
|  | typedef void timer_handler_t(iot_addrword_t data); | ||
|  | 
 | ||
|  | /* brief isr_handler_t - function callback to interrupt handle.
 | ||
|  |  * @param data:         reserved data, used for customer. | ||
|  |  * @param retval:       flag of next step. 1 mean that continue | ||
|  |  *                      running the timer handler. 0 mean that no | ||
|  |  *                      need to continue running the timer handler. | ||
|  |  */ | ||
|  | typedef uint8_t isr_handler_t(iot_addrword_t data); | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @brief  iot_gp_timer_init() - initialize the gp timer module. | ||
|  |  */ | ||
|  | void iot_gp_timer_init(void); | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @brief  iot_gp_timer_task_register() - registe the gp timer task to | ||
|  |  *                          share task event . | ||
|  |  */ | ||
|  | void iot_gp_timer_task_register(void); | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @brief iot_gp_timer_create() - create gptimer's ISR handle and normal handl. | ||
|  |  * @param cpu:              indicate whitch cpu will the fw runs on | ||
|  |  * @param task_handle:      normal task handle, excuted by msg queue. | ||
|  |  * @param isr_handle:       task handle, whitch excuted in GP timer's ISR. | ||
|  |  * @param data:             reserved data, used for customer. | ||
|  |  * @param retval:           ID of gp timer | ||
|  |  */ | ||
|  | uint8_t iot_gp_timer_create(uint8_t cpu, timer_handler_t *task_handle, | ||
|  |     isr_handler_t *isr_handle, iot_addrword_t data); | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @brief iot_gp_timer_set() - config gp timer. | ||
|  |  * @param id:           ID of gp timer | ||
|  |  * @param val:          gp timer's period, unit: us. | ||
|  |  * @param repeat:       indicate whether the timer should be reloaded. | ||
|  |  */ | ||
|  | void iot_gp_timer_set(uint8_t id, uint32_t val, uint8_t repeat); | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @brief iot_gp_timer_start() - start gp timer. | ||
|  |  * @param id:           ID of gp timer | ||
|  |  */ | ||
|  | void iot_gp_timer_start(uint8_t id); | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @brief iot_gp_timer_start() - start gp timer. | ||
|  |  * @param id:           ID of gp timer | ||
|  |  */ | ||
|  | void iot_gp_timer_stop(uint8_t id); | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @brief get gp timer current ts() - get gp timer's current ticks. | ||
|  |  * @retval:             current ts, uint is 1us. | ||
|  |  */ | ||
|  | uint32_t iot_gp_timer_get_curr_ts(void); | ||
|  | 
 | ||
|  | #ifdef __cplusplus
 | ||
|  | } | ||
|  | #endif
 | ||
|  | 
 | ||
|  | #endif
 | ||
|  | 
 |