ESP32-CAN/main/main.cpp

37 lines
897 B
C++
Raw Normal View History

#include "esp_log.h"
2026-03-16 14:25:49 +00:00
#include "esp_timer.h"
#include <cmath>
2026-03-16 14:25:49 +00:00
#include <cstdint>
#include <stdio.h>
2026-03-16 00:49:02 +00:00
#include "env_sens.h"
#include "freertos/idf_additions.h"
#include "imu.h"
2026-03-16 00:49:02 +00:00
static const constexpr char *TAG = "Main";
2026-03-16 14:25:49 +00:00
extern "C" void app_main(void) {
env_sens::setup();
2026-03-16 00:49:02 +00:00
imu_state imu_state;
BNO08x *imu = setup_imu(&imu_state);
if (imu == nullptr) {
ESP_LOGE(TAG, "IMU setup failed.");
2026-03-16 14:25:49 +00:00
return;
}
2026-03-16 00:49:02 +00:00
ESP_LOGE(TAG, "IMU setup sucess.");
2026-03-16 14:25:49 +00:00
while (1) {
vTaskDelay(pdMS_TO_TICKS(300));
if (xSemaphoreTake(imuStateMutex, pdMS_TO_TICKS(5)) == pdTRUE) {
ESP_LOGI(TAG, "accel - %f, %f, %f", imu_state.accel.x, imu_state.accel.y,
imu_state.accel.z);
ESP_LOGI(TAG, "; euler - %f, %f, %f\n", imu_state.euler_ang.x,
imu_state.euler_ang.y, imu_state.euler_ang.z);
xSemaphoreGive(imuStateMutex);
}
env_sens::dbg_sens();
2026-03-16 00:49:02 +00:00
}
}