mirror of
https://gitlvb.teallvbs.xyz/IQ.Lvbs/IQ.Pilot.git
synced 2026-08-24 05:43:42 +08:00
37 lines
1.0 KiB
C
37 lines
1.0 KiB
C
#pragma once
|
|
|
|
#define HARNESS_STATUS_NC 0U
|
|
#define HARNESS_STATUS_NORMAL 1U
|
|
#define HARNESS_STATUS_FLIPPED 2U
|
|
|
|
// orientation sampling runs in thread context and shares this state with
|
|
// interrupt handlers, so the fields are volatile
|
|
struct harness_t {
|
|
volatile uint8_t status;
|
|
volatile uint16_t sbu1_voltage_mV;
|
|
volatile uint16_t sbu2_voltage_mV;
|
|
volatile bool ignition_line;
|
|
volatile bool relay_driven;
|
|
volatile bool sbu_adc_lock;
|
|
};
|
|
extern struct harness_t harness;
|
|
|
|
struct harness_configuration {
|
|
GPIO_TypeDef * const GPIO_SBU1;
|
|
GPIO_TypeDef * const GPIO_SBU2;
|
|
GPIO_TypeDef * const GPIO_relay_SBU1;
|
|
GPIO_TypeDef * const GPIO_relay_SBU2;
|
|
const uint8_t pin_SBU1;
|
|
const uint8_t pin_SBU2;
|
|
const uint8_t pin_relay_SBU1;
|
|
const uint8_t pin_relay_SBU2;
|
|
const adc_signal_t adc_signal_SBU1;
|
|
const adc_signal_t adc_signal_SBU2;
|
|
};
|
|
|
|
// The ignition relay is only used for testing purposes
|
|
void set_intercept_relay(bool intercept, bool ignition_relay);
|
|
bool harness_check_ignition(void);
|
|
void harness_tick(void);
|
|
void harness_init(void);
|