Skip to content

Commit

Permalink
SUKU grid_esp32_nvm dependency added, init and erase mechaizem implem…
Browse files Browse the repository at this point in the history
…ented
  • Loading branch information
SukuWc committed Mar 13, 2024
1 parent a8efbc0 commit 44a66fa
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 23 deletions.
2 changes: 2 additions & 0 deletions Firmware/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## IDF Component Manager Manifest File
dependencies:
sukuwc/grid_esp32_led: "*"
sukuwc/grid_esp32_nvm: "*"
sukuwc/grid_common: "*"
joltwallet/littlefs: "*"
## Required IDF version
idf:
version: ">=4.1.0"
Expand Down
37 changes: 28 additions & 9 deletions Firmware/main/midi_host_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ uint8_t grid_platform_get_adc_bit_depth(void) { return 12; }
#include "grid_ui.h"

#include "grid_esp32_led.h"
#include "grid_esp32_nvm.h"

void knot_module_ui_init(struct grid_ain_model* ain, struct grid_led_model* led, struct grid_ui_model* ui) {

Expand Down Expand Up @@ -138,6 +139,13 @@ void knot_lua_ui_init_knot(struct grid_lua_model* mod) {

void app_main(void) {

// MIDI A/B SWITCH AND THROUGH BUTTON INTERACTIVITY
gpio_set_direction(SW_AB_PIN, GPIO_MODE_INPUT);
gpio_set_direction(SW_MODE_PIN, GPIO_MODE_INPUT);

SemaphoreHandle_t nvm_or_port = xSemaphoreCreateBinary();
xSemaphoreGive(nvm_or_port);

ESP_LOGI(TAG, "===== MAIN START =====");

// gpio_set_direction(GRID_ESP32_PINS_MAPMODE, GPIO_MODE_INPUT);
Expand All @@ -163,6 +171,26 @@ void app_main(void) {
grid_led_set_layer_color(&grid_led_state, 1, 2, 0, 0, 0);
grid_led_set_layer_color(&grid_led_state, 2, 2, 0, 0, 0);

// Create the class driver task
TaskHandle_t led_task_hdl;
xTaskCreatePinnedToCore(grid_esp32_led_task, // was led_task
"led", 4096, NULL, LED_TASK_PRIORITY, &led_task_hdl, 0);

ESP_LOGI(TAG, "===== NVM START =====");

xSemaphoreTake(nvm_or_port, 0);
grid_esp32_nvm_init(&grid_esp32_nvm_state);

if (gpio_get_level(SW_MODE_PIN) == 0) {

grid_alert_all_set(&grid_led_state, GRID_LED_COLOR_YELLOW_DIM, 1000);
grid_alert_all_set_frequency(&grid_led_state, 4);
grid_esp32_nvm_erase(&grid_esp32_nvm_state);
vTaskDelay(pdMS_TO_TICKS(1600));
}

xSemaphoreGive(nvm_or_port);

ESP_LOGI(TAG, "===== LUA INIT =====");
grid_lua_init(&grid_lua_state);
grid_lua_set_memory_target(&grid_lua_state, 80); // 80kb
Expand All @@ -188,7 +216,6 @@ void app_main(void) {

TaskHandle_t daemon_task_hdl;
TaskHandle_t class_driver_task_hdl;
TaskHandle_t led_task_hdl;

TaskHandle_t uart_rx_task_hdl;
TaskHandle_t uart_housekeeping_task_hdl;
Expand All @@ -197,10 +224,6 @@ void app_main(void) {
// Create the class driver task
xTaskCreatePinnedToCore(class_driver_task, "class", 4096, (void*)signaling_sem, CLASS_TASK_PRIORITY, &class_driver_task_hdl, 0);

// Create the class driver task
xTaskCreatePinnedToCore(grid_esp32_led_task, // was led_task
"led", 4096, (void*)signaling_sem, LED_TASK_PRIORITY, &led_task_hdl, 0);

// Create a task to handler UART event from ISR

vTaskDelay(10); // Add a short delay to let the tasks run
Expand All @@ -209,10 +232,6 @@ void app_main(void) {

xTaskCreatePinnedToCore(knot_midi_uart_rx_task, "uart_rx", 2048, (void*)signaling_sem, UART_RX_TASK_PRIORITY, &uart_rx_task_hdl, 0);

// MIDI A/B SWITCH AND THROUGH BUTTON INTERACTIVITY
gpio_set_direction(SW_AB_PIN, GPIO_MODE_INPUT);
gpio_set_direction(SW_MODE_PIN, GPIO_MODE_INPUT);

uint8_t last_button_state = 1;
grid_led_set_layer_color(&grid_led_state, 2, GRID_LED_LAYER_UI_A, 0, 255, 0);

Expand Down
2 changes: 1 addition & 1 deletion Firmware/monitor.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
idf.py -b 115200 -p $(ls /dev/ttyUSB* | head -n 1) monitor
idf.py -b 115200 -p $(ls /dev/ttyUSB1 | head -n 1) monitor
Binary file modified Firmware/output/midi_host_fw.uf2
Binary file not shown.
80 changes: 72 additions & 8 deletions Firmware/sdkconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Automatically generated file. DO NOT EDIT.
# Espressif IoT Development Framework (ESP-IDF) Project Configuration
# Espressif IoT Development Framework (ESP-IDF) 5.1.2 Project Configuration
#
CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000
CONFIG_SOC_MPU_REGIONS_MAX_NUM=8
Expand Down Expand Up @@ -103,6 +103,7 @@ CONFIG_SOC_DEDIC_GPIO_IN_CHANNELS_NUM=8
CONFIG_SOC_DEDIC_GPIO_OUT_AUTO_ENABLE=y
CONFIG_SOC_I2C_NUM=2
CONFIG_SOC_I2C_FIFO_LEN=32
CONFIG_SOC_I2C_CMD_REG_NUM=8
CONFIG_SOC_I2C_SUPPORT_SLAVE=y
CONFIG_SOC_I2C_SUPPORT_HW_CLR_BUS=y
CONFIG_SOC_I2C_SUPPORT_XTAL=y
Expand Down Expand Up @@ -296,6 +297,7 @@ CONFIG_SOC_SPI_MEM_SUPPORT_TIME_TUNING=y
CONFIG_SOC_SPI_MEM_SUPPORT_CONFIG_GPIO_BY_EFUSE=y
CONFIG_SOC_SPI_MEM_SUPPORT_WRAP=y
CONFIG_SOC_COEX_HW_PTI=y
CONFIG_SOC_EXTERNAL_COEX_LEADER_TX_LINE=y
CONFIG_SOC_SDMMC_USE_GPIO_MATRIX=y
CONFIG_SOC_SDMMC_NUM_SLOTS=2
CONFIG_SOC_SDMMC_SUPPORT_XTAL_CLOCK=y
Expand All @@ -313,6 +315,7 @@ CONFIG_SOC_BLE_50_SUPPORTED=y
CONFIG_SOC_BLE_DEVICE_PRIVACY_SUPPORTED=y
CONFIG_SOC_BLUFI_SUPPORTED=y
CONFIG_SOC_ULP_HAS_ADC=y
CONFIG_SOC_PHY_COMBO_MODULE=y
CONFIG_IDF_CMAKE=y
CONFIG_IDF_TARGET_ARCH_XTENSA=y
CONFIG_IDF_TARGET_ARCH="xtensa"
Expand Down Expand Up @@ -401,6 +404,9 @@ CONFIG_ESP_ROM_HAS_ETS_PRINTF_BUG=y
CONFIG_ESP_ROM_HAS_NEWLIB_NANO_FORMAT=y
CONFIG_ESP_ROM_NEEDS_SET_CACHE_MMU_SIZE=y
CONFIG_ESP_ROM_RAM_APP_NEEDS_MMU_INIT=y
CONFIG_ESP_ROM_HAS_FLASH_COUNT_PAGES_BUG=y
CONFIG_ESP_ROM_HAS_CACHE_SUSPEND_WAITI_BUG=y
CONFIG_ESP_ROM_HAS_CACHE_WRITEBACK_BUG=y

#
# Boot ROM Behavior
Expand Down Expand Up @@ -578,6 +584,7 @@ CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM=y
#
# GPTimer Configuration
#
CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y
# CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM is not set
# CONFIG_GPTIMER_ISR_IRAM_SAFE is not set
# CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN is not set
Expand Down Expand Up @@ -760,8 +767,8 @@ CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES=4
CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y
CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y
CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y
# CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set
CONFIG_ESP_SLEEP_DEEP_SLEEP_WAKEUP_DELAY=2000
CONFIG_ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS=y
# end of Sleep Config

#
Expand Down Expand Up @@ -820,6 +827,7 @@ CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120
CONFIG_ESP_NETIF_TCPIP_LWIP=y
# CONFIG_ESP_NETIF_LOOPBACK is not set
CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y
# CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS is not set
# CONFIG_ESP_NETIF_L2_TAP is not set
# CONFIG_ESP_NETIF_BRIDGE_EN is not set
# end of ESP NETIF Adapter
Expand Down Expand Up @@ -1014,6 +1022,10 @@ CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER=y
CONFIG_ESP_WIFI_TX_BUFFER_TYPE=1
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=32
CONFIG_ESP_WIFI_STATIC_RX_MGMT_BUFFER=y
# CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER is not set
CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF=0
CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF=5
# CONFIG_ESP_WIFI_CSI_ENABLED is not set
CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y
CONFIG_ESP_WIFI_TX_BA_WIN=6
Expand All @@ -1025,6 +1037,7 @@ CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0=y
CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN=752
CONFIG_ESP_WIFI_MGMT_SBUF_NUM=32
CONFIG_ESP_WIFI_IRAM_OPT=y
# CONFIG_ESP_WIFI_EXTRA_IRAM_OPT is not set
CONFIG_ESP_WIFI_RX_IRAM_OPT=y
CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y
CONFIG_ESP_WIFI_ENABLE_SAE_PK=y
Expand Down Expand Up @@ -1057,6 +1070,7 @@ CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y

# CONFIG_ESP_WIFI_DEBUG_PRINT is not set
# CONFIG_ESP_WIFI_TESTING_OPTIONS is not set
CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=y
# end of Wi-Fi

#
Expand Down Expand Up @@ -1195,12 +1209,14 @@ CONFIG_IEEE802154_PENDING_TABLE_SIZE=20
# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set
# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set
# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set
# CONFIG_LOG_DEFAULT_LEVEL_INFO is not set
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set
CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y
CONFIG_LOG_DEFAULT_LEVEL=5
# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y
CONFIG_LOG_MAXIMUM_LEVEL=5
# CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set
# CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set
CONFIG_LOG_MAXIMUM_LEVEL=3
CONFIG_LOG_COLORS=y
CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y
# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set
Expand All @@ -1211,12 +1227,15 @@ CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y
#
CONFIG_LWIP_LOCAL_HOSTNAME="espressif"
# CONFIG_LWIP_NETIF_API is not set
CONFIG_LWIP_TCPIP_TASK_PRIO=18
# CONFIG_LWIP_TCPIP_CORE_LOCKING is not set
# CONFIG_LWIP_CHECK_THREAD_SAFETY is not set
CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y
# CONFIG_LWIP_L2_TO_L3_COPY is not set
# CONFIG_LWIP_IRAM_OPTIMIZATION is not set
# CONFIG_LWIP_EXTRA_IRAM_OPTIMIZATION is not set
CONFIG_LWIP_TIMERS_ONDEMAND=y
CONFIG_LWIP_ND6=y
CONFIG_LWIP_MAX_SOCKETS=10
# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set
# CONFIG_LWIP_SO_LINGER is not set
Expand Down Expand Up @@ -1347,6 +1366,9 @@ CONFIG_LWIP_HOOK_IP6_ROUTE_NONE=y
CONFIG_LWIP_HOOK_ND6_GET_GW_NONE=y
# CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT is not set
# CONFIG_LWIP_HOOK_ND6_GET_GW_CUSTOM is not set
CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_NONE=y
# CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_DEFAULT is not set
# CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_CUSTOM is not set
CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y
# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set
# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set
Expand Down Expand Up @@ -1393,7 +1415,7 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200
# end of Certificate Bundle

# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set
# CONFIG_MBEDTLS_CMAC_C is not set
CONFIG_MBEDTLS_CMAC_C=y
CONFIG_MBEDTLS_HARDWARE_AES=y
CONFIG_MBEDTLS_AES_USE_INTERRUPT=y
CONFIG_MBEDTLS_HARDWARE_MPI=y
Expand Down Expand Up @@ -1477,12 +1499,12 @@ CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y
CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y
CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y
CONFIG_MBEDTLS_ECP_NIST_OPTIM=y
CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y
# CONFIG_MBEDTLS_POLY1305_C is not set
# CONFIG_MBEDTLS_CHACHA20_C is not set
# CONFIG_MBEDTLS_HKDF_C is not set
# CONFIG_MBEDTLS_THREADING_C is not set
# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set
# CONFIG_MBEDTLS_SECURITY_RISKS is not set
# end of mbedTLS

#
Expand Down Expand Up @@ -1527,6 +1549,20 @@ CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y
# OpenThread
#
# CONFIG_OPENTHREAD_ENABLED is not set

#
# Thread Operational Dataset
#
CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread-ESP"
CONFIG_OPENTHREAD_MESH_LOCAL_PREFIX="fd00:db8:a0:0::/64"
CONFIG_OPENTHREAD_NETWORK_CHANNEL=15
CONFIG_OPENTHREAD_NETWORK_PANID=0x1234
CONFIG_OPENTHREAD_NETWORK_EXTPANID="dead00beef00cafe"
CONFIG_OPENTHREAD_NETWORK_MASTERKEY="00112233445566778899aabbccddeeff"
CONFIG_OPENTHREAD_NETWORK_PSKC="104810e2315100afd6bc9215a6bfac53"
# end of Thread Operational Dataset

CONFIG_OPENTHREAD_XTAL_ACCURACY=130
# end of OpenThread

#
Expand Down Expand Up @@ -1700,6 +1736,7 @@ CONFIG_VFS_SUPPORT_DIR=y
CONFIG_VFS_SUPPORT_SELECT=y
CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y
CONFIG_VFS_SUPPORT_TERMIOS=y
CONFIG_VFS_MAX_COUNT=8

#
# Host File System I/O (Semihosting)
Expand All @@ -1725,6 +1762,33 @@ CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION=y
CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN=y
# CONFIG_WIFI_PROV_STA_FAST_SCAN is not set
# end of Wi-Fi Provisioning Manager

#
# LittleFS
#
# CONFIG_LITTLEFS_SDMMC_SUPPORT is not set
CONFIG_LITTLEFS_MAX_PARTITIONS=3
CONFIG_LITTLEFS_PAGE_SIZE=256
CONFIG_LITTLEFS_OBJ_NAME_LEN=64
CONFIG_LITTLEFS_READ_SIZE=128
CONFIG_LITTLEFS_WRITE_SIZE=128
CONFIG_LITTLEFS_LOOKAHEAD_SIZE=128
CONFIG_LITTLEFS_CACHE_SIZE=512
CONFIG_LITTLEFS_BLOCK_CYCLES=512
CONFIG_LITTLEFS_USE_MTIME=y
# CONFIG_LITTLEFS_USE_ONLY_HASH is not set
# CONFIG_LITTLEFS_HUMAN_READABLE is not set
CONFIG_LITTLEFS_MTIME_USE_SECONDS=y
# CONFIG_LITTLEFS_MTIME_USE_NONCE is not set
# CONFIG_LITTLEFS_SPIFFS_COMPAT is not set
# CONFIG_LITTLEFS_FLUSH_FILE_EVERY_WRITE is not set
# CONFIG_LITTLEFS_FCNTL_GET_PATH is not set
# CONFIG_LITTLEFS_MULTIVERSION is not set
# CONFIG_LITTLEFS_MALLOC_STRATEGY_DISABLE is not set
CONFIG_LITTLEFS_MALLOC_STRATEGY_DEFAULT=y
# CONFIG_LITTLEFS_MALLOC_STRATEGY_INTERNAL is not set
CONFIG_LITTLEFS_ASSERTS=y
# end of LittleFS
# end of Component config

# CONFIG_IDF_EXPERIMENTAL_FEATURES is not set
Expand Down
Loading

0 comments on commit 44a66fa

Please sign in to comment.