The SX1262's NSS, RESET, BUSY and DIO1 sit on the TCA9535 (P0.0..P0.3) while SCK/MISO/MOSI are real GPIOs. IndicatorRadioHal derives from ArduinoHal, keeps hardware FSPI at 4 MHz and maps the virtual pins 0x40..0x43 onto expander transfers; every other pin goes straight to the Arduino pin and interrupt functions, as ArduinoHal does. The meshcomod core is used as is: CustomSX1262 and its wrapper run unchanged on top of the HAL. DIO1 has no GPIO edge. The expander's open-drain /INT on GPIO42 has an IRAM ISR that only notifies a dispatch task, because the read needs I2C and the bus mutex. That task reads both input bytes under the bus lock: the TCA9535 releases /INT only when the port that changed is read, and several port-1 inputs float, so a port-0-only read could leave GPIO42 low for good. Every port-0 byte feeds a small edge detector (Dio1Edge) through the expander's port-0 observer, which calls the callback RadioLib attached to DIO1 once per rise. That callback is the core's setFlag, so TX-done and RX-done reach the core exactly as they would from a DIO1 interrupt. A BUSY poll is a port-0 read as well, and it clears /INT. Sampling DIO1 in those reads means a rise that lands while RadioLib waits on BUSY fires the callback from that read instead of being lost; the dispatch task's next read sees the level already high and does not fire again. The task also re-reads every 50 ms, so a rise whose /INT was missed still fires the callback, at most 50 ms late. MESH_RADIO_DIO1_POLLED is not set: polling the IRQ register would add an SPI transfer, and with it expander writes for NSS, on every pass of the receive path. Floating port-1 inputs can keep /INT toggling, each toggle an I2C read at high priority. The task counts ISR wakes and timeouts and logs them for each of the first six 10 s windows, then only above 500 wakes/s and at most once a minute, so the idle wake rate is visible at bring-up without flooding the console later. TCXO or crystal comes from the radio strap read at boot: the env's SX126X_DIO3_TCXO_VOLTAGE calls indicatorTcxoVoltage(), which returns 2.4 V for the TCXO radio and 0 for the crystal one. radio_init() starts the radio with the strap's setting and, if that fails, with the other one, because std_init only falls back from TCXO to 0 V and a TCXO board whose strap misread as crystal would never start otherwise. main.cpp's one retry runs both again. The log says which voltage was requested and which one the radio came up with. The board reports GPIO42 (indicator::kExpanderIntGpio, shared with the HAL) as its IRQ line and never light-sleeps: the inherited ESP32Board versions would treat the virtual DIO1 pin as a GPIO, and /INT is active low while the light-sleep wake source is high-level. test_indicator_dio1 covers the virtual-pin routing and the once-per-rise rule across dispatch and BUSY reads; run-host-tests.sh gets its include path. Signed-off-by: Confituurke <9595028+Confituurke@users.noreply.github.com>
73 lines
2.7 KiB
Bash
Executable File
73 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build and run every host test in test/.
|
|
#
|
|
# These are plain g++ binaries, no framework: each file documents its own build
|
|
# line in a comment and is compiled standalone. That is cheap and fast, but it
|
|
# also means nothing ever ran them all together -- so test_touch_prefs_schema
|
|
# sat broken for two schema versions (v64 appended two fields and its sums were
|
|
# not updated) without anyone noticing. A static_assert that does not compile is
|
|
# not a guard, and that particular one exists to catch the mid-struct insert
|
|
# that poisoned beta_44 and beta_57. One command, run it before a release.
|
|
#
|
|
# Usage: scripts/run-host-tests.sh
|
|
set -uo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$ROOT" || exit 1
|
|
CXX="${CXX:-g++}"
|
|
STD="-std=c++17"
|
|
OUT="${TMPDIR:-/tmp}/wada-host-tests"
|
|
mkdir -p "$OUT"
|
|
|
|
# Tests needing more than `-I src`. Anything not listed builds with the default.
|
|
extra_flags() {
|
|
case "$1" in
|
|
# Its subject is a board variant header, not shared src/.
|
|
test_crowpanel_sd_codec) echo "-I variants/crowpanel_35" ;;
|
|
test_m9_keyboard) echo "-I test/m9_keyboard_fakes" ;;
|
|
test_indicator_expander|test_indicator_dio1) echo "-I variants/sensecap_indicator" ;;
|
|
*) echo "" ;;
|
|
esac
|
|
}
|
|
|
|
# Not unit tests, with the reason. Kept visible rather than deleted: a silent
|
|
# skip list is how a suite quietly stops covering things.
|
|
skip_reason() {
|
|
case "$1" in
|
|
test_minimp3_decoder)
|
|
echo "takes an .mp3 path on argv; it is a decoder harness, not a unit test" ;;
|
|
test_reader_content)
|
|
# Fixing this means lifting ReaderContent out of UITask.cpp, which is a
|
|
# refactor of a 60k-line file, not a test change. Left failing-by-design
|
|
# and named, so it is a known gap rather than a mystery.
|
|
echo "subject (ReaderContent::htmlToText) is defined inside UITask.cpp, which cannot build on the host" ;;
|
|
*) echo "" ;;
|
|
esac
|
|
}
|
|
|
|
pass=0; fail=0; skip=0; failed=""
|
|
for t in test/test_*.cpp; do
|
|
n="$(basename "$t" .cpp)"
|
|
reason="$(skip_reason "$n")"
|
|
if [ -n "$reason" ]; then
|
|
printf 'SKIP %-34s %s\n' "$n" "$reason"; skip=$((skip+1)); continue
|
|
fi
|
|
# shellcheck disable=SC2046
|
|
if ! $CXX $STD -I src $(extra_flags "$n") -o "$OUT/$n" "$t" > "$OUT/$n.build" 2>&1; then
|
|
printf 'BUILD %-34s %s\n' "$n" "see $OUT/$n.build"
|
|
grep -m2 -E 'error:|Undefined' "$OUT/$n.build" | sed 's/^/ /'
|
|
failed="$failed $n"; fail=$((fail+1)); continue
|
|
fi
|
|
if ! "$OUT/$n" > "$OUT/$n.run" 2>&1; then
|
|
printf 'FAIL %-34s %s\n' "$n" "see $OUT/$n.run"
|
|
tail -3 "$OUT/$n.run" | sed 's/^/ /'
|
|
failed="$failed $n"; fail=$((fail+1)); continue
|
|
fi
|
|
printf 'ok %s\n' "$n"
|
|
pass=$((pass+1))
|
|
done
|
|
|
|
echo
|
|
echo "pass=$pass fail=$fail skip=$skip"
|
|
[ "$fail" -eq 0 ] || { echo "failing:$failed"; exit 1; }
|