📄 initial.c
字号:
/****************************************Copyright (c)**************************************************
**
**
**
** 文 件 名: initial.c
** 最后修改日期: 2006-1-23 13:47
** 描 述: 初始化程序
** 版 本: V1.0
** 主 控 芯 片:M16 晶振频率:7.3728MHZ,
**********************************************************************************************************/
#include <iom8v.h>
#include <macros.h>
#include "define.h"
#include "extern.h"
#include "function.h"
#include "command.h"
/**********************************************************************
functionName:void paraInit(void)
description:变量初始化
**********************************************************************/
void globalParaInit(void)
{
statusMachine = ST_START;
paramControllerInit=0x00;
prgMode=0;
}
/**********************************************************************
functionName:void uart0Init(void)
description:串口初始化函数
desired baud rate: UBRRL决定
UBRRL = 3; //115200
UBRRL = 7; //57600
UBRRL = 23; //19200
UBRRL = 47; //9600
char size: 8 bit
parity: Disabled
**********************************************************************/
void uart0Init(void)
{
UCSRB = 0x00; //disable while setting baud rate
UCSRA = 0x00;
UCSRC = 0x86;
UBRRL = BAUD115200; //set baud rate lo
UBRRH = 0x00; //set baud rate hi
UCSRB = 0x98; //使用中断
//UCSRB = 0x18;
}
/**********************************************************************
functionName:void portInit(void)
description:M16 IO初始化
**********************************************************************/
void portInit(void)
{
PORTB=0xFF;
DDRB=0x00;
PORTC=0xFF;
DDRC=0x00;
PORTD=0xFF;
DDRD=0x00;
}
/**********************************************************************
functionName:void allInit(void)
description:初始化所有的器件以及变量
**********************************************************************/
void allInit(void)
{
//开始初始化工作
CLI(); //关闭中断源
globalParaInit(); //变量初始化
portInit(); //M16 IO初始化
uart0Init(); //串口初始化函数
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x00;
//SEI(); //中断使能
//完成所有的初始化工作
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -