Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 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
43d0c2c
init
Heinzino Dec 7, 2024
3c0280c
Updated Cube++ submodule reference
Heinzino Dec 24, 2024
ebd2912
feat: Enable CAN Interrupts on IOC
Heinzino Jan 4, 2025
40d284a
feat: CAN RX Interrupt Setup
Heinzino Jan 4, 2025
cce1be4
fix: CAN RX Declaration
Heinzino Jan 4, 2025
89db374
feat: ISR Callback on CANRX
Heinzino Jan 8, 2025
e95c1c9
feat: Show Print Message on CAN Interrupt
Heinzino Jan 8, 2025
2790d93
fix: Can RX PR comments
Heinzino Feb 22, 2025
4386b70
falling edge on rx interrupt
Heinzino Feb 22, 2025
e78ddec
fix: Move callback to CanRX.cpp
Heinzino Mar 15, 2025
0beaa97
feat: Decode CANRX messages
Heinzino Mar 22, 2025
07d0bd5
feat: Task UML B3 Reference
Heinzino Apr 3, 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
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="1488038463076734800" 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="1488036678533493769" 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
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
"files.associations": {
"cstring": "cpp",
"__config": "cpp",
"typeinfo": "cpp"
"typeinfo": "cpp",
"array": "cpp",
"xstring": "cpp",
"xlocinfo": "cpp",
"algorithm": "cpp",
"list": "cpp",
"xutility": "cpp",
"runinterface.hpp": "c"
}
}
67 changes: 67 additions & 0 deletions B3 Reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# B3 Board Reference


## Task Diagram

```mermaid
classDiagram
class CANRxTask {
+InitTask()
+GetCAN_RX_QUEUE() : Queue*
-Run(void* pvParams)
-HandleCommand(Command& cm)
}

class CANTxTask {
+InitTask()
-Run(void* pvParams)
-HandleCommand(Command& cm)
}

class DebugTask {
+InitTask()
-Run(void* pvParams)
-HandleDebugMessage(const char* msg)
-ReceiveData() : bool
-InterruptRxData(uint8_t errors)
}

class GPIOTask {
+InitTask()
+LightsInputsBase() : uint8_t
+DriverBase() : uint8_t
+LightStatus() : uint8_t
-Run(void* pvParams)
}

class SPI_Task {
+InitTask()
+readAccelerationPedal_P() : uint16_t
+readBrakingPedal_P() : uint16_t
+getAccelerationReading_P() : uint16_t
+getBrakingReading_P() : uint16_t
+calculatePedalPosition(uint16_t) : float
+getAccelerationPedalPercent() : float
+getBrakePedalPercent() : float
-Run(void* pvParams)
}

class MCP2510

DebugTask --> CANTxTask : Sends CAN commands
DebugTask --> IOExpander : Uses IO driver
MCP2510 --> CANRxTask : ISR to Queue

CANTxTask --> GPIOTask : Queries GPIO status
CANTxTask --> SPI_Task : Queries pedal data
CANTxTask --> CAN : Uses CAN driver

CANRxTask --> CAN : Uses CAN driver

GPIOTask --> IOExpander
```


## Task Descriptions


25 changes: 13 additions & 12 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 @@ -75,6 +75,7 @@ MxCube.Version=6.10.0
MxDb.Version=DB.6.0.100
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
NVIC.EXTI9_5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
Expand Down Expand Up @@ -208,26 +209,29 @@ PC3.GPIOParameters=GPIO_Label
PC3.GPIO_Label=LED GREEN
PC3.Locked=true
PC3.Signal=GPIO_Output
PC6.GPIOParameters=GPIO_Label
PC6.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
PC6.GPIO_Label=CAN_RX1BF
PC6.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
PC6.Locked=true
PC6.Signal=GPXTI6
PC7.GPIOParameters=GPIO_Label
PC7.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
PC7.GPIO_Label=CAN_RX0BF
PC7.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
PC7.Locked=true
PC7.Signal=GPXTI7
PC8.GPIOParameters=GPIO_Label
PC8.GPIO_Label=CS_CAN_N
PC8.Locked=true
PC8.Signal=GPIO_Output
PC9.GPIOParameters=GPIO_Label
PC9.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
PC9.GPIO_Label=CAN_INT
PC9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
PC9.Locked=true
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,22 +302,20 @@ 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
SPI1.VirtualType=VM_MASTER
SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2
SPI2.CalculateBaudRate=16.0 MBits/s
SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16
SPI2.CalculateBaudRate=2.0 MBits/s
SPI2.Direction=SPI_DIRECTION_2LINES
SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler
SPI2.Mode=SPI_MODE_MASTER
Expand All @@ -330,4 +332,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
143 changes: 143 additions & 0 deletions Components/CANRx/CanRxTask.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/**
******************************************************************************
* File Name : CANRxTask.cpp
* Description : Task for receiving CAN messages
******************************************************************************
*/

#include "CanRxTask.hpp"

// Maybe add a header file
CANPeripheral peripheral2 = {
.CS_PORT = CS_CAN_N_GPIO_Port,
.CS_PIN = CS_CAN_N_Pin,
.hspi = SystemHandles::CAN_SPI};

/**
* @brief Constructor for CANTxTask
*/
CANRxTask::CANRxTask() : Task(CAN_TX_TASK_QUEUE_DEPTH_OBJS)
{
}

/**
* @brief Initialize the CANTxTask
*/
void CANRxTask::InitTask()
{
// Make sure the task is not already initialized
CUBE_ASSERT(rtTaskHandle == nullptr, "Cannot initialize CAN RX task twice");

BaseType_t rtValue =
xTaskCreate((TaskFunction_t)CANRxTask::RunTask,
(const char *)"CANRxTask",
(uint16_t)CAN_RX_TASK_STACK_DEPTH_WORDS,
(void *)this,
(UBaseType_t)CAN_RX_TASK_PRIORITY,
(TaskHandle_t *)&rtTaskHandle);

CUBE_ASSERT(rtValue == pdPASS, "CANRxTask::InitTask() - xTaskCreate() failed");
}

void CANRxTask::Run(void *pvParams)
{
ConfigureCANSPI(&peripheral2);

while (1)
{
/***
* MCP2510: https://usw.365.altium.com/librarycomponentsapi/api/v1/References/79FC5B82-F317-4482-BD19-9D6F8666BE78
* Plan:
* On buffer interrupt add to queue
* While(1) Task processes Queue
* Later Optimization: Add Mutex to
*
* 1. Detect RX Interrupt RXBUFF
* - Set interrupts RXBuff pg 21
* - RXBUFF0 and RXBUFF1 .
* 2. Queue buffer contents
* - CAN_RX_QUEUE.SendFromISR()
* - Parse data into command
* receiveCANMessage()
* 3. Mutex the SPI Peripheral
* Mutex
* 4. Handle buffer
*/

// Wait forever for a command on interrupt
Command cm;
qEvtQueue->ReceiveWait(cm);

// Process the command
HandleCommand(cm);

cm.Reset();
}
}

void CANRxTask::HandleCommand(Command &cm)
{
uint32_t id = 0;
uint8_t dlc = 0;
uint8_t data[8] = {0};

switch (static_cast<CAN_RX_COMMANDS>(cm.GetTaskCommand()))
{
case CAN_INTERRUPT_HAPPENED:
CUBE_PRINT("Received a CAN RX Message by interrupt\n");
break;
case CAN_RX0_INTERRUPT_HAPPENED:
receiveCANMessage(0, &id, &dlc, data, &peripheral2);
CUBE_PRINT("CAN RX0 Message:\n");
CUBE_PRINT_CAN_MESSAGE(id, dlc, data);
break;
case CAN_RX1_INTERRUPT_HAPPENED:
receiveCANMessage(1, &id, &dlc, data, &peripheral2);
CUBE_PRINT("CAN RX1 Message:\n");
CUBE_PRINT_CAN_MESSAGE(id, dlc, data);
break;
default:
CUBE_PRINT("CANRXTask - Received unsupported command: %d\n", cm.GetCommand());
break;
}
}

// Handle CAN_INT Callback here ?
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
// NOTE: Can Implement Call back on RXBUF0 and RXBUF1 and decode the message accordingly.
if (GPIO_Pin == CAN_INT_Pin)
{
// Handle or Event Flag into CPP Task
Command canInterruptHappenedCommandFlag = Command(TASK_SPECIFIC_COMMAND, CAN_INTERRUPT_HAPPENED);
CANRxTask::Inst()
.GetCAN_RX_QUEUE()
->SendFromISR(canInterruptHappenedCommandFlag);
}
else if (GPIO_Pin == CAN_RX0BF_Pin)
{
Command canInterruptHappenedCommandFlag = Command(TASK_SPECIFIC_COMMAND, CAN_RX0_INTERRUPT_HAPPENED);
CANRxTask::Inst()
.GetCAN_RX_QUEUE()
->SendFromISR(canInterruptHappenedCommandFlag);
}
else if (GPIO_Pin == CAN_RX1BF_Pin)
{
Command canInterruptHappenedCommandFlag = Command(TASK_SPECIFIC_COMMAND, CAN_RX1_INTERRUPT_HAPPENED);
CANRxTask::Inst()
.GetCAN_RX_QUEUE()
->SendFromISR(canInterruptHappenedCommandFlag);
}
}

//Helper function to print CAN message
void CUBE_PRINT_CAN_MESSAGE(uint32_t id, uint8_t dlc, uint8_t *data)
{
CUBE_PRINT(" ID: 0x%08X\n", id);
CUBE_PRINT(" DLC: %u\n", dlc);
CUBE_PRINT(" Data: ");
for (uint8_t i = 0; i < dlc; ++i)
{
CUBE_PRINT("%02X ", data[i]);
}
}
41 changes: 41 additions & 0 deletions Components/CANRx/CanRxTask.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
******************************************************************************
* File Name : CANTxTask.hpp
* Description :
******************************************************************************
*/
#include "Task.hpp"
#include "main.h"
#include "Queue.hpp"
#include "Mutex.hpp"
#include "CAN.h"

enum CAN_RX_COMMANDS {
CAN_INTERRUPT_HAPPENED, //Task specific command queued on CAN_INT ISR
CAN_RX0_INTERRUPT_HAPPENED, //Task specific command queued on CAN_RX0BF ISR
CAN_RX1_INTERRUPT_HAPPENED, //Task specific command queued on CAN_RX1BF ISR
};
class CANRxTask : public Task
{
public:
static CANRxTask& Inst() {
static CANRxTask inst;
return inst;
}

void InitTask();
Queue* GetCAN_RX_QUEUE() const { return qEvtQueue; }

protected:
static void RunTask(void* pvParams) { CANRxTask::Inst().Run(pvParams); } // Static Task Interface, passes control to the instance Run();
void Run(void * pvParams); // Main run code
void HandleCommand(Command& cm);

private:
CANRxTask(); // Private constructor
CANRxTask(const CANRxTask&); // Prevent copy-construction
CANRxTask& operator=(const CANRxTask&); // Prevent assignment
};

//Helper function to print CAN message
void CUBE_PRINT_CAN_MESSAGE(uint32_t id, uint8_t dlc, uint8_t *data);
Loading