diff --git a/.gitignore b/.gitignore index 89cc49c..b33f54f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,8 @@ .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch +build/ +sdkconfig +sdkconfig.old +managed_components/ +dependencies.lock diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..98fd06f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(autofilm) diff --git a/components/board_jc4827w543/CMakeLists.txt b/components/board_jc4827w543/CMakeLists.txt new file mode 100644 index 0000000..cc73554 --- /dev/null +++ b/components/board_jc4827w543/CMakeLists.txt @@ -0,0 +1 @@ +idf_component_register(SRCS "board.c" INCLUDE_DIRS "include" REQUIRES driver) diff --git a/components/board_jc4827w543/board.c b/components/board_jc4827w543/board.c new file mode 100644 index 0000000..c536edf --- /dev/null +++ b/components/board_jc4827w543/board.c @@ -0,0 +1,16 @@ +#include "board.h" + +const char *board_name(void) +{ + return "jc4827w543"; +} + +gpio_num_t board_pin_motor_en(void) +{ + return GPIO_NUM_NC; +} + +int board_motor_en_disable_level(void) +{ + return 1; +} diff --git a/components/board_jc4827w543/include/board.h b/components/board_jc4827w543/include/board.h new file mode 100644 index 0000000..ae9994c --- /dev/null +++ b/components/board_jc4827w543/include/board.h @@ -0,0 +1,5 @@ +#pragma once +#include "driver/gpio.h" +const char *board_name(void); +gpio_num_t board_pin_motor_en(void); +int board_motor_en_disable_level(void); diff --git a/components/board_wroom/CMakeLists.txt b/components/board_wroom/CMakeLists.txt new file mode 100644 index 0000000..cc73554 --- /dev/null +++ b/components/board_wroom/CMakeLists.txt @@ -0,0 +1 @@ +idf_component_register(SRCS "board.c" INCLUDE_DIRS "include" REQUIRES driver) diff --git a/components/board_wroom/board.c b/components/board_wroom/board.c new file mode 100644 index 0000000..b5e712e --- /dev/null +++ b/components/board_wroom/board.c @@ -0,0 +1,16 @@ +#include "board.h" + +const char *board_name(void) +{ + return "wroom"; +} + +gpio_num_t board_pin_motor_en(void) +{ + return (gpio_num_t)27; +} + +int board_motor_en_disable_level(void) +{ + return 1; +} diff --git a/components/board_wroom/include/board.h b/components/board_wroom/include/board.h new file mode 100644 index 0000000..ae9994c --- /dev/null +++ b/components/board_wroom/include/board.h @@ -0,0 +1,5 @@ +#pragma once +#include "driver/gpio.h" +const char *board_name(void); +gpio_num_t board_pin_motor_en(void); +int board_motor_en_disable_level(void); diff --git a/docs/megaplans/REFACTOR-MEGAPLAN.md b/docs/megaplans/REFACTOR-MEGAPLAN.md index 42c308e..03751ca 100644 --- a/docs/megaplans/REFACTOR-MEGAPLAN.md +++ b/docs/megaplans/REFACTOR-MEGAPLAN.md @@ -33,7 +33,7 @@ If blocked: stop, commit nothing broken, write `BLOCKED:` at top of the phase fi | ID | File | Session goal | STATUS | | --- | --- | --- | --- | | P00 | `refactor/P00-docs-lock.md` | Architecture docs already on branch | DONE | -| P01 | `refactor/P01-idf-skeleton.md` | Dual-board IDF project compiles | TODO | +| P01 | `refactor/P01-idf-skeleton.md` | Dual-board IDF project compiles | BLOCKED | | P02 | `refactor/P02-ui-cmd-process.md` | `ui_cmd` + `app_process` + golden tests | TODO | | P03 | `refactor/P03-machine-host.md` | `app_machine` + stub HAL + SM tests | TODO | | P04 | `refactor/P04-gitea-ci.md` | `.gitea/workflows/ci.yml` live | TODO | diff --git a/docs/megaplans/refactor/P01-idf-skeleton.md b/docs/megaplans/refactor/P01-idf-skeleton.md index 2022820..4d5d344 100644 --- a/docs/megaplans/refactor/P01-idf-skeleton.md +++ b/docs/megaplans/refactor/P01-idf-skeleton.md @@ -1,6 +1,7 @@ # P01 — IDF dual-board skeleton -STATUS: TODO +STATUS: BLOCKED +BLOCKED: no IDF (IDF_PATH unset; no idf.py; no docker.io/espressif/idf:v5.4). Sources landed; builds not run; no binaries faked. DEPENDS: P00 READ: `AGENTS.md`, `docs/megaplans/REFACTOR-MEGAPLAN.md`, this file OUT: recipes, UI, motor, Arduino-as-component, Gitea workflow, touching `src/` behaviour diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt new file mode 100644 index 0000000..d4b69d0 --- /dev/null +++ b/main/CMakeLists.txt @@ -0,0 +1,11 @@ +if(NOT DEFINED AUTOFILM_BOARD) + set(AUTOFILM_BOARD wroom CACHE STRING "wroom|jc4827w543") +endif() +if(AUTOFILM_BOARD STREQUAL "wroom") + set(BOARD_COMP board_wroom) +elseif(AUTOFILM_BOARD STREQUAL "jc4827w543") + set(BOARD_COMP board_jc4827w543) +else() + message(FATAL_ERROR "AUTOFILM_BOARD=${AUTOFILM_BOARD}") +endif() +idf_component_register(SRCS "main.c" INCLUDE_DIRS "." REQUIRES ${BOARD_COMP} driver) diff --git a/main/idf_component.yml b/main/idf_component.yml new file mode 100644 index 0000000..c093387 --- /dev/null +++ b/main/idf_component.yml @@ -0,0 +1 @@ +dependencies: {} diff --git a/main/main.c b/main/main.c new file mode 100644 index 0000000..f88670e --- /dev/null +++ b/main/main.c @@ -0,0 +1,28 @@ +#include "board.h" +#include "esp_log.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +static const char *TAG = "app"; + +void app_main(void) +{ + ESP_LOGI(TAG, "board=%s", board_name()); + + gpio_num_t en_pin = board_pin_motor_en(); + if (en_pin != GPIO_NUM_NC) { + gpio_config_t io = { + .pin_bit_mask = 1ULL << en_pin, + .mode = GPIO_MODE_OUTPUT, + .pull_up_en = GPIO_PULLUP_DISABLE, + .pull_down_en = GPIO_PULLDOWN_DISABLE, + .intr_type = GPIO_INTR_DISABLE, + }; + gpio_config(&io); + gpio_set_level(en_pin, board_motor_en_disable_level()); + } + + while (1) { + vTaskDelay(pdMS_TO_TICKS(1000)); + } +} diff --git a/sdkconfig.defaults b/sdkconfig.defaults new file mode 100644 index 0000000..2f7768b --- /dev/null +++ b/sdkconfig.defaults @@ -0,0 +1,3 @@ +CONFIG_ESP_TASK_WDT_EN=y +CONFIG_ESP_TASK_WDT_TIMEOUT_S=10 +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y diff --git a/sdkconfig.s3 b/sdkconfig.s3 new file mode 100644 index 0000000..2f09bc0 --- /dev/null +++ b/sdkconfig.s3 @@ -0,0 +1,4 @@ +CONFIG_IDF_TARGET="esp32s3" +CONFIG_SPIRAM=y +CONFIG_SPIRAM_MODE_OCT=y +CONFIG_SPIRAM_SPEED_80M=y diff --git a/sdkconfig.wroom b/sdkconfig.wroom new file mode 100644 index 0000000..2a43df1 --- /dev/null +++ b/sdkconfig.wroom @@ -0,0 +1 @@ +CONFIG_IDF_TARGET="esp32"