Compare commits

..

No commits in common. "bf4860b5094a0598859e69fd84c9a6c5a64a240c" and "cc2499e0e5f743dc3560cc1f031351310e2b1372" have entirely different histories.

3 changed files with 15 additions and 75 deletions

View file

@ -121,7 +121,7 @@ int ESP32SJA1000Class::begin(long baudRate)
} }
modifyRegister(REG_BTR1, 0x80, 0x80); // SAM = 1 modifyRegister(REG_BTR1, 0x80, 0x80); // SAM = 1
writeRegister(REG_IER, 0xef); // enable all interrupts writeRegister(REG_IER, 0xff); // enable all interrupts
// set filter to allow anything // set filter to allow anything
writeRegister(REG_ACRn(0), 0x00); writeRegister(REG_ACRn(0), 0x00);

View file

@ -16,7 +16,6 @@ monitor_speed = 115200
monitor_filters = esp32_exception_decoder monitor_filters = esp32_exception_decoder
upload_speed = 115200 upload_speed = 115200
build_flags = -DCORE_DEBUG_LEVEL=5 build_flags = -DCORE_DEBUG_LEVEL=5
lib_deps = fastled/FastLED@^3.6.0
[env:nodemcu-32s-prod] [env:nodemcu-32s-prod]
platform = espressif32 platform = espressif32
@ -24,5 +23,4 @@ board = nodemcu-32s
framework = arduino framework = arduino
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 115200 upload_speed = 115200
build_flags = -DCORE_DEBUG_LEVEL=3 build_flags = -DCORE_DEBUG_LEVEL=3
lib_deps = fastled/FastLED@^3.6.0

View file

@ -4,9 +4,6 @@
#include <CAN.h> #include <CAN.h>
#include "esp_log.h" #include "esp_log.h"
#include <FastLED.h>
CRGB led[1];
static SemaphoreHandle_t mutex; static SemaphoreHandle_t mutex;
// Task handles // Task handles
@ -66,8 +63,6 @@ unsigned long standbyStartTime = 0; // Tracks the start time of standby mode
// Internal variables // Internal variables
bool serial_init = false; bool serial_init = false;
bool can_enabled = false; bool can_enabled = false;
bool led_status = false;
int serial_ping = 0;
// Function to initialize CAN bus // Function to initialize CAN bus
void initCAN() void initCAN()
@ -290,11 +285,11 @@ void vSerialConsoleTask(void *pvParameters)
ESP_LOGD("State machine", "Try to enable CAN Interface"); ESP_LOGD("State machine", "Try to enable CAN Interface");
initCAN(); initCAN();
} }
if (standbyStartTime != 0) if (standbyStartTime != 0) {
{
standbyStartTime = 0; // Reset standby timer standbyStartTime = 0; // Reset standby timer
ESP_LOGI("State machine", " Ignition standby timer disabled"); ESP_LOGI("State machine"," Ignition standby timer disabled");
} }
} }
else if (input.endsWith("off")) else if (input.endsWith("off"))
{ {
@ -321,10 +316,10 @@ void vSerialConsoleTask(void *pvParameters)
standbyStartTime = millis(); standbyStartTime = millis();
ESP_LOGI("State machine", "Ignition set to standby mode, retype command to see duration left"); ESP_LOGI("State machine", "Ignition set to standby mode, retype command to see duration left");
if (!can_enabled) if (!can_enabled)
{ {
ESP_LOGD("State machine", "Try to enable CAN Interface"); ESP_LOGD("State machine", "Try to enable CAN Interface");
initCAN(); initCAN();
} }
standbyState = true; standbyState = true;
ignitionState = true; ignitionState = true;
} }
@ -401,49 +396,7 @@ void vSerialConsoleTask(void *pvParameters)
} }
} }
} }
vTaskDelay(50); vTaskDelay(10);
if (millis() - serial_ping >= 10000)
{
serial_ping += 10000;
ESP_LOGI("Serial Console", "Ping, Time %d s", millis() / 1000);
}
unsigned long previousMillis = 0;
long interval = 1000;
if (standbyState)
{
led[0] = CRGB::Yellow;
interval = 500;
}
else if (ignitionState)
{
led[0] = CRGB::Green;
interval = 250;
}
else if (!ignitionState)
{
led[0] = CRGB::Red;
interval = 1000;
}
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval)
{
previousMillis = currentMillis;
if (led_status)
{
FastLED.setBrightness(25);
led_status = false;
}
else
{
FastLED.setBrightness(25);
led_status = true;
}
FastLED.show();
}
} }
} }
@ -453,31 +406,20 @@ void setup()
Serial.setTimeout(5000); Serial.setTimeout(5000);
ESP_LOGI("SYS", "Easylink CAN Waker application starting up..."); ESP_LOGI("SYS", "Easylink CAN Waker application starting up...");
//TCAN Enable CAN Interface
pinMode(16, OUTPUT);
digitalWrite(16, HIGH);
pinMode(23, OUTPUT);
digitalWrite(23, LOW);
CAN.setPins(26, 27);
mutex = xSemaphoreCreateMutex(); mutex = xSemaphoreCreateMutex();
// Print state of variables during bootup //Print state of variables during bootup
ESP_LOGD("SYS", "Print actual variable states"); ESP_LOGD("SYS", "Print actual variable states");
printVariableSummary(); printVariableSummary();
FastLED.addLeds<WS2812, 4, GRB>(led, 1);
ESP_LOGD("SYS", "Init WS2812 LED");
xTaskCreatePinnedToCore(vCANSendTask, "CANSendTask", 8096, NULL, 10, &xCANSendTaskHandle, 0); xTaskCreatePinnedToCore(vCANSendTask, "CANSendTask", 8096, NULL, 10, &xCANSendTaskHandle, 0);
ESP_LOGD("SYS", "Started CANSendTask"); ESP_LOGD("SYS", "Start CANSendTask");
xTaskCreatePinnedToCore(vSerialConsoleTask, "SerialConsoleTask", 8096, NULL, 10, &xSerialConsoleTaskHandle, 1); xTaskCreatePinnedToCore(vSerialConsoleTask, "SerialConsoleTask", 8096, NULL, 10, &xSerialConsoleTaskHandle, 1);
ESP_LOGD("SYS", "Started SerialConsoleTask"); ESP_LOGD("SYS", "Start SerialConsoleTask");
} }
void loop() void loop()
{ {
// We are using tasks instead //We are using tasks instead
} }