From 6ce2cb47ddb722db8519152beb9764a75deb80b1 Mon Sep 17 00:00:00 2001 From: dufourj Date: Wed, 24 May 2006 00:59:10 +0000 Subject: RVB : - portage du code atmega8 pour atmega64. --- n/rvb/src/Makefile | 2 +- n/rvb/src/avrconfig.h | 2 +- n/rvb/src/test_rvb.c | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 45 insertions(+), 10 deletions(-) (limited to 'n') diff --git a/n/rvb/src/Makefile b/n/rvb/src/Makefile index 5c5f970..791941a 100644 --- a/n/rvb/src/Makefile +++ b/n/rvb/src/Makefile @@ -4,7 +4,7 @@ test_rvb_SOURCES = test_rvb.c MODULES = proto uart utils CONFIGFILE = avrconfig.h # atmega8, atmega8535, atmega128... -AVR_MCU = atmega8 +AVR_MCU = atmega64 # -O2 : speed # -Os : size OPTIMIZE = -O2 diff --git a/n/rvb/src/avrconfig.h b/n/rvb/src/avrconfig.h index 6c02e34..85af063 100644 --- a/n/rvb/src/avrconfig.h +++ b/n/rvb/src/avrconfig.h @@ -32,7 +32,7 @@ /* uart - UART module. */ /** Select hardware uart for primary uart: 0, 1 or -1 to disable. */ -#define AC_UART0_PORT 0 +#define AC_UART0_PORT 1 /** Baudrate: 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 76800, * 115200, 230400, 250000, 500000, 1000000. */ #define AC_UART0_BAUDRATE 115200 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) { -- cgit v1.2.3