?? intmcu.c
字號(hào):
#include "main.h"
void port_init(void)
{
PORTA = 0x00;
DDRA = 0xff;
PORTB = 0x00;
DDRB = 0x00;
PORTC = 0x00; //m103 output only
DDRC = 0xff;
PORTD = 0x00;
DDRD = 0x83;
PORTE = 0xff;
DDRE = 0xfc;
PORTF = 0x00;
DDRF = 0xff;
PORTG = 0xf8;
DDRG = 0x18;
}
void watchdog_init(void)
{
WDR(); //this prevents a timout on enabling
WDTCR = 0x0e; //WATCHDOG ENABLED - dont forget to issue WDRs
}
//UART1 initialize
// desired baud rate:9600
// actual baud rate:9615 (0.2%)
void uart0_init(void)
{
UCSR0B = 0x00; //disable while setting baud rate
UCSR0A = 0x00;
UCSR0C = 0x06;
UBRR0L = 0x67; //set baud rate lo
UBRR0H = 0x00; //set baud rate hi
UCSR0B = 0xD8;
}
void timer0_init(void)
{
TCCR0A = 0x00; //stop
ASSR = 0x00; //set async mode
TCNT0 = 0x83; //set count
OCR0 = 0x7D;
TCCR0A = 0x05; //start timer
}
void USART_Transmit( unsigned char data )
{
//Wait for empty transmit buffer
while ( !( UCSR0A & (1<<UDRE0)) )
;
//Put data into buffer, sends the data
UDR0 = data;
}
unsigned char USART_Receive( void )
{
//Wait for data to be received
while ( !(UCSR0A & (1<<RXC0)) )
;
//Get and return received data from buffer
return UDR0;
}
#pragma interrupt_handler uart0_rx_isr:22
void uart0_rx_isr(void)
{
}
void init_devices(void)
{
port_init();
timer0_init();
uart0_init();
TIMSK0 = 0x01;
relay_out_reset(); //繼電器輸出復(fù)位
buzzer_off();
led_clear(); //LED輸出復(fù)位
led7_clear(); //7段碼輸出復(fù)位
shd_led_init(); //LED屬性初始化
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -