Commit Graph

3 Commits

Author SHA1 Message Date
wandering1 74efa671bb feat(ioboard): wire 6 new CubeMX pins into 10-channel DO driver
Flat-expand the board output driver from 4 to 10 channels as decided:
IOBOARD_DO_COUNT 4->10, mask uint8_t->uint16_t, IOBOARD_DO_MASK_ALL
0x03FF.  The 6 new pins keep their bit positions: KO_LED1=PF2(bit4),
KO_LED2=PF3(bit5), KO_24V=PF4(bit6), KO4=PF5(bit7), KO5=PC15(bit8),
KO_LED3=PE6(bit9); the original 4 (KO6/TRIP/ERT/CLZ) keep bit0..3.
Backups-domain PC15 is used as a signal bit only (+/-3 mA limit).

No 24V supply interlock and no LED special-casing: the driver writes
KO_24V as an ordinary bit; callers needing relay power sequencing must
assert it before energizing a channel.  do_write/get/read_level and the
shadow register are all uint16_t; do_apply flushes four port segments
(GPIOC/GPIOF/GPIOC/GPIOE) and do_read_level caches three port ODRs.

UI: UI_DATA_DO_N 4->10, dio_do_mask uint16_t, UI_DATA_VER 3->4 because
dio_do_valid shifts 211->212; feed mask and dio row table extended;
content-page golden references regenerated for 51 rows / 7 pages.
Host ioboard tests 127/127 and ui_data tests 305/305 pass; Keil rebuild
0 errors 0 warnings.  RAM ledger, memory snapshot and size attestation
refilled from the authoritative map.  Docs: ioboard spec v1.2->v1.3 and
the resolved 6-pin question closed out.
2026-11-18 14:25:32 +08:00
wandering1 3e80c301e5 fix(ioboard): repair three judgement bugs in the DI/DO board suite
The suite ran on the bench and reset the target every 56 seconds, right
after the last Phase 3 assertion. Root cause was the suite itself: the
worker thread entry function returned instead of calling vTaskDelete.
Returning from a FreeRTOS task function is undefined behaviour, and on the
Cortex-M4F port the saved LR points at prvTaskExitError, so the return
trips configASSERT. This project routes configASSERT to
vApplicationAssertFailed, which resets the MCU. The assert banner never
reached the console because the reset happened 0.27 s after the last
line, while its bytes were still queued.

Two assertions were also wrong in ways that hid real state:

- The "which relay is commanded" mask was computed as MASK_ALL & ~bit,
  i.e. the complement of what the comment claimed, so the suite reported
  the three idle relays as commanded and failed every Phase 3 row even
  though the shadow register was correct.
- The "other relays stay released" check was written as (a|b)==b, which
  is the same predicate as "at least bit b set" and therefore duplicated
  the check above it instead of testing the remaining channels. It now
  asserts (active & ~only)==0.

Phase counters are also reset on entry to each phase. The report macro
only prints, so without a reset each phase summary carried every earlier
phase's failures and Phase 2 read 44/62 with no failures of its own.

Hard-coded 0x0F masks are replaced by IOBOARD_TEST_DO_MASK_ALL.

Bench result after the fix: the suite completes in about 54 s with one
reset cause line (boot only), and prints Phase 4, the final release check
and "IOBOARD Tests: 17/17 PASSED". Phase 2 moves to 21/21 and Phase 3 to
16/16.

Still unverified, and not claimed as passing: the eight DI channel order
needs a person to short the terminals, and the relay polarity needs a
person to hear the contacts. Note that ioboard_do_read_level reads ODR,
so the Phase 3 level assertions prove write intent propagation, not
electrical actuation.

Keil build with the suite enabled: Code=264880, 0 errors 0 warnings.
Product build after the suite switch is restored: Code=257932, unchanged.
2026-11-16 19:58:52 +08:00
wandering1 10323c4c22 feat(ioboard): board test suite for DI/DO, fix default_task conditional compile
Bench verification of the IO board needs an observation window: production
build has no consumer of ioboard_di_snap_read(), so the DI values were
invisible. Add TEST_SUITE_IOBOARD as a semi-automatic bench sequence and fix
two real bugs found while wiring it in.

New files:
- test/board/ioboard_test.h, test/board/ioboard_test_task.c

Test suite:
- Owns its own thread (iobTest, 4096 words) instead of running in testTask:
  testTask is osPriorityBelowNormal, below defaultTask whose 1ms console
  drain loop can starve a blocking wait in a lower priority context.
- Phases: bit-order self-check, DI eight-point bijection, DO point-by-point
  toggle with operator confirmation, release-all on every exit path.
- Only exit is ioboard_release_all(); it is called from the entry guard,
  every phase failure, the write-failure branch and the thread tail.
- Sample window is 20 reads x 2ms = 40ms and does overlap the 50ms
  production poll. That is stated as harmless in the header: the driver
  wraps the whole read in taskENTER_CRITICAL (26us, not the whole 40ms),
  both sides only read, and a torn cross-reader sample is caught by the
  debounce layer rather than acted upon.

default_task.c fix:
- DEFAULT_TASK_DI_PUBLISH_EN was defined twice: once at file scope and once
  inside default_task_func(). #define has no scope, so the second was a
  redefinition of the first. Collapsed to a single authoritative site.
- Add TEST_SUITE_STORAGE to the disable list: the STORAGE suite owns the
  file system via testTask, and default_task_di_poll() referenced four
  statics that live inside an !TEST_SUITE_STORAGE block, which broke the
  STORAGE build with 11 errors.
- Shrink the !TEST_SUITE_STORAGE block to cover only
  default_task_net_cfg_save_notify() and move the three declarations out;
  move edges/fails into the #else branch so the empty branch references
  none of the four statics.

Registration and gates:
- MDK-ARM/STM32F407-Demo.uvprojx and simulator/CMakeLists.txt entries.
- scripts/check_test_suite.py: whitelist TEST_SUITE_IOBOARD.
- scripts/stack_report.py: let a self-started thread that is not declared in
  Src/freertos.c osThreadAttr_t still be budget checked.
- test/run_all_suites.py: bring the suite into the orchestrator view.

Verified: six-build matrix all 0 errors 0 warnings. CH395F/STORAGE/GD5F/RTC
and the product build are bit-identical at Code=257936; the IOBOARD build is
Code=264640 (+6704), which is the evidence that the suite really enters the
image. Host unit tests 100/100, stack report 1760/4096 words (57%).
2026-11-16 19:35:15 +08:00