32ESPecial Version 1.00 (#9)

This release reworked the initialization code to provide more robust initialization, especially when no USB stick is present.

It incorporates [Version 1.0 of SystemK](Software/SystemK#9).

This is the first release for the [32ESPecial Blaster Kits](https://link.clubk.club/2025002).

Co-authored-by: Joe Kearney <joe@clubk.club>
Reviewed-on: #9
This commit is contained in:
Joe Kearney 2025-11-30 21:46:46 +00:00
parent 14ec8fe280
commit e12ee17973
67 changed files with 1232 additions and 649 deletions

View file

@ -41,8 +41,8 @@
#include <string.h>
#include <SystemK.h>
#include <SPIFFS.h>
#include <USB.h>
#include <System_Events.h>
#include <NVM.h>
#include <I2S_Audio.h>
#include <Switches.h>
#include <BLE.h>
@ -54,7 +54,6 @@
#include "Reprogramming.h"
static const char *TAG = "KTag 2024A";
static SemaphoreHandle_t init_complete_semaphore;
static const uint16_t INITIALIZATION_TIMEOUT_IN_ms = 10 * 1000;
void app_main(void)
@ -62,7 +61,8 @@ void app_main(void)
KLOG_INFO(TAG, VERSION_AS_STR());
KLOG_INFO(TAG, "Initializing app...");
init_complete_semaphore = xSemaphoreCreateBinary();
Initialize_System_Events();
// Initialize NVS — it is used by both the BLE and WiFi drivers.
esp_err_t ret = nvs_flash_init();
@ -71,19 +71,25 @@ void app_main(void)
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
Initialize_SPIFFS(init_complete_semaphore);
if (xSemaphoreTake(init_complete_semaphore, pdMS_TO_TICKS(INITIALIZATION_TIMEOUT_IN_ms)) != pdTRUE)
if (ret == ESP_OK)
{
KLOG_ERROR(TAG, "Timeout initializing SPIFFS!");
xEventGroupSetBits(Get_System_Events(), SYS_NVS_READY);
KLOG_INFO(TAG, "NVS initialized.");
}
else
{
KLOG_ERROR(TAG, "Error initializing NVS: %s", esp_err_to_name(ret));
}
Initialize_USB(init_complete_semaphore);
if (xSemaphoreTake(init_complete_semaphore, pdMS_TO_TICKS(INITIALIZATION_TIMEOUT_IN_ms)) != pdTRUE)
{
KLOG_ERROR(TAG, "Timeout initializing USB!");
}
Initialize_SPIFFS();
Wait_For_System_Event(SYS_SPIFFS_READY, "Timeout initializing SPIFFS!", INITIALIZATION_TIMEOUT_IN_ms);
Initialize_USB();
Wait_For_System_Event(SYS_USB_FS_PRESENT, "Timeout initializing USB!", INITIALIZATION_TIMEOUT_IN_ms);
Initialize_Settings();
Wait_For_System_Event(SYS_SETTINGS_READY, "Timeout initializing Settings!", INITIALIZATION_TIMEOUT_IN_ms);
if (OTA_File_Exists() == true)
{
@ -94,20 +100,17 @@ void app_main(void)
else
{
Initialize_Audio();
Wait_For_System_Event(SYS_AUDIO_READY, "Timeout initializing Audio!", INITIALIZATION_TIMEOUT_IN_ms);
Initialize_SystemK_NeoPixels(init_complete_semaphore);
if (xSemaphoreTake(init_complete_semaphore, pdMS_TO_TICKS(INITIALIZATION_TIMEOUT_IN_ms)) != pdTRUE)
{
KLOG_ERROR(TAG, "Timeout initializing NeoPixels!");
}
Initialize_SystemK_NeoPixels();
Wait_For_System_Event(SYS_NEOPIXELS_READY, "Timeout initializing NeoPixels!", INITIALIZATION_TIMEOUT_IN_ms);
Initialize_BLE();
Wait_For_System_Event(SYS_BLE_READY, "Timeout initializing BLE!", INITIALIZATION_TIMEOUT_IN_ms);
Initialize_IR();
Wait_For_System_Event(SYS_IR_READY, "Timeout initializing IR!", INITIALIZATION_TIMEOUT_IN_ms);
Initialize_IR(init_complete_semaphore);
if (xSemaphoreTake(init_complete_semaphore, pdMS_TO_TICKS(INITIALIZATION_TIMEOUT_IN_ms)) != pdTRUE)
{
KLOG_ERROR(TAG, "Timeout initializing IR!");
}
if (Initialize_SystemK() != SYSTEMK_RESULT_SUCCESS)
{
KLOG_ERROR(TAG, "Error initializing SystemK!");
@ -116,7 +119,6 @@ void app_main(void)
// Initialize the switches after SystemK, so xQueueEvents will have already been created.
Initialize_Switches();
vSemaphoreDelete(init_complete_semaphore);
KLOG_INFO(TAG, "Initialization complete.");
}