Author SHA1 Message Date
gronod b6c385e09c Mark I03 status DONE
ci / test (pull_request) Successful in 1m14s
ci / test (push) Successful in 1m17s
ci / firmware (wroom, sdkconfig.wroom, esp32) (pull_request) Successful in 3m48s
ci / firmware (jc4827w543, sdkconfig.s3, esp32s3) (pull_request) Successful in 3m57s
ci / firmware (wroom, sdkconfig.wroom, esp32) (push) Successful in 4m4s
ci / firmware (jc4827w543, sdkconfig.s3, esp32s3) (push) Successful in 4m8s
2026-09-16 21:58:26 +01:00
gronod a9f76ea058 Share RMT motor HAL across both boards
ci / test (push) Successful in 1m18s
ci / firmware (wroom, sdkconfig.wroom, esp32) (push) Successful in 4m30s
ci / firmware (jc4827w543, sdkconfig.s3, esp32s3) (push) Successful in 4m39s
2026-09-16 21:51:32 +01:00
gronod c40c714028 Mark I02 status DONE
ci / test (pull_request) Successful in 1m13s
ci / firmware (wroom, sdkconfig.wroom, esp32) (pull_request) Successful in 4m39s
ci / firmware (jc4827w543, sdkconfig.s3, esp32s3) (pull_request) Successful in 4m41s
ci / test (push) Successful in 1m8s
ci / firmware (wroom, sdkconfig.wroom, esp32) (push) Successful in 4m9s
ci / firmware (jc4827w543, sdkconfig.s3, esp32s3) (push) Successful in 4m15s
2026-09-16 21:31:03 +01:00
gronod f87ab0c65f Fix temp_task starvation bug on non-WROOM
ci / test (push) Successful in 1m9s
ci / firmware (wroom, sdkconfig.wroom, esp32) (push) Successful in 4m9s
ci / firmware (jc4827w543, sdkconfig.s3, esp32s3) (push) Successful in 4m10s
2026-09-16 21:21:12 +01:00
gronod b4230b2a0e Share onewire temp HAL across both boards 2026-09-16 21:20:18 +01:00
gronod 04e1ed0f16 Merge pull request 'I01 board pin allocations & accessors' (#12) from feature/integration-I01 into develop
ci / test (push) Successful in 1m14s
ci / firmware (wroom, sdkconfig.wroom, esp32) (push) Successful in 4m46s
ci / firmware (jc4827w543, sdkconfig.s3, esp32s3) (push) Successful in 4m48s
Merge I01 board pin allocations & accessors into develop
2026-09-16 21:15:46 +01:00
11 changed files with 72 additions and 40 deletions
+4 -1
View File
@@ -3,8 +3,11 @@ set(priv_inc)
set(priv_req driver) set(priv_req driver)
if(IDF_TARGET STREQUAL "esp32") if(IDF_TARGET STREQUAL "esp32")
list(APPEND srcs wroom/hal_motor.c) list(APPEND srcs hal_motor.c)
list(APPEND priv_req board_wroom) list(APPEND priv_req board_wroom)
elseif(IDF_TARGET STREQUAL "esp32s3")
list(APPEND srcs hal_motor.c)
list(APPEND priv_req board_jc4827w543)
else() else()
list(APPEND srcs stub/hal_motor.c) list(APPEND srcs stub/hal_motor.c)
endif() endif()
@@ -10,9 +10,9 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#define PIN_STEP 12 #include "board.h"
#define PIN_DIR 14 #include "hal_motor.h"
#define PIN_EN 27
#define STEPS_PER_REV 4800 #define STEPS_PER_REV 4800
#define DEFAULT_RPM 60 #define DEFAULT_RPM 60
#define ACCEL 9600 #define ACCEL 9600
@@ -23,6 +23,10 @@
static const char *TAG = "motor"; static const char *TAG = "motor";
static gpio_num_t s_pin_en = GPIO_NUM_NC;
static gpio_num_t s_pin_dir = GPIO_NUM_NC;
static gpio_num_t s_pin_step = GPIO_NUM_NC;
static int s_en_disable_level = 1;
static TaskHandle_t s_task; static TaskHandle_t s_task;
static atomic_uint s_stop_req; static atomic_uint s_stop_req;
static float s_cw; static float s_cw;
@@ -35,13 +39,17 @@ static rmt_encoder_handle_t s_enc;
static void en_disable(void) static void en_disable(void)
{ {
gpio_set_level((gpio_num_t)PIN_EN, 1); if (s_pin_en != GPIO_NUM_NC) {
gpio_set_level(s_pin_en, s_en_disable_level);
}
s_enabled = false; s_enabled = false;
} }
static void en_enable(void) static void en_enable(void)
{ {
gpio_set_level((gpio_num_t)PIN_EN, 0); if (s_pin_en != GPIO_NUM_NC) {
gpio_set_level(s_pin_en, !s_en_disable_level);
}
s_enabled = true; s_enabled = true;
} }
@@ -111,7 +119,7 @@ static bool run_move(long steps)
if (steps < 0) { if (steps < 0) {
steps = -steps; steps = -steps;
} }
gpio_set_level((gpio_num_t)PIN_DIR, dir); gpio_set_level(s_pin_dir, dir);
uint32_t cruise = (s_rpm * STEPS_PER_REV) / 60; uint32_t cruise = (s_rpm * STEPS_PER_REV) / 60;
if (cruise == 0) { if (cruise == 0) {
@@ -189,22 +197,31 @@ void hal_motor_init(void)
if (s_inited) { if (s_inited) {
return; return;
} }
s_pin_en = board_pin_motor_en();
s_pin_dir = board_pin_motor_dir();
s_pin_step = board_pin_motor_step();
s_en_disable_level = board_motor_en_disable_level();
if (s_pin_en == GPIO_NUM_NC || s_pin_dir == GPIO_NUM_NC || s_pin_step == GPIO_NUM_NC) {
ESP_LOGW(TAG, "no motor pins on this board");
s_inited = true;
return;
}
gpio_config_t io = { gpio_config_t io = {
.pin_bit_mask = (1ULL << PIN_EN) | (1ULL << PIN_DIR), .pin_bit_mask = (1ULL << s_pin_en) | (1ULL << s_pin_dir),
.mode = GPIO_MODE_OUTPUT, .mode = GPIO_MODE_OUTPUT,
.pull_up_en = GPIO_PULLUP_DISABLE, .pull_up_en = GPIO_PULLUP_DISABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE, .pull_down_en = GPIO_PULLDOWN_DISABLE,
.intr_type = GPIO_INTR_DISABLE, .intr_type = GPIO_INTR_DISABLE,
}; };
gpio_config(&io); gpio_config(&io);
gpio_set_level((gpio_num_t)PIN_EN, 1); gpio_set_level(s_pin_en, s_en_disable_level);
gpio_set_level((gpio_num_t)PIN_DIR, 0); gpio_set_level(s_pin_dir, 0);
s_enabled = false; s_enabled = false;
atomic_store(&s_stop_req, 0); atomic_store(&s_stop_req, 0);
rmt_tx_channel_config_t txcfg = { rmt_tx_channel_config_t txcfg = {
.clk_src = RMT_CLK_SRC_DEFAULT, .clk_src = RMT_CLK_SRC_DEFAULT,
.gpio_num = PIN_STEP, .gpio_num = s_pin_step,
.mem_block_symbols = 64, .mem_block_symbols = 64,
.resolution_hz = RMT_RES_HZ, .resolution_hz = RMT_RES_HZ,
.trans_queue_depth = 4, .trans_queue_depth = 4,
@@ -219,7 +236,8 @@ void hal_motor_init(void)
configMAX_PRIORITIES - 2, &s_task, 0); configMAX_PRIORITIES - 2, &s_task, 0);
} }
s_inited = true; s_inited = true;
ESP_LOGI(TAG, "init EN=HIGH RMT step=%d dir=%d", PIN_STEP, PIN_DIR); ESP_LOGI(TAG, "init en=%d step=%d dir=%d dis_lvl=%d",
s_pin_en, s_pin_step, s_pin_dir, s_en_disable_level);
} }
void hal_motor_enable(bool on) void hal_motor_enable(bool on)
@@ -234,8 +252,7 @@ void hal_motor_enable(bool on)
void hal_motor_request_stop(void) void hal_motor_request_stop(void)
{ {
atomic_store(&s_stop_req, 1); atomic_store(&s_stop_req, 1);
gpio_set_level((gpio_num_t)PIN_EN, 1); en_disable();
s_enabled = false;
rmt_abort(); rmt_abort();
if (s_task != NULL) { if (s_task != NULL) {
xTaskNotifyGive(s_task); xTaskNotifyGive(s_task);
+4 -1
View File
@@ -3,8 +3,11 @@ set(priv_inc)
set(priv_req driver) set(priv_req driver)
if(IDF_TARGET STREQUAL "esp32") if(IDF_TARGET STREQUAL "esp32")
list(APPEND srcs wroom/hal_temp.c) list(APPEND srcs hal_temp.c)
list(APPEND priv_req board_wroom onewire_bus) list(APPEND priv_req board_wroom onewire_bus)
elseif(IDF_TARGET STREQUAL "esp32s3")
list(APPEND srcs hal_temp.c)
list(APPEND priv_req board_jc4827w543 onewire_bus)
else() else()
list(APPEND srcs stub/hal_temp.c) list(APPEND srcs stub/hal_temp.c)
endif() endif()
@@ -8,8 +8,9 @@
#include "freertos/task.h" #include "freertos/task.h"
#include "onewire_bus.h" #include "onewire_bus.h"
#include "board.h"
#include "hal_temp.h"
#define PIN_DS 13
#define TEMP_OFFSET 0.4f #define TEMP_OFFSET 0.4f
#define CMD_SKIP_ROM 0xCC #define CMD_SKIP_ROM 0xCC
#define CMD_CONVERT_T 0x44 #define CMD_CONVERT_T 0x44
@@ -40,7 +41,7 @@ static bool scratch_valid(const uint8_t *sp)
return crc == sp[8]; return crc == sp[8];
} }
void autofilm_temp_tick(void) void hal_temp_tick(void)
{ {
if (s_bus == NULL) { if (s_bus == NULL) {
s_last_ok = false; s_last_ok = false;
@@ -84,21 +85,19 @@ void autofilm_temp_tick(void)
s_last_ok = true; s_last_ok = true;
} }
void autofilm_temp_task(void *arg)
{
(void)arg;
for (;;) {
autofilm_temp_tick();
}
}
void hal_temp_init(void) void hal_temp_init(void)
{ {
if (s_inited) { if (s_inited) {
return; return;
} }
gpio_num_t pin = board_pin_temp();
if (pin == GPIO_NUM_NC) {
ESP_LOGW(TAG, "no temp pin on this board");
s_inited = true;
return;
}
onewire_bus_config_t bus_config = { onewire_bus_config_t bus_config = {
.bus_gpio_num = PIN_DS, .bus_gpio_num = pin,
.flags = { .flags = {
.en_pull_up = true, .en_pull_up = true,
}, },
@@ -108,12 +107,12 @@ void hal_temp_init(void)
}; };
if (onewire_new_bus_rmt(&bus_config, &rmt_config, &s_bus) != ESP_OK) { if (onewire_new_bus_rmt(&bus_config, &rmt_config, &s_bus) != ESP_OK) {
s_bus = NULL; s_bus = NULL;
ESP_LOGE(TAG, "onewire_bus install failed pin=%d", PIN_DS); ESP_LOGE(TAG, "onewire_bus install failed pin=%d", pin);
} }
s_last_ok = false; s_last_ok = false;
s_last_c = 0.0f; s_last_c = 0.0f;
s_inited = true; s_inited = true;
ESP_LOGI(TAG, "init onewire_bus pin=%d offset=%.1f", PIN_DS, (double)TEMP_OFFSET); ESP_LOGI(TAG, "init onewire_bus pin=%d offset=%.1f", pin, (double)TEMP_OFFSET);
} }
esp_err_t hal_temp_read_c(float *out) esp_err_t hal_temp_read_c(float *out)
+1
View File
@@ -7,4 +7,5 @@
#endif #endif
void hal_temp_init(void); void hal_temp_init(void);
void hal_temp_tick(void); /* blocking conversion poll; blocks >=750 ms */
esp_err_t hal_temp_read_c(float *out); /* ESP_FAIL → disconnected */ esp_err_t hal_temp_read_c(float *out); /* ESP_FAIL → disconnected */
+8
View File
@@ -1,9 +1,17 @@
#include "hal_temp.h" #include "hal_temp.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
void hal_temp_init(void) void hal_temp_init(void)
{ {
} }
void hal_temp_tick(void)
{
vTaskDelay(pdMS_TO_TICKS(750));
}
esp_err_t hal_temp_read_c(float *out) esp_err_t hal_temp_read_c(float *out)
{ {
(void)out; (void)out;
+2 -2
View File
@@ -36,6 +36,6 @@ If blocked: stop, commit nothing broken, write `BLOCKED:` at top of the phase fi
| ID | File | Session goal | STATUS | | ID | File | Session goal | STATUS |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| I01 | `integration/I01-board-configs.md` | Board pin allocations & accessors | DONE | | I01 | `integration/I01-board-configs.md` | Board pin allocations & accessors | DONE |
| I02 | `integration/I02-temp-fix.md` | Temp HAL shared & starvation fix | TODO | | I02 | `integration/I02-temp-fix.md` | Temp HAL shared & starvation fix | DONE |
| I03 | `integration/I03-motor-hal.md` | Motor HAL shared across boards | TODO | | I03 | `integration/I03-motor-hal.md` | Motor HAL shared across boards | DONE |
| I04 | `integration/I04-audio-i2s.md` | I2S audio implementation for S3 | TODO | | I04 | `integration/I04-audio-i2s.md` | I2S audio implementation for S3 | TODO |
+5 -4
View File
@@ -1,5 +1,6 @@
STATUS: TODO STATUS: DONE
DEPENDS: I01 DEPENDS: I01
Notes: Poll API named `hal_temp_tick` (declared in hal_temp.h). `idf.py build` for both targets verified via CI run 38616 (no local IDF). S3 flash watchdog check not run — no device attached to this machine.
**READ:** `docs/megaplans/INTEGRATION-MEGAPLAN.md`, `main/main.c`, `components/hal_temp/*` **READ:** `docs/megaplans/INTEGRATION-MEGAPLAN.md`, `main/main.c`, `components/hal_temp/*`
@@ -17,6 +18,6 @@ DEPENDS: I01
2. `Fix temp_task starvation bug on non-WROOM` 2. `Fix temp_task starvation bug on non-WROOM`
**DoD checkboxes:** **DoD checkboxes:**
- [ ] `hal_temp` generalized to use board accessors. - [x] `hal_temp` generalized to use board accessors.
- [ ] `temp_task` starvation bug fixed. - [x] `temp_task` starvation bug fixed.
- [ ] Build succeeds on both targets. - [x] Build succeeds on both targets.
+1 -1
View File
@@ -1,4 +1,4 @@
STATUS: TODO STATUS: DONE
DEPENDS: I01 DEPENDS: I01
**READ:** `docs/megaplans/INTEGRATION-MEGAPLAN.md`, `components/hal_motor/*` **READ:** `docs/megaplans/INTEGRATION-MEGAPLAN.md`, `components/hal_motor/*`
+1 -5
View File
@@ -28,8 +28,6 @@ static const char *TAG = "app";
#if defined(AUTOFILM_BOARD_WROOM) || defined(AUTOFILM_BOARD_S3) #if defined(AUTOFILM_BOARD_WROOM) || defined(AUTOFILM_BOARD_S3)
static QueueHandle_t s_cmdq; static QueueHandle_t s_cmdq;
extern void autofilm_temp_tick(void);
static void map_and_post_key(char key) static void map_and_post_key(char key)
{ {
ui_cmd_t cmd; ui_cmd_t cmd;
@@ -168,9 +166,7 @@ static void temp_task(void *arg)
(void)arg; (void)arg;
esp_task_wdt_add(NULL); esp_task_wdt_add(NULL);
for (;;) { for (;;) {
#ifdef AUTOFILM_BOARD_WROOM hal_temp_tick();
autofilm_temp_tick();
#endif
float c = 0.0f; float c = 0.0f;
bool ok = (hal_temp_read_c(&c) == ESP_OK); bool ok = (hal_temp_read_c(&c) == ESP_OK);
app_machine_on_temp(ok ? c : 0.0f, ok); app_machine_on_temp(ok ? c : 0.0f, ok);
+4
View File
@@ -10,6 +10,10 @@ void hal_temp_init(void)
stub_temp_c = 20.0f; stub_temp_c = 20.0f;
} }
void hal_temp_tick(void)
{
}
esp_err_t hal_temp_read_c(float *out) esp_err_t hal_temp_read_c(float *out)
{ {
if (stub_temp_fail) { if (stub_temp_fail) {