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

📄 fhl.c

📁 风火轮 小崔风火轮资料.玩得很开心!下来看先.
💻 C
字号:
/******************************************************************************
 * fhl.c - fhl
 * 
 * Copyright 1998-2003 Routon Technology Co.,Ltd.
 * 
 * DESCRIPTION: - 
 *    fhl驱动
 * modification history
 * --------------------
 * 01a, 15.01.2007, cuiqingwei written
 * --------------------
 ******************************************************************************/

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include <avr/sleep.h>
#include <avr/eeprom.h>

#include <util/delay.h>
/*----------------*
sleep.h里面定义的常数,对应各种睡眠模式
#define SLEEP_MODE_IDLE         0   							空闲模式
#define SLEEP_MODE_ADC          _BV(SM0)  						ADC 噪声抑制模式
#define SLEEP_MODE_PWR_DOWN     _BV(SM1)						掉电模式
#define SLEEP_MODE_PWR_SAVE     (_BV(SM0)|_BV(SM1))				省电模式
#define SLEEP_MODE_STANDBY      (_BV(SM1)|_BV(SM2))				Standby 模式
#define SLEEP_MODE_EXT_STANDBY  (_BV(SM0)|_BV(SM1)|_BV(SM2))	扩展Standby模式
//
void set_sleep_mode (uint8_t mode);		设定睡眠模式
void sleep_mode (void);					进入睡眠状态
 *----------------*/

/*----------------*
 *	  时钟主频    *
 *----------------*/
#ifndef F_CPU
#define F_CPU 7372800UL
#endif
/*----------------*
 *	  端口定义    *
 *----------------*/

#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 + -