diff --git a/main.c b/main.c index 14a4629..239338d 100644 --- a/main.c +++ b/main.c @@ -19,12 +19,6 @@ #include "main.h" char STATE; char btnState; -char addr[] = {0x20,0xDF}; -char vol_up[] = {0x40,0xBF}; -char vol_down[] = {0xC0,0x3F}; -char input_select[] = {0xD0,0x2F}; -char ok[] = {0x22,0xdd}; -char power[] = {0x10,0xEF}; char ir_command[4]; void __interrupt() handle_interrupt(void) @@ -60,6 +54,7 @@ void main(void) static inline void init() { //Configure GPIO + CMCON = 7; //Turn off comparator GPIO = 0x0; //Clear GPIO port TRISIO = 0; //Clear TRISIO register ANSEL = 0; //Set all pins to digital IO @@ -69,14 +64,9 @@ static inline void init() clear_bit(OPTION_REG, 7); //Global weak pull-up enable WPU = INPUT_PINS; //Weak pull-up for 0,1,3,4,5 pins IOC = INPUT_PINS; //IOC enable for 0,1,3,4,5 pins - - //Configure Timer 1 - //TMR1 = 0; //Clear timer 1 value - //T1CONbits.TMR1ON = 0; //Turn timer 1 Off - //T1CONbits.T1CKPS0 = 1; //Set prescale 1:8 - //T1CONbits.T1CKPS1 = 1; - //PIE1bits.TMR1IE = 1; //Enable timer 1 overflow interrupt - //INTCONbits.PEIE = 1; //Enable peripheral interrupt + + ir_command[0] = 0x20; + ir_command[1] = 0xDF; } static inline void handle_TMR1() @@ -88,22 +78,60 @@ static inline void handle_TMR1() static inline void handle_IOC() { - + btnState = 0; handle_buttons(0); handle_buttons(1); handle_buttons(3); handle_buttons(4); handle_buttons(5); + + //Volume up if(test_bit(btnState, 5)) { - ir_command[0] = addr[0]; - ir_command[1] = addr[1]; - ir_command[2] = vol_up[0]; - ir_command[3] = vol_up[1]; + ir_command[2] = 0x40; + ir_command[3] = 0xBF; while(!GP5) send_command(ir_command); } + + //volume down + if(test_bit(btnState, 4)) + { + ir_command[2] = 0xC0; + ir_command[3] = 0x3F; + + while(!GP4) + send_command(ir_command); + } + + //input select + if(test_bit(btnState, 3)) + { + ir_command[2] = 0xD0; + ir_command[3] = 0x2F; + + while(!GP3) + send_command(ir_command); + } + //Ok + if(test_bit(btnState, 1)) + { + ir_command[2] = 0x22; + ir_command[3] = 0xDD; + + while(!GP1) + send_command(ir_command); + } + //Power + if(test_bit(btnState, 0)) + { + ir_command[2] = 0x10; + ir_command[3] = 0xEF; + + while(!GP0) + send_command(ir_command); + } clear_bit(INTCON, 0); } @@ -116,8 +144,8 @@ static inline void sleep() } static inline void handle_buttons(char bit) -{ - clear_bit(btnState, bit); +{ + clear_bit(btnState, bit); if(!test_bit(GPIO, bit)) { __delay_ms(10); diff --git a/nbproject/Makefile-genesis.properties b/nbproject/Makefile-genesis.properties index f6ca65d..e40f862 100644 --- a/nbproject/Makefile-genesis.properties +++ b/nbproject/Makefile-genesis.properties @@ -1,11 +1,11 @@ # -#Mon Mar 18 06:01:25 MSK 2024 +#Mon Mar 18 06:18:34 MSK 2024 default.languagetoolchain.version=2.45 default.Pack.dfplocation=C\:\\Program Files\\Microchip\\MPLABX\\v6.15\\packs\\Microchip\\PIC10-12Fxxx_DFP\\1.6.174 conf.ids=default default.languagetoolchain.dir=C\:\\Program Files\\Microchip\\xc8\\v2.45\\bin host.id=1jna-tnj5-7f -configurations-xml=215034e96a2f762c825b7c03119c12d4 +configurations-xml=07975d7e7282e550ac8decaaea8a2cd7 default.com-microchip-mplab-mdbcore-PICKit3Tool-PICkit3DbgToolManager.md5=50072f33d27b72924000ca2dca4b7622 com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=e62346c0c0ecee2637e613b49cb7b7fa default.com-microchip-mplab-nbide-toolchain-xc8-XC8LanguageToolchain.md5=486b02ed36e5bdffb1f797e38fa058e5 diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml index d5da495..b09e598 100644 --- a/nbproject/configurations.xml +++ b/nbproject/configurations.xml @@ -183,7 +183,7 @@ - + @@ -230,7 +230,7 @@ - +