1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #include "t_define.h"
- #include "t_bk3231sf.h"
- //#include "t_uart.h"
- #include "t_gpio.h"
- #include "t_icu.h"
- #include "t_timer.h"
- //¸ÃÎļþûÓÃÉϵÄ
- static TIMER_INT_HANDLE_CB_PFN timerIntHandleCbPfn = NULL;
- void TimerGenCfg(uint8 timerid, uint8 en, uint8 inten, uint16 period)
- {
- REG_TIMER_CFG = SET_VALUE(REG_TIMER_CFG,
- (BM_TIMER_EN|BM_TIMER_INT_EN)<<(timerid<<1),
- (((uint32)en<<BO_TIMER_EN) |((uint32)inten<<BO_TIMER_INT_EN))<<(timerid<<1));
- *((volatile uint32 *)(REG_TIMER_BASE+0x08ul+(timerid<<3))) = ((uint32)period<<BO_TIMER_PERIOD_CNT);
- }
- void TimerPeriodCntCfg(uint8 timerid, uint16 period)
- {
- *((volatile uint32 *)(REG_TIMER_BASE+0x08ul+(timerid<<3))) = ((uint32)period<<BO_TIMER_PERIOD_CNT);
- }
- uint32 TimerGetIntSta(void)
- {
- return REG_TIMER_INT_STA;
- }
- void TimerClearIntSta(uint32 timerintsta)
- {
- REG_TIMER_INT_STA = timerintsta;
- }
- uint16 TimerGetCurrCnt(uint8 timerid)
- {
- return (uint16)((*((volatile uint32 *)(REG_TIMER_BASE+0x08ul+(timerid<<3)+0x04ul))) & BM_TIMER_CNT) >> BO_TIMER_CNT;
- }
- void TimerIntHandleCbCfg(TIMER_INT_HANDLE_CB_PFN cbpfn)
- {
- timerIntHandleCbPfn = cbpfn;
- }
- void TimerIntHandle(void)
- {
- uint32 timerintsta = REG_TIMER_INT_STA;
-
- REG_TIMER_INT_STA = timerintsta;
-
- if(timerIntHandleCbPfn != NULL)
- {
- (*timerIntHandleCbPfn)(timerintsta);
- }
- }
|