timer.c

来自「zip3.lost some files 4.Description is 」· C语言 代码 · 共 44 行

C
44
字号

/*
 * $Revision: 1.3 $
 */

#include "config.h"
#include "timer.h"
#include "button.h"

static volatile int ms_ctr = 0;
static volatile int tick = 0;

extern int test_number;

static void ProcessInput(void);


void TimerBeat(void)
{
  // Called at 1000 Hz rate.
  ms_ctr++; // Sleep counter.
  tick++; // Button debounce counter.
  ProcessInput(); // Check buttons.
}


void Sleep(int milliseconds)
{
  ms_ctr = 0;
  while (ms_ctr < milliseconds) ;
}


static void ProcessInput(void)
{
  /* Scan buttons with 50 ms interval     */
  if (tick >= 50)       
  {
     ButtonScan();
     tick = 0;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?