Cleaned up switch statement. Also put in early returns where possible - #272
Merged
Merged
Conversation
Member
|
Thanks! |
Agwld
added a commit
that referenced
this pull request
Sep 12, 2026
* Feat: Add New VCU IOC file * feat/add-new-IO-functions * feat: add useful pin labels to important pins * Update VCU.ioc with new stag12 config for digital io * I/O fixes Added input inversion, ensured RTDS is active high. made inputs in trc.c and dash.c use new bsp functions * rename RTD_DRIVE to R2D_DRIVE in the .ioc * Fix some other IOC issues (missing ThreadX and changed the HAL timer source to TIM6) and reran code generation * Rename GREEN_LED (heartbeat) usages to ROB_LED and comment out undefined DRS_LED * Use ROB_LED alias rather than direct gpio pin, and flash every 200ms to make it obvious something is wrong * use uart8 instead of uart1 (todo: also mirror debug output over USART1->RS232) * Configure adcs for apps and bps * Add missing files to makefile -> build now works! * remove unused adc_reading to fix warning * GPIO fixes: wheelspeed inputs (3/4 were defined as outputs instead of inputs) and SPARE_OUT_3 was also set as an input * Simplify weird comparison for VCU_Input_Read * log over both UART and USART (debug header + rs232) * fix all compilation warnings (except those from middlewares) * Realised we never configure SCS channels in the config (used to be one ADC per SCS), so now is dynamically changed based on the config * Update CAN baud rate to 1Mbit/s * disable SD card temporarily * add rs232 logic * update Makefile * use gdb-multiarch to support new arm installations when debugging on vscode * Fix RS232 by switching UART8 RX/TX * Sample 144 times rather than every 3 times for every SCS signal/ADC reading * add CAN error logging * enable CAN NVIC interrupts * Enable auto-bus off recovery * Switch to rtcan rewrite branch * Log errors on CAN TX failure * Rename CAN-C to CAN-T, pin can-defs to stag-12 branch * Update APPS calib values * Update can-defs to stag-12 layout with updated cantools output * Allow RS232 transciever to auto power off * Fix/add some missing broadcast states * Update to latest can-defs * Update apps logging to do everything in 1 line so that readings don't get cut * Fix apps multiplier (off by factor of 10) * Lots and lots of rtcan related fixes * Update apps calib thresholds * Add wheelspeed can-defs, config and implementation * Update rs232 header attribution * Update log levels for apps.c -- use a warn log level on discrepancy and info otherwise to avoid spamming SD card with info * Move SUFST middlewares from src/Middlewares/SUFST to src/SUFST/Middlewares so that they're not rewritten on every CubeMX regeneration * Add newlines to bps.c logging * Add SD implementation (included both FileX and USBX middlewares, USB will be required later) * Get USB passthrough working * Actually increment the rolling counter field * Add value table for VCU_CTRL_State * Switch PM100 direction to forwards mode lol (the inverter is the correct way around this year) * Remove duplicate pm100 call/break * Add PDM ECU to CAN-T * Update wheelspeed ticks/wheel and circumference * Reset apps_bps_start on TS_ON * Add Vector CANoe workspace + control panel + Ignore .cbf files generated by CANoe * Update ctrl.c to use functions per switch statement rather than one massive switch with inlined logic * update can-defs * Switch CAN-S and CAN-T (sigh) * Move PDM from CAN-S to CAN-T * Add VCU_Sensors_Raw message * Configure RTDS pin as digital output, not PWM timer * Add inverted option (enabled) to APPS config for when potentiometer is flipped in pedal * Add implementation of raw APPS/BPS signals CAN message for debugging * Rename BPS_ADC to BPS_F_ADC, and re-configure bps code to use BPS_R_ADC * Temporarily switch BPS to use SAGL ADC due to PCB opamp issues, and update bps calibration values * Update BPS threshold to 10% (from 4%), calibrate pedals, and move VCU messages from CAN-S to CAN-T * Update CANoe workspace * Try and fix VCU crashing upon CAN bus error * add filters to rtcan * Increase queue sizes for RTCAN and the inverter * Change BPS log levels * Update calib values * Don't enter Error_Handler() on any CAN errors * Update CAN-T baud rate to 500kbps, enable AutoRetransmission on both channels and change JumpWidth to 2TQ * Switch SAGL and BPS back over * APPS and BPS calib again * Add rtcan_s_h to canbc so we can broadcast states on both buses * Split canbc to use CAN-S for non critical sensors * Add SAGL implementation * Don't clamp raw ADC value for APPS and BPS * Update CANoe workspace * Fix apps inversion issue when at 0% throttle by applying it earlier * Update BPS threshold warning log level to INFO * Fix broken error message in pm100.c (missing index) * Add fans implementation (subscribing to sensor hub fan switch message to trigger power) * Allow inverting fan switch * Switch BPS log threshold back to DEBUG * Add slightly redundant (but useful for debugging) inversion conversion for apps1 on top of apps2 * More calibration * Re-enable dynamic fan control while keeping override, and turn on pumps with override too * Add configurable hard max torque and config stubs for future modes implementation * Update BPS thresh from 40 to 80 and max torque to 100nm * Fix temperature conversions (was 10x too small for fan threshold) * Delete backup makefile * Move breaklight threshold into config.c (instead of hardcoded #define) -- the simulation threshold is still hardcoded in remote_ctrl.c * Fix vscode settings for error handling * Fix torque map percentage (off by a factor of 10), update CAN TQ and JW, reduce deadzone from 28 to 15% and calibrate some bits * Update CANoe workspace * Disable software BSPD, don't turn off inverter in TS fault * Add current+requested mode enum and can defs * Only sample SAGL (and other ext_inputs, currently just SAGL soon to be mode switch) at 10Hz not 100Hz * Implement mode switch ADC -> requested mode, Implement modes (except torque control) * Add brakelight debounce * Reset VCU after flash * Switch to only 10 modes (switch was configured differently than the schematic) * Fixes * Update APPS max discrepancy to 9.5% (2x bigger than before) * Disable R2D requires brake for dyno testing * Update priorities and thread names and logging levels for Fans + Wheelspeeds + SD logging (wheelspeed + SD had the same priority and wheelspeeds are definetly more important than the SD logs) * Massively simplify remote control logic to just do a simple torque request * Fix torque map to use dynamically set max output * Add remote ctrl mode * Add CANoe workspace generator for remote control * Actually send errors (latching rtcan errors) in the messages that were designed for them * Allow exiting TS_Run_Fault via TS_Off * Clear R2D led after fault * Update CANoe workspace * Flip R2D led states (inverted due to loom/vcu pcb buffers) * Don't enter a TS fault on APPS failure (just SCS fault) so it can auto resume if it fixes itself * Clear SCS error on success * Update CANoe workspace * Update can-defs to latest commit * More calibration * Use brakelight as threshold check for BPS due to noise * fixes * elec scrut complete * FSUK 2026 endurance fixes * Drop wheelspeed priority below logging * drop discrepancy configs for apps * Update makefile to production builds (-DCOMPETITION_MODE), fine because debugger will flash with DEBUG=1 using vscode launch configuration * Update CANoe workspace * Merge reliability fixes from claude-fixes * Improve interface for setting max output torque * Up torque limit for remote ctrl to 230 Nm * Flip motor direction * Switch to exponential torque map * Strip out speed limiting * Add configurable (powf) exponent to the exponential torque map * Update README and setup script * Add clang-format command for src/SUFST and run it * Up discrepancies for testing * pre fsg apps cal Updated ADC min and max values for apps_1_scs and apps_2_scs based on new measurements. * Add comment on apps_bps_high_threshold * Run trunk fmt * Fix trunk issues * Update CANoe workspace to include individual BMS values * Add trunk CI action * fsg scrut changes * Sketchy theories * Update IOC for DMA * unsafe but functional for testing * DMA ADC attempts * Strip out ext inputs sample divider (doesn't do anything) * fix: disabled reverse & change crawl to 150Nm * fix: change torque + disable brake implausibility check * fix: final endurance config changes * Some resets for testing * Reformat * Update IOC for DMA * DMA ADC attempts * Strip out ext inputs sample divider (doesn't do anything) * fix: disabled reverse & change crawl to 150Nm * fix: change torque + disable brake implausibility check * fix: final endurance config changes * Some resets for testing * Reformat * Update setup script * Update fan threshold * Fix trunk issues * Tidy up/refactor a lot of things * torque limiting implementations for wheel slip and power using PI controller * Switch SAGL and current sensor around (woops) * Convert vcu-setup-script to unix line endings and make readme show clone command for current branch * Update submodules to use main version (merged on remote) * Update docs! * Update state machine docs * Fix trunk issues * Cleaned up switch statement. Also put in early returns where possible (#272) Update torque_map.c * Ignore missing venv on github runner * Change setup script to link to main --------- Co-authored-by: r-kirkbride <r_kirkbride@outlook.com> Co-authored-by: Adam Eastman <eastman.adam1@gmail.com> Co-authored-by: espitt <ethan.spittles@outlook.com> Co-authored-by: sghillie <shaungilmore2255@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.