summaryrefslogtreecommitdiff
path: root/n/rvb/src/test_rvb.c
diff options
context:
space:
mode:
Diffstat (limited to 'n/rvb/src/test_rvb.c')
-rw-r--r--n/rvb/src/test_rvb.c51
1 files changed, 43 insertions, 8 deletions
diff --git a/n/rvb/src/test_rvb.c b/n/rvb/src/test_rvb.c
index f107b50..00af13d 100644
--- a/n/rvb/src/test_rvb.c
+++ b/n/rvb/src/test_rvb.c
@@ -29,6 +29,11 @@
#include "modules/utils/utils.h"
int rvb_output, rvb_output_cpt;
+#ifdef __AVR_ATmega8__
+#define RVB_TIMER TCNT0
+#else
+#define RVB_TIMER TCNT2
+#endif
void
proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
@@ -78,8 +83,14 @@ timer_wait (void)
static inline void
counter_init (void)
{
+#ifdef __AVR_ATmega8__
TCCR0 = regv (7, 6, 5, 4, 3, CS02, CS01, CS00,
0, 0, 0, 0, 0, 1, 1, 1);
+#else
+ TCCR2 = regv (FOC2, WGM20, COM21, COM20, WGM21, CS22, CS21, CS20,
+ 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 );
+
+#endif
/* Increment on rising edge. */
}
@@ -92,35 +103,59 @@ main (void)
counter_init ();
sei ();
proto_send0 ('z');
+#ifdef __AVR_ATmega8__
DDRC = 0x0f;
PORTC = 0x0e;
+#else
+ DDRC = 0xff;
+ DDRD |= _BV(6);
+ DDRF |= _BV(6) | _BV(7);
+ PORTD &= ~_BV(6);
+ PORTC = 0xff;
+#endif
r = v = b = c = 0;
while (1)
{
/* Rouge. */
+#ifdef __AVR_ATmega8__
PORTC = 0x3;
+#else
+ PORTF = (PORTF & ~0xC0) | (0 << 6);
+#endif
timer_wait ();
- TCNT0 = 0;
+ RVB_TIMER = 0;
timer_wait ();
- r = TCNT0;
+ r = RVB_TIMER;
/* Bleu. */
+#ifdef __AVR_ATmega8__
PORTC = 0x7;
+#else
+ PORTF = (PORTF & ~0xC0) | (1 << 6);
+#endif
timer_wait ();
- TCNT0 = 0;
+ RVB_TIMER = 0;
timer_wait ();
- b = TCNT0;
+ b = RVB_TIMER;
/* Vert. */
+#ifdef __AVR_ATmega8__
PORTC = 0xf;
+#else
+ PORTF = (PORTF & ~0xC0) | (3 << 6);
+#endif
timer_wait ();
- TCNT0 = 0;
+ RVB_TIMER = 0;
timer_wait ();
- v = TCNT0;
+ v = RVB_TIMER;
/* Clair. */
+#ifdef __AVR_ATmega8__
PORTC = 0xb;
+#else
+ PORTF = (PORTF & ~0xC0) | (2 << 6);
+#endif
timer_wait ();
- TCNT0 = 0;
+ RVB_TIMER = 0;
timer_wait ();
- c = TCNT0;
+ c = RVB_TIMER;
/* Envois. */
if (rvb_output && !--rvb_output_cpt)
{