diff --git a/demos/AVR-ATmega128-GCC/Makefile b/demos/AVR-ATmega128-GCC/Makefile index 42104bc7a..dea57ee61 100644 --- a/demos/AVR-ATmega128-GCC/Makefile +++ b/demos/AVR-ATmega128-GCC/Makefile @@ -85,11 +85,10 @@ SRC = ../../ports/AVR/chcore.c \ ../../src/chschd.c ../../src/chthreads.c ../../src/chsem.c ../../src/chmtx.c \ ../../src/chevents.c ../../src/chmsg.c ../../src/chsleep.c ../../src/chqueues.c \ ../../src/chserial.c \ - ../../src/lib/evtimer.c ../../test/test.c \ + ../../src/lib/evtimer.c \ board.c main.c - # List C++ source files here. (C dependencies are automatically generated.) CPPSRC = diff --git a/demos/AVR-ATmega128-GCC/board.c b/demos/AVR-ATmega128-GCC/board.c index b0907d6c4..6ac43a218 100644 --- a/demos/AVR-ATmega128-GCC/board.c +++ b/demos/AVR-ATmega128-GCC/board.c @@ -24,7 +24,7 @@ #include "board.h" -ISR(TIMER0_OVF_vect) { +ISR(TIMER0_COMP_vect) { chSysIRQEnterI(); @@ -73,7 +73,7 @@ void hwinit(void) { */ TCCR0 = (1 << WGM01) | (0 << WGM00) | // CTC mode. (0 << COM01) | (0 << COM00) | // OC0A disabled (normal I/O). - (0 << CS02) | (1 << CS01) | (1 << CS00); // CLK/64 clock source. + (1 << CS02) | (0 << CS01) | (0 << CS00); // CLK/64 clock source. OCR0 = F_CPU / 64 / CH_FREQUENCY - 1; TCNT0 = 0; // Reset counter. TIFR = (1 << OCF0); // Reset pending (if any). diff --git a/demos/AVR-ATmega128-GCC/board.h b/demos/AVR-ATmega128-GCC/board.h index ee0e9b624..a29ee8664 100644 --- a/demos/AVR-ATmega128-GCC/board.h +++ b/demos/AVR-ATmega128-GCC/board.h @@ -84,6 +84,25 @@ #define VAL_DDRG 0x00 #define VAL_PORTG 0x07 +#define PORTA_BUTTON1 (1 << 0) +#define PORTA_BUTTON2 (1 << 1) +#define PORTA_BUTTON3 (1 << 2) +#define PORTA_BUTTON4 (1 << 3) +#define PORTA_BUTTON5 (1 << 4) +#define PORTA_DALLAS (1 << 5) +#define PORTA_RELAY (1 << 6) + +#define PORTC_44780_RS (1 << 0) +#define PORTC_44780_RW (1 << 1) +#define PORTC_44780_E (1 << 2) +#define PORTC_44780_D4 (1 << 4) +#define PORTC_44780_D5 (1 << 5) +#define PORTC_44780_D6 (1 << 6) +#define PORTC_44780_D7 (1 << 7) + +#define PORTE_BUZZ1 (1 << 4) +#define PORTE_BUZZ2 (1 << 5) + void hwinit(void); #endif /* _BOARD_H_ */ diff --git a/demos/AVR-ATmega128-GCC/main.c b/demos/AVR-ATmega128-GCC/main.c index 14c45cf47..b5103521e 100644 --- a/demos/AVR-ATmega128-GCC/main.c +++ b/demos/AVR-ATmega128-GCC/main.c @@ -21,13 +21,16 @@ #include +#include "board.h" + void hwinit(void); static WorkingArea(waThread1, 32); static t_msg Thread1(void *arg) { while (TRUE) { - chThdSleep(800); + PORTA ^= PORTA_RELAY; + chThdSleep(1000); } return 0; } @@ -48,7 +51,7 @@ int main(int argc, char **argv) { chThdCreate(NORMALPRIO, 0, waThread1, sizeof(waThread1), Thread1, NULL); while(TRUE) - /* Do stuff*/ ; + chThdSleep(1000); return 0; } diff --git a/ports/AVR/chcore.c b/ports/AVR/chcore.c index 7907de1dd..022e80e64 100644 --- a/ports/AVR/chcore.c +++ b/ports/AVR/chcore.c @@ -24,7 +24,7 @@ void _IdleThread(void *p) { while (TRUE) { -// asm("sleep"); + asm("sleep"); } } diff --git a/ports/AVR/chcore.h b/ports/AVR/chcore.h index 3fd027951..dd3f65ba8 100644 --- a/ports/AVR/chcore.h +++ b/ports/AVR/chcore.h @@ -94,7 +94,7 @@ typedef struct { tp->p_ctx.sp->pch = (int)threadstart; \ } -#define INT_REQUIRED_STACK 0x10 +#define INT_REQUIRED_STACK 8 #define StackAlign(n) (n) #define UserStackSize(n) StackAlign(sizeof(Thread) + \ (sizeof(struct intctx) - 1) + \ diff --git a/readme.txt b/readme.txt index 16a8afad2..9a1a991ee 100644 --- a/readme.txt +++ b/readme.txt @@ -67,6 +67,8 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet, scheduled - Added an AVRmega128 port, it is still experimental. The previous AT90CANx port is still present but it will be redone after the AVRmega128 port is complete because it will share most of it. + The code only ran in the AVR Studio simulator, it will be tested on real + hardware ASAP. - Reorganized the code of the two ARM7 ports, now all the common ARM7 code is in ./ports/ARM7. This will make maintenance and new ARM7 ports much much easier.