Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 15 additions & 15 deletions .mxproject

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions .settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
<project>
<configuration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1910886301" name="Debug">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/>
<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="-1436124437320108471" 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>
</extension>
</configuration>
<configuration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.783339558" name="Release">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/>
<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="-1436125939973682704" 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
3 changes: 2 additions & 1 deletion .settings/stm32cubeide.project.prefs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2F62501ED4689FB349E356AB974DBE57=05328855C4E51ECDCD46876FE3491C71
635E684B79701B039C64EA45C3F84D30=06D51718D4F3D877E4CF008AE59E16BB
66BE74F758C12D739921AEA421D593D3=2
8DF89ED150041C4CBC7CB9A9CAA90856=05328855C4E51ECDCD46876FE3491C71
DC22A860405A8BF2F2C095E5B6529F12=05328855C4E51ECDCD46876FE3491C71
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"
}
}
11 changes: 4 additions & 7 deletions BCubed.ioc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FREERTOS.configTOTAL_HEAP_SIZE=65536
FREERTOS.configUSE_NEWLIB_REENTRANT=1
FREERTOS.configUSE_TIMERS=1
File.Version=6
GPIO.groupedBy=
GPIO.groupedBy=Group By Peripherals
KeepUserPlacement=false
Mcu.CPN=STM32L152RET6
Mcu.Family=STM32L1
Expand Down Expand Up @@ -227,7 +227,7 @@ PC9.Signal=GPXTI9
PD2.GPIOParameters=GPIO_Label
PD2.GPIO_Label=Board_SLCT_0
PD2.Locked=true
PD2.Signal=GPXTI2
PD2.Signal=GPIO_Output
PH0-OSC_IN.Locked=true
PH0-OSC_IN.Mode=HSE-External-Oscillator
PH0-OSC_IN.Signal=RCC_OSC_IN
Expand Down Expand Up @@ -298,16 +298,14 @@ SH.GPXTI0.0=GPIO_EXTI0
SH.GPXTI0.ConfNb=1
SH.GPXTI13.0=GPIO_EXTI13
SH.GPXTI13.ConfNb=1
SH.GPXTI2.0=GPIO_EXTI2
SH.GPXTI2.ConfNb=1
SH.GPXTI6.0=GPIO_EXTI6
SH.GPXTI6.ConfNb=1
SH.GPXTI7.0=GPIO_EXTI7
SH.GPXTI7.ConfNb=1
SH.GPXTI9.0=GPIO_EXTI9
SH.GPXTI9.ConfNb=1
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2
SPI1.CalculateBaudRate=16.0 MBits/s
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32
SPI1.CalculateBaudRate=1000.0 KBits/s
SPI1.Direction=SPI_DIRECTION_2LINES
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler
SPI1.Mode=SPI_MODE_MASTER
Expand All @@ -330,4 +328,3 @@ VP_SYS_VS_tim2.Mode=TIM2
VP_SYS_VS_tim2.Signal=SYS_VS_tim2
board=custom
rtos.0.ip=FREERTOS
isbadioc=false
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
7 changes: 7 additions & 0 deletions Components/Debug/DebugTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <cstring>

#include "IOExpander.hpp"
#include "SPI/SPI_Task.hpp"

// External Tasks (to send debug commands to)

Expand Down Expand Up @@ -96,6 +97,12 @@ void DebugTask::HandleDebugMessage(const char* msg)
// Echo the message (without the 'echo')
CUBE_PRINT("\n%s", &msg[5]);
}
else if (strncmp(msg, "readAccel ", 5) == 0) {
// test_SPI_Pedals.readAccelerationPedal();
}
else if (strncmp(msg, "readBrake ", 5) == 0) {
// test_SPI_Pedals.readBrakingPedal();
}
else if (strncmp(msg, "iecho ", 6) == 0) {
// Int echo the message (echo an int parameter)
int32_t val = Utils::ExtractIntParameter(msg, 6);
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 = 0; 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;
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
20 changes: 20 additions & 0 deletions Components/GPIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ namespace GPIO

inline bool IsOn() { return HAL_GPIO_ReadPin(LED_GREEN_GPIO_Port, LED_GREEN_Pin) == GPIO_PIN_SET; }
}
namespace BOARD_SELECT_0
{
inline void On() {HAL_GPIO_WritePin(Board_SLCT_0_GPIO_Port, Board_SLCT_0_Pin, GPIO_PIN_SET); }
inline void Off() {HAL_GPIO_WritePin(Board_SLCT_0_GPIO_Port, Board_SLCT_0_Pin, GPIO_PIN_RESET); }
}
namespace BOARD_SELECT_1
{
inline void On() {HAL_GPIO_WritePin(Board_SLCT_1_GPIO_Port, Board_SLCT_1_Pin, GPIO_PIN_SET); }
inline void Off() {HAL_GPIO_WritePin(Board_SLCT_1_GPIO_Port, Board_SLCT_1_Pin, GPIO_PIN_RESET); }
}
namespace SPI_DATA_CS0
{
inline void On() {HAL_GPIO_WritePin(SPI_Data_CS0_GPIO_Port, SPI_Data_CS0_Pin, GPIO_PIN_SET); }
inline void Off() {HAL_GPIO_WritePin(SPI_Data_CS0_GPIO_Port, SPI_Data_CS0_Pin, GPIO_PIN_RESET); }
}
namespace SPI_DATA_CS1
{
inline void On() {HAL_GPIO_WritePin(SPI_Data_CS1_GPIO_Port, SPI_Data_CS1_Pin, GPIO_PIN_SET); }
inline void Off() {HAL_GPIO_WritePin(SPI_Data_CS1_GPIO_Port, SPI_Data_CS1_Pin, GPIO_PIN_RESET); }
}
}

#endif /* HELIOS_INCLUDE_SC_CORE_GPIO_H */
Loading