Here is bit of code when I am creating a task and passing an object
Code: Select all
LinHandler lin;
TaskHandle_t Task1;
void loop2(void* parameter) {
LinHandler& lin = *((LinHandler*)parameter);
for (;;) {
lin.write(); // Write data to LIN
delay(100);
}
}
void setup() {
// Initialize your task (2nd loop)
xTaskCreatePinnedToCore(
loop2, // name of the task function
"ledCheck", // name of the task
1000, // memory assigned for the task
(void*)&lin, // parameter to pass if any
1, // priority of task, starting from 0(Highestpriority) *IMPORTANT*( if set to 1 and there is no activity in your 2nd loop, it will reset the esp32)
&Task1, // Reference name of taskHandle variable
0);
}
And just for reference, inside my object that's how I initialize it
Code: Select all
private:
lin_bus _lin = lin_bus(LIN_SERIAL, LIN_V2, LIN_EN, LIN_WK, LIN_TX);
What I am doing wrong ?