⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.c

📁 这是nrf24lu1的无线鼠标源代码,应用平台是keil c
💻 C
字号:
/* 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -