From d196038f20eadeda4c2769241b11026b61dedfb6 Mon Sep 17 00:00:00 2001 From: tcfshcrw <48719709+tcfshcrw@users.noreply.github.com> Date: Tue, 30 Jul 2024 08:08:20 +0800 Subject: [PATCH] change pedal update task to core 1 others move to core 0 for ESPNow --- ESP32/include/ESPNOW_lib.h | 1 + ESP32/src/Main.cpp | 58 +++++--------------------------------- 2 files changed, 8 insertions(+), 51 deletions(-) diff --git a/ESP32/include/ESPNOW_lib.h b/ESP32/include/ESPNOW_lib.h index ff05c189..cc90559a 100644 --- a/ESP32/include/ESPNOW_lib.h +++ b/ESP32/include/ESPNOW_lib.h @@ -6,6 +6,7 @@ uint8_t Clu_mac[] = {0x36, 0x33, 0x33, 0x33, 0x33, 0x32}; uint8_t Gas_mac[] = {0x36, 0x33, 0x33, 0x33, 0x33, 0x33}; uint8_t Brk_mac[] = {0x36, 0x33, 0x33, 0x33, 0x33, 0x34}; +uint8_t Host_mac[] = {0x36, 0x33, 0x33, 0x33, 0x33, 0x35}; uint8_t* Recv_mac; uint16_t ESPNow_send=0; uint16_t ESPNow_recieve=0; diff --git a/ESP32/src/Main.cpp b/ESP32/src/Main.cpp index de721a2f..110c6c09 100644 --- a/ESP32/src/Main.cpp +++ b/ESP32/src/Main.cpp @@ -499,7 +499,7 @@ void setup() NULL, /* parameter of the task */ 1, /* priority of the task */ &Task1, /* Task handle to keep track of created task */ - 0); /* pin task to core 1 */ + 1); /* pin task to core 1 */ delay(500); xTaskCreatePinnedToCore( @@ -510,7 +510,7 @@ void setup() NULL, 1, &Task2, - 1); + 0); delay(500); #ifdef ISV_COMMUNICATION @@ -523,7 +523,7 @@ void setup() NULL, 1, &Task3, - 1); + 0); delay(500); #endif @@ -559,7 +559,7 @@ void setup() NULL, 1, &Task4, - 1); + 0); delay(500); } #endif @@ -632,7 +632,7 @@ void setup() NULL, 1, &Task5, - 1); + 0); delay(500); #endif @@ -642,51 +642,7 @@ void setup() dap_calculationVariables_st.rudder_brake_status=false; if(dap_config_st.payLoadPedalConfig_.OTA_flag==0) { - /* - WiFi.mode(WIFI_MODE_STA); - Serial.print("MAC Address: "); - Serial.println(WiFi.macAddress()); - if(dap_config_st.payLoadPedalConfig_.pedal_type==0) - { - esp_wifi_set_mac(WIFI_IF_STA, &Clu_mac[0]); - } - if(dap_config_st.payLoadPedalConfig_.pedal_type==1) - { - esp_wifi_set_mac(WIFI_IF_STA, &Brk_mac[0]); - } - if(dap_config_st.payLoadPedalConfig_.pedal_type==2) - { - esp_wifi_set_mac(WIFI_IF_STA, &Gas_mac[0]); - } - delay(300); - Serial.print("new MAC Address: "); - Serial.println(WiFi.macAddress()); - ESPNow.init(); - Serial.println("wait for ESPNOW initialized"); - delay(10000); - - if(dap_config_st.payLoadPedalConfig_.pedal_type==1) - { - Recv_mac=Gas_mac; - } - - if(dap_config_st.payLoadPedalConfig_.pedal_type==2) - { - Recv_mac=Brk_mac; - } - if(ESPNow.add_peer(Recv_mac)== ESP_OK) - { - ESPNOW_status=true; - Serial.println("Sucess to add peer"); - } - else - { - ESPNOW_status=false; - Serial.println("Fail to add peer"); - } - ESPNow.reg_recv_cb(onRecv); - ESPNow.reg_send_cb(OnSent); - */ + xTaskCreatePinnedToCore( ESPNOW_SyncTask, "ESPNOW_update_Task", @@ -695,7 +651,7 @@ void setup() NULL, 1, &Task6, - 1); + 0); delay(500);