📄 init_m8.i
字号:
void init_m8(void)
{
// Input/Output Ports initialization
// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0x07;
DDRB=0x81;
// Port C initialization
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;
// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0xC0;
DDRD=0xE0;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 0.977 kHz
TCCR0=0x05;
TCNT0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 0.977 kHz
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: On
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1B = 0x00; //stop
TCNT1H = 0xFE; //setup
TCNT1L = 0x18;
OCR1AH = 0x01;
OCR1AL = 0xE8;
OCR1BH = 0x01;
OCR1BL = 0xE8;
ICR1H = 0x01;
ICR1L = 0xE8;
TCCR1A = 0x00;
TCCR1B = 0x05; //start Timer
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
MCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x05;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
// Global enable interrupts
#asm("sei")
if(InitialCC1000())
bell(2);
}
void bell(unsigned char abc)
{
for( ;abc>0;abc--)
{
DDRD |=0x08;
PORTD.3 = 1;
delay_ms(200);
PORTD.3 =0;
delay_ms(150);
}
}
void Registrion(void)
{
DDRD &=0xFC;
get_long_key = PIND&0x03;
temp_key=get_long_key;
temp_long_key=(old_long_key<<4);
get_long_key = get_long_key+temp_long_key;
switch(get_long_key)
{
case 0x33: break;
case 0x30:
case 0x31:
case 0x32: old_long_key=temp_key;
break;
case 0x03:
case 0x13:
case 0x23:
break;
case 0x00:
case 0x11:
case 0x22: long_counter++;
break;
default : long_counter=0;
old_long_key=temp_key;
break;
}
if(long_counter==2)lock_key=1;
if(long_counter==8)
{
old_long_key=0x03;
long_counter = 0;
Registration_table[4]=temp_key;
Self_ID[0]=temp_key;
Registration_table[5]=Self_ID[1];
Registration_table[6]=Self_ID[2];
Registration_table[7]=Self_ID[3];
Registration_Return_table[0]=Self_ID[0];
Registration_Return_table[1]=Self_ID[1];
Registration_Return_table[2]=Self_ID[2];
Registration_Return_table[3]=Self_ID[3];
key_flag = SendOnePacketToCC1000(&Registration_table[0]);
lock_key=0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -