Added boot diagnostics

This commit is contained in:
Mark Qvist 2021-12-26 11:27:32 +01:00
parent af794fc882
commit b319e2b0e8
3 changed files with 50 additions and 9 deletions

View file

@ -7,6 +7,13 @@
#include "Framing.h"
#include "MD5.h"
uint8_t boot_vector = 0x00;
uint8_t OPTIBOOT_MCUSR __attribute__ ((section(".noinit")));
void resetFlagsInit(void) __attribute__ ((naked)) __attribute__ ((used)) __attribute__ ((section (".init0")));
void resetFlagsInit(void) {
__asm__ __volatile__ ("sts %0, r2\n" : "=m" (OPTIBOOT_MCUSR) :);
}
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
@ -28,6 +35,17 @@ void led_indicate_error(int cycles) {
digitalWrite(pin_led_tx, LOW);
}
void led_indicate_boot_error() {
while (true) {
led_tx_on();
led_rx_off();
delay(10);
led_rx_on();
led_tx_off();
delay(5);
}
}
void led_indicate_warning(int cycles) {
bool forever = (cycles == 0) ? true : false;
cycles = forever ? 1 : cycles;