56 lines
1.4 KiB
Makefile
56 lines
1.4 KiB
Makefile
|
# Makefile for Arduino project
|
||
|
|
||
|
# Detect OS
|
||
|
ifeq ($(OS),Windows_NT)
|
||
|
ARDUINO_CLI := arduino-cli.exe
|
||
|
RM := del /Q
|
||
|
PORT ?= COM20
|
||
|
else
|
||
|
ARDUINO_CLI := arduino-cli
|
||
|
RM := rm -f
|
||
|
PORT ?= /dev/ttyACM0
|
||
|
endif
|
||
|
|
||
|
# Arduino CLI configuration
|
||
|
BOARD ?= arduino:avr:nano:cpu=atmega328old
|
||
|
SKETCH := apply_stimulation/apply_stimulation.ino
|
||
|
|
||
|
# Python configuration
|
||
|
PYTHON := python
|
||
|
|
||
|
# Targets
|
||
|
.PHONY: all generate compile upload clean
|
||
|
|
||
|
all: generate compile upload
|
||
|
|
||
|
generate:
|
||
|
$(PYTHON) gen_stimulat.py
|
||
|
|
||
|
compile:
|
||
|
$(ARDUINO_CLI) compile --fqbn $(BOARD) $(SKETCH)
|
||
|
|
||
|
upload:
|
||
|
$(ARDUINO_CLI) upload -p $(PORT) --fqbn $(BOARD) $(SKETCH)
|
||
|
|
||
|
clean:
|
||
|
$(RM) apply_stimulation/build
|
||
|
$(RM) stimulation_pattern.h
|
||
|
|
||
|
# Help target
|
||
|
help:
|
||
|
@echo "Available targets:"
|
||
|
@echo " all - Generate pattern, compile and upload the sketch"
|
||
|
@echo " generate - Generate the stimulation pattern"
|
||
|
@echo " compile - Compile the sketch"
|
||
|
@echo " upload - Upload the compiled sketch to the Arduino"
|
||
|
@echo " clean - Remove build files and generated pattern"
|
||
|
@echo " help - Display this help message"
|
||
|
@echo ""
|
||
|
@echo "You can specify the Arduino port and board using the PORT and BOARD variables:"
|
||
|
@echo " make upload PORT=COM20 BOARD=arduino:avr:nano:cpu=atmega328old"
|
||
|
@echo ""
|
||
|
@echo "Default board is set to Arduino Nano with old bootloader (atmega328old)"
|
||
|
|
||
|
# Default target
|
||
|
.DEFAULT_GOAL := help
|