?? init.c
字號:
/************************************************
* 文件名:init.c *
* 文件功能:初始化程序,完成寄存器及端口初始化 *
* 作者:xxlxws *
* 日期:2007-05-15 *
* 版本號:1.0 *
************************************************/
#include <ioavr.h>
#include <intrinsics.h>
#include "mylib.h"
#include "common.h"
#include "main.h"
#include "init.h"
#include "iic.h"
#include "func.h"
#include "inter.h"
//__root __flash char Copyright[]@"CODES"="Copyright@SLen(知道)";
extern struct _Led Led;
extern struct _Data Data;
extern struct _Count Count;
extern struct _Moto Moto_A,Moto_B,Moto_Mid,Moto_HT;
extern uint8 Mass[4];
extern uint8 LedCode[10];
/************************************************
* 函數名:Init *
* 入口參數:無 *
* 出口參數:無 *
* 作者:xxlxws *
* 日期:2007-05-15 *
* 函數功能:初始化調用 *
************************************************/
void Init(void)
{
cli(); /*關中斷*/
/********端口初始化*****************************/
PORTB = 0x00;
DDRB = ~(BIT(PB2)); /*輸出*/
PORTC = 0x00;
DDRC = ~(BIT(PC5)|BIT(PC4)); /*SCL(PC5)/SDA(PC4)輸入*/
// PORTC = 0x30;
PORTD = 0x00;
DDRD = 0xff; /*輸出*/
/********TWI初始化,從機接收模式****************************/
// TWBR = 30; /*波特率,32us/bit*/
// TWSR = BIT(TWPS0); /*4分頻*/
// TWAR = TWI_ADDR;
// TWCR = (BIT(TWEA)|BIT(TWEN)); /*啟動從機接收模式*/
/********變量初始化*****************************/
Led.Sel[0] = 0xfe; //LED位選值
Led.Sel[1] = 0xfd;
Led.Sel[2] = 0xfb;
Led.Sel[3] = 0xf7;
Led.Sel[4] = 0xef;
Data.Key = 0x00;
Data.Time = 0x0a;
Data.Mode = 0x00;
Data.Flag = 0x00;
Data.Mass_Max = 0x00;
Data.Read[0] = 0x05;
Data.Read[1] = 0x04;
Data.Read[2] = 0x03;
Data.Read[3] = 0x02;
Data.Read[4] = 0x01;
Data.Write[0] = 0x01;
Data.Write[1] = 0x02;
Data.Write[2] = 0x03;
Data.Write[3] = 0x04;
Data.Write[4] = 0x05;
clrwdt();
wdt_enable(WDTO_500MS);
// sei(); /*開中斷*/
return;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -