tools.c
来自「基于MEGA8单片机的AVR单片机STK500编程器源代码(GCC编译器),改软」· C语言 代码 · 共 44 行
C
44 行
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include "tools.h"
volatile unsigned char t1_tick;
unsigned char t1_cnt;
//Konstanten im EEPROM
#define EEPROM __attribute__ ((section (".eeprom")))
//Variablen im EEPROM
EEPROM unsigned char eeprom_sck_period=10;
ISR(SIG_OUTPUT_COMPARE1A)
{
t1_tick=1;
t1_cnt++;
}
unsigned char get_t1_tick(void)
{
if (t1_tick)
{
t1_tick=0;
return 1;
}
return 0;
}
/**
Wartet n*1ms - 1ms max.
*/
void wait_ms(unsigned int n)
{
while (n)
{
if (get_t1_tick()) n--;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?