?? 10.c
字號:
//ICC-AVR application builder : 2005-3-11 15:28:29
// Target : M48
// Crystal: 8.0000Mhz
#include <iom48v.h>
#include <macros.h>
unsigned char size;
void port_init(void)
{
PORTB = 0xFF;
DDRB = 0xff;
PORTC = 0x7F; //m103 output only
DDRC = 0x00;
PORTD = 0xFF;
DDRD = 0xF0;
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
MCUCR = 0x00;
EICRA = 0x00; //extended ext ints
EIMSK = 0x00;
TIMSK0 = 0x00; //timer 0 interrupt sources
TIMSK1 = 0x00; //timer 1 interrupt sources
TIMSK2 = 0x00; //timer 2 interrupt sources
PCMSK0 = 0x00; //pin change mask 0
PCMSK1 = 0x00; //pin change mask 1
PCMSK2 = 0x00; //pin change mask 2
PCICR = 0x00; //pin change enable
PRR = 0x00; //power controller
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
/*前行*/
void forward(void)
{
PORTD = 0X9F;
PORTB = 0XF8;
}
/*停止*/
void stop(void)
{
PORTD = 0XFF;
PORTB = 0XFF;
}
void mic_startup()
{//聲控啟動程序運行
unsigned char mic_in;
while(1)
{ //無鍵按下等待
mic_in=PINC & 0x20; //pc5=0
if(mic_in==0){break;}
}//有鍵按下運行下面的程序
}
/*主程序*/
void main()
{
unsigned char i;
init_devices();
demand:
mic_startup();
//while(1){
//i = PINC&20;
//if(i == 0){
size++;
//break;
//}
//}
while(1)
{
if(size==1)
{
forward();}
else if(size==2)
{
stop();
size=0;}
goto demand;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -