Initial public release of WII5 Buoy firmware
Firmware for an autonomous wave-measurement buoy (ATmega2560-based WII5 v2 board). Reads wave motion from a Sparton AHRS-M1/M2 IMU, samples GPS and battery state, and reports back over Iridium SBD satellite telemetry. Originally developed 2012-2024. This is the first public release. Code, documentation, and field-tested operating modes (Capture, Sleep, Position, ManualTest, SelfTest, LowBattery) are licensed under Apache 2.0 — see LICENSE and NOTICE. See README.md for an overview and build instructions, CONTRIBUTING.md for how to contribute, and DEPLOYMENTS.md for the field-deployment log.
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright (c) 2012-2024 Scott Penrose <scottp@dd.com.au> and WII5 Buoy contributors
|
||||
//
|
||||
// This file is part of WII5 Buoy firmware.
|
||||
// See LICENSE for full terms.
|
||||
|
||||
/**
|
||||
* @file WII5ModeSelfTest.h
|
||||
* @brief Self test mode: automated boot-time hardware checks.
|
||||
*/
|
||||
|
||||
#ifndef WII5ModeSelfTest_h
|
||||
#define WII5ModeSelfTest_h
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <WII5.h>
|
||||
#include <TimeLib.h>
|
||||
|
||||
enum WII5SELFTEST_STEPS {
|
||||
WII5ST_START,
|
||||
WII5ST_SHUTDOWN, // Shutdown the existing bits
|
||||
WII5ST_INFORMATION, // What do we know, our ID, our run count etc
|
||||
WII5ST_LED,
|
||||
WII5ST_BUZZER,
|
||||
WII5ST_BUTTON,
|
||||
WII5ST_CONFIG, // Check we can read and write config
|
||||
WII5ST_GPS_RECEIVE, // Turn on GPS and receive some NMEA
|
||||
WII5ST_GPS_OFF, // Turn off, and check GPS is ok
|
||||
WII5ST_SD0, // Make sure SD are both turned off
|
||||
WII5ST_SD1, // Open SD1, write a file with unique id/datetime
|
||||
WII5ST_SD2, // Open SD2 and write a new file
|
||||
WII5ST_SD1_B, // Check the SD1 data is there
|
||||
WII5ST_SD2_B, // Check the SD2 data is there
|
||||
WII5ST_SD_OFF, // Shut it down
|
||||
WII5ST_IRIDIUM, // Turn on Iridium and wait for some responses
|
||||
WII5ST_BATTERY_1, // Check battery 1 has volts and doesn't jitter too much
|
||||
WII5ST_BATTERY_2, // If it exists
|
||||
WII5ST_WEATHER, // Do we get some temperatures
|
||||
WII5ST_MATHS_START, // Turn it on ! and make sure we get response
|
||||
WII5ST_MATHS_OFF, // Turn it off, and make sure it is off
|
||||
WII5ST_5VOLT_START, // Turn it on ! and make sure we get response
|
||||
WII5ST_5VOLT_OFF, // Turn it off, and make sure it is off
|
||||
WII5ST_RTC, // Do we have one, what version, what details
|
||||
WII5ST_SPARTON, // Turn it on, get some values, tun it off
|
||||
WII5ST_REPORT, // Report what happened
|
||||
};
|
||||
|
||||
enum WII5SELFTEST_MODE {
|
||||
WII5SM_DEFAULT, // Run from AVR CPU (while running), Maths not running, but tested
|
||||
WII5SM_FROMMATHS, // Test being run by the Maths CPU, therefore can't play maths
|
||||
WII5SM_NOMATHS, // Simple test, no maths installed, user entered variables
|
||||
};
|
||||
|
||||
#define WII5ST_MAX 25
|
||||
|
||||
/**
|
||||
* @brief Self test mode: automated hardware checkout.
|
||||
*
|
||||
* Walks every subsystem once (LED, buzzer, button, config, GPS, SD x2,
|
||||
* Iridium, batteries, weather, Maths CPU, 5V rail, RTC, Sparton) and
|
||||
* records pass/fail in `results[]`. Three submodes:
|
||||
* - WII5SM_DEFAULT: AVR-driven, expects an attached operator
|
||||
* - WII5SM_FROMMATHS: invoked by the Maths CPU; skips Maths checks
|
||||
* - WII5SM_NOMATHS: simple check, no Maths CPU present
|
||||
*/
|
||||
class WII5ModeSelfTest : public WII5Mode {
|
||||
public:
|
||||
WII5ModeSelfTest() {}
|
||||
/** @brief Reset to WII5ST_START. */
|
||||
void reset();
|
||||
/** @brief One-time bring-up. */
|
||||
void begin();
|
||||
/** @brief Run the next test step (called repeatedly while active). */
|
||||
void loop();
|
||||
/** @brief Print the results table; `toOther` optionally mirrors elsewhere. */
|
||||
void dump(bool toConsole = true, Print* toOther = NULL, bool hideNone = false);
|
||||
/** @brief Current self-test submode. */
|
||||
WII5SELFTEST_MODE getMode();
|
||||
/** @brief Select self-test submode. */
|
||||
void setMode(WII5SELFTEST_MODE m);
|
||||
|
||||
protected:
|
||||
WII5SELFTEST_MODE mode;
|
||||
elapsedMillis wait;
|
||||
WII5SELFTEST_STEPS step;
|
||||
WII5SELFTEST_STEPS stepLast;
|
||||
elapsedMillis stepWait;
|
||||
uint32_t stepCount; // Use for what ever you like
|
||||
bool first;
|
||||
|
||||
uint16_t count;
|
||||
uint16_t count_passed;
|
||||
uint16_t count_failed;
|
||||
uint16_t count_nonenc;
|
||||
|
||||
WII5SELFTEST_STATUS results[WII5STD_DEVICES];
|
||||
};
|
||||
|
||||
extern WII5ModeSelfTest wii5ModeSelfTest;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user