rt-thread/bsp/ls1cdev/libraries/ls1c_timer.h

70 lines
1.1 KiB
C
Raw Normal View History

// Ӳ<><D3B2><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ͷ<EFBFBD>ļ<EFBFBD>
#ifndef __OPENLOONGSON_TIMER_H
#define __OPENLOONGSON_TIMER_H
#include "ls1c_public.h"
// Ӳ<><D3B2><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
typedef enum
{
TIMER_PWM0, // PWM0<4D><30><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
TIMER_PWM1, // PWM1<4D><31><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
TIMER_PWM2, // PWM2<4D><32><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
TIMER_PWM3 // PWM3<4D><33><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
}ls1c_timer_t;
// Ӳ<><D3B2><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ϣ
typedef struct
{
ls1c_timer_t timer; // Ӳ<><D3B2><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
unsigned long time_ns; // <20><>ʱʱ<CAB1><CAB1>
}timer_info_t;
/*
* <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ʱ
* @timer_info <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
*/
void timer_init(timer_info_t *timer_info);
/*
* <EFBFBD>ж<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ʱ
* @timer_info <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
* @ret TRUE or FALSE
*/
BOOL timer_is_time_out(timer_info_t *timer_info);
/*
* ֹͣ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
* @timer_info <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
*/
void timer_stop(timer_info_t *timer_info);
/*
* <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ʱ<EFBFBD><EFBFBD>(ʵ<EFBFBD>ּ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λns
* @timer_info Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
* @ret ʱ<EFBFBD><EFBFBD><EFBFBD>λns
*/
unsigned long timer_get_time_ns(timer_info_t *timer_info);
/*
* <EFBFBD><EFBFBD>ӡtimer<EFBFBD><EFBFBD><EFBFBD>ؼĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
* @timer_info Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
*/
void timer_print_regs(timer_info_t *timer_info);
#endif