timer.c
来自「这是nrf24lu1的无线鼠标源代码,应用平台是keil c」· C语言 代码 · 共 52 行
C
52 行
/* Copyright (c) 2006 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is confidential property of
* Nordic Semiconductor. The use, copying, transfer or disclosure of such
* information is prohibited except by express written agreement with
* Nordic Semiconductor.
*/
/** @file
* Timer for the Wireless Desktop Protocol.
* Sets up Timer2 to call WDP and FAP functions at the correct timing
* intervals.
*/
#include <Nordic\reg24lu1.h>
#include <stdint.h>
#include "nordic_common.h"
#include "wdp_common.h"
volatile uint16_t timer_cnt = 0;
void t2_init(uint16_t val)
{
// Setup Timer2:
// 1/12 prescaler, reload Mode 0, Stopped
T2CON = BIT_4;
T2 = CRC = ~((val * 4) / 3);
T2I0 = 1; // Start Timer2
}
static void t2_interrupt(void) interrupt 5
{
TF2 = 0;
wdp_timer_isr_function();
fap_timer_isr_function();
if(timer_cnt < 0xffff)
{
timer_cnt++;
}
}
void fap_modify_timer_period(void)
{
T2 = ~((FAP_TIMER_MODIFY_PERIOD*4) / 3);
TF2 = 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?