Signed-off-by: Philipp Hachtmann <hachti@hachti.de>
MM_FIRST_SLOW_SAMPLE, /* If clock arrives, we stay on the fast path! */
MM_FAST_SAMPLE,
MM_FAST_WAIT_FOR_CLOCK,
MM_FIRST_SLOW_SAMPLE, /* If clock arrives, we stay on the fast path! */
MM_FAST_SAMPLE,
MM_FAST_WAIT_FOR_CLOCK,
+ MM_SLOW_WAIT_FOR_CLOCK_DELAY,
MM_SLOW_WAIT_FOR_CLOCK,
};
MM_SLOW_WAIT_FOR_CLOCK,
};
+static volatile uint8_t mm_rec_tolerated_timeouts;
+
- static uint8_t tolerated_timeouts = 0;
static volatile uint8_t shift_command_first;
static volatile uint8_t shift_function_first;
static volatile uint8_t shift_command_first;
static volatile uint8_t shift_function_first;
uint8_t address;
uint8_t command;
uint8_t address;
uint8_t command;
#ifdef MM_FILTER_REPEATED
static uint8_t address_last = 0xff;
static uint8_t function_last = 0xff;
#ifdef MM_FILTER_REPEATED
static uint8_t address_last = 0xff;
static uint8_t function_last = 0xff;
#endif
switch(recstate) {
#endif
switch(recstate) {
case MM_FIRST_FAST_SAMPLE:
case MM_FIRST_FAST_SAMPLE:
- recstate = MM_FIRST_SLOW_SAMPLE;
- MM_TSTART_FAST; /* Will not run out in fast! */
+ recstate = MM_FIRST_SLOW_SAMPLE ;
break;
case MM_FIRST_SLOW_SAMPLE:
bitno = 0;
case MM_SLOW_SAMPLE:
break;
case MM_FIRST_SLOW_SAMPLE:
bitno = 0;
case MM_SLOW_SAMPLE:
- recstate = MM_SLOW_WAIT_FOR_CLOCK;
- MM_TSTART_SLOW;
+ recstate = MM_SLOW_WAIT_FOR_CLOCK_DELAY;
case MM_FAST_SAMPLE:
recstate = MM_FAST_WAIT_FOR_CLOCK;
case MM_FAST_SAMPLE:
recstate = MM_FAST_WAIT_FOR_CLOCK;
break;
case MM_FAST_WAIT_FOR_CLOCK: /* A timeout! */
break;
case MM_FAST_WAIT_FOR_CLOCK: /* A timeout! */
- if (tolerated_timeouts) {
- tolerated_timeouts--;
- MM_TSTART_FAST;
- return;
+ if (mm_rec_tolerated_timeouts) {
+ mm_rec_tolerated_timeouts--;
+ } else {
+ recstate = MM_IDLE;
+
- recstate = MM_IDLE;
- MM_TSTOP;
+ return;
+
+ case MM_SLOW_SAMPLE_DELAY:
+ recstate = MM_SLOW_SAMPLE;
+ return;
+
+ case MM_SLOW_WAIT_FOR_CLOCK_DELAY:
+ recstate = MM_SLOW_WAIT_FOR_CLOCK;
return;
case MM_SLOW_WAIT_FOR_CLOCK:
return;
case MM_SLOW_WAIT_FOR_CLOCK:
- if (tolerated_timeouts) {
- tolerated_timeouts--;
- MM_TSTART_SLOW;
+ if (mm_rec_tolerated_timeouts) {
+ mm_rec_tolerated_timeouts--;
+ recstate = MM_SLOW_WAIT_FOR_CLOCK_DELAY;
shift_address_first = shift_address;
shift_function_first = shift_function;
shift_command_first = shift_command;
shift_address_first = shift_address;
shift_function_first = shift_function;
shift_command_first = shift_command;
-
- tolerated_timeouts = 18;
+ mm_rec_tolerated_timeouts = 18;
#endif
address = lookup_decoder(shift_address);
#endif
address = lookup_decoder(shift_address);
- if (recstate == MM_SLOW_WAIT_FOR_CLOCK) {
+ if (recstate == MM_SLOW_WAIT_FOR_CLOCK_DELAY) {
+ trigger();
mm_switch_drive(address, shift_function, shift_command);
} else if (recstate == MM_FAST_WAIT_FOR_CLOCK) {
mm_switch_drive(address, shift_function, shift_command);
} else if (recstate == MM_FAST_WAIT_FOR_CLOCK) {
command = lookup_command(shift_command);
mm_switch_command(address, command);
}
command = lookup_command(shift_command);
mm_switch_command(address, command);
}
switch(recstate) {
case MM_IDLE:
bitno = 0;
recstate = MM_FIRST_FAST_SAMPLE;
switch(recstate) {
case MM_IDLE:
bitno = 0;
recstate = MM_FIRST_FAST_SAMPLE;
case MM_FIRST_SLOW_SAMPLE:
recstate = MM_FAST_SAMPLE;
case MM_FIRST_SLOW_SAMPLE:
recstate = MM_FAST_SAMPLE;
case MM_FAST_WAIT_FOR_CLOCK:
recstate = MM_FAST_SAMPLE;
case MM_FAST_WAIT_FOR_CLOCK:
recstate = MM_FAST_SAMPLE;
+ mm_rec_tolerated_timeouts = 0;
+
+ case MM_SLOW_WAIT_FOR_CLOCK_DELAY: /* If clock comes early */
+ recstate = MM_SLOW_WAIT_FOR_CLOCK;
+ break;
+
case MM_SLOW_WAIT_FOR_CLOCK:
case MM_SLOW_WAIT_FOR_CLOCK:
- recstate = MM_SLOW_SAMPLE;
- MM_TSTART_SLOW;
+ recstate = MM_SLOW_SAMPLE_DELAY;
+ mm_rec_tolerated_timeouts = 0;
break;
/* Not expected */
case MM_FIRST_FAST_SAMPLE:
case MM_FAST_SAMPLE:
case MM_SLOW_SAMPLE:
break;
/* Not expected */
case MM_FIRST_FAST_SAMPLE:
case MM_FAST_SAMPLE:
case MM_SLOW_SAMPLE: