|
@@ -37,14 +37,16 @@ void fmrx_init(void)
|
|
|
|
|
|
TIMSK1 = (1 << ICIE1);
|
|
|
|
|
|
+
|
|
|
+ TIFR1 = (1 << ICF1);
|
|
|
+
|
|
|
|
|
|
TCNT1 = 0;
|
|
|
|
|
|
|
|
|
- * Input capture noise canceler on, no prescaler, normal mode;
|
|
|
- * start timer
|
|
|
+ * Input capture noise canceler on, normal mode; not counting yet
|
|
|
*/
|
|
|
- tccr1b = (1 << ICNC1) + (1 << CS10);
|
|
|
+ tccr1b = (1 << ICNC1) + (0 << CS10);
|
|
|
if (!(PIND & (1 << 4)))
|
|
|
tccr1b |= 1 << ICES1;
|
|
|
TCCR1B = tccr1b;
|
|
@@ -54,12 +56,20 @@ static uint16_t bytes;
|
|
|
|
|
|
void fmrx_set_speed(uint32_t baudrate)
|
|
|
{
|
|
|
- char msg[256];
|
|
|
+ uint8_t prescale = 1;
|
|
|
+
|
|
|
+
|
|
|
+ if (baudrate < 976) {
|
|
|
+ baudrate <<= 3;
|
|
|
+ prescale++;
|
|
|
+ }
|
|
|
|
|
|
one_bit_lo = F_CPU / (4 * baudrate);
|
|
|
one_bit_hi = 3 * one_bit_lo;
|
|
|
|
|
|
bytes = 0;
|
|
|
+
|
|
|
+ TCCR1B = (TCCR1B & ~7) | prescale;
|
|
|
}
|
|
|
|
|
|
|