This commit is contained in:
2023-12-26 16:55:02 -05:00
commit 71329d5484
32 changed files with 1248 additions and 0 deletions

2
Firmware/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.pio
.vscode

46
Firmware/Makefile Normal file
View File

@@ -0,0 +1,46 @@
# A very simple makefile full of shortcuts
# What port the arduino is on
ifndef SERIAL_DEV
ifneq (,$(wildcard /dev/ttyUSB0))
SERIAL_DEV = /dev/ttyUSB0
else ifneq (,$(wildcard /dev/ttyACM0))
SERIAL_DEV = /dev/ttyACM0
else
SERIAL_DEV = unknown
endif
endif
.PHONY: help
help: ## Prints this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
build: ## Invokes pio run
pio run
# For CI
binaries: ## Builds the binaries
pio run
pio run -t .pio/build/uno328/firmware.hex
flash: ## Flashes the code to the processor
pio run -t upload
deep: ## Flashes the code to processor with fresh EEPROM values
pio run -t uploadeep
clean: ## Cleans the repo of artefacts
pio run -t clean
git clean -fdx
lint: ## De-lints the repo
pio check
test: ## Run automated tests
pio test --upload-port $(SERIAL_DEV)
debug: flash monitor ## Flashes then Monitors
monitor: ## Monitors the device serial
pio device monitor --filter=direct --filter=time

76
Firmware/build_flags.py Normal file
View File

@@ -0,0 +1,76 @@
import logging
import subprocess
from datetime import date
today = date.today()
try:
revision = (
subprocess.check_output(
[
"git",
"describe",
"--abbrev=8",
"--dirty",
"--always",
"--tags",
]
)
.strip()
.decode("utf-8")
)
print(f"-D REVISION='\"{revision}\"'")
except Exception as e:
logging.warning("Getting git revision failed!! Check that you have git installed?")
logging.warning(e)
print("-D REVISION='Unknown'")
try:
host = (
subprocess.check_output(
[
"hostname",
]
)
.strip()
.decode("utf-8")
)
print(f"-D FWHOST='\"{host}\"'")
except Exception as e:
logging.warning("Getting host failed!! Are you using a UNIX compatible system?")
logging.warning(e)
print("-D FWHOST='Unknown'")
try:
username = (
subprocess.check_output(
[
"id",
"-u",
"-n",
]
)
.strip()
.decode("utf-8")
)
# Cleanup CI
if username == "root":
username = "git"
host = "git"
print(f"-D USERNAME='\"{username}\"'")
except Exception as e:
logging.warning("Getting host failed!! Are you using a UNIX compatible system?")
logging.warning(e)
print("-D USERNAME='Unknown'")
# Print to enable debugging
# print("-D DEBUG")

View File

@@ -0,0 +1,7 @@
#ifndef _BOARD_PINS_H
#define _BOARD_PINS_H
// LEDs
#define STAT_LED 13
#endif

1
Firmware/lib/README.md Normal file
View File

@@ -0,0 +1 @@
PIO stores lib data in here, you can create lib folders with objects inside.

23
Firmware/platformio.ini Normal file
View File

@@ -0,0 +1,23 @@
; PlatformIO Project Configuration File
[env:ATmega328P]
platform = atmelavr ; Platform to build for
board = ATmega328P ; Supported board
framework = arduino ; What framework we're using
board_build.mcu = atmega328p ; Microcontroller
board_build.f_cpu = 16000000L ; Frequency
build_flags = !python build_flags.py ; Build flags before we push
check_tool = clangtidy ; De-linter
check_flags =
clangtidy: --fix --checks=abseil,boost,bugprone,cert,cppcoreguidelines,clang-analyzer,google,hicpp,modernize,performance,portability,readability,cppcoreguidelines-avoid-magic-numbers,fuchsia-statically-constructed-objects,cert-err58-cpp,cppcoreguidelines-avoid-non-const-global-variables,cppcoreguidelines-macro-usage
lib_deps = ; External libraries
SPI
# Monitor Settings
monitor_speed = 115200
monitor_rts = 0
monitor_dtr = 0

31
Firmware/src/main.cpp Normal file
View File

@@ -0,0 +1,31 @@
/**
* @file main.cpp
* @author Joe
* @brief Source code for InstrumentVisor
*/
// Libs
#include <Arduino.h>
// Headers
#include "boardPins.h"
void setup()
{
// Setup serial
delay(200);
Serial.begin(115200);
Serial.println(REVISION);
// Pins
pinMode(STAT_LED, OUTPUT);
}
void loop()
{
// Flash LED
digitalWrite(STAT_LED, HIGH);
delay(1000);
digitalWrite(STAT_LED, LOW);
delay(1000);
}

11
Firmware/test/README Normal file
View File

@@ -0,0 +1,11 @@
This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html