entwurf einer irempfargstatemachine skizziert....

sry mehr ging heute einfach nicht mehr.... wir sollten um schnell was zu
haben mal eine solche kacke runtercoden, und das senden dann
dementsprechend machen.... ich schlage vor das eine msg immer 2 byte
lang ist ... sowas wie adresse, keycode ... oder eben einfach eine
temperatur oder wtf.... jedenfalls feste länge....
This commit is contained in:
john stone 2013-09-05 23:06:13 +02:00
parent f37b56b6d4
commit 42a94254e5

View File

@ -43,8 +43,6 @@ ISR(TIMER2_COMPA_vect,ISR_NOBLOCK) {
ISR(TIMER0_COMPA_vect) { ISR(TIMER0_COMPA_vect) {
// (2*38)kHz ISR // (2*38)kHz ISR
//
//generate 38kHz signal: //generate 38kHz signal:
if(ir_active) { if(ir_active) {
PORTD ^= 1 << 2; PORTD ^= 1 << 2;
@ -53,11 +51,59 @@ ISR(TIMER0_COMPA_vect) {
//quaterdivider for wait_ms //quaterdivider for wait_ms
if(!(timerdivider & 0x03)) { if(!(timerdivider & 0x03)) {
--wait_time; --wait_time;
} }
} }
#if 0
pinchangeportisr(ireingangport)
{
if pinchanged is ir input:
if ir inactive
irrstate = IRR_IDLE
return
time_since_last = timedivider - oldtime //2d handle overflow
//State machine:
select (irrstate){
case ( IRR_IDLE):
irrstate = IRR_AWAIT_START_COMP;
break;
case (IRR_AWAIT_START_COMP):
//check for transition in time
if (time_since_last > IR_MAX_STARTBIT_TICKS)
{
irrstate = IRR_GET_BIT_FIRSTHALF;
bitnum = 0;
} else { irrstate = IRR_IDLE // errorreset}
break;
case (IRR_GET_BIT_FIRSTHALF)
//check beeing in time
// -> buffer bit[bitnum]
// else reset
irrstate = IRR_GET_BIT_SECHALF;
break;
case (IRR_GET_BIT_SECHALF)
//check beeing in time
// -> inc bitnum
// -> irrstate = (maxbits)?IRR_GET_STOP_COND:IRR_GET_BIT_FIRSTHALF;
// else reset
break;
case (IRR_GET_STOP_COND):
//check beeing in time <- need macro for this :-)
//-> mark received done and set ir inactive (mainloop has to poll done or idle loop callback registration?)
//-> else reset
}
}
#endif
void init_hw(void) { void init_hw(void) {
// we need to get real fast (8MHz) to handle 38kHz IR frequency ... // we need to get real fast (8MHz) to handle 38kHz IR frequency ...