111 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			111 lines
		
	
	
		
			3.9 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 __BB_CPU_TIMER_H__
							 | 
						||
| 
								 | 
							
								#define __BB_CPU_TIMER_H__
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* os shim includes */
							 | 
						||
| 
								 | 
							
								#include "os_types.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								extern "C" {
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* define max timer id */
							 | 
						||
| 
								 | 
							
								#define BB_CPU_TIMER_MAX_ID                     32
							 | 
						||
| 
								 | 
							
								/* define max time of timer, 0xFFFFFFFF ntb */
							 | 
						||
| 
								 | 
							
								#define BB_CPU_TIMER_MAX_TIME_US                171000000
							 | 
						||
| 
								 | 
							
								/* define the time of reset rx immediatily, unit us */
							 | 
						||
| 
								 | 
							
								#define BB_CPU_RESET_RX_IMME                    1
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*********************** define timer id ***********************/
							 | 
						||
| 
								 | 
							
								/* timer of tx */
							 | 
						||
| 
								 | 
							
								#define TIMER_OF_TX                             0
							 | 
						||
| 
								 | 
							
								/* timer of rx */
							 | 
						||
| 
								 | 
							
								#define TIMER_OF_RX                             1
							 | 
						||
| 
								 | 
							
								/* timer of wait sack */
							 | 
						||
| 
								 | 
							
								#define TIMER_OF_WAIT_SACK                      2
							 | 
						||
| 
								 | 
							
								/* timer of reset */
							 | 
						||
| 
								 | 
							
								#define TIMER_OF_RST                            3
							 | 
						||
| 
								 | 
							
								/* timer of vcs */
							 | 
						||
| 
								 | 
							
								#define TIMER_OF_VCS                            4
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*********************** timer interruption id ***********************/
							 | 
						||
| 
								 | 
							
								/* generate from bb cpu when bb tx timeout */
							 | 
						||
| 
								 | 
							
								#define BB_CPU_ISR_TX_TIMEOUT_ID                TIMER_OF_TX
							 | 
						||
| 
								 | 
							
								/* generate from bb cpu when bb rx timeout */
							 | 
						||
| 
								 | 
							
								#define BB_CPU_ISR_RX_TIMEOUT_ID                TIMER_OF_RX
							 | 
						||
| 
								 | 
							
								/* generate from bb cpu when bb rx timeout */
							 | 
						||
| 
								 | 
							
								#define BB_CPU_ISR_WAIT_SACK_TIMEOUT_ID         TIMER_OF_WAIT_SACK
							 | 
						||
| 
								 | 
							
								/* generate from bb cpu when bb reset timeout */
							 | 
						||
| 
								 | 
							
								#define BB_CPU_ISR_RST_TIMEOUT_ID               TIMER_OF_RST
							 | 
						||
| 
								 | 
							
								/* generate from bb cpu when vcs timer timeout */
							 | 
						||
| 
								 | 
							
								#define BB_CPU_ISR_VCS_TIMEOUT_ID               TIMER_OF_VCS
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief bb_cpu_timer_get_timeout_id()    - bb cpu get timeout timerid.
							 | 
						||
| 
								 | 
							
								 * @param void                      - void.
							 | 
						||
| 
								 | 
							
								 * @return uint32_t                 - timer id.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t bb_cpu_timer_get_timeout_id();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief bb_cpu_timer_clr_timeout_id()    - bb cpu clear timeout timerid.
							 | 
						||
| 
								 | 
							
								 * @param timer_sts                        - timer sts.
							 | 
						||
| 
								 | 
							
								 * @return void                            - void.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void bb_cpu_timer_clr_timeout_id(uint32_t timer_sts);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief bb_cpu_timer_enable()            - bb cpu timer enable.
							 | 
						||
| 
								 | 
							
								 * @param void                             - void.
							 | 
						||
| 
								 | 
							
								 * @return void                            - void.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void bb_cpu_timer_enable();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief bb_cpu_timer_disable()           - bb cpu timer disable.
							 | 
						||
| 
								 | 
							
								 * @param void                             - void.
							 | 
						||
| 
								 | 
							
								 * @return void                            - void.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void bb_cpu_timer_disable();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief bb_cpu_timer_start()             - bb cpu timer start.
							 | 
						||
| 
								 | 
							
								 * @param timer_id                         - timer id.
							 | 
						||
| 
								 | 
							
								 * @return void                            - void.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void bb_cpu_timer_start(uint32_t timer_id);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief bb_cpu_timer_stop()              - bb cpu timer stop.
							 | 
						||
| 
								 | 
							
								 * @param timer_id                         - timer id.
							 | 
						||
| 
								 | 
							
								 * @return void                            - void.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void bb_cpu_timer_stop(uint32_t timer_id);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief bb_cpu_timer_set()            - bb cpu timer set time value.
							 | 
						||
| 
								 | 
							
								 * @param timer_id                      - timer id.
							 | 
						||
| 
								 | 
							
								 * @param time_ms                       - timer uint us.
							 | 
						||
| 
								 | 
							
								 * @return void                         - void.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void bb_cpu_timer_set(uint32_t timer_id, uint32_t time_us);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif // !__BB_CPU_TIMER_H__
							 |