From 42a94254e58e15cf96f45edcb08a261529ea9357 Mon Sep 17 00:00:00 2001 From: john stone Date: Thu, 5 Sep 2013 23:06:13 +0200 Subject: [PATCH] entwurf einer irempfargstatemachine skizziert.... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.... --- firmware/lib/hal.c | 52 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/firmware/lib/hal.c b/firmware/lib/hal.c index 1fb1cf7..7190b17 100644 --- a/firmware/lib/hal.c +++ b/firmware/lib/hal.c @@ -43,8 +43,6 @@ ISR(TIMER2_COMPA_vect,ISR_NOBLOCK) { ISR(TIMER0_COMPA_vect) { // (2*38)kHz ISR - // - //generate 38kHz signal: if(ir_active) { PORTD ^= 1 << 2; @@ -53,11 +51,59 @@ ISR(TIMER0_COMPA_vect) { //quaterdivider for wait_ms 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) { // we need to get real fast (8MHz) to handle 38kHz IR frequency ...