add all ir commands
This commit is contained in:
parent
adef642b5b
commit
4088830f28
64
main.c
64
main.c
|
|
@ -19,12 +19,6 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
char STATE;
|
char STATE;
|
||||||
char btnState;
|
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];
|
char ir_command[4];
|
||||||
|
|
||||||
void __interrupt() handle_interrupt(void)
|
void __interrupt() handle_interrupt(void)
|
||||||
|
|
@ -60,6 +54,7 @@ void main(void)
|
||||||
static inline void init()
|
static inline void init()
|
||||||
{
|
{
|
||||||
//Configure GPIO
|
//Configure GPIO
|
||||||
|
CMCON = 7; //Turn off comparator
|
||||||
GPIO = 0x0; //Clear GPIO port
|
GPIO = 0x0; //Clear GPIO port
|
||||||
TRISIO = 0; //Clear TRISIO register
|
TRISIO = 0; //Clear TRISIO register
|
||||||
ANSEL = 0; //Set all pins to digital IO
|
ANSEL = 0; //Set all pins to digital IO
|
||||||
|
|
@ -70,13 +65,8 @@ static inline void init()
|
||||||
WPU = INPUT_PINS; //Weak pull-up for 0,1,3,4,5 pins
|
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
|
IOC = INPUT_PINS; //IOC enable for 0,1,3,4,5 pins
|
||||||
|
|
||||||
//Configure Timer 1
|
ir_command[0] = 0x20;
|
||||||
//TMR1 = 0; //Clear timer 1 value
|
ir_command[1] = 0xDF;
|
||||||
//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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void handle_TMR1()
|
static inline void handle_TMR1()
|
||||||
|
|
@ -88,23 +78,61 @@ static inline void handle_TMR1()
|
||||||
|
|
||||||
static inline void handle_IOC()
|
static inline void handle_IOC()
|
||||||
{
|
{
|
||||||
|
btnState = 0;
|
||||||
handle_buttons(0);
|
handle_buttons(0);
|
||||||
handle_buttons(1);
|
handle_buttons(1);
|
||||||
handle_buttons(3);
|
handle_buttons(3);
|
||||||
handle_buttons(4);
|
handle_buttons(4);
|
||||||
handle_buttons(5);
|
handle_buttons(5);
|
||||||
|
|
||||||
|
//Volume up
|
||||||
if(test_bit(btnState, 5))
|
if(test_bit(btnState, 5))
|
||||||
{
|
{
|
||||||
ir_command[0] = addr[0];
|
ir_command[2] = 0x40;
|
||||||
ir_command[1] = addr[1];
|
ir_command[3] = 0xBF;
|
||||||
ir_command[2] = vol_up[0];
|
|
||||||
ir_command[3] = vol_up[1];
|
|
||||||
|
|
||||||
while(!GP5)
|
while(!GP5)
|
||||||
send_command(ir_command);
|
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);
|
clear_bit(INTCON, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.languagetoolchain.version=2.45
|
||||||
default.Pack.dfplocation=C\:\\Program Files\\Microchip\\MPLABX\\v6.15\\packs\\Microchip\\PIC10-12Fxxx_DFP\\1.6.174
|
default.Pack.dfplocation=C\:\\Program Files\\Microchip\\MPLABX\\v6.15\\packs\\Microchip\\PIC10-12Fxxx_DFP\\1.6.174
|
||||||
conf.ids=default
|
conf.ids=default
|
||||||
default.languagetoolchain.dir=C\:\\Program Files\\Microchip\\xc8\\v2.45\\bin
|
default.languagetoolchain.dir=C\:\\Program Files\\Microchip\\xc8\\v2.45\\bin
|
||||||
host.id=1jna-tnj5-7f
|
host.id=1jna-tnj5-7f
|
||||||
configurations-xml=215034e96a2f762c825b7c03119c12d4
|
configurations-xml=07975d7e7282e550ac8decaaea8a2cd7
|
||||||
default.com-microchip-mplab-mdbcore-PICKit3Tool-PICkit3DbgToolManager.md5=50072f33d27b72924000ca2dca4b7622
|
default.com-microchip-mplab-mdbcore-PICKit3Tool-PICkit3DbgToolManager.md5=50072f33d27b72924000ca2dca4b7622
|
||||||
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=e62346c0c0ecee2637e613b49cb7b7fa
|
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=e62346c0c0ecee2637e613b49cb7b7fa
|
||||||
default.com-microchip-mplab-nbide-toolchain-xc8-XC8LanguageToolchain.md5=486b02ed36e5bdffb1f797e38fa058e5
|
default.com-microchip-mplab-nbide-toolchain-xc8-XC8LanguageToolchain.md5=486b02ed36e5bdffb1f797e38fa058e5
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@
|
||||||
<property key="programoptions.preservedataflash" value="false"/>
|
<property key="programoptions.preservedataflash" value="false"/>
|
||||||
<property key="programoptions.preservedataflash.ranges"
|
<property key="programoptions.preservedataflash.ranges"
|
||||||
value="${programoptions.preservedataflash.ranges}"/>
|
value="${programoptions.preservedataflash.ranges}"/>
|
||||||
<property key="programoptions.preserveeeprom" value="false"/>
|
<property key="programoptions.preserveeeprom" value="true"/>
|
||||||
<property key="programoptions.preserveeeprom.ranges" value="0-7f"/>
|
<property key="programoptions.preserveeeprom.ranges" value="0-7f"/>
|
||||||
<property key="programoptions.preserveprogram.ranges" value=""/>
|
<property key="programoptions.preserveprogram.ranges" value=""/>
|
||||||
<property key="programoptions.preserveprogramrange" value="false"/>
|
<property key="programoptions.preserveprogramrange" value="false"/>
|
||||||
|
|
@ -230,7 +230,7 @@
|
||||||
<property key="programoptions.preservedataflash" value="false"/>
|
<property key="programoptions.preservedataflash" value="false"/>
|
||||||
<property key="programoptions.preservedataflash.ranges"
|
<property key="programoptions.preservedataflash.ranges"
|
||||||
value="${programoptions.preservedataflash.ranges}"/>
|
value="${programoptions.preservedataflash.ranges}"/>
|
||||||
<property key="programoptions.preserveeeprom" value="false"/>
|
<property key="programoptions.preserveeeprom" value="true"/>
|
||||||
<property key="programoptions.preserveeeprom.ranges" value="0-7f"/>
|
<property key="programoptions.preserveeeprom.ranges" value="0-7f"/>
|
||||||
<property key="programoptions.preserveprogram.ranges" value=""/>
|
<property key="programoptions.preserveprogram.ranges" value=""/>
|
||||||
<property key="programoptions.preserveprogramrange" value="false"/>
|
<property key="programoptions.preserveprogramrange" value="false"/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user