diff --git a/src/arch/avr/uart.c b/src/arch/avr/uart.c index 88cd7c0..0efead5 100644 --- a/src/arch/avr/uart.c +++ b/src/arch/avr/uart.c @@ -19,7 +19,11 @@ _BV(UCSZ ## N ## 1) | _BV(UCSZ ## N ## 0) \ } -#if defined(__AVR_ATmega32U4__) +#if defined(__AVR_ATmega328P__) + static struct Uart UARTS[] = { + UART(0) + }; +#elif defined(__AVR_ATmega32U4__) static struct Uart UARTS[] = { UART(1) }; diff --git a/src/board/arduino/mega2560/board.mk b/src/board/arduino/mega2560/board.mk index dcdaa57..b846db3 100644 --- a/src/board/arduino/mega2560/board.mk +++ b/src/board/arduino/mega2560/board.mk @@ -1 +1,9 @@ EC=atmega2560 + +PORT=$(wildcard /dev/ttyACM*) + +console: + sudo tio -b 9600 $(PORT) + +flash: $(BUILD)/ec.ihx + sudo avrdude -v -v -p $(EC) -c wiring -P $(PORT) -b 115200 -D -U flash:w:$<:i diff --git a/src/board/arduino/mega2560/main.c b/src/board/arduino/mega2560/main.c index 57b0942..dbcd5c8 100644 --- a/src/board/arduino/mega2560/main.c +++ b/src/board/arduino/mega2560/main.c @@ -6,9 +6,16 @@ void init(void) { uart_stdio_init(0, 9600); } -void main(void) { +int main(void) { init(); printf("Hello from System76 EC for the Arduino Mega 2560!\n"); - for (;;) {} + for (;;) { + int c = getchar(); + if (c == '\r') { + putchar('\n'); + } else if (c > 0) { + putchar(c); + } + } } diff --git a/src/board/arduino/micro/board.mk b/src/board/arduino/micro/board.mk new file mode 100644 index 0000000..bf8c208 --- /dev/null +++ b/src/board/arduino/micro/board.mk @@ -0,0 +1,9 @@ +EC=atmega32u4 + +PORT=$(wildcard /dev/ttyACM*) + +console: + sudo tio -b 9600 $(PORT) + +flash: $(BUILD)/ec.ihx + sudo avrdude -v -v -p $(EC) -c avr109 -P $(PORT) -b 115200 -D -U flash:w:$<:i diff --git a/src/board/arduino/micro/include/board/cpu.h b/src/board/arduino/micro/include/board/cpu.h new file mode 100644 index 0000000..3d1fe04 --- /dev/null +++ b/src/board/arduino/micro/include/board/cpu.h @@ -0,0 +1,6 @@ +#ifndef _BOARD_CPU_H +#define _BOARD_CPU_H + +#define F_CPU 16000000ULL + +#endif // _BOARD_CPU_H diff --git a/src/board/arduino/micro/main.c b/src/board/arduino/micro/main.c new file mode 100644 index 0000000..c1a5255 --- /dev/null +++ b/src/board/arduino/micro/main.c @@ -0,0 +1,21 @@ +#include + +#include + +void init(void) { + uart_stdio_init(0, 9600); +} + +int main(void) { + init(); + + printf("Hello from System76 EC for the Arduino Micro!\n"); + for (;;) { + int c = getchar(); + if (c == '\r') { + putchar('\n'); + } else if (c > 0) { + putchar(c); + } + } +} diff --git a/src/board/arduino/uno/board.mk b/src/board/arduino/uno/board.mk new file mode 100644 index 0000000..2916066 --- /dev/null +++ b/src/board/arduino/uno/board.mk @@ -0,0 +1,9 @@ +EC=atmega328p + +PORT=$(wildcard /dev/ttyACM*) + +console: + sudo tio -b 9600 $(PORT) + +flash: $(BUILD)/ec.ihx + sudo avrdude -v -v -p $(EC) -c arduino -P $(PORT) -b 115200 -D -U flash:w:$<:i diff --git a/src/board/arduino/uno/include/board/cpu.h b/src/board/arduino/uno/include/board/cpu.h new file mode 100644 index 0000000..3d1fe04 --- /dev/null +++ b/src/board/arduino/uno/include/board/cpu.h @@ -0,0 +1,6 @@ +#ifndef _BOARD_CPU_H +#define _BOARD_CPU_H + +#define F_CPU 16000000ULL + +#endif // _BOARD_CPU_H diff --git a/src/board/arduino/uno/main.c b/src/board/arduino/uno/main.c new file mode 100644 index 0000000..0bb752b --- /dev/null +++ b/src/board/arduino/uno/main.c @@ -0,0 +1,21 @@ +#include + +#include + +void init(void) { + uart_stdio_init(0, 9600); +} + +int main(void) { + init(); + + printf("Hello from System76 EC for the Arduino Uno!\n"); + for (;;) { + int c = getchar(); + if (c == '\r') { + putchar('\n'); + } else if (c > 0) { + putchar(c); + } + } +} diff --git a/src/ec/atmega328p/ec.mk b/src/ec/atmega328p/ec.mk new file mode 100644 index 0000000..40fb5ae --- /dev/null +++ b/src/ec/atmega328p/ec.mk @@ -0,0 +1 @@ +ARCH=avr diff --git a/src/ec/atmega32u4/ec.mk b/src/ec/atmega32u4/ec.mk new file mode 100644 index 0000000..40fb5ae --- /dev/null +++ b/src/ec/atmega32u4/ec.mk @@ -0,0 +1 @@ +ARCH=avr