git.droids-corp.org
/
beacon-rx-433.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
13a330e
)
use macros to read/write ports
author
Olivier Matz
<zer0@droids-corp.org>
Thu, 23 May 2013 17:54:33 +0000
(19:54 +0200)
committer
Olivier Matz
<zer0@droids-corp.org>
Thu, 23 May 2013 17:54:33 +0000
(19:54 +0200)
main.c
patch
|
blob
|
history
diff --git
a/main.c
b/main.c
index
5dd4f1d
..
e794376
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-19,9
+19,19
@@
#endif
/* port B */
#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;
static uint32_t bitfield;
@@
-330,7
+340,7
@@
static uint8_t get_input(int i)
#ifdef HOST_VERSION
return !!x[i];
#else
#ifdef HOST_VERSION
return !!x[i];
#else
- return
!!(PINB & (1 << RADIO_BIT)
);
+ return
RADIO_READ(
);
#endif
}
#endif
}
@@
-348,15
+358,15
@@
static void set_output(int16_t i)
i, pow_fond, pow_harm1, pow_other, cpt_filter, detected);
#else
if (detected)
i, pow_fond, pow_harm1, pow_other, cpt_filter, detected);
#else
if (detected)
-
PORTB |= (1 << LED_BIT
);
+
LED_ON(
);
else
else
-
PORTB &= ~(1 << LED_BIT
);
+
LED_OFF(
);
/* when we receive, output a square signal at 625 hz */
if ((detected == 1) && (i & 4))
/* when we receive, output a square signal at 625 hz */
if ((detected == 1) && (i & 4))
-
PORTB |= (1 << BUZ_BIT
);
+
BUZZER_ON(
);
else
else
-
PORTB &= ~(1 << BUZ_BIT
);
+
BUZZER_OFF(
);
#endif
}
#endif
}
@@
-373,7
+383,7
@@
int main(void)
/* led and buzzer are outputs */
#if defined(__AVR_ATtiny45__)
/* led and buzzer are outputs */
#if defined(__AVR_ATtiny45__)
- DDRB |= (1 << LED_BIT) | (1 << BUZ_BIT);
+ DDRB |= (1 << LED_BIT) | (1 << BUZ
ZER
_BIT);
#endif
i = 0;
#endif
i = 0;