Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
84ff3b9
Added new git branch
Ethan-Caracoglia Sep 30, 2024
213a367
Checking if commits work
Ethan-Caracoglia Sep 30, 2024
363a9c8
Ready for testing
Ethan-Caracoglia Oct 10, 2024
e2d66d2
Ready for CAN, just need it to be implemented on f4
Ethan-Caracoglia Oct 19, 2024
d115e6b
Ready for CAN, just need it to be implemented on f4
Ethan-Caracoglia Nov 5, 2024
a85fdce
added vs folder
Ethan-Caracoglia Nov 8, 2024
cc93622
Saving work with the brake until we are ready to implement it
Ethan-Caracoglia Dec 3, 2024
545394c
Should probably work now :)
Ethan-Caracoglia Dec 3, 2024
f070a6f
Working on fixes for the payload transference
Ethan-Caracoglia Jan 28, 2025
a9c7932
Need to change HIB for new ADCs
Ethan-Caracoglia Feb 7, 2025
f05b0e1
Getting things up to date
Ethan-Caracoglia Mar 12, 2025
1cd87cb
Hopefully this works
Ethan-Caracoglia Mar 31, 2025
e7d3808
ADS8689IPWR driver created, needs to be tested and verified
Ethan-Caracoglia Apr 14, 2025
bb1e415
Merge remote-tracking branch 'origin/ErrorCheckingAndPosition' into E…
Ethan-Caracoglia Apr 14, 2025
9782656
This is broken but I need to move the code
Ethan-Caracoglia Apr 22, 2025
e6f7b45
Almost done changing margin errors to a static voltage difference
Ethan-Caracoglia Apr 22, 2025
40714d9
Hopefully a fully function driver with a few interface pins missing
Ethan-Caracoglia Apr 23, 2025
464b4ea
CAN it do it? Yes it CAN!
Ethan-Caracoglia Apr 23, 2025
f4d830b
It CAN now go even faster
Ethan-Caracoglia Apr 23, 2025
d03b6fe
Attempted to fix the read issue on the ADCs
Ethan-Caracoglia May 2, 2025
404a142
Really not sure how to fix this issue
Ethan-Caracoglia May 2, 2025
122c140
I tried to prevent int overflow but that did not solve the problem
Ethan-Caracoglia May 2, 2025
4ab2d07
Beginning to change statements to logger
Ethan-Caracoglia Aug 20, 2025
00411da
Update for Oleg
Ethan-Caracoglia Sep 15, 2025
b0cdaa7
Altered Clang-Format path in the cmake file
Ethan-Caracoglia Nov 1, 2025
61d82a6
Altered Clang-Format path in the cmake file
Ethan-Caracoglia Nov 3, 2025
9b0b110
Apply suggestions from code review
Ethan-Caracoglia Nov 7, 2025
127cef7
Saving progress on dependecy refactor
Ethan-Caracoglia Jan 17, 2026
436f26c
Refactored a good deal of the code and altered the dependencies so no…
Ethan-Caracoglia Jan 24, 2026
c9adcbe
Fixed the macro and include errors for size_t
Ethan-Caracoglia Jan 24, 2026
eeecdf7
Attempting to fix build error by only building f446
Ethan-Caracoglia Jan 25, 2026
8233985
Changed the EVT-core branch back to main
Ethan-Caracoglia Jan 25, 2026
6ca79d4
Took main() out of hib namespace to avoid missing main reference
Ethan-Caracoglia Jan 25, 2026
904e7ab
Sorrowful attempt to fix IWDG compilation error
Ethan-Caracoglia Jan 25, 2026
12477c9
Sorrowful attempt to fix IWDG and timer compilation error
Ethan-Caracoglia Jan 25, 2026
80af261
Errasign timer sample
Ethan-Caracoglia Jan 25, 2026
a8be383
Fully erasing timer
Ethan-Caracoglia Jan 25, 2026
e793e35
Trying to get the build to work by converting the build back to norma…
Ethan-Caracoglia Jan 25, 2026
546606c
Reverting last change
Ethan-Caracoglia Jan 25, 2026
346257a
Chained EVT-core target
Ethan-Caracoglia Jan 25, 2026
416220c
Merge remote-tracking branch 'origin/ErrorCheckingAndPosition' into E…
Ethan-Caracoglia Jan 26, 2026
3121aa5
Updated github workflow and main to read out can connect result
Ethan-Caracoglia Jan 26, 2026
67a4416
Removed all samples to fix compile errors
Ethan-Caracoglia Jan 26, 2026
c8d49dd
Fixed namespace errors faulting on main()
Ethan-Caracoglia Jan 26, 2026
e3b4f32
Messed around with clang-format issue
Ethan-Caracoglia Jan 26, 2026
f407ffb
Applied Formatting Changes During GitHub Build
Jan 26, 2026
cc5b0a5
Ready to push (I am aware that the GPIO checking for the various Star…
Ethan-Caracoglia Feb 24, 2026
f4d4296
Applied Formatting Changes During GitHub Build
Feb 24, 2026
79d6375
Added Brake error information to the UART logging section just in cas…
Ethan-Caracoglia Feb 24, 2026
5f2d57d
Merge remote-tracking branch 'origin/ErrorCheckingAndPosition' into E…
Ethan-Caracoglia Feb 24, 2026
8346b11
Created a basic self-test target to test all of the non-ADC inputs an…
Ethan-Caracoglia Apr 4, 2026
13c6ec7
FWT-20: Basic self-test setup code added.
Ethan-Caracoglia Apr 18, 2026
a30239b
Fixed an issue with leftover code taht was not updated with the pinMa…
Ethan-Caracoglia Apr 18, 2026
d3378f5
Hopefully fixed error with pinMap incorrectly being inititialized wit…
Ethan-Caracoglia Apr 18, 2026
a57c301
Applied Formatting Changes During GitHub Build
Apr 18, 2026
5143170
Small fix to forcefully push this build
Ethan-Caracoglia Apr 20, 2026
5b9378c
Applied Formatting Changes During GitHub Build
Apr 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,17 @@ jobs:
ref: ${{ github.event.pull_request.head.ref }}
submodules: recursive

# Install the gcc-arm tools and clang-format, and ensure clang-format 12 is being used
# Install the gcc-arm tools and clang-format, and ensure clang-format 15 is being used
- name: Install Compiler and Linter
run: |
sudo apt-get install gcc-arm-none-eabi
sudo apt-get install clang-format-12
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-12 10000
sudo apt-get install clang-format-15
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 10000

# Build the code for all supported chips
- name: F302 Build
- name: Project Build
run: |
cmake -DTARGET_DEV=STM32F302x8 -B ${{github.workspace}}/build
cmake --build ${{github.workspace}}/build

- name: F334 Build
run: |
cmake -DTARGET_DEV=STM32F334x8 -B ${{github.workspace}}/build
cmake -B ${{github.workspace}}/build
cmake --build ${{github.workspace}}/build

# Apply clang-format formatting to the branch and create a new commit if any files are changed
Expand Down
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ if(EVT_CORE_LOG_ENABLE)
endif()

# Handle selection of the target device
option(TARGET_DEV "Target device" "STM32F334x8")
option(TARGET_DEV "Target device" "STM32F446xx")
if(NOT TARGET_DEV)
set(TARGET_DEV "STM32F334x8")
set(TARGET_DEV "STM32F446xx")
endif()

if(TARGET_DEV STREQUAL "STM32F302x8")
Expand All @@ -22,6 +22,9 @@ if(TARGET_DEV STREQUAL "STM32F302x8")
elseif(TARGET_DEV STREQUAL "STM32F334x8")
add_compile_definitions(STM32F334x8)
add_compile_definitions(STM32F3xx)
elseif(TARGET_DEV STREQUAL "STM32F446xx")
add_compile_definitions(STM32F446xx)
add_compile_definitions(STM32F4xx)
else()
message(FATAL_ERROR "The target device is not supported")
endif()
Expand Down Expand Up @@ -57,12 +60,18 @@ project(${BOARD_LIB_NAME}
LANGUAGES CXX C
)

add_library(${PROJECT_NAME} STATIC)
add_library(${PROJECT_NAME} STATIC
include/dev/ADS8689IPWR.hpp
include/dev/RedundantADC.hpp
include/HIB.hpp
targets/self_test/main.cpp
)

# Add sources
target_sources(${PROJECT_NAME} PRIVATE
src/HIB.cpp
src/dev/RedundantADC.cpp
src/dev/ADS8689IPWR.cpp
)

###############################################################################
Expand Down
15 changes: 15 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@ Contains notable changes there were added, fixed, or removed in each release.
* Build Board source as a library
* Template to build arbitrary number of targets
* Auto-generating documentation template

## 0.2.0

### Changes

* ADS8689IPWR driver created and implemented
* RedundantADC driver created and implemented
* HIB driver created and implemented
* Updated README.md
* Created targets for HIB, RedundantADC testing, and ADS88689IPWR testing
* Improved dependency order
* Verified ADC results
* Added error checking for ADCs
* Added logger statements for easier debugging
* Documentation added for each class as well as each target
196 changes: 192 additions & 4 deletions include/HIB.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,201 @@
#pragma once
#ifndef HIB_
#define HIB_

#include "core/io/types/CANMessage.hpp"
#include <cstddef>
#include <dev/RedundantADC.hpp>

namespace io = core::io;

namespace HIB {
/**
* Id of the message being sent from the HIB
*/
#define HIB_MESSAGE_ID 0xD0

/**
* Deadzone for the ADCs so they do not send a signal before the throttle is twisted
*/
#define VOLTAGE_DEADZONE 475

/**
* Start Switch Pin
*/
#define START io::Pin::PB_1

/**
* Throttle Switch Pin
*/
#define THROTTLE_SWITCH io::Pin::PB_2

/**
* Forward Enable Pins
*/
#define FORWARD_ENABLE_1 io::Pin::PB_4
#define FORWARD_ENABLE_2 io::Pin::PB_5
#define FORWARD_ENABLE_3 io::Pin::PB_6

/**
* Short circuit checking pins that should remain high unless there is a short
*/
#define NSHORT_1 io::Pin::PA_0
#define NSHORT_2 io::Pin::PA_1

/**
* Open circuit checking pins that should remain high unless the circuit is open
*/
#define NOPEN_1 io::Pin::PA_8
#define NOPEN_2 io::Pin::PA_9

/**
* Self test DAC output pins
*/
#define DAC_OUT_1 io::Pin::PA_4
#define DAC_OUT_2 io::Pin::PA_5

/**
* Enable pins for each self test loop
*/
#define SELF_TEST_ENABLE_1 io::Pin::PA_6
#define SELF_TEST_ENABLE_2 io::Pin::PA_7

/**
* HIB header file
* JTAG serial wire pins
*/
#define SWDIO io::Pin::PA_13 // Serial wire debug input/output
#define SWO io::Pin::PB_3 // Serial wire output
#define SWDCLK io::Pin::PA_14// Serial wire clock

/**
* ADC reset pins
*/
#define ADC_1_NRST io::Pin::PA_15
#define ADC_2_NRST io::Pin::PB_0

/**
* Debug LED pins
*/
#define DEBUG_LED_1 io::Pin::PC_6
#define DEBUG_LED_2 io::Pin::PC_13

/**
* Throttle ADC ready pins
*/
#define THROTTLE_RVS0 io::Pin::PC_3
#define THROTTLE_RVS1 io::Pin::PC_4
#define THROTTLE_RVS2 io::Pin::PC_5

/**
* Brake ADC ready pins
*/
#define BRAKE_RVS0 io::Pin::PC_0
#define BRAKE_RVS1 io::Pin::PC_1
#define BRAKE_RVS2 io::Pin::PC_2

constexpr size_t payloadLength = 6;

typedef struct {
io::GPIO* throttleSwitch = nullptr;
io::GPIO* start = nullptr;
io::GPIO* forwardEnable1 = nullptr;
io::GPIO* forwardEnable2 = nullptr;
io::GPIO* forwardEnable3 = nullptr;
io::GPIO* nshort1 = nullptr;
io::GPIO* nshort2 = nullptr;
io::GPIO* nopen1 = nullptr;
io::GPIO* nopen2 = nullptr;
io::GPIO* throttleRvs0 = nullptr;
io::GPIO* throttleRvs1 = nullptr;
io::GPIO* throttleRvs2 = nullptr;
io::GPIO* brakeRvs0 = nullptr;
io::GPIO* brakeRvs1 = nullptr;
io::GPIO* brakeRvs2 = nullptr;
io::GPIO* debugLed1 = nullptr;
io::GPIO* debugLed2 = nullptr;
io::GPIO* swdio = nullptr;
io::GPIO* swo = nullptr;
io::GPIO* swdclk = nullptr;
io::GPIO* adcNrst1 = nullptr;
io::GPIO* adcNrst2 = nullptr;
io::GPIO* dacOut1 = nullptr;
io::GPIO* dacOut2 = nullptr;
io::GPIO* selfTestEnable1 = nullptr;
io::GPIO* selfTestEnable2 = nullptr;
} HibPinMap;

/**
* The Handlebar Interface Board Takes in a 0.0 to 12.0 volt signal from the throttle and brake
* which it then converts to a 16 bit value through its "double-triple" ADC setup. It then sends
* this voltage value along with any error codes that were generated to the Vehicle Control Unit
* (VCU).
*
* It reads in the voltage from either the throttle or the brake through one set of three ADCs
* that communicate with the microcontroller using SPI. After the controller sets up the devices
* they are read in and then averaged and contrasted with the average to find any margin errors.
*
* The data after being correctly parsed and checked for errors is then sent through CAN to the
* VCU for decision-making.
*/
class HIB {
public:
HIB(RedundantADC& throttle, RedundantADC& brake, HibPinMap pinMap);

HIB(RedundantADC& throttle, RedundantADC& brake);

/**
* Reads the voltages and errors from the redundant ADCs and returns a can message containing
* the data from each read
* @return The can message that should be transmitted
*/
io::CANMessage process();

/**
* Payload for CAN message transmission.
* Byte 0: MSB for Throttle Voltage
* Byte 1: LSB for Throttle Voltage
* Byte 2: MSB for Brake Voltage
* Byte 3: LSB for Brake Voltage
* Byte 4: Error Byte for Throttle
* Byte 5: Error Byte for Brake
* Error Byte Layout: 0: No Error, 1: Precision Error, 2: Margin Error, 3: Comparison Error
*/
struct {
uint8_t throttleVoltageMSB = 0;
uint8_t throttleVoltageLSB = 0;
uint8_t brakeVoltageMSB = 0;
uint8_t brakeVoltageLSB = 0;
uint8_t throttleError = 0;
uint8_t brakeError = 0;
} hibPayload;

HibPinMap pinMap;

private:
};
/**
* Reads the 0V-12V signal coming from the throttle potentiometer
*/
void readThrottleVoltage();

/**
* Do nothing because there is no brake setup yet
*/
void readBrakeVoltage();

RedundantADC& throttle;
RedundantADC& brake;

}// namespace HIB
uint16_t throttleVoltage = 0;
uint16_t brakeVoltage = 0;

// Counters for throttle errors
uint32_t acceptableThrottleMarginErrors = 0;
uint32_t precisionThrottleMarginErrors = 0;
uint32_t comparisonThrottleErrors = 0;

// Counters for brake errors
uint32_t acceptableBrakeMarginErrors = 0;
uint32_t precisionBrakeMarginErrors = 0;
uint32_t comparisonBrakeErrors = 0;
};
}// namespace HIB
#endif
Loading