2018-12-24 18:49:00 +08:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*
|
|
|
|
|
* Change Logs:
|
|
|
|
|
* Date Author Notes
|
|
|
|
|
* first version
|
|
|
|
|
*/
|
2017-07-18 11:33:27 +08:00
|
|
|
|
// Ӳ<><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>
|
2018-12-24 18:49:00 +08:00
|
|
|
|
unsigned long time_ns; // <20>Ͷ<EFBFBD>ʱʱ<CAB1><CAB1>
|
|
|
|
|
unsigned long time_h_ns; // <20>߶<EFBFBD>ʱʱ<CAB1><CAB1>
|
2017-07-18 11:33:27 +08:00
|
|
|
|
}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);
|
|
|
|
|
|
2018-12-24 18:49:00 +08:00
|
|
|
|
/*
|
|
|
|
|
* <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);
|
2017-07-18 11:33:27 +08:00
|
|
|
|
|
2018-12-24 18:49:00 +08:00
|
|
|
|
/*
|
|
|
|
|
* <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);
|
2017-07-18 11:33:27 +08:00
|
|
|
|
#endif
|
|
|
|
|
|