📄 fhl0.c
字号:
/****************************************************************************** * fhl.c - 编译环境AVRGCC * * Copyright 1998-2003 Routon Technology Co.,Ltd. * * DESCRIPTION: - * 风火轮控制源码 * modification history * -------------------- * 01a, 16.01.2007, cuiqingwei written * -------------------- ******************************************************************************/#include <avr/io.h>#include <avr/interrupt.h>#include <avr/eeprom.h>//#include <avr/wdt.h>//#include <avr/eeprom.h>//#include <avr/pgmspace.h> #include <util/delay.h>/*----------------* * 端口定义 * *----------------*/#define BOTTON_PIN PIND#define bitBOTTON 2#define HALL_PORT PORTD#define HALL_PIN PIND#define bitHALLOUT 3#define bitHALLPWR 6/*----------------* * 74HC595引脚 * *----------------*/#define SEL_SIDE PORTD // 锁存时钟--74HC595 12# #define bitFRONT 4#define bitBACK 5#define SET_SER PORTB|= _BV(PB4) // 数据------74HC595 14# #define CLR_SER PORTB&=~_BV(PB4) #define SET_SCLK PORTB|= _BV(PB5) // 移位时钟--74HC595 11# #define CLR_SCLK PORTB&=~_BV(PB5)/*----------------* * 宏定义 * *----------------*/#define EN_ANIMATE 1 // 支持动画#define NUM_PIXELS 256 // 像素数256 (刚好一个字节)#define NUM_LEDS 32 // 单面LED数据#define HALL_DEBOUNCE 4 // #define BUTTON_DEBOUNCE 100 // 100ms#define STANDBY_TIMEOUT 5*((F_CPU/256)/0xff)// F_CPU晶振频率 约5S#define POWEROFF_TIMEOUT 2*60*((F_CPU/256)/0xff) /*----------------* * EE地址定义 * *----------------*/#ifndef EEWE#define EEWE 1#endif#ifndef EEMWE#define EEMWE 2#endif#define E2_ROTATION_OFFSET 0x00#define E2_MIRROR 0x01 // 镜相#define E2_ANIMATION 0x02 // 动画/*----------------* * 变量定义 * *----------------*/volatile unsigned int tLap; // 轮子转一圈所用时间存放变量 volatile unsigned char tHall; // 霍尔传感器检测时间unsigned char mirror; // 镜相unsigned char fleds[4], bleds[4]; // 前、后面LED对应缓
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -