The FC (Flight Control) driver provides a complete interface to configure hardware fault inputs, program fault routing to interrupt/trigger/reset outputs, and consume the FC fault log stream.
The driver supports callback-based ISR notification, timing control for interrupt timeout and pulse widths, and runtime programming of association tables used for fault propagation.
Features:
- Fault input type and logging mask configuration
- Interrupt output timeout/mask/type configuration
- Fault association programming for interrupt, trigger, and reset outputs
- Trigger and reset pulse width configuration
- Fault log erase, count, indexed read, multi-read, and software-log injection
- ISR callback registration and dispatch
Configuration Considerations
Typical FC initialization and operation flow:
- Call fc_init for the target instance.
- Configure fault inputs through fc_config_fault.
- Configure interrupt outputs with fc_config_interrupt.
- Program fault routing maps via fc_set_fault_association.
- Program timing controls with fc_config_timing or helper APIs.
- Optionally register callback via fc_register_callback.
- Use log APIs to erase/read/inject and process interrupt events in fc_isr.
- Call fc_deinit when FC is no longer needed.
- Note
- Each association output has two 32-bit entries. Bit 0 in entry 0 maps fault ID 0, and bit 0 in entry 1 maps fault ID 32.
- Warning
- FC callbacks run in fc_isr caller context, usually ISR context. Keep callbacks short and nonblocking.
Usage Examples
Basic Initialization and Fault Configuration
fc_fault_config_t fault_cfg = {
.fault_id = 3,
.type = FC_FAULT_LEVEL,
.mask = false
};
fc_init(FC0);
fc_config_fault(FC0, &fault_cfg);
fc_set_interrupt_timeout(FC0, 100);
Read Retained Fault Logs
fc_log_entry_t logs[8];
uint16_t read_count = 0;
if (fc_read_logs(FC0, logs, 8, &read_count) == FC_OK) {
}