Skip to content

Instantly share code, notes, and snippets.

@mongonta0716
Last active May 25, 2020 06:55
Show Gist options
  • Save mongonta0716/e8e1cb2a39e44c6cc114cd197acf51ed to your computer and use it in GitHub Desktop.
Save mongonta0716/e8e1cb2a39e44c6cc114cd197acf51ed to your computer and use it in GitHub Desktop.
#include <Arduino.h>
#include "FreeRTOS.h"
#include "task.h"
#include <bsp.h>
#include <sysctl.h>
#define MP_TASK_PRIORITY 4
#define MP_TASK_STACK_SIZE (32 * 1024)
#define MP_TASK_STACK_LEN (MP_TASK_STACK_SIZE / sizeof(StackType_t))
TaskHandle_t mp_main_task_handle0;
TaskHandle_t mp_main_task_handle1;
void core0_task(void *args) {
while(true) {
digitalWrite(LED_BLUE, HIGH);
delay(1000);
digitalWrite(LED_BLUE, LOW);
delay(1000);
}
}
void core1_task(void *args) {
while(true) {
digitalWrite(LED_RED, HIGH);
delay(500);
digitalWrite(LED_RED, LOW);
delay(500);
}
}
void startThread() {
xTaskCreate(// processor
core0_task, // function entry
"task0", //task name
MP_TASK_STACK_LEN, //stack_deepth
NULL, //function arg
MP_TASK_PRIORITY, //task priority
&mp_main_task_handle0);//task handl
xTaskCreate( // processor
core1_task, // function entry
"task1", //task name
256, //stack_deepth
NULL, //function arg
MP_TASK_PRIORITY + 1, //task priority
&mp_main_task_handle1);//task handl
// xTaskCreateAtProcessor(1, core2_task, "core2_task", 256, NULL, tskIDLE_PRIORITY+1, NULL );
vTaskStartScheduler();
}
void setup() {
pinMode(LED_BLUE, OUTPUT);
pinMode(LED_RED, OUTPUT);
startThread();
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment