Build and upload tool (arduino-build.sh): - Compile, upload, and monitor via arduino-cli - Device discovery with USB ID identification (--devices) - Persistent reconnecting serial monitor (--watch) - Split compile/upload workflow (--verify, --upload-only) - First-time setup wizard (--setup) - Comprehensive --help with troubleshooting and RedBoard specs Testable application architecture: - Hardware abstraction layer (lib/hal/) decouples logic from Arduino API - Google Mock HAL for unit tests (exact call verification) - Simulated HAL for system tests (GPIO state, virtual clock, I2C devices) - Example I2C temperature sensor simulator (TMP102) - Host-side test suite via CMake + Google Test (21 tests) Example sketch: - blink/ -- LED blink with button-controlled speed, wired through HAL
33 lines
810 B
C++
33 lines
810 B
C++
/*
|
|
* blink.ino -- LED blink with button-controlled speed
|
|
*
|
|
* This .ino file is just the entry point. All logic lives in
|
|
* BlinkApp (lib/app/blink_app.h) which depends on the HAL
|
|
* interface (lib/hal/hal.h), making it testable on the host.
|
|
*
|
|
* The build script auto-discovers lib/ subdirectories and passes
|
|
* them as --library flags to arduino-cli, so angle-bracket includes
|
|
* work for project-local libraries.
|
|
*
|
|
* Wiring:
|
|
* Pin 13 (LED_BUILTIN) -- onboard LED (no wiring needed)
|
|
* Pin 2 -- momentary button to GND (uses INPUT_PULLUP)
|
|
*
|
|
* Serial: 115200 baud
|
|
* Prints "FAST" or "SLOW" on button press.
|
|
*/
|
|
|
|
#include <hal_arduino.h>
|
|
#include <blink_app.h>
|
|
|
|
static ArduinoHal hw;
|
|
static BlinkApp app(&hw);
|
|
|
|
void setup() {
|
|
app.begin();
|
|
}
|
|
|
|
void loop() {
|
|
app.update();
|
|
}
|