forked from test34/can_wizard
fix logs while canup + make curr_can_state volatile
This commit is contained in:
parent
4315b513d7
commit
c3594ab41e
3 changed files with 6 additions and 2 deletions
|
@ -14,7 +14,7 @@ static const char* LOG_TAG = "can";
|
||||||
bool is_error_passive = false;
|
bool is_error_passive = false;
|
||||||
|
|
||||||
SemaphoreHandle_t can_mutex;
|
SemaphoreHandle_t can_mutex;
|
||||||
can_status_t curr_can_state = { 0 };
|
volatile can_status_t curr_can_state = { 0 };
|
||||||
|
|
||||||
static can_status_t get_can_state() {
|
static can_status_t get_can_state() {
|
||||||
can_status_t result;
|
can_status_t result;
|
||||||
|
|
|
@ -51,7 +51,7 @@ static const twai_general_config_t g_config = {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SemaphoreHandle_t can_mutex;
|
extern SemaphoreHandle_t can_mutex;
|
||||||
extern can_status_t curr_can_state;
|
extern volatile can_status_t curr_can_state;
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "cmd_can.h"
|
#include "cmd_can.h"
|
||||||
|
#include "esp_log.h"
|
||||||
#include "freertos/portmacro.h"
|
#include "freertos/portmacro.h"
|
||||||
#include "inttypes.h"
|
#include "inttypes.h"
|
||||||
#include "driver/twai.h"
|
#include "driver/twai.h"
|
||||||
|
@ -116,6 +117,8 @@ static int canstats(int argc, char **argv) {
|
||||||
|
|
||||||
static int canup(int argc, char **argv) {
|
static int canup(int argc, char **argv) {
|
||||||
esp_err_t res;
|
esp_err_t res;
|
||||||
|
esp_log_level_t prev_gpio_lvl = esp_log_level_get("gpio");
|
||||||
|
esp_log_level_set("gpio", ESP_LOG_ERROR);
|
||||||
xSemaphoreTake(can_mutex, portMAX_DELAY);
|
xSemaphoreTake(can_mutex, portMAX_DELAY);
|
||||||
// Install CAN driver
|
// Install CAN driver
|
||||||
// TODO: add CAN filtering
|
// TODO: add CAN filtering
|
||||||
|
@ -130,6 +133,7 @@ static int canup(int argc, char **argv) {
|
||||||
res = twai_start();
|
res = twai_start();
|
||||||
printf("CAN driver started\n");
|
printf("CAN driver started\n");
|
||||||
xSemaphoreGive(can_mutex);
|
xSemaphoreGive(can_mutex);
|
||||||
|
esp_log_level_set("gpio", prev_gpio_lvl);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue