#endif
/* port B */
-#define BUZ_BIT 0
-#define RADIO_BIT 2
-#define LED_BIT 4
+#define BUZZER_BIT 0
+#define BUZZER_ON() PORTB |= _BV(BUZZER_BIT)
+#define BUZZER_OFF() PORTB &= (~_BV(BUZZER_BIT))
+
+#define RADIO_BIT 2
+#define RADIO_READ() (!!(PINB & (_BV(RADIO_BIT))))
+
+#define BUTTON_BIT 3
+#define BUTTON_IS_PRESSED() (!!(PINB & (_BV(BUTTON_BIT))))
+
+#define LED_BIT 4
+#define LED_ON() PORTB |= _BV(LED_BIT)
+#define LED_OFF() PORTB &= (~_BV(LED_BIT))
static uint32_t bitfield;
#ifdef HOST_VERSION
return !!x[i];
#else
- return !!(PINB & (1 << RADIO_BIT));
+ return RADIO_READ();
#endif
}
i, pow_fond, pow_harm1, pow_other, cpt_filter, detected);
#else
if (detected)
- PORTB |= (1 << LED_BIT);
+ LED_ON();
else
- PORTB &= ~(1 << LED_BIT);
+ LED_OFF();
/* when we receive, output a square signal at 625 hz */
if ((detected == 1) && (i & 4))
- PORTB |= (1 << BUZ_BIT);
+ BUZZER_ON();
else
- PORTB &= ~(1 << BUZ_BIT);
+ BUZZER_OFF();
#endif
}
/* led and buzzer are outputs */
#if defined(__AVR_ATtiny45__)
- DDRB |= (1 << LED_BIT) | (1 << BUZ_BIT);
+ DDRB |= (1 << LED_BIT) | (1 << BUZZER_BIT);
#endif
i = 0;