From a5ae433b7f12246adb709a57223a853bd2a948c1 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Tue, 25 Apr 2023 20:55:35 +0200 Subject: WIP arduino + pololu libraries build system --- .gitmodules | 24 +++++++++++++++ zumo/lib/ArduinoCore-avr | 1 + zumo/lib/fastgpio-arduino | 1 + zumo/lib/pololu-buzzer-arduino | 1 + zumo/lib/pololu-hd44780-arduino | 1 + zumo/lib/pololu-menu-arduino | 1 + zumo/lib/pololu-oled-arduino | 1 + zumo/lib/pushbutton-arduino | 1 + zumo/lib/usb-pause-arduino | 1 + zumo/lib/zumo-32u4-arduino-library | 1 + zumo/main.c | 15 ---------- zumo/main.cpp | 13 ++++++++ zumo/makefile | 15 ++++++++-- zumo/zumo.mk | 61 ++++++++++++++++++++++++++++++++++++++ 14 files changed, 119 insertions(+), 18 deletions(-) create mode 160000 zumo/lib/ArduinoCore-avr create mode 160000 zumo/lib/fastgpio-arduino create mode 160000 zumo/lib/pololu-buzzer-arduino create mode 160000 zumo/lib/pololu-hd44780-arduino create mode 160000 zumo/lib/pololu-menu-arduino create mode 160000 zumo/lib/pololu-oled-arduino create mode 160000 zumo/lib/pushbutton-arduino create mode 160000 zumo/lib/usb-pause-arduino create mode 160000 zumo/lib/zumo-32u4-arduino-library delete mode 100644 zumo/main.c create mode 100644 zumo/main.cpp create mode 100644 zumo/zumo.mk diff --git a/.gitmodules b/.gitmodules index e29501f..a60d698 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,27 @@ [submodule "zumo/lib/zumo-32u4-arduino-library"] path = zumo/lib/zumo-32u4-arduino-library url = https://github.com/pololu/zumo-32u4-arduino-library +[submodule "zumo/lib/fastgpio-arduino"] + path = zumo/lib/fastgpio-arduino + url = https://github.com/pololu/fastgpio-arduino +[submodule "zumo/lib/pushbutton-arduino"] + path = zumo/lib/pushbutton-arduino + url = https://github.com/pololu/pushbutton-arduino +[submodule "zumo/lib/ArduinoCore-avr"] + path = zumo/lib/ArduinoCore-avr + url = https://github.com/arduino/ArduinoCore-avr +[submodule "zumo/lib/usb-pause-arduino"] + path = zumo/lib/usb-pause-arduino + url = https://github.com/pololu/usb-pause-arduino +[submodule "zumo/lib/pololu-buzzer-arduino"] + path = zumo/lib/pololu-buzzer-arduino + url = https://github.com/pololu/pololu-buzzer-arduino +[submodule "zumo/lib/pololu-hd44780-arduino"] + path = zumo/lib/pololu-hd44780-arduino + url = https://github.com/pololu/pololu-hd44780-arduino +[submodule "zumo/lib/pololu-menu-arduino"] + path = zumo/lib/pololu-menu-arduino + url = https://github.com/pololu/pololu-menu-arduino +[submodule "zumo/lib/pololu-oled-arduino"] + path = zumo/lib/pololu-oled-arduino + url = https://github.com/pololu/pololu-oled-arduino diff --git a/zumo/lib/ArduinoCore-avr b/zumo/lib/ArduinoCore-avr new file mode 160000 index 0000000..42fa4a1 --- /dev/null +++ b/zumo/lib/ArduinoCore-avr @@ -0,0 +1 @@ +Subproject commit 42fa4a1ea1b1b11d1cc0a60298e529d37f9d14bd diff --git a/zumo/lib/fastgpio-arduino b/zumo/lib/fastgpio-arduino new file mode 160000 index 0000000..5853c59 --- /dev/null +++ b/zumo/lib/fastgpio-arduino @@ -0,0 +1 @@ +Subproject commit 5853c593b07730e632127570279e7dea06de1af3 diff --git a/zumo/lib/pololu-buzzer-arduino b/zumo/lib/pololu-buzzer-arduino new file mode 160000 index 0000000..20ef7b7 --- /dev/null +++ b/zumo/lib/pololu-buzzer-arduino @@ -0,0 +1 @@ +Subproject commit 20ef7b734814a7c5e9f02f54a2cdd41729759d51 diff --git a/zumo/lib/pololu-hd44780-arduino b/zumo/lib/pololu-hd44780-arduino new file mode 160000 index 0000000..0a35789 --- /dev/null +++ b/zumo/lib/pololu-hd44780-arduino @@ -0,0 +1 @@ +Subproject commit 0a35789a58ca92ca6f69b63fbc269959b2d18584 diff --git a/zumo/lib/pololu-menu-arduino b/zumo/lib/pololu-menu-arduino new file mode 160000 index 0000000..8970b8d --- /dev/null +++ b/zumo/lib/pololu-menu-arduino @@ -0,0 +1 @@ +Subproject commit 8970b8db6e4e80b1c0e95172a87a35410bf593bf diff --git a/zumo/lib/pololu-oled-arduino b/zumo/lib/pololu-oled-arduino new file mode 160000 index 0000000..e6b83b6 --- /dev/null +++ b/zumo/lib/pololu-oled-arduino @@ -0,0 +1 @@ +Subproject commit e6b83b6c181962ffb98f99a4a4c3fd7cbf7e6707 diff --git a/zumo/lib/pushbutton-arduino b/zumo/lib/pushbutton-arduino new file mode 160000 index 0000000..442884e --- /dev/null +++ b/zumo/lib/pushbutton-arduino @@ -0,0 +1 @@ +Subproject commit 442884e004859ff550d5c0cae70033d7d568fc21 diff --git a/zumo/lib/usb-pause-arduino b/zumo/lib/usb-pause-arduino new file mode 160000 index 0000000..3f76e48 --- /dev/null +++ b/zumo/lib/usb-pause-arduino @@ -0,0 +1 @@ +Subproject commit 3f76e486460bb351f9738c86595f22db2da34c51 diff --git a/zumo/lib/zumo-32u4-arduino-library b/zumo/lib/zumo-32u4-arduino-library new file mode 160000 index 0000000..f4dfe05 --- /dev/null +++ b/zumo/lib/zumo-32u4-arduino-library @@ -0,0 +1 @@ +Subproject commit f4dfe054e23176ba445748b4b91f463701e7eb76 diff --git a/zumo/main.c b/zumo/main.c deleted file mode 100644 index ab66db4..0000000 --- a/zumo/main.c +++ /dev/null @@ -1,15 +0,0 @@ -#define F_CPU 16000000 - -#include -#include - -int main() { - DDRC |= (1 << DDC7); - while(1) { - PORTC |= (1 << PORTC7); - _delay_ms(500); - PORTC &= ~(1 << PORTC7); - _delay_ms(500); - } -} - diff --git a/zumo/main.cpp b/zumo/main.cpp new file mode 100644 index 0000000..23d13db --- /dev/null +++ b/zumo/main.cpp @@ -0,0 +1,13 @@ +#include +#include +#include + +void setup() { +} + +void loop() { + ledRed(1); + delay(1000); + ledRed(0); + delay(1000); +} diff --git a/zumo/makefile b/zumo/makefile index aac11f4..1a7ad36 100644 --- a/zumo/makefile +++ b/zumo/makefile @@ -1,10 +1,13 @@ PORT = /dev/ttyUSB0 +C++ = avr-g++ CC = avr-gcc LD = avr-ld RM = rm -f -MCU=atmega32u4 +MCU = atmega32u4 +TARGET = main +SRCS += main.cpp CFLAGS += -mcall-prologues CFLAGS += -mmcu=$(MCU) @@ -13,14 +16,20 @@ CFLAGS += -g CFLAGS += -Wl,-gc-sections CFLAGS += -Wl,-relax -TARGET = main -SRCS += main.c +include zumo.mk + OBJS := $(patsubst %.c,%.o, $(SRCS)) +OBJS := $(patsubst %.cpp,%.o, $(OBJS)) + +MAKEFLAGS += -j4 .PHONY: all clean flash all: $(TARGET).hex +%.o: %.cpp + $(C++) -c $(CFLAGS) $< -o $@ + %.o: %.c $(CC) -c $(CFLAGS) $< -o $@ diff --git a/zumo/zumo.mk b/zumo/zumo.mk new file mode 100644 index 0000000..9605cb7 --- /dev/null +++ b/zumo/zumo.mk @@ -0,0 +1,61 @@ +CFLAGS += -DF_CPU=16000000 +CFLAGS += -I./lib/zumo-32u4-arduino-library/src +CFLAGS += -I./lib/fastgpio-arduino +CFLAGS += -I./lib/pushbutton-arduino +CFLAGS += -I./lib/usb-pause-arduino +CFLAGS += -I./lib/pololu-buzzer-arduino/src +CFLAGS += -I./lib/pololu-hd44780-arduino +CFLAGS += -I./lib/pololu-menu-arduino/src +CFLAGS += -I./lib/pololu-oled-arduino/src +CFLAGS += -I./lib/ArduinoCore-avr/cores/arduino +CFLAGS += -I./lib/ArduinoCore-avr/libraries/HID/src +CFLAGS += -I./lib/ArduinoCore-avr/libraries/SoftwareSerial/src +CFLAGS += -I./lib/ArduinoCore-avr/libraries/SPI/src +CFLAGS += -I./lib/ArduinoCore-avr/libraries/EEPROM/src +CFLAGS += -I./lib/ArduinoCore-avr/libraries/Wire/src +CFLAGS += -I./lib/ArduinoCore-avr/variants/circuitplay32u4 + +LIBS += lib/ArduinoCore-avr/libraries/HID/src/HID.cpp \ + lib/ArduinoCore-avr/libraries/SoftwareSerial/src/SoftwareSerial.cpp \ + lib/ArduinoCore-avr/libraries/SPI/src/SPI.cpp \ + lib/ArduinoCore-avr/libraries/Wire/src/Wire.cpp \ + lib/ArduinoCore-avr/cores/arduino/HardwareSerial1.cpp \ + lib/ArduinoCore-avr/cores/arduino/HardwareSerial0.cpp \ + lib/ArduinoCore-avr/cores/arduino/WString.cpp \ + lib/ArduinoCore-avr/cores/arduino/PluggableUSB.cpp \ + lib/ArduinoCore-avr/cores/arduino/WMath.cpp \ + lib/ArduinoCore-avr/cores/arduino/IPAddress.cpp \ + lib/ArduinoCore-avr/cores/arduino/abi.cpp \ + lib/ArduinoCore-avr/cores/arduino/HardwareSerial.cpp \ + lib/ArduinoCore-avr/cores/arduino/CDC.cpp \ + lib/ArduinoCore-avr/cores/arduino/new.cpp \ + lib/ArduinoCore-avr/cores/arduino/Stream.cpp \ + lib/ArduinoCore-avr/cores/arduino/HardwareSerial2.cpp \ + lib/ArduinoCore-avr/cores/arduino/Print.cpp \ + lib/ArduinoCore-avr/cores/arduino/main.cpp \ + lib/ArduinoCore-avr/cores/arduino/HardwareSerial3.cpp \ + lib/pololu-buzzer-arduino/src/PololuBuzzer.cpp \ + lib/pushbutton-arduino/Pushbutton.cpp \ + lib/zumo-32u4-arduino-library/src/QTRSensors.cpp \ + lib/zumo-32u4-arduino-library/src/Zumo32U4IRPulses.cpp \ + lib/zumo-32u4-arduino-library/src/Zumo32U4Encoders.cpp \ + lib/zumo-32u4-arduino-library/src/Zumo32U4IMU.cpp \ + lib/zumo-32u4-arduino-library/src/Zumo32U4Motors.cpp \ + lib/zumo-32u4-arduino-library/src/Zumo32U4ProximitySensors.cpp \ + lib/usb-pause-arduino/USBPause.cpp \ + lib/pololu-hd44780-arduino/PololuHD44780.cpp \ + lib/fastgpio-arduino/FastGPIO.cpp \ + lib/pololu-oled-arduino/src/font.cpp +# lib/ArduinoCore-avr/cores/arduino/Tone.cpp +# lib/ArduinoCore-avr/libraries/Wire/src/utility/twi.c + +LIBS += lib/ArduinoCore-avr/cores/arduino/WInterrupts.c \ + lib/ArduinoCore-avr/cores/arduino/hooks.c \ + lib/ArduinoCore-avr/cores/arduino/wiring_shift.c \ + lib/ArduinoCore-avr/cores/arduino/wiring_digital.c \ + lib/ArduinoCore-avr/cores/arduino/wiring_analog.c \ + lib/ArduinoCore-avr/cores/arduino/wiring_pulse.c \ + lib/ArduinoCore-avr/cores/arduino/wiring.c + +SRCS += $(LIBS) + -- cgit v1.2.3