// // Error: Provides a simple interface for asserting and checking errors // #include "error.h" #include "stm32f0xx_hal.h" #include volatile uint32_t err_reg; volatile uint8_t num_errors_asserted = 0; // Moderately detailed messages corresponding to each error enum char * error_message[] = { "GPS off", "GPS checksum", }; // Set the passed error flag void error_assert(uint8_t errno) { // Errno invalid: exceeds bit length of error register if(errno >= 32) return; // Set error flag err_reg |= (1<= 32) return; // Set error flag err_reg |= (1< 0; } // Return 1 if any error has occurred uint8_t error_occurred(void) { return err_reg > 0; } // Return the number of errors that have occurred uint8_t error_count(void) { return num_errors_asserted; } // vim:softtabstop=4 shiftwidth=4 expandtab