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

90 lines
1.8 KiB
C
Raw Normal View History

/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* first version
*/
// Ӳ<><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>Ͷ<EFBFBD>ʱʱ<CAB1><CAB1>
unsigned long time_h_ns; // <20>߶<EFBFBD>ʱʱ<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);
/*
* <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD>
* @timer_info <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
*/
void timer_int_clr(timer_info_t *timer_info);
/*
* <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @timer_info <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
*/
void timer_cnt_clr(timer_info_t *timer_info);
/*
* <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>Ϣ
* @hrc <EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> lrc <EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> Ϊ1<EFBFBD>򿪣<EFBFBD>Ϊ0<EFBFBD>ر<EFBFBD>
*/
void timer_int_init(timer_info_t *timer_info, int hrc, int lrc);
#endif