//ICC-AVR application builder : 2008-11-12 11:41:28
// Target : M16
// Crystal: 8.0000Mhz
#include <iom16v.h>
#include <macros.h>
#include "delay.h"
#include "ir.h"
#include "lcd1602.h"
void port_init(void)
{
PORTD = 0xC0;
DDRD = 0x80;
}
//TIMER1 initialize - prescale:8
// WGM: 0) Normal, TOP=0xFFFF
// desired value: 8uSec
// actual value: 8.000uSec (0.0%)
void timer1_init(void)
{
TCCR1B = 0x00; //stop
ICR1H = 0x00;
ICR1L = 0x08;
TCCR1A = 0x00;
TCCR1B = 0x82; //start Timer
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
timer1_init();
LCD_init();
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x20; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
//
void main(void)
{
init_devices();
//insert your functional code here...
LCD_write_string(0,0,"opr_code:");
LCD_write_string(0,1,"key dis:");
while(1)
{
get_ir_code();
if(ir_num==0)
LCD_write_string(9,1," 0 ");
if(ir_num==1)
LCD_write_string(9,1," 1 ");
if(ir_num==2)
LCD_write_string(9,1," 2 ");
if(ir_num==3)
LCD_write_string(9,1," 3 ");
if(ir_num==4)
LCD_write_string(9,1," 4 ");
if(ir_num==5)
LCD_write_string(9,1," 5 ");
if(ir_num==6)
LCD_write_string(9,1," 6 ");
if(ir_num==7)
LCD_write_string(9,1," 7 ");
if(ir_num==8)
LCD_write_string(9,1," 8 ");
if(ir_num==9)
LCD_write_string(9,1," 9 ");
if(ir_num==10)
LCD_write_string(9,1,"power ");
if(ir_num==11)
LCD_write_string(9,1,"Colour ");
if(ir_num==12)
LCD_write_string(9,1,"Volume+");
if(ir_num==13)
LCD_write_string(9,1,"Chanel+");
if(ir_num==14)
LCD_write_string(9,1,"Volume-");
if(ir_num==15)
LCD_write_string(9,1,"Chanel-");
if(ir_num==16)
LCD_write_string(9,1,"Sound ");
if(ir_num==17)
LCD_write_string(9,1,"TV/VIde");
if(ir_num==18)
LCD_write_string(9,1,"Display");
if(ir_num==19)
LCD_write_string(9,1,"OFF_TIM");
if(ir_num==20)
LCD_write_string(9,1,"PI_ADup");
if(ir_num==21)
LCD_write_string(9,1,"HY_Bass");
if(ir_num==22)
LCD_write_string(9,1,"PI_AD--");
if(ir_num==23)
LCD_write_string(9,1,"PI_AD +");
if(ir_num==24)
LCD_write_string(9,1,"PI_ADdm");
if(ir_num==25)
LCD_write_string(9,1,"PC_MODE");
if(ir_num==26)
LCD_write_string(9,1," -/-- ");
if(ir_num==27)
LCD_write_string(9,1," MUTE ");
}
}