#include <state_manager.h>
Classes | |
| struct | State |
Public Types | |
| enum | : uint16_t { ERROR_NONE = 0x0000, ERROR_INVALID_MIXER = 0x0001, ERROR_IMU_NOT_RESPONDING = 0x0002, ERROR_RC_LOST = 0x0004, ERROR_UNHEALTHY_ESTIMATOR = 0x0008, ERROR_TIME_GOING_BACKWARDS = 0x0010, ERROR_UNCALIBRATED_IMU = 0x0020 } |
| enum | Event { EVENT_INITIALIZED, EVENT_REQUEST_ARM, EVENT_REQUEST_DISARM, EVENT_RC_LOST, EVENT_RC_FOUND, EVENT_ERROR, EVENT_NO_ERROR, EVENT_CALIBRATION_COMPLETE, EVENT_CALIBRATION_FAILED } |
Public Member Functions | |
| struct | __attribute__ ((packed)) BackupData |
| Stores backup data for restoring the system state after a hard fault. More... | |
| void | check_backup_memory () |
| void | clear_error (uint16_t error) |
| void | init () |
| void | run () |
| void | set_error (uint16_t error) |
| void | set_event (Event event) |
| const State & | state () const |
| StateManager (ROSflight &parent) | |
| void | write_backup_data (const BackupData::DebugInfo &debug) |
| Write recovery data to backup memory in the case of a hard fault. More... | |
Private Types | |
| enum | FsmState { FSM_STATE_INIT, FSM_STATE_PREFLIGHT, FSM_STATE_ARMED, FSM_STATE_ERROR, FSM_STATE_FAILSAFE, FSM_STATE_CALIBRATING } |
Private Member Functions | |
| void | process_errors () |
| void | update_leds () |
Private Attributes | |
| FsmState | fsm_state_ |
| uint32_t | hardfault_count_ = 0 |
| uint32_t | next_arming_error_msg_ms_ = 0 |
| uint32_t | next_led_blink_ms_ = 0 |
| ROSflight & | RF_ |
| State | state_ |
Definition at line 44 of file state_manager.h.
| anonymous enum : uint16_t |
| Enumerator | |
|---|---|
| ERROR_NONE | |
| ERROR_INVALID_MIXER | |
| ERROR_IMU_NOT_RESPONDING | |
| ERROR_RC_LOST | |
| ERROR_UNHEALTHY_ESTIMATOR | |
| ERROR_TIME_GOING_BACKWARDS | |
| ERROR_UNCALIBRATED_IMU | |
Definition at line 68 of file state_manager.h.
| Enumerator | |
|---|---|
| EVENT_INITIALIZED | |
| EVENT_REQUEST_ARM | |
| EVENT_REQUEST_DISARM | |
| EVENT_RC_LOST | |
| EVENT_RC_FOUND | |
| EVENT_ERROR | |
| EVENT_NO_ERROR | |
| EVENT_CALIBRATION_COMPLETE | |
| EVENT_CALIBRATION_FAILED | |
Definition at line 55 of file state_manager.h.
|
private |
| Enumerator | |
|---|---|
| FSM_STATE_INIT | |
| FSM_STATE_PREFLIGHT | |
| FSM_STATE_ARMED | |
| FSM_STATE_ERROR | |
| FSM_STATE_FAILSAFE | |
| FSM_STATE_CALIBRATING | |
Definition at line 170 of file state_manager.h.
| rosflight_firmware::StateManager::StateManager | ( | ROSflight & | parent | ) |
Definition at line 38 of file state_manager.cpp.
|
inline |
Stores backup data for restoring the system state after a hard fault.
Also stores debugging information to be sent over serial after the connection is restored.
< magic number to ensure we only arm on startup if we really intended to
< number of hard faults since normal system startup
< state manager error codes
< set to ARM_MAGIC if the system was armed when the hard fault occured, 0 otherwise
Low-level debugging information for case of hard fault
It is up to the board support layer to populate this data
< register 0
< register 1
< register 2
< register 3
< register 12
< link register
< program counter
< program status register
< checksum for data in the struct, must be the last member
Computes checksum and prepares struct to be written to backup memory
Checks whether the checksum of a struct read from backup memory is valid
Definition at line 85 of file state_manager.h.
| void rosflight_firmware::StateManager::check_backup_memory | ( | ) |
Definition at line 285 of file state_manager.cpp.
| void rosflight_firmware::StateManager::clear_error | ( | uint16_t | error | ) |
Definition at line 75 of file state_manager.cpp.
| void rosflight_firmware::StateManager::init | ( | ) |
Definition at line 46 of file state_manager.cpp.
|
private |
Definition at line 322 of file state_manager.cpp.
| void rosflight_firmware::StateManager::run | ( | void | ) |
Definition at line 57 of file state_manager.cpp.
| void rosflight_firmware::StateManager::set_error | ( | uint16_t | error | ) |
Definition at line 66 of file state_manager.cpp.
| void rosflight_firmware::StateManager::set_event | ( | StateManager::Event | event | ) |
Definition at line 91 of file state_manager.cpp.
|
inline |
Definition at line 140 of file state_manager.h.
|
private |
Definition at line 330 of file state_manager.cpp.
| void rosflight_firmware::StateManager::write_backup_data | ( | const BackupData::DebugInfo & | debug | ) |
Write recovery data to backup memory in the case of a hard fault.
This function should only be called by the hardfault interrupt handler
| debug | Low-level debugging data populated by the hardfault handler |
Definition at line 273 of file state_manager.cpp.
|
private |
Definition at line 180 of file state_manager.h.
|
private |
Definition at line 168 of file state_manager.h.
|
private |
Definition at line 166 of file state_manager.h.
|
private |
Definition at line 165 of file state_manager.h.
|
private |
Definition at line 162 of file state_manager.h.
|
private |
Definition at line 163 of file state_manager.h.