Switched hub Freertos to multicore
This commit is contained in:
@@ -104,10 +104,11 @@
|
||||
|
||||
#if FREE_RTOS_KERNEL_SMP // set by the RP2040 SMP port of FreeRTOS
|
||||
/* SMP port only */
|
||||
#define configNUMBER_OF_CORES 1
|
||||
#define configNUMBER_OF_CORES 2
|
||||
#define configTICK_CORE 0
|
||||
#define configRUN_MULTIPLE_PRIORITIES 1
|
||||
#define configUSE_CORE_AFFINITY 0
|
||||
#define configUSE_CORE_AFFINITY 1
|
||||
#define configUSE_PASSIVE_IDLE_HOOK 0
|
||||
#endif
|
||||
|
||||
/* RP2040 specific */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<mxfile host="Electron" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/25.0.1 Chrome/128.0.6613.186 Electron/32.2.6 Safari/537.36" version="25.0.1">
|
||||
<diagram name="Page-1" id="VLDBnTalcAr4j7jpmEzg">
|
||||
<mxGraphModel dx="819" dy="497" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
|
||||
<mxGraphModel dx="1195" dy="725" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
@@ -810,9 +810,6 @@
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-256" value="Status" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="1641.5899999999997" y="1320" width="81.95" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-257" value="4" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="332.45" y="770" width="160" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-258" value="4" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="491.72999999999996" y="770" width="160.72" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
@@ -1099,6 +1096,9 @@
|
||||
<mxPoint x="1800" y="1740" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-374" value="Empty Buffer Queue" style="sketch=0;aspect=fixed;pointerEvents=1;shadow=0;dashed=0;html=1;strokeColor=none;labelPosition=center;verticalLabelPosition=bottom;verticalAlign=top;align=center;fillColor=#00188D;shape=mxgraph.azure.queue_generic" vertex="1" parent="1">
|
||||
<mxGeometry x="2096.67" y="1680" width="183.33" height="55" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<mxfile host="Electron" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/25.0.1 Chrome/128.0.6613.186 Electron/32.2.6 Safari/537.36" version="25.0.1">
|
||||
<diagram name="Page-1" id="VLDBnTalcAr4j7jpmEzg">
|
||||
<mxGraphModel dx="1195" dy="725" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
|
||||
<mxGraphModel dx="1366" dy="829" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
@@ -1042,8 +1042,8 @@
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-344" value="InputBuffer" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="1269.61" y="1692.5" width="70" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-349" value="Core0" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontStyle=1" vertex="1" parent="1">
|
||||
<mxGeometry x="1038.15" y="1610" width="722" height="30" as="geometry" />
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-349" value="Core0" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontStyle=1;fontSize=26;" vertex="1" parent="1">
|
||||
<mxGeometry x="1038.15" y="1600" width="1111.85" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-361" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="1215" y="1700" width="15" height="160" as="geometry" />
|
||||
@@ -1078,24 +1078,45 @@
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-369" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="1030" y="1600" as="sourcePoint" />
|
||||
<mxPoint x="2030" y="1600" as="targetPoint" />
|
||||
<mxPoint x="2160" y="1600" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-370" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="2030" y="1930" as="sourcePoint" />
|
||||
<mxPoint x="2030" y="1600" as="targetPoint" />
|
||||
<mxPoint x="2160" y="1930" as="sourcePoint" />
|
||||
<mxPoint x="2160" y="1600" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-371" value="<div style="color: rgb(204, 204, 204); background-color: rgb(31, 31, 31); font-family: &quot;Droid Sans Mono&quot;, &quot;monospace&quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;"><span style="color: #9cdcfe;">cb_rxData</span></div>" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="1800" y="1760" width="160" height="40" as="geometry" />
|
||||
<mxGeometry x="1820" y="1710" width="160" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-373" value="" style="endArrow=classic;html=1;rounded=0;entryX=-0.009;entryY=0.431;entryDx=0;entryDy=0;entryPerimeter=0;exitX=0.935;exitY=0.449;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="weFQkCekfF49Ojb9-c9R-367" target="weFQkCekfF49Ojb9-c9R-371">
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-373" value="" style="endArrow=classic;html=1;rounded=0;entryX=-0.009;entryY=0.431;entryDx=0;entryDy=0;entryPerimeter=0;exitX=1;exitY=0.25;exitDx=0;exitDy=0;" edge="1" parent="1" source="weFQkCekfF49Ojb9-c9R-367" target="weFQkCekfF49Ojb9-c9R-371">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="1750" y="1790" as="sourcePoint" />
|
||||
<mxPoint x="1800" y="1740" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-374" value="Gobot RPC TX Queue" style="sketch=0;aspect=fixed;pointerEvents=1;shadow=0;dashed=0;html=1;strokeColor=none;labelPosition=center;verticalLabelPosition=bottom;verticalAlign=top;align=center;fillColor=#00188D;shape=mxgraph.azure.queue_generic" vertex="1" parent="1">
|
||||
<mxGeometry x="2080.79" y="1702.5" width="183.33" height="55" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-376" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="weFQkCekfF49Ojb9-c9R-371" target="weFQkCekfF49Ojb9-c9R-374">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-377" value="Core1" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontStyle=1;fontSize=26;" vertex="1" parent="1">
|
||||
<mxGeometry x="2160" y="1600" width="1111.85" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-378" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="2160" y="1600" as="sourcePoint" />
|
||||
<mxPoint x="3280" y="1600" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="weFQkCekfF49Ojb9-c9R-379" value="" style="endArrow=none;dashed=1;html=1;rounded=0;" edge="1" parent="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="2350" y="1934" as="sourcePoint" />
|
||||
<mxPoint x="2351.03" y="1654" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#include "task.h"
|
||||
|
||||
|
||||
GobotRPC_CI::GobotRPC_CI(I_GobotRPC_CI_Hardware *hardware) {
|
||||
GobotRPC_CI::GobotRPC_CI(I_GobotRPC_CI_Hardware *hardware, UBaseType_t core) {
|
||||
this->hardware = hardware;
|
||||
this->hardware->registerCB_RxData(GobotRPC_CI_rxData_cb, this);
|
||||
|
||||
xTaskCreate(GobotRPC_CI_heartBeatTaskFn, "Heartbeat Task", 2048, this, 2, &this->heartBeatTaskHandle);
|
||||
xTaskCreateAffinitySet(GobotRPC_CI_heartBeatTaskFn, "Heartbeat Task", 2048, this, 2, core, &this->heartBeatTaskHandle);
|
||||
}
|
||||
|
||||
// Rx Side
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
// Initialize stuff
|
||||
GobotRPC_CI_Hardware_RP2040_UART * g_GobotRPC_CI_Hardware_RP2040_UART;
|
||||
|
||||
GobotRPC_CI_Hardware_RP2040_UART::GobotRPC_CI_Hardware_RP2040_UART(uart_inst_t *uart, uint baudrate) {
|
||||
GobotRPC_CI_Hardware_RP2040_UART::GobotRPC_CI_Hardware_RP2040_UART(uart_inst_t *uart, uint baudrate, UBaseType_t core) {
|
||||
g_GobotRPC_CI_Hardware_RP2040_UART = this;
|
||||
this->core = core;
|
||||
|
||||
initRxTaskAndQueues();
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ void GobotRPC_CI_Hardware_RP2040_UART::initRxTaskAndQueues() {
|
||||
}
|
||||
|
||||
rxSignalSemaphore = xSemaphoreCreateBinary();
|
||||
xTaskCreate(GobotRPC_CI_Hardware_RP2040_UART_Task_RXProcessing, "UART RX Processing", 1024, this, 3, &this->rxProcessingTaskHandle);
|
||||
|
||||
xTaskCreateAffinitySet(GobotRPC_CI_Hardware_RP2040_UART_Task_RXProcessing, "UART RX Processing", 1024, this, 3, core, &this->rxProcessingTaskHandle);
|
||||
}
|
||||
|
||||
inputBufferRXState_t fillBuffer(inputBuffers_t * buffer, char data) {
|
||||
|
||||
@@ -29,7 +29,7 @@ private:
|
||||
TaskHandle_t heartBeatTaskHandle;
|
||||
|
||||
public:
|
||||
GobotRPC_CI(I_GobotRPC_CI_Hardware *hardware);
|
||||
GobotRPC_CI(I_GobotRPC_CI_Hardware *hardware, UBaseType_t core);
|
||||
|
||||
void registerCB_TxPacket(callback_TxPacket cb, void *args);
|
||||
void send_RxPacket(char *data, size_t len, uint32_t addr);
|
||||
|
||||
@@ -45,7 +45,6 @@ private:
|
||||
inputBuffers_t inputBufferPool[NUM_INPUT_BUFFERS];
|
||||
|
||||
TaskHandle_t rxProcessingTaskHandle;
|
||||
|
||||
|
||||
SemaphoreHandle_t rxSignalSemaphore;
|
||||
QueueHandle_t emptyInputBuffersQueue;
|
||||
@@ -56,12 +55,15 @@ private:
|
||||
|
||||
SemaphoreHandle_t txMutex;
|
||||
|
||||
UBaseType_t core;
|
||||
|
||||
public:
|
||||
GobotRPC_CI_Hardware_RP2040_UART(uart_inst_t *uart, uint baudrate);
|
||||
GobotRPC_CI_Hardware_RP2040_UART(uart_inst_t *uart, uint baudrate, UBaseType_t core);
|
||||
void send(char *data, size_t len) override;
|
||||
void registerCB_RxData(callback_rxData cb, void *args);
|
||||
|
||||
void initRxTaskAndQueues();
|
||||
|
||||
void onRx_ISR();
|
||||
void rxBufferingTaskFn();
|
||||
void rxProcessingTaskFn();
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
|
||||
#define LED_PIN 25
|
||||
|
||||
#define UART_CORE_MASK 0b01
|
||||
#define I2C_CORE_MASK 0b10
|
||||
|
||||
void vTaskMain(void * pvParameters) {
|
||||
while(1) {
|
||||
gpio_put(LED_PIN, 1);
|
||||
@@ -37,13 +40,15 @@ int main() {
|
||||
gpio_init(LED_PIN);
|
||||
gpio_set_dir(LED_PIN, true);
|
||||
|
||||
GobotRPC_CI_Hardware_RP2040_UART gobotrpc_ci_hardware(uart0, 115200);
|
||||
GobotRPC_CI gobotRPC_ci(&gobotrpc_ci_hardware);
|
||||
GobotRPC_CI_Hardware_RP2040_UART gobotrpc_ci_hardware(uart0, 115200, 0b01);
|
||||
GobotRPC_CI gobotRPC_ci(&gobotrpc_ci_hardware, 0b01);
|
||||
|
||||
gobotRPC_ci.registerCB_TxPacket(onTxPacket, &gobotRPC_ci);
|
||||
|
||||
TaskHandle_t taskHandle;
|
||||
xTaskCreate(vTaskMain, "Main Task", 2048, &gobotRPC_ci, 1, &taskHandle);
|
||||
xTaskCreateAffinitySet(vTaskMain, "Main Task", 2048, &gobotRPC_ci, 1, UART_CORE_MASK, &taskHandle);
|
||||
vTaskCoreAffinitySet(taskHandle, 0);
|
||||
|
||||
vTaskStartScheduler();
|
||||
|
||||
while(1) {}
|
||||
|
||||
Reference in New Issue
Block a user