Mod Library
Sun Devil Rocketry's hardware agnostic utility library
Loading...
Searching...
No Matches
error_sdr.h
Go to the documentation of this file.
1
20
21
22/* Define to prevent recursive inclusion -------------------------------------*/
23#ifndef ERROR_SDR_H
24#define ERROR_SDR_H
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*------------------------------------------------------------------------------
31 Includes
32------------------------------------------------------------------------------*/
33#include <string.h>
34#include <stdbool.h>
35
36/*------------------------------------------------------------------------------
37 Constants
38------------------------------------------------------------------------------*/
39#define TEXT_MESSAGE_LENGTH 36
40
41#ifndef F1_TESTBED
42#define Error_Handler( a ) error_fail_fast( a ) /* backwards compatible */
43#endif
44
45/*------------------------------------------------------------------------------
46 Typdefs
47------------------------------------------------------------------------------*/
48
49/* Error codes */
50typedef enum _ERROR_CODE
51 {
52 ERROR_UNKNOWN_FATAL_ERROR , /* An unknown error occurred */
53 ERROR_FLASH_INIT_ERROR , /* Flash initialization error */
54 ERROR_BARO_INIT_ERROR , /* Baro initialization error */
55 ERROR_IMU_INIT_ERROR , /* IMU initialization error */
56 ERROR_DATA_LOG_LOAD_HEADER_ERROR , /* Error loading flash header */
57 ERROR_DATA_LOG_CORRECT_HEADER_ERROR, /* Error correcting flash header */
58 ERROR_DATA_LOG_PREP_MEM_ERROR , /* Error eraseing flight memory */
59 ERROR_CAL_GROUND_ALT_ERROR , /* Error calibratiing the ground alt */
60 ERROR_TERMINAL_ERROR , /* Error from terminal command */
61 ERROR_FSM_STATE_ERROR , /* State transition error */
62 ERROR_DUAL_DEPLOY_EXTRACT_ERROR , /* Dual deploy extract data failed */
63 ERROR_RECORD_FLIGHT_EVENTS_ERROR , /* Error recording flight evetns */
64 ERROR_SYSCLOCK_CONFIG_ERROR , /* Error configuring the sysclock */
65 ERROR_COMMON_CLOCK_CONFIG_ERROR , /* Error configuring shared clocks */
66 ERROR_IMU_I2C_INIT_ERROR , /* Error initializing IMU I2C bus */
67 ERROR_BARO_I2C_INIT_ERROR , /* Error initializing the baro I2C */
68 ERROR_FLASH_SPI_INIT_ERROR , /* Error initializing the flash SPI */
69 ERROR_USB_UART_INIT_ERROR , /* Error initializing the USB UART */
70 ERROR_BUZZER_TIM_INIT_ERROR , /* Error initializing the buzzer TIM */
71 ERROR_MICRO_TIM_INIT_ERROR , /* Error initializing the micro TIM */
72 ERROR_I2C_HAL_MSP_ERROR , /* Error in I2C HAL MSP */
73 ERROR_SPI_HAL_MSP_ERROR , /* Error in SPI HAL MSP */
74 ERROR_UART_HAL_MSP_ERROR , /* Error in UART HAL MSP */
75 ERROR_RF_ERROR , /* RF tx/rx error */
76 ERROR_RF_UNRECOGNIZED_PING , /* RF ping byte incorrect */
77 ERROR_USB_UART_ERROR , /* General UART USB I/O error */
78 ERROR_XBEE_UART_CONFIG_ERROR , /* Error initializing XBee UART */
79 ERROR_RF_UART_INIT_ERROR , /* Error initializing wireless UART */
80 ERROR_UNSUPPORTED_OP_ERROR , /* Unimplimented feature error */
81 ERROR_THERMO_INIT_ERROR , /* Error initializaing thermocouple */
82 ERROR_PT_ADC_INIT_ERROR , /* Error initializing PT ADC */
83 ERROR_LC_ADC_INIT_ERROR , /* Error initializing LC ADC */
84 ERROR_THERMO_I2C_INIT_ERROR , /* Error initializing TC I2C */
85 ERROR_VALVE_UART_INIT_ERROR , /* Error initializing Valve UART */
86 ERROR_IGN_CMD_ERROR , /* Error executing ignition command */
87 ERROR_FLASH_CMD_ERROR , /* Error executing flash command */
88 ERROR_SENSOR_CMD_ERROR , /* Error executing sensor command */
89 ERROR_SERVO_CMD_ERROR , /* Error executing servo command */
90 ERROR_VALVE_CMD_ERROR , /* Error executing valve command */
91 ERROR_BARO_CAL_ERROR , /* Error calibrating ground pressure */
92 ERROR_DATA_HAZARD_ERROR , /* Potential data corruption error */
93 ERROR_FSM_INVALID_STATE_ERROR , /* Invalid state variable value */
94 ERROR_VC_OFFLINE_ERROR , /* Can't connect to valve controller */
95 ERROR_VC_INIT_ERROR , /* Error initializing main valves */
96 ERROR_PING_TIMEOUT_ERROR , /* Ping Timeout */
97 ERROR_RS485_UART_INIT_ERROR , /* Error initializing RS485 UART */
98 ERROR_RS485_UART_ERROR , /* Error during RS485 transmission */
99 ERROR_SOL_CMD_ERROR , /* Error passing on solenoid command */
100 ERROR_PT_ADC_CHANNEL_ERROR , /* Error switching adc channel */
101 ERROR_FSM_INVALID_STATE_TRANSITION_ERROR, /* Error changing state */
102 ERROR_GPS_UART4_INITIALIZATION , /* Error initializing UART for GPS */
103 ERROR_GPS_UART4_DEMSP , /* Error initializing DEMSP UART for GPS */
104 ERROR_PWM4_ERROR , /* Error with PWM timer 4 */
105 ERROR_PWM123_ERROR , /* Error with PWM timer 1,2,3 */
106 ERROR_SERVO_INIT_ERROR , /* Error initializing servos */
107 ERROR_SENSOR_FORMAT_ERROR , /* unused */
108 ERROR_INVALID_STATE_ERROR , /* FSM has reached an invalid state */
109 ERROR_CONFIG_VALIDITY_ERROR , /* Loaded configuration is invalid */
110 ERROR_USB_CDC_INIT_ERROR , /* Error initializing USB CDC device */
111 ERROR_IGNITION_CONTINUITY_ERROR , /* No continuity on IGN terminals */
112 ERROR_LORA_SPI_INIT_ERROR , /* Error with LoRa SPI init */
113 ERROR_LORA_INIT_ERROR , /* Error with LoRa init */
114 ERROR_LORA_CMD_ERROR , /* Error with LoRa command */
115 ERROR_IMU_I2C_ERROR , /* Error with IMU I2C handle */
116 ERROR_BARO_I2C_ERROR , /* Error with Baro I2C handle */
117 } ERROR_CODE;
118
119/* Error callback table entry */
120typedef struct _ERROR_CALLBACK {
121 volatile ERROR_CODE error_code;
122 void (*error_callback)(ERROR_CODE);
123} ERROR_CALLBACK;
124
125typedef struct TEXT_MESSAGE
126 {
127 uint32_t systick;
128 char message[TEXT_MESSAGE_LENGTH];
129 } TEXT_MESSAGE;
130
131/*------------------------------------------------------------------------------
132 Macros & Inlines
133------------------------------------------------------------------------------*/
134
140#define assert_fail_fast( condition, error ) do { if ( !(condition) ) error_fail_fast( error ); } while(0)
141
142
148#define assert_return( condition, retval ) do { if ( !(condition) ) return retval; } while(0)
149
150
151/*------------------------------------------------------------------------------
152 Function Prototypes
153------------------------------------------------------------------------------*/
154
161 (
162 volatile ERROR_CODE error_code
163 );
164
165#ifdef __cplusplus
166}
167#endif
168#endif /* ERROR_SDR_H */
169
170/*******************************************************************************
171 * END OF FILE *
172 *******************************************************************************/
void error_fail_fast(volatile ERROR_CODE error_code)
Dispatches an error to its registered callback or default handler.
Definition error_sdr.c:104
Definition error_sdr.h:120
Definition error_sdr.h:126