@@ -32,12 +32,12 @@ extern "C"
3232#define ADC1_BRAKE_INPUT_PIN GPIO_PIN_4
3333#define ADC1_BRAKE_INPUT_PORT GPIOC
3434
35- #define ADC1_BRAKE_PRESSURE_1_CHANNEL ADC_CHANNEL_0 /* PA0 - Brake Pressure Sensor 1 */
36- #define ADC1_BRAKE_PRESSURE_1_PIN GPIO_PIN_0
35+ #define ADC1_BRAKE_PRESSURE_1_CHANNEL ADC_CHANNEL_1 /* PA1 - Brake Pressure Sensor 1 (BP1) */
36+ #define ADC1_BRAKE_PRESSURE_1_PIN GPIO_PIN_1
3737#define ADC1_BRAKE_PRESSURE_1_PORT GPIOA
3838
39- #define ADC1_BRAKE_PRESSURE_2_CHANNEL ADC_CHANNEL_1 /* PA1 - Brake Pressure Sensor 2 */
40- #define ADC1_BRAKE_PRESSURE_2_PIN GPIO_PIN_1
39+ #define ADC1_BRAKE_PRESSURE_2_CHANNEL ADC_CHANNEL_0 /* PA0 - Brake Pressure Sensor 2 (BP2) */
40+ #define ADC1_BRAKE_PRESSURE_2_PIN GPIO_PIN_0
4141#define ADC1_BRAKE_PRESSURE_2_PORT GPIOA
4242
4343/* -------------------------------------------------------------------------- */
@@ -58,11 +58,11 @@ extern "C"
5858/* -------------------------------------------------------------------------- */
5959/* ADC3 CHANNELS */
6060/* -------------------------------------------------------------------------- */
61- #define ADC3_BSPD_INDICATOR_CHANNEL ADC_CHANNEL_8 /* PC0 - BSPD Indicator */
61+ #define ADC3_BSPD_INDICATOR_CHANNEL ADC_CHANNEL_10 /* PC0 - BSPD Indicator (ADC123_IN10) */
6262#define ADC3_BSPD_INDICATOR_PIN GPIO_PIN_0
6363#define ADC3_BSPD_INDICATOR_PORT GPIOC
6464
65- #define ADC3_BSPD_RESET_CHANNEL ADC_CHANNEL_9 /* PC1 - BSPD Reset Signal */
65+ #define ADC3_BSPD_RESET_CHANNEL ADC_CHANNEL_11 /* PC1 - BSPD Reset Signal (ADC123_IN11) */
6666#define ADC3_BSPD_RESET_PIN GPIO_PIN_1
6767#define ADC3_BSPD_RESET_PORT GPIOC
6868
@@ -130,25 +130,22 @@ extern "C"
130130/* These are DEFAULTS only - actual values are stored in calibration structs */
131131
132132/* Single-APPS mode is now a runtime flag (FEB_APPS_SingleSensorMode in FEB_ADC.c).
133- * Default at boot is OFF — dual-sensor plausibility enforced (FSAE EV.5.3 ).
133+ * Default at boot is OFF — dual-sensor plausibility enforced (FSAE T.4.2.2 ).
134134 * Toggle for bench testing only via PCU|apps|mode|single|<on|off> while not in
135135 * drive state. */
136136
137137/* Accelerator Pedal Calibration (APPS) - per-car values, post-divider
138138 * (sensor-side) mV: the domain FEB_ADC maps against (APPS1 = ADC pin x1.168,
139- * APPS2 = pin x1.0; see VOLTAGE_DIVIDER_RATIO_ACCEL* in FEB_ADC.c).
140- * Bench estimate 2026-05-28 from a pedal sweep (APPS1 pin 1.16-2.06V,
141- * APPS2 pin 0.40-1.03V); CONFIRM on-car via PCU|apps|raw / PCU|apps|cal|capture
142- * before driving. Asymmetric APPS1 vs APPS2 ranges are expected and preserve
143- * FSAE EV.5.3 transfer-function diversity. */
144- #define APPS1_DEFAULT_MIN_VOLTAGE_MV 1450 /* APPS1 0% throttle (est.; verify per-car) */
145- #define APPS1_DEFAULT_MAX_VOLTAGE_MV 2330 /* APPS1 100% throttle (est.; verify per-car) */
146- #define APPS2_DEFAULT_MIN_VOLTAGE_MV 555 /* APPS2 0% throttle (est.; verify per-car) */
147- #define APPS2_DEFAULT_MAX_VOLTAGE_MV 1150 /* APPS2 100% throttle (est.; verify per-car) */
139+ * APPS2 = pin x1.0; see VOLTAGE_DIVIDER_RATIO_ACCEL* in FEB_ADC.c). */
140+ #define APPS1_DEFAULT_MIN_VOLTAGE_MV 1360 /* APPS1 0% throttle */
141+ #define APPS1_DEFAULT_MAX_VOLTAGE_MV 2200 /* APPS1 100% throttle */
142+ #define APPS2_DEFAULT_MIN_VOLTAGE_MV 450 /* APPS2 0% throttle */
143+ #define APPS2_DEFAULT_MAX_VOLTAGE_MV 940 /* APPS2 100% throttle */
148144#define APPS_MIN_PHYSICAL_PERCENT 0.0f /* Physical minimum: 0% throttle */
149145#define APPS_MAX_PHYSICAL_PERCENT 100.0f /* Physical maximum: 100% throttle */
150146#define APPS_DEADZONE_PERCENT 5 /* Deadzone at pedal extremes (%) */
151147#define APPS_PLAUSIBILITY_TOLERANCE 10 /* Maximum deviation between sensors (%) */
148+
152149/* FSAE T.4.2.3: the two APPS use different transfer functions, so their RAW
153150 * pin-domain outputs (raw/ADC_MAX_VALUE*100) stay >=~23% apart across the pedal
154151 * range on SN5. If the two signal lines short together that designed separation
@@ -161,14 +158,14 @@ extern "C"
161158/* Brake Pressure Sensor Default Calibration — per-sensor, sensor-side mV
162159 * (i.e. before the 5V->3.3V PCB divider; FEB_ADC_GetBrakePressureNVoltage()
163160 * already multiplies by VOLTAGE_DIVIDER_RATIO_BRAKE to give sensor-side V). */
164- #define BRAKE_PRESSURE_1_MIN_MV 545 /* Sensor 1 @ 0% brake: 0.545 V sensor-side (5/3.3 divider) */
165- #define BRAKE_PRESSURE_1_MAX_MV 2363 /* Sensor 1 @ 100% brake: 2.363 V sensor-side (5/3.3 divider) */
166- #define BRAKE_PRESSURE_2_MIN_MV 480 /* Sensor 2 @ 0% brake: 0.480 V sensor-side (5/3.3 divider) */
167- #define BRAKE_PRESSURE_2_MAX_MV 1844 /* Sensor 2 @ 100% brake: 1.844 V sensor-side (5/3.3 divider) */
168- #define BRAKE_PRESSURE_MIN_PHYSICAL_BAR 0.0f /* Physical minimum: 0 bar */
169- #define BRAKE_PRESSURE_MAX_PHYSICAL_BAR 200.0f /* Physical maximum: 200 bar */
170- #define BRAKE_PRESSURE_THRESHOLD_BAR 5 /* Brake activation threshold */
171- #define BRAKE_PRESSURE_THRESHOLD_PERCENT 2.5f /* Brake activation threshold in percent */
161+ #define BRAKE_PRESSURE_1_MIN_MV 465 /* Sensor 1 @ 0% brake: */
162+ #define BRAKE_PRESSURE_1_MAX_MV 1130 /* Sensor 1 @ 100% brake: */
163+ #define BRAKE_PRESSURE_2_MIN_MV 555 /* Sensor 2 @ 0% brake: */
164+ #define BRAKE_PRESSURE_2_MAX_MV 1455 /* Sensor 2 @ 100% brake: */
165+ #define BRAKE_PRESSURE_MIN_PHYSICAL_BAR 0.0f /* Physical minimum: 0 bar */
166+ #define BRAKE_PRESSURE_MAX_PHYSICAL_BAR 200.0f /* Physical maximum: 200 bar */
167+ #define BRAKE_PRESSURE_THRESHOLD_BAR 5 /* Brake activation threshold */
168+ #define BRAKE_PRESSURE_THRESHOLD_PERCENT 2.5f /* Brake activation threshold in percent */
172169#define BRAKE_PRESSURE_PLAUSIBILITY_TOLERANCE_PERCENT 20.0f /* Max disagreement between brake pressure sensors */
173170#define BRAKE_PRESSED_POSITION_PERCENT 10.0f /* Brake "pressed" when combined position exceeds this */
174171
@@ -190,14 +187,38 @@ extern "C"
190187/* ========================================================================== */
191188
192189/* FSAE Rules Compliance */
193- #define APPS_IMPLAUSIBILITY_TIME_MS 100 /* Time before APPS implausibility fault */
194- #define BRAKE_PLAUSIBILITY_TIME_MS 100 /* Time before brake plausibility fault */
195- #define APPS_SHORT_CIRCUIT_DETECT_MV 100 /* Voltage below this indicates short (both sensors) */
196- /* Per-sensor open-circuit thresholds: each must sit above the sensor's valid
197- * max (2406 mV for APPS1, 1030 mV for APPS2) and below the post-divider ADC
198- * ceiling (~3854 mV for APPS1, ~3300 mV for APPS2 with no divider). */
199- #define APPS1_OPEN_CIRCUIT_DETECT_MV 3500 /* APPS1 above this indicates open */
200- #define APPS2_OPEN_CIRCUIT_DETECT_MV 1500 /* APPS2 above this indicates open */
190+ #define APPS_IMPLAUSIBILITY_TIME_MS 100 /* T.4.2.4: APPS >10% disagreement must persist >100ms to fault */
191+ #define BRAKE_PLAUSIBILITY_TIME_MS 100 /* T.4.3.4: BSE sensor open/short must persist >100ms to fault */
192+ /* EV.4.7 (brakes engaged + APPS >25%) must stop motor power IMMEDIATELY — the
193+ * 100 ms grace above does NOT apply to it (that is T.4.2.4 / T.4.3.4 only). Use
194+ * a short noise-rejection debounce so a single noisy frame can't false-trip. */
195+ #define EV47_PLAUSIBILITY_DEBOUNCE_MS 10 /* EV.4.7 brake+throttle debounce (effectively immediate) */
196+ #define APPS_RELEASE_PERCENT 5.0f /* EV.4.7.2.b / T.4.2.4 release: APPS travel below this clears the latch */
197+
198+ /* APPS short/open detection (T.4.2.10/.11/.13): a sensor has "failed" when its
199+ * post-divider voltage is outside its normal operating range. Thresholds are
200+ * PER-SENSOR — the two ranges differ, and APPS2's 0% sits at ~0.40 V (below the
201+ * rule's generic <0.5 V example), so a single global floor cannot be used.
202+ * Floors sit below each valid min, ceilings above each valid max, both with
203+ * margin and inside the recoverable range (APPS1 ceiling 3.3V*1.168=3854mV,
204+ * APPS2 3300mV). High-side over-range can't make phantom torque because the
205+ * torque command uses MIN(APPS1,APPS2). RE-VERIFY after every recalibration so
206+ * the margins still clear filter ripple at 0% and 100% pedal. */
207+ #define APPS1_SHORT_CIRCUIT_DETECT_MV 1000 /* APPS1 below this = short/under-range */
208+ #define APPS2_SHORT_CIRCUIT_DETECT_MV 250 /* APPS2 below this = short/under-range */
209+ #define APPS1_OPEN_CIRCUIT_DETECT_MV 2800 /* APPS1 above this = open/over-range */
210+ #define APPS2_OPEN_CIRCUIT_DETECT_MV 1300 /* APPS2 above this = open/over-range */
211+
212+ /* BSE (brake) open/short detection (T.4.3.4/.5): per-sensor, sensor-side mV
213+ * (post 5V->3.3V divider; recoverable ceiling ~5000 mV). Floors catch a short-
214+ * to-ground or a lost shared 5 V supply (both sensors read ~0 V — the dangerous
215+ * "looks like no brake" case); ceilings catch a short to 5 V. Open-circuit
216+ * detectability REQUIRES a pull resistor on each brake line (confirm in HW).
217+ * RE-VERIFY against the brake sensors' real 0%/100% voltages. */
218+ #define BRAKE_PRESSURE_1_UNDER_MV 350 /* Brake P1 below this = short/lost supply */
219+ #define BRAKE_PRESSURE_1_OVER_MV 4600 /* Brake P1 above this = open/short-to-5V */
220+ #define BRAKE_PRESSURE_2_UNDER_MV 300 /* Brake P2 below this = short/lost supply */
221+ #define BRAKE_PRESSURE_2_OVER_MV 4600 /* Brake P2 above this = open/short-to-5V */
201222
202223/* Brake Over Travel Protection (BOTS) */
203224#define BOTS_ACTIVATION_PERCENT 25 /* Brake travel % that triggers BOTS */
0 commit comments