Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
df74f46
Update Cube++ to latest commit
MacKante Oct 30, 2024
adfc050
added base implentation of GPIO task
MacKante Nov 1, 2024
a1abdd3
fixed CUBE_PRINT for gpio pin states
MacKante Nov 1, 2024
7501d69
modified CUBE_PRINT of GPIO status
MacKante Nov 1, 2024
3ddb0ff
Added base functionality for driver control
MacKante Nov 3, 2024
0ff967f
fixed IO expander debug message
MacKante Nov 3, 2024
7dc0967
added namespaces for IO expander pin names
MacKante Nov 4, 2024
9d26284
completed io expander drivers
MacKante Nov 6, 2024
4c62218
Heinz/spi task (#7)
MacKante Nov 9, 2024
1111089
refactoring code, added getter functions for IOExpander last read/write
MacKante Nov 9, 2024
e694adf
added base code for CAN Tx Task
MacKante Nov 17, 2024
db58935
reformating code
MacKante Nov 23, 2024
ef5d2b0
feat: set DLC and command Free Data()
Heinzino Nov 23, 2024
deb6101
feat: Free Data on Command
Heinzino Nov 23, 2024
d318224
feat: globalize SPI pedal reading for CAN task
Heinzino Nov 23, 2024
614cea2
feat: GPIO CAN data formatted
Heinzino Nov 30, 2024
bc06652
feat: Driver_Base with SPI Task formatted
Heinzino Nov 30, 2024
bd7d734
fix: LightsInput follows Communication Protocol
Heinzino Jan 16, 2025
30fdbc4
fix: Digital Inputs formatted to Helio Communication Board
Heinzino Jan 16, 2025
04aaf29
fix: Analog Inputs follows Communication Excel
Heinzino Jan 16, 2025
3bdca0d
fix: Lights Status so that it follows Communication standard
Heinzino Jan 16, 2025
7b012a0
fix: powerBoard State get Expander State Now size
Heinzino Jan 16, 2025
e26405e
feat: Add CAN_TX_FREQ delays based on communication standard
Heinzino Jan 16, 2025
af33026
chore: Formatting for PR
Heinzino Jan 16, 2025
bf399f9
feat: Update Debug Task with new CanTX commands for testing
Heinzino Jan 16, 2025
3fb475c
feat: Send CAN TX Messages at intervals with counter tick in GPIO Task
Heinzino Jan 18, 2025
56048af
fix: counterTick not global
Heinzino Jan 18, 2025
c0f17b7
fix: Function signature of checkCounterTick
Heinzino Jan 18, 2025
dceebbf
fix: counterTick to be a field and not a static variable
Heinzino Jan 18, 2025
89705e3
fix: Change to send DATA_COMMAND
Heinzino Jan 18, 2025
0f20d42
fix: u16_t type , driverControl State on active Low, bit masking on 9…
Heinzino Jan 23, 2025
143f5d6
fix: Forward Neutral Reverse L follows binary encoding
Heinzino Jan 30, 2025
1a89e68
send all CAN TX commands
Heinzino Feb 6, 2025
75e6417
feat: Add heartbeat to TX commands
Heinzino Feb 22, 2025
38e9dd2
feat: CanTX setup
Heinzino Feb 22, 2025
5a64e0f
fix: CanTX with proper folder for mergability
Heinzino Mar 22, 2025
2a2e950
fix: Remove zoom zoom flag from Digital Inputs
Heinzino May 3, 2025
c393cff
fixing git submodule error
MacKante May 9, 2025
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
4 changes: 2 additions & 2 deletions .settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="985175499654131366" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1088525663691497890" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="985173715110890335" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1088528351958295163" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
5 changes: 3 additions & 2 deletions .settings/stm32cubeide.project.prefs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2F62501ED4689FB349E356AB974DBE57=2CE54FD71E149B997073596C6B0E9512
635E684B79701B039C64EA45C3F84D30=06D51718D4F3D877E4CF008AE59E16BB
66BE74F758C12D739921AEA421D593D3=2
8DF89ED150041C4CBC7CB9A9CAA90856=05328855C4E51ECDCD46876FE3491C71
DC22A860405A8BF2F2C095E5B6529F12=05328855C4E51ECDCD46876FE3491C71
8DF89ED150041C4CBC7CB9A9CAA90856=2CE54FD71E149B997073596C6B0E9512
DC22A860405A8BF2F2C095E5B6529F12=D7B61603071EE7338842D45EDC3395F0
eclipse.preferences.version=1
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"files.associations": {
"cstring": "cpp",
"__config": "cpp",
"typeinfo": "cpp"
"typeinfo": "cpp",
"array": "cpp",
"xstring": "cpp",
"xlocinfo": "cpp"
}
}
2 changes: 1 addition & 1 deletion BCubed.launch
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/>
Expand Down
51 changes: 44 additions & 7 deletions Components/Drivers/IOExpander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bool IOExpander::Commit() {
*
* @return true on success, false on failure (invalid arguments)
*/
bool IOExpander::SetPin(IOExpanderPin pin, IOState state) {
bool IOExpander::SetPin(IOPin pin, IOState state) {
// Check for invalid arguments
if(pin >= IOExpanderPin::IO_NUM_PINS ||
state >= IOState::ERROR) return false;
Expand All @@ -47,7 +47,7 @@ bool IOExpander::SetPin(IOExpanderPin pin, IOState state) {
*
* @return true on success, false on failure
*/
bool IOExpander::SetPinNow(IOExpanderPin pin, IOState state) {
bool IOExpander::SetPinNow(IOPin pin, IOState state) {
if (SetPin(pin, state)) {
return Commit();
}
Expand All @@ -62,7 +62,7 @@ bool IOExpander::SetPinNow(IOExpanderPin pin, IOState state) {
* @param pin Pin to toggle
* @return true on success, false on failure (invalid arguments)
*/
bool IOExpander::TogglePin(IOExpanderPin pin) {
bool IOExpander::TogglePin(IOPin pin) {
// Check for invalid arguments
if(pin >= IOExpanderPin::IO_NUM_PINS) return false;

Expand All @@ -80,7 +80,7 @@ bool IOExpander::TogglePin(IOExpanderPin pin) {
* @param pin Pin to toggle
* @return true on success, false on failure
*/
bool IOExpander::TogglePinNow(IOExpanderPin pin) {
bool IOExpander::TogglePinNow(IOPin pin) {
if (TogglePin(pin)) {
Commit();
}
Expand All @@ -106,7 +106,7 @@ bool IOExpander::Update() {
* ERROR if pin is not set as an input
* or if pin is invalid
*/
IOState IOExpander::GetPinState(IOExpanderPin pin) {
IOState IOExpander::GetPinState(IOPin pin) {
// Check for invalid arguments
if(pin >= IOExpanderPin::IO_NUM_PINS) return IOState::ERROR;

Expand All @@ -129,9 +129,46 @@ IOState IOExpander::GetPinState(IOExpanderPin pin) {
* or if pin is invalid
* or if I2C read fails
*/
IOState IOExpander::GetPinStateNow(IOExpanderPin pin) {
IOState IOExpander::GetPinStateNow(IOPin pin) {
if (Update()) {
return GetPinState(pin);
}
return IOState::ERROR;
}
}

/**
* @brief Get pin state of all pins
*
* @return array of IOState, each index corresponding to each pin
*/
std::array<IOState, 16> IOExpander::GetExpanderState() {
std::array<IOState, 16> expanderState;

for(uint8_t i = 1; i < 8; i++) {
IOPin pin = static_cast<IOPin>(i);
expanderState[i] = GetPinState(pin);
}

for(uint8_t i = 10; i < 18; i++) {
IOPin pin = static_cast<IOPin>(i);
expanderState[i - 2] = GetPinState(pin);
}

return expanderState;
}

/**
* @brief Get pin in state of all pins with Update
*
* @return array of IOState, each index corresponding to a pin
*/
std::array<IOState, 16> IOExpander::GetExpanderStateNow() {
if(Update()) {
return GetExpanderState();
}
// Initialize and return an array filled with ERROR state for failure
std::array<IOState, 16> errorState;
errorState.fill(IOState::ERROR);
return errorState;
}

42 changes: 41 additions & 1 deletion Components/Drivers/IOExpander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
// -- Includes ------------------------------------------------------------------
#include "main_system.hpp" // This should have the platform specific HAL included
#include <stdint.h>
#include <array>

// -- Macros --------------------------------------------------------------------
#define I2C_TIMEOUT_MS 1000
Expand Down Expand Up @@ -63,10 +64,47 @@ enum class IOState {
HIGH = 1,
HI = HIGH,

INPUT = 1,
INPUT = 2,
ERROR
};

/* ------------------------------- Namespace for Alternative IOPin names -------------------------------*/
namespace DriverControls {
constexpr IOPin FORWARD_NEUTRAL_REVERSE_H = IOPin::P00;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be an enum

constexpr IOPin FORWARD_NEUTRAL_REVERSE_L = IOPin::P01;
constexpr IOPin ARRAYS_DISCONNECT = IOPin::P02;
constexpr IOPin RACE_MODE_ENABLE = IOPin::P03;
constexpr IOPin HEADLIGHTS_ENABLE = IOPin::P04;
constexpr IOPin DISPLAY_SCREEN_ROTATE = IOPin::P05;
constexpr IOPin PROXIMITY_SENSOR_ENABLE = IOPin::P06;
constexpr IOPin LAP_BUTTON = IOPin::P07;
constexpr IOPin HORN_ENABLE = IOPin::P10;
constexpr IOPin LEFT_SIGNAL_ENABLE = IOPin::P11;
constexpr IOPin RIGHT_SIGNAL_ENABLE = IOPin::P12;
constexpr IOPin EMERGENCY_HAZARD = IOPin::P13;
constexpr IOPin MOTOR_RESET = IOPin::P14;
constexpr IOPin PARKING_BRAKE_DETECT = IOPin::P15;
constexpr IOPin MECHANICAL_BRAKE = IOPin::P16;
constexpr IOPin GREEN_LED = IOPin::P17;
}

namespace PowerBoard {
constexpr IOPin RIGHT_TURN_LIGHT_SIGNAL = IOPin::P00;
constexpr IOPin LEFT_TURN_LIGHT_SIGNAL = IOPin::P01;
constexpr IOPin DAYTIME_RUNNING_LIGHT_SIGNAL = IOPin::P02;
constexpr IOPin HEADLIGHT_SIGNAL = IOPin::P03;
constexpr IOPin BRAKE_LIGHT_SIGNAL = IOPin::P04;
constexpr IOPin HORN_SIGNAL = IOPin::P05;
constexpr IOPin ORANGE_LED = IOPin::P06;
constexpr IOPin GREEN_LED = IOPin::P07;

constexpr IOPin P13 = IOPin::P13;
constexpr IOPin P14 = IOPin::P14;
constexpr IOPin P15 = IOPin::P15;
constexpr IOPin P16 = IOPin::P16;
constexpr IOPin P17 = IOPin::P17;
}

// -- Typedefs ------------------------------------------------------------------
typedef IOPin IOExpanderPin; // In case we want to change the name of IOPin

Expand All @@ -93,6 +131,8 @@ class IOExpander {
bool Update(); // Update IO Expander Read State
IOState GetPinState(IOPin pin); // Get pin state (note. last read state)
IOState GetPinStateNow(IOPin pin); // Get pin state with update
std::array<IOState, 16> GetExpanderState(); // Get exapnder state
std::array<IOState, 16> GetExpanderStateNow(); // Get expander state with update

static inline const uint8_t CalculateAddress(uint8_t ad0, uint8_t ad1, uint8_t ad2);

Expand Down
Loading