mirror of
https://github.com/badgeteam/mch2022-template-app.git
synced 2024-12-22 15:16:35 +00:00
Add better fault indication
This commit is contained in:
parent
5c4e99738c
commit
ecfa663110
1 changed files with 30 additions and 12 deletions
42
main/main.c
42
main/main.c
|
@ -71,6 +71,24 @@ void display_fatal_error(pax_buf_t* pax_buffer, ILI9341* ili9341, const char* li
|
||||||
ili9341_write(ili9341, pax_buffer->buf);
|
ili9341_write(ili9341, pax_buffer->buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stop() {
|
||||||
|
ESP_LOGW(TAG, "*** HALTED ***");
|
||||||
|
gpio_set_direction(GPIO_SD_PWR, GPIO_MODE_OUTPUT);
|
||||||
|
gpio_set_level(GPIO_SD_PWR, 1);
|
||||||
|
ws2812_init(GPIO_LED_DATA);
|
||||||
|
uint8_t led_off[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
uint8_t led_red[15] = {0, 50, 0, 0, 50, 0, 0, 50, 0, 0, 50, 0, 0, 50, 0};
|
||||||
|
uint8_t led_red2[15] = {0, 0xFF, 0, 0, 0xFF, 0, 0, 0xFF, 0, 0, 0xFF, 0, 0, 0xFF, 0};
|
||||||
|
while (true) {
|
||||||
|
ws2812_send_data(led_red2, sizeof(led_red2));
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(200));
|
||||||
|
ws2812_send_data(led_red, sizeof(led_red));
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(200));
|
||||||
|
ws2812_send_data(led_off, sizeof(led_off));
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(200));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void app_main(void) {
|
void app_main(void) {
|
||||||
esp_err_t res;
|
esp_err_t res;
|
||||||
|
|
||||||
|
@ -117,7 +135,7 @@ void app_main(void) {
|
||||||
if (res != ESP_OK) {
|
if (res != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "NVS init failed: %d", res);
|
ESP_LOGE(TAG, "NVS init failed: %d", res);
|
||||||
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "NVS failed to initialize", "Flash may be corrupted", NULL);
|
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "NVS failed to initialize", "Flash may be corrupted", NULL);
|
||||||
esp_restart();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
display_boot_screen(pax_buffer, ili9341, "Starting...");
|
display_boot_screen(pax_buffer, ili9341, "Starting...");
|
||||||
|
@ -125,13 +143,13 @@ void app_main(void) {
|
||||||
if (bsp_rp2040_init() != ESP_OK) {
|
if (bsp_rp2040_init() != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to initialize the RP2040 co-processor");
|
ESP_LOGE(TAG, "Failed to initialize the RP2040 co-processor");
|
||||||
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "RP2040 co-processor error", NULL, NULL);
|
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "RP2040 co-processor error", NULL, NULL);
|
||||||
esp_restart();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
RP2040* rp2040 = get_rp2040();
|
RP2040* rp2040 = get_rp2040();
|
||||||
if (rp2040 == NULL) {
|
if (rp2040 == NULL) {
|
||||||
ESP_LOGE(TAG, "rp2040 is NULL");
|
ESP_LOGE(TAG, "rp2040 is NULL");
|
||||||
esp_restart();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
rp2040_updater(rp2040, pax_buffer, ili9341); // Handle RP2040 firmware update & bootloader mode
|
rp2040_updater(rp2040, pax_buffer, ili9341); // Handle RP2040 firmware update & bootloader mode
|
||||||
|
@ -142,7 +160,7 @@ void app_main(void) {
|
||||||
if (rp2040_get_uid(rp2040, rp2040_uid) != ESP_OK) {
|
if (rp2040_get_uid(rp2040, rp2040_uid) != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to get RP2040 UID");
|
ESP_LOGE(TAG, "Failed to get RP2040 UID");
|
||||||
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "Failed to read UID", NULL, NULL);
|
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "Failed to read UID", NULL, NULL);
|
||||||
esp_restart();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("RP2040 UID: %02X%02X%02X%02X%02X%02X%02X%02X\n", rp2040_uid[0], rp2040_uid[1], rp2040_uid[2], rp2040_uid[3], rp2040_uid[4], rp2040_uid[5], rp2040_uid[6], rp2040_uid[7]);*/
|
printf("RP2040 UID: %02X%02X%02X%02X%02X%02X%02X%02X\n", rp2040_uid[0], rp2040_uid[1], rp2040_uid[2], rp2040_uid[3], rp2040_uid[4], rp2040_uid[5], rp2040_uid[6], rp2040_uid[7]);*/
|
||||||
|
@ -150,13 +168,13 @@ void app_main(void) {
|
||||||
if (bsp_ice40_init() != ESP_OK) {
|
if (bsp_ice40_init() != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to initialize the ICE40 FPGA");
|
ESP_LOGE(TAG, "Failed to initialize the ICE40 FPGA");
|
||||||
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "ICE40 FPGA error", NULL, NULL);
|
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "ICE40 FPGA error", NULL, NULL);
|
||||||
esp_restart();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
ICE40* ice40 = get_ice40();
|
ICE40* ice40 = get_ice40();
|
||||||
if (ice40 == NULL) {
|
if (ice40 == NULL) {
|
||||||
ESP_LOGE(TAG, "ice40 is NULL");
|
ESP_LOGE(TAG, "ice40 is NULL");
|
||||||
esp_restart();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*display_boot_screen(pax_buffer, ili9341, "Initializing BNO055...");
|
/*display_boot_screen(pax_buffer, ili9341, "Initializing BNO055...");
|
||||||
|
@ -164,13 +182,13 @@ void app_main(void) {
|
||||||
if (bsp_bno055_init() != ESP_OK) {
|
if (bsp_bno055_init() != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to initialize the BNO055 position sensor");
|
ESP_LOGE(TAG, "Failed to initialize the BNO055 position sensor");
|
||||||
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "BNO055 sensor error", "Check I2C bus", "Remove SAO and try again");
|
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "BNO055 sensor error", "Check I2C bus", "Remove SAO and try again");
|
||||||
esp_restart();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
BNO055* bno055 = get_bno055();
|
BNO055* bno055 = get_bno055();
|
||||||
if (bno055 == NULL) {
|
if (bno055 == NULL) {
|
||||||
ESP_LOGE(TAG, "bno055 is NULL");
|
ESP_LOGE(TAG, "bno055 is NULL");
|
||||||
esp_restart();
|
stop();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/*display_boot_screen(pax_buffer, ili9341, "Initializing BME680...");
|
/*display_boot_screen(pax_buffer, ili9341, "Initializing BME680...");
|
||||||
|
@ -178,13 +196,13 @@ void app_main(void) {
|
||||||
if (bsp_bme680_init() != ESP_OK) {
|
if (bsp_bme680_init() != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to initialize the BME680 position sensor");
|
ESP_LOGE(TAG, "Failed to initialize the BME680 position sensor");
|
||||||
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "BME680 sensor error", "Check I2C bus", "Remove SAO and try again");
|
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "BME680 sensor error", "Check I2C bus", "Remove SAO and try again");
|
||||||
esp_restart();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
BME680* bme680 = get_bme680();
|
BME680* bme680 = get_bme680();
|
||||||
if (bme680 == NULL) {
|
if (bme680 == NULL) {
|
||||||
ESP_LOGE(TAG, "bme680 is NULL");
|
ESP_LOGE(TAG, "bme680 is NULL");
|
||||||
esp_restart();
|
stop();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
//display_boot_screen(pax_buffer, ili9341, "Initializing AppFS...");
|
//display_boot_screen(pax_buffer, ili9341, "Initializing AppFS...");
|
||||||
|
@ -194,7 +212,7 @@ void app_main(void) {
|
||||||
if (res != ESP_OK) {
|
if (res != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "AppFS init failed: %d", res);
|
ESP_LOGE(TAG, "AppFS init failed: %d", res);
|
||||||
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "AppFS failed to initialize", "Flash may be corrupted", NULL);
|
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "AppFS failed to initialize", "Flash may be corrupted", NULL);
|
||||||
esp_restart();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
//display_boot_screen(pax_buffer, ili9341, "Initializing filesystem...");
|
//display_boot_screen(pax_buffer, ili9341, "Initializing filesystem...");
|
||||||
|
@ -244,7 +262,7 @@ void app_main(void) {
|
||||||
if (res != ESP_OK) {
|
if (res != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to read WebUSB mode: %d", res);
|
ESP_LOGE(TAG, "Failed to read WebUSB mode: %d", res);
|
||||||
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "Failed to read WebUSB mode", NULL, NULL);
|
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "Failed to read WebUSB mode", NULL, NULL);
|
||||||
esp_restart();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG, "WebUSB mode 0x%02X", webusb_mode);
|
ESP_LOGI(TAG, "WebUSB mode 0x%02X", webusb_mode);
|
||||||
|
|
Loading…
Reference in a new issue