#include "STM8S003F3.h"
#define uchar unsigned char
#define uint unsigned int
#define _Nop() {_asm("nop
");_asm("nop
");_asm("nop
");_asm("nop
");_asm("nop
");_asm("nop
");} /* No Opera
tion */
//VIN=0.0048828125*AD
#define UX 614
#define IX 614
#define PX 2500
_Bool RLED @PC_ODR:5;
_Bool GLED @PC_ODR:6;
_Bool YLED @PD_ODR:4; //模式指示灯
_Bool BLED @PD_ODR:5; //模式指示灯
_Bool KEY1 @PB_IDR:4; //模式按键
_Bool KEY2 @PB_IDR:5; //启动停止按键
uchar ms;
uchar key_flag;
uchar key1_flag,key2_flag;
uchar eeprom_flag;
uchar mode,old_mode;
uint delay_ms;
//EEPROM初始化
void eeprom_init(void)
{
FLASH_CR1=0x00;
FLASH_CR2=0x00;
FLASH_NCR2=0xFF;
FLASH_DUKR=0xae; //锁1密匙
FLASH_DUKR=0x56; //锁2密匙
while(!(FLASH_IAPSR&0x08)); //等待解密就绪
}
//EEPROM指定地址写入一个数据
void eeprom_write(unsigned char addr, unsigned char dat)
{
unsigned char *p;
p=(unsigned char *)(0x4000+addr);
*p=dat;
while(!(FLASH_IAPSR&0x04)); //等待写操作成功
}
//EEPROM指定地址读出一个数据
uint eeprom_read( unsigned char addr)
{
unsigned char *p;
p=( unsigned char *)(0x4000+addr);
return *p;
}
//delay ms 延时函数
void DelayMS(uchar iMs)
{
ms=0;
while(ms<iMs);
}
STM8S 单片机哦...函数库?
http://www.stmcu.org/document/list/index/category-543
一周热门 更多>