diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8e8c8e75..2adf56d5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1316,11 +1316,13 @@ jobs: - name: Unpack the ESP32 firmware run: | gunzip firmware-esp32.gz + gunzip firmware-esp32s3.gz - name: Test Raspberry Pi env: TOIT_EXE_HW: ${{ github.workspace }}/rpi/toit/bin/toit ESP32_ENVELOPE: ${{ github.workspace }}/firmware-esp32 + ESP32S3_ENVELOPE: ${{ github.workspace }}/firmware-esp32s3 run: | # Get the pin configuration from the file in the runner's home. source $HOME/pi-test.env diff --git a/tests/hw/CMakeLists.txt b/tests/hw/CMakeLists.txt index 2a2997fd0..08c518441 100644 --- a/tests/hw/CMakeLists.txt +++ b/tests/hw/CMakeLists.txt @@ -19,7 +19,8 @@ project(hw NONE) # No need for compilers. add_custom_target( check_hw - COMMAND ${CMAKE_CTEST_COMMAND} -j1 -T test -C hw --output-on-failure + # The current Raspberry Pi can't run more than 2 tests in parallel. + COMMAND ${CMAKE_CTEST_COMMAND} -j2 -T test -C hw --output-on-failure USES_TERMINAL ) diff --git a/tests/hw/esp-tester/tester.toit b/tests/hw/esp-tester/tester.toit index e7e03e90b..be0b926b8 100644 --- a/tests/hw/esp-tester/tester.toit +++ b/tests/hw/esp-tester/tester.toit @@ -164,13 +164,13 @@ class TestDevice: finally: read-task = null + if port: + port.close + port = null close: if read-task: read-task.cancel - if port: - port.close - port = null if file.is-directory tmp-dir: directory.rmdir --recursive tmp-dir diff --git a/tests/hw/esp32/CMakeLists.txt b/tests/hw/esp32/CMakeLists.txt index 68c8f67a9..46db2f074 100644 --- a/tests/hw/esp32/CMakeLists.txt +++ b/tests/hw/esp32/CMakeLists.txt @@ -20,70 +20,117 @@ set(TESTER ${CMAKE_CURRENT_SOURCE_DIR}/../esp-tester/tester.toit) add_custom_target( check_esp32 - COMMAND ${CMAKE_CTEST_COMMAND} -j1 -T test -C esp32 --output-on-failure + COMMAND ${CMAKE_CTEST_COMMAND} -j2 -T test -C esp32 --output-on-failure USES_TERMINAL ) -foreach(board board1 board2) - if (board STREQUAL "board1") - set(port "$ENV{ESP32_BOARD1_PORT}") - else() - set(port "$ENV{ESP32_BOARD2_PORT}") - endif() - add_test( - NAME "setup-${board}" - COMMAND "${TOIT_EXE_HW}" "${TESTER}" setup - --verbose - --toit-exe "${TOIT_EXE_HW}" - --port "${port}" - --envelope "$ENV{ESP32_ENVELOPE}" - --wifi-ssid "$ENV{ESP32_WIFI_SSID}" - --wifi-password "$ENV{ESP32_WIFI_PASSWORD}" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - CONFIGURATIONS esp32 hw - ) - - set_tests_properties("setup-${board}" PROPERTIES TIMEOUT 80) - set_tests_properties("setup-${board}" PROPERTIES FIXTURES_SETUP "setup-boards") -endforeach() +add_custom_target( + check_esp32s3 + COMMAND ${CMAKE_CTEST_COMMAND} -j2 -T test -C esp32s3 --output-on-failure + USES_TERMINAL +) + +include(fail.cmake OPTIONAL) + +set(VARIANTS + esp32 + esp32s3 + ) + +foreach(esp_variant ${VARIANTS}) + string(TOUPPER ${esp_variant} ESP_VARIANT) + foreach(board board1 board2) + string(TOUPPER ${board} BOARD) + set(port "$ENV{${ESP_VARIANT}_${BOARD}_PORT}") + set(test_name "setup-${board}-${esp_variant}") + add_test( + NAME ${test_name} + COMMAND "${TOIT_EXE_HW}" "${TESTER}" setup + --verbose + --toit-exe "${TOIT_EXE_HW}" + --port "${port}" + --envelope "$ENV{${ESP_VARIANT}_ENVELOPE}" + # Typically the SSID and password are the same for all variants, but + # this makes it more consistent. + --wifi-ssid "$ENV{${ESP_VARIANT}_WIFI_SSID}" + --wifi-password "$ENV{${ESP_VARIANT}_WIFI_PASSWORD}" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + CONFIGURATIONS ${esp_variant} hw + ) -foreach(file ${SINGLE_TESTS}) - get_filename_component(name ${file} NAME_WE) - set(toit_file ${CMAKE_CURRENT_SOURCE_DIR}/${file}) - set(test_name ${name}) - - add_test( - NAME ${file} - COMMAND ${TOIT_EXE_HW} "${TESTER}" run ${toit_file} - --verbose - --toit-exe "${TOIT_EXE_HW}" - --port-board1 "$ENV{ESP32_BOARD1_PORT}" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - CONFIGURATIONS esp32 - ) - - set_tests_properties(${file} PROPERTIES TIMEOUT 120) - set_tests_properties(${file} PROPERTIES FIXTURES_REQUIRED "setup-boards") + set_tests_properties("${test_name}" PROPERTIES TIMEOUT 80) + set_tests_properties("${test_name}" PROPERTIES FIXTURES_SETUP "setup-boards-${esp_variant}") + endforeach() endforeach() -foreach(file ${MULTI_TESTS}) - get_filename_component(name ${file} NAME_WE) - set(toit_file ${CMAKE_CURRENT_SOURCE_DIR}/${file}) - set(test_name ${name}) - - string(REPLACE "board1" "board2" toit_file_board2 ${toit_file}) - - add_test( - NAME ${file} - COMMAND ${TOIT_EXE_HW} "${TESTER}" run ${toit_file} ${toit_file_board2} - --verbose - --toit-exe "${TOIT_EXE_HW}" - --port-board1 "$ENV{ESP32_BOARD1_PORT}" - --port-board2 "$ENV{ESP32_BOARD2_PORT}" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - CONFIGURATIONS esp32 hw - ) - - set_tests_properties(${file} PROPERTIES TIMEOUT 120) - set_tests_properties(${file} PROPERTIES FIXTURES_REQUIRED "setup-boards") +foreach(esp_variant ${VARIANTS}) + string(TOUPPER ${esp_variant} ESP_VARIANT) + foreach(file ${SINGLE_TESTS}) + set(toit_file ${CMAKE_CURRENT_SOURCE_DIR}/${file}) + set(test_name ${file}-${esp_variant}) + + if ("${test_name}" IN_LIST TOIT_SKIP_TESTS) + continue() + endif() + + set(failing FALSE) + if ("${test_name}" IN_LIST TOIT_FAILING_TESTS) + set(test_name "${test_name}-failing") + set(failing TRUE) + endif() + + add_test( + NAME ${test_name} + COMMAND ${TOIT_EXE_HW} "${TESTER}" run ${toit_file} + --verbose + --toit-exe "${TOIT_EXE_HW}" + --port-board1 "$ENV{${ESP_VARIANT}_BOARD1_PORT}" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + CONFIGURATIONS ${esp_variant} hw + ) + + set_tests_properties(${test_name} PROPERTIES TIMEOUT 120) + set_tests_properties(${test_name} PROPERTIES FIXTURES_REQUIRED "setup-boards-${esp_variant}") + set_tests_properties(${test_name} PROPERTIES RESOURCE_LOCK ${esp_variant}) + + if (${failing}) + set_tests_properties(${test_name} PROPERTIES WILL_FAIL TRUE) + endif() + endforeach() + + foreach(file ${MULTI_TESTS}) + set(toit_file ${CMAKE_CURRENT_SOURCE_DIR}/${file}) + set(test_name ${file}-${esp_variant}) + + if ("${test_name}" IN_LIST TOIT_SKIP_TESTS) + continue() + endif() + + set(failing FALSE) + if ("${test_name}" IN_LIST TOIT_FAILING_TESTS) + set(test_name "${test_name}-failing") + set(failing TRUE) + endif() + + string(REPLACE "board1" "board2" toit_file_board2 ${toit_file}) + + add_test( + NAME "${test_name}" + COMMAND ${TOIT_EXE_HW} "${TESTER}" run ${toit_file} ${toit_file_board2} + --verbose + --toit-exe "${TOIT_EXE_HW}" + --port-board1 "$ENV{${ESP_VARIANT}_BOARD1_PORT}" + --port-board2 "$ENV{${ESP_VARIANT}_BOARD2_PORT}" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + CONFIGURATIONS ${esp_variant} hw + ) + + set_tests_properties("${test_name}" PROPERTIES TIMEOUT 120) + set_tests_properties("${test_name}" PROPERTIES FIXTURES_REQUIRED "setup-boards-${esp_variant}") + set_tests_properties("${test_name}" PROPERTIES RESOURCE_LOCK ${esp_variant}) + + if (${failing}) + set_tests_properties("${test_name}" PROPERTIES WILL_FAIL TRUE) + endif() + endforeach() endforeach() diff --git a/tests/hw/esp32/adc-test.toit b/tests/hw/esp32/adc-test.toit index c87869a77..b9cde27ee 100644 --- a/tests/hw/esp32/adc-test.toit +++ b/tests/hw/esp32/adc-test.toit @@ -12,22 +12,16 @@ On Jaguar use: `jag container install -D jag.disabled -D jag.timeout=1m adc adc.toit` -Setup: -Connect pin 12 to pin 14 with a 330 Ohm resistor. -Connect pin 14 to pin 32 with a 330 Ohm resistor. -Connect pin 32 to pin 25 with a 330 Ohm resistor. +For the setup, see the documentation at $Variant.adc1-pin. */ import gpio.adc as gpio import gpio +import system import expect show * import .test - -ADC1-PIN ::= 32 -ADC2-PIN ::= 14 -CONTROL-PIN ::= 25 -V33-PIN ::= 12 +import .variants main: run-test: test @@ -35,20 +29,23 @@ main: test: test-restricted := true - v33-pin := gpio.Pin V33-PIN --output + v33-pin := gpio.Pin Variant.CURRENT.adc-v33-pin --output v33-pin.set 1 - adc1-pin := gpio.Pin ADC1-PIN - control-pin := gpio.Pin CONTROL-PIN --output + adc1-pin := gpio.Pin Variant.CURRENT.adc1-pin + control-pin := gpio.Pin Variant.CURRENT.adc-control-pin --output adc := gpio.Adc adc1-pin control-pin.set 0 + // The resistors create a voltage divider of ration 2/3. value := adc.get - expect 1.0 < value < 1.2 + print value + expect 0.9 < value < 1.2 raw-value := adc.get --raw - expect 1115 < raw-value < 1500 + print raw-value + expect 1100 < raw-value < 1500 control-pin.set 1 // The voltage is now 3.3V. @@ -77,9 +74,9 @@ test: if not test-restricted: return print "Testing restricted ADC" print "This only works if no WiFi is running" - print "There are other restrictings." + print "There are other restrictions." - adc2-pin := gpio.Pin ADC2-PIN + adc2-pin := gpio.Pin Variant.CURRENT.adc2-pin expect-throw "OUT_OF_RANGE": adc = gpio.Adc adc2-pin diff --git a/tests/hw/esp32/ble1-shared.toit b/tests/hw/esp32/ble1-shared.toit index 212314d8a..d33c12c77 100644 --- a/tests/hw/esp32/ble1-shared.toit +++ b/tests/hw/esp32/ble1-shared.toit @@ -15,9 +15,10 @@ import monitor import .ble-util import .test +import .variants -SERVICE-TEST ::= BleUuid "df451d2d-e899-4346-a8fd-bca9cbfebc0b" -SERVICE-TEST2 ::= BleUuid "94a11d6a-fa23-4a09-aa6f-2ca0b7cdbb70" +SERVICE-TEST ::= BleUuid Variant.CURRENT.ble1-service +SERVICE-TEST2 ::= BleUuid Variant.CURRENT.ble1-service2 CHARACTERISTIC-READ-ONLY ::= BleUuid "77d0b04e-bf49-4048-a4cd-fb46be32ebd0" CHARACTERISTIC-READ-ONLY-CALLBACK ::= BleUuid "9e9f578c-745b-41ec-b0f6-7773157bb5a9" diff --git a/tests/hw/esp32/ble2-shared.toit b/tests/hw/esp32/ble2-shared.toit index 17614467e..dff0078e2 100644 --- a/tests/hw/esp32/ble2-shared.toit +++ b/tests/hw/esp32/ble2-shared.toit @@ -15,8 +15,9 @@ import monitor import .ble-util import .test +import .variants -SERVICE-TEST ::= BleUuid "a1bcf0ba-7557-4968-91f8-6b0f187af2b5" +SERVICE-TEST ::= BleUuid Variant.CURRENT.ble2-service CHARACTERISTIC-WRITE-ONLY ::= BleUuid "c8aa5ee4-f93e-48cd-b32c-703965a8798f" CHARACTERISTIC-WRITE-ONLY-WITH-RESPONSE ::= BleUuid "a59d8140-9e81-4a87-aa40-e9c6cab3ed52" diff --git a/tests/hw/esp32/ble3-shared.toit b/tests/hw/esp32/ble3-shared.toit index d4ac93dc4..e37ab240c 100644 --- a/tests/hw/esp32/ble3-shared.toit +++ b/tests/hw/esp32/ble3-shared.toit @@ -22,11 +22,12 @@ import monitor import .ble-util import .test +import .variants ITERATIONS ::= 100 UUIDS ::= [ - "ffe21239-d8a2-4536-b751-0881a9f2e3de", + Variant.CURRENT.ble3-first-service, "9e3d1c10-9421-499e-851d-8e6bf2bd8808", "f626e5c8-1551-4e64-861c-25705f35f8c2", "417b7728-8ccf-4b78-b18b-4719326dc61b", diff --git a/tests/hw/esp32/ble4-shared.toit b/tests/hw/esp32/ble4-shared.toit index 73fe50c83..1bfaa6f4b 100644 --- a/tests/hw/esp32/ble4-shared.toit +++ b/tests/hw/esp32/ble4-shared.toit @@ -15,8 +15,9 @@ import monitor import .ble-util import .test +import .variants -TEST-SERVICE ::= BleUuid "650a73d3-d7fd-4d08-b734-d11e25b0856d" +TEST-SERVICE ::= BleUuid Variant.CURRENT.ble4-service TEST-CHARACTERISTIC ::= BleUuid "77d0b04e-bf49-4048-a4cd-fb46be32ebd0" TEST-CHARACTERISTIC-CALLBACK ::= BleUuid "1a1bb179-c006-4217-a57b-342e24eca694" diff --git a/tests/hw/esp32/ble5-shared.toit b/tests/hw/esp32/ble5-shared.toit index fb6e26878..0cd6879c6 100644 --- a/tests/hw/esp32/ble5-shared.toit +++ b/tests/hw/esp32/ble5-shared.toit @@ -15,8 +15,9 @@ import monitor import .ble-util import .test +import .variants -TEST-SERVICE ::= BleUuid "e5c245a3-1b7e-44cf-bc37-7040b719fe46" +TEST-SERVICE ::= BleUuid Variant.CURRENT.ble5-service TEST-CHARACTERISTIC ::= BleUuid "77d0b04e-bf49-4048-a4cd-fb46be32ebd0" main-peripheral: diff --git a/tests/hw/esp32/ble6-advertise-shared.toit b/tests/hw/esp32/ble6-advertise-shared.toit index bf0154992..accf4a367 100644 --- a/tests/hw/esp32/ble6-advertise-shared.toit +++ b/tests/hw/esp32/ble6-advertise-shared.toit @@ -17,8 +17,9 @@ import monitor import .ble-util import .test +import .variants -TEST-SERVICE ::= BleUuid "eede145e-b6a6-4d61-8156-ed10d5b75903" +TEST-SERVICE ::= BleUuid Variant.CURRENT.ble6-service TEST-CHARACTERISTIC ::= BleUuid "6b50d82f-ae33-4e0e-b161-50db92c49ad2" COMPANY-ID ::= #[0x12, 0x34] diff --git a/tests/hw/esp32/bme280-board2.toit b/tests/hw/esp32/bme280-board2.toit index fb5adc685..eeb2460c8 100644 --- a/tests/hw/esp32/bme280-board2.toit +++ b/tests/hw/esp32/bme280-board2.toit @@ -8,13 +8,14 @@ import gpio import i2c import .test +import .variants main: run-test: test test: - scl := gpio.Pin 32 - sda := gpio.Pin 33 + scl := gpio.Pin Variant.CURRENT.board2-i2c-scl-pin + sda := gpio.Pin Variant.CURRENT.board2-i2c-sda-pin bus := i2c.Bus --scl=scl --sda=sda device := bus.device bme280.I2C-ADDRESS-ALT driver := bme280.Driver device diff --git a/tests/hw/esp32/dac-test.toit b/tests/hw/esp32/dac-test.toit index e0517e8ea..abd657d76 100644 --- a/tests/hw/esp32/dac-test.toit +++ b/tests/hw/esp32/dac-test.toit @@ -5,10 +5,7 @@ /** Tests the DAC functionality of the ESP32. -Setup: -Connect pin 26 to pin 32. -Connect pin 25 to pin 33. -The connections can be done with a resistor. +For the setup see $Variant.dac-in1-pin. */ import gpio @@ -17,11 +14,13 @@ import gpio.adc as gpio import expect show * import .test +import .variants -ADC-IN1 := 33 -ADC-IN2 := 32 -DAC-OUT1 := 26 -DAC-OUT2 := 25 +DAC-OUT1 := Variant.CURRENT.dac-out1-pin +ADC-IN1 := Variant.CURRENT.dac-in1-pin + +DAC-OUT2 := Variant.CURRENT.dac-out2-pin +ADC-IN2 := Variant.CURRENT.dac-in2-pin test-wave data/List: bucket1 := 0 diff --git a/tests/hw/esp32/dht11-board2.toit b/tests/hw/esp32/dht11-board2.toit index 480cbf195..dc47974b2 100644 --- a/tests/hw/esp32/dht11-board2.toit +++ b/tests/hw/esp32/dht11-board2.toit @@ -7,12 +7,13 @@ import gpio import dhtxx.dht11 import .test +import .variants main: run-test: test test: - data := gpio.Pin 14 + data := gpio.Pin Variant.CURRENT.board2-dht11-pin driver := dht11.Dht11 data 2.repeat: diff --git a/tests/hw/esp32/ds18b20-board2.toit b/tests/hw/esp32/ds18b20-board2.toit index 1e8e860f1..87b9dbfd3 100644 --- a/tests/hw/esp32/ds18b20-board2.toit +++ b/tests/hw/esp32/ds18b20-board2.toit @@ -7,12 +7,13 @@ import expect show * import gpio import .test +import .variants main: run-test: test test: - data := gpio.Pin 15 + data := gpio.Pin Variant.CURRENT.board2-ds18b20-pin driver := ds18b20.Ds18b20 data 2.repeat: diff --git a/tests/hw/esp32/espnow1-shared.toit b/tests/hw/esp32/espnow1-shared.toit index 211b8ffb0..e3d7b0cd9 100644 --- a/tests/hw/esp32/espnow1-shared.toit +++ b/tests/hw/esp32/espnow1-shared.toit @@ -3,8 +3,9 @@ // be found in the tests/LICENSE file. import esp32.espnow +import .variants -PMK ::= espnow.Key.from-string "pmk1234567890123" +PMK ::= espnow.Key.from-string Variant.CURRENT.espnow-password END-TOKEN ::= "" @@ -21,4 +22,4 @@ TEST-DATA ::= [ END-TOKEN ] -CHANNEL ::= 1 +CHANNEL ::= Variant.CURRENT.espnow-channel diff --git a/tests/hw/esp32/fail.cmake b/tests/hw/esp32/fail.cmake new file mode 100644 index 000000000..781225707 --- /dev/null +++ b/tests/hw/esp32/fail.cmake @@ -0,0 +1,31 @@ +# Copyright (C) 2025 Toitware ApS. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; version +# 2.1 only. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# The license can be found in the file `LICENSE` in the top level +# directory of this repository. + + +set(TOIT_SKIP_TESTS + # The S3 doesn't have a DAC. + dac-test.toit-esp32s3 + # We are missing a DHT11. + dht11-board1.toit-esp32s3 +) + +set(TOIT_FAILING_TESTS + # The anti-glitching doesn't seem to work. + pulse-counter-test.toit-esp32s3 + # Idle level 1 doesn't seem to work. + rmt-drain-pullup-test.toit-esp32s3 + # Probably just an issue with the number of RMT channels. + rmt-test.toit-esp32s3 +) diff --git a/tests/hw/esp32/gpio-open-drain-test.toit b/tests/hw/esp32/gpio-open-drain-test.toit index 8fddc48b2..c479ce9b8 100644 --- a/tests/hw/esp32/gpio-open-drain-test.toit +++ b/tests/hw/esp32/gpio-open-drain-test.toit @@ -5,21 +5,19 @@ /** Tests changing the open-drain setting of gpio pins. -Setup: -Connect pin 18 and 19 with a 330 Ohm (or any other 300-1K) resistor. -Connect pin 18 to pin 34. -Connect pin 18 to GND with a 1M Ohm resistor (or any other big number). +For the setup, see the instructions near $Variant.open-drain-test-pin. */ import gpio import expect show * import .test +import .variants import ..shared.gpio-open-drain -TEST-PIN ::= 18 -LEVEL-PIN ::= 19 -MEASURE-PIN ::= 34 +TEST-PIN ::= Variant.CURRENT.open-drain-test-pin +LEVEL-PIN ::= Variant.CURRENT.open-drain-level-pin +MEASURE-PIN ::= Variant.CURRENT.open-drain-measure-pin main: run-test: test diff --git a/tests/hw/esp32/gpio-test.toit b/tests/hw/esp32/gpio-test.toit index d69d449b5..99e286587 100644 --- a/tests/hw/esp32/gpio-test.toit +++ b/tests/hw/esp32/gpio-test.toit @@ -5,8 +5,7 @@ /** Tests gpio pins. -Setup: -Connect pin 18 to pin 19, optionally with a 330 Ohm resistor to avoid short circuits. +For the setup see the instructions near $Variant.gpio-pin1. */ import gpio @@ -14,10 +13,11 @@ import expect show * import .test import ..shared.gpio as shared +import .variants -RESTRICTED ::= 7 -PIN1 ::= 18 -PIN2 ::= 19 +RESTRICTED ::= Variant.CURRENT.gpio-pin-restricted +PIN1 ::= Variant.CURRENT.gpio-pin1 +PIN2 ::= Variant.CURRENT.gpio-pin2 class PinFactory implements shared.PinFactory: pin1/gpio.Pin? := null diff --git a/tests/hw/esp32/i2c-bad-test.toit b/tests/hw/esp32/i2c-bad-test.toit index 5a58af65b..6f3f065e6 100644 --- a/tests/hw/esp32/i2c-bad-test.toit +++ b/tests/hw/esp32/i2c-bad-test.toit @@ -14,9 +14,10 @@ import gpio import i2c import .test +import .variants -SDA-PIN := 2 -SCL-PIN := 4 +SDA-PIN := Variant.CURRENT.unconnected-pin1 +SCL-PIN := Variant.CURRENT.unconnected-pin2 main: run-test: test diff --git a/tests/hw/esp32/i2c-pullup-test.toit b/tests/hw/esp32/i2c-pullup-test.toit index 5915b441b..199e13991 100644 --- a/tests/hw/esp32/i2c-pullup-test.toit +++ b/tests/hw/esp32/i2c-pullup-test.toit @@ -5,10 +5,7 @@ /** Tests the i2c pull-up resistors. -Setup: -Connect pin 18 to pin 34. -Connect pin 18 to GND with a 1M Ohm resistor (or any other big number). -Pin 4 shoul not be connected. +For the setup see the documentation near $Variant.i2c-pullup-test-pin. */ import expect show * @@ -16,10 +13,11 @@ import gpio import i2c import .test +import .variants -TEST-PIN := 18 -OTHER-PIN := 4 -MEASURE-PIN := 34 +TEST-PIN := Variant.CURRENT.i2c-pullup-test-pin +OTHER-PIN := Variant.CURRENT.i2c-pullup-other-pin +MEASURE-PIN := Variant.CURRENT.i2c-pullup-measure-pin main: run-test: test diff --git a/tests/hw/esp32/pin-hold1-shared.toit b/tests/hw/esp32/pin-hold1-shared.toit index 9926c67ac..55a97249e 100644 --- a/tests/hw/esp32/pin-hold1-shared.toit +++ b/tests/hw/esp32/pin-hold1-shared.toit @@ -5,12 +5,6 @@ /** Tests the pin-holding capability. Including with deep sleep. -# Setup -You need two boards. -- Connect GND of board1 to GND of board2. -- Connect pin 22 of board1 to pin 23 of board2. -- Connect pin 23 of board1 to pin 22 of board2. - Run `pin-hold-board1.toit` on board1. Once that one is running, run `pin-hold-board2.toit` on board2. @@ -23,7 +17,9 @@ the WiFi unnecessarily: `jag container install -D jag.disabled -D jag.timeout=30s hold-test pin-hold1-board2.toit` */ -PIN-OUT ::= 22 -PIN-IN ::= 23 +import .variants + +PIN-OUT ::= Variant.CURRENT.board-connection-pin1 +PIN-IN ::= Variant.CURRENT.board-connection-pin2 -PIN-FREE-AND-UNUSED ::= 16 +PIN-FREE-AND-UNUSED ::= Variant.CURRENT.unconnected-pin1 diff --git a/tests/hw/esp32/pulse-counter.toit b/tests/hw/esp32/pulse-counter-test.toit similarity index 93% rename from tests/hw/esp32/pulse-counter.toit rename to tests/hw/esp32/pulse-counter-test.toit index e8fbfaacf..42aa7c496 100644 --- a/tests/hw/esp32/pulse-counter.toit +++ b/tests/hw/esp32/pulse-counter-test.toit @@ -5,11 +5,7 @@ /** Tests the pulse_counter library. -Setup: -Connect pin 18 and 19 with a 330 Ohm resistor. The resistor isn't - strictly necessary but can prevent accidental short circuiting. - -Similarly, connect pin 26 to pin 33 with a 330 Ohm resistor. +For the setup see the comment near $Variant.pulse-counter1-in1. */ import expect show * @@ -18,12 +14,15 @@ import pulse-counter import rmt import .test +import .variants + +IN1 /int ::= Variant.CURRENT.pulse-counter1-in1 +OUT1 /int := Variant.CURRENT.pulse-counter1-out1 -IN1 /int ::= 18 -IN2 /int ::= 33 +IN2 /int ::= Variant.CURRENT.pulse-counter1-in2 +OUT2 /int := Variant.CURRENT.pulse-counter1-out2 -OUT1 /int := 19 -OUT2 /int := 26 +CHANNEL-COUNT ::= Variant.CURRENT.pulse-counter-channel-count main: run-test: test @@ -77,9 +76,8 @@ test: unit.close - /** ---- Use all 8 units, each with 2 channels. ---- */ - // This requires an ESP32 with 8 units. - units := List 8: unit = pulse-counter.Unit + /** ---- Use all 4/8 units, each with 2 channels. ---- */ + units := List CHANNEL-COUNT: unit = pulse-counter.Unit units.do: it.add-channel in it.add-channel in2 @@ -98,7 +96,7 @@ test: /** ---- Do it again, showing that the values a reset and that we properly release the resources. ---- */ - units = List 8: unit = pulse-counter.Unit + units = List CHANNEL-COUNT: unit = pulse-counter.Unit units.do: it.add-channel in it.add-channel in2 diff --git a/tests/hw/esp32/pulse-counter2.toit b/tests/hw/esp32/pulse-counter2-test.toit similarity index 89% rename from tests/hw/esp32/pulse-counter2.toit rename to tests/hw/esp32/pulse-counter2-test.toit index 39655e517..111fa78e3 100644 --- a/tests/hw/esp32/pulse-counter2.toit +++ b/tests/hw/esp32/pulse-counter2-test.toit @@ -12,12 +12,12 @@ import gpio import pulse-counter import .test +import .variants -IN1 /int ::= 18 -IN2 /int ::= 25 +IN/int ::= Variant.CURRENT.unconnected-pin1 allocate-unit --close/bool=false: - in := gpio.Pin IN1 + in := gpio.Pin IN unit := pulse-counter.Unit channel := unit.add-channel in if close: diff --git a/tests/hw/esp32/pwm-test.toit b/tests/hw/esp32/pwm-test.toit index babc57ea0..ea4e86e10 100644 --- a/tests/hw/esp32/pwm-test.toit +++ b/tests/hw/esp32/pwm-test.toit @@ -5,11 +5,7 @@ /** Tests the LEDC (pwm) library. -Setup: -Connect pin 18 and 19 with a 330 Ohm resistor. The resistor isn't - strictly necessary but can prevent accidental short circuiting. - -Similarly, connect pin 26 to pin 33 with a 330 Ohm resistor. +For the setup see the comment near $Variant.pwm-in1. */ import expect show * @@ -18,12 +14,13 @@ import pulse-counter import gpio.pwm import .test +import .variants -IN1 /int ::= 18 -IN2 /int ::= 33 +IN1 /int ::= Variant.CURRENT.pwm-in1 +OUT1 /int ::= Variant.CURRENT.pwm-out1 -OUT1 /int := 19 -OUT2 /int := 26 +IN2 /int ::= Variant.CURRENT.pwm-in2 +OUT2 /int := Variant.CURRENT.pwm-out2 main: run-test: test diff --git a/tests/hw/esp32/rmt-drain-pullup-test.toit b/tests/hw/esp32/rmt-drain-pullup-test.toit index 45c317892..6f97af221 100644 --- a/tests/hw/esp32/rmt-drain-pullup-test.toit +++ b/tests/hw/esp32/rmt-drain-pullup-test.toit @@ -5,10 +5,7 @@ /** Tests the bidirectional open-drain/pull-up functionality of the RMT peripheral. -Setup: -Connect pin 18 and 19 with a 330 Ohm (or any other 300-1K) resistor. -Connect pin 18 to pin 34. -Connect pin 18 to GND with a 1M Ohm resistor (or any other big number). +For the setup see the comment near $Variant.rmt-drain-pullup-test-pin. */ import rmt @@ -17,10 +14,11 @@ import monitor import expect show * import .test +import .variants -RMT-PIN ::= 18 -LEVEL-PIN ::= 19 -MEASURE-PIN ::= 34 +RMT-PIN ::= Variant.CURRENT.rmt-drain-pullup-test-pin +LEVEL-PIN ::= Variant.CURRENT.rmt-drain-pullup-level-pin +MEASURE-PIN ::= Variant.CURRENT.rmt-drain-pullup-measure-pin main: run-test: diff --git a/tests/hw/esp32/rmt-many-test.toit b/tests/hw/esp32/rmt-many-test.toit index 679509345..18eb2e4e2 100644 --- a/tests/hw/esp32/rmt-many-test.toit +++ b/tests/hw/esp32/rmt-many-test.toit @@ -5,12 +5,7 @@ /** Tests a simple pulse from the RMT peripheral. -Setup: -Connect pin 18 and 19 with a 330 Ohm resistor. The resistor isn't - strictly necessary but can prevent accidental short circuiting. - -Similarly, connect pin 21 to pin 19 with a 330 Ohm resistor. We will - use that one to pull the line high. +For the setup see the comment near $Variant.rmt-many-in1. */ import rmt @@ -19,20 +14,22 @@ import monitor import expect show * import .test +import .variants + +RMT-IN1 ::= Variant.CURRENT.rmt-many-in1 +RMT-OUT1 ::= Variant.CURRENT.rmt-many-out1 -RMT-PIN-1 ::= 18 -RMT-PIN-2 ::= 19 -RMT-PIN-3 ::= 21 -RMT-PIN-4 ::= 32 +RMT-IN2 ::= Variant.CURRENT.rmt-many-in2 +RMT-OUT2 ::= Variant.CURRENT.rmt-many-out2 main: run-test: test test: - pin1 := gpio.Pin RMT-PIN-1 - pin2 := gpio.Pin RMT-PIN-2 - pin3 := gpio.Pin RMT-PIN-3 - pin4 := gpio.Pin RMT-PIN-4 + pin1 := gpio.Pin RMT-IN1 + pin2 := gpio.Pin RMT-IN2 + pin3 := gpio.Pin RMT-OUT1 + pin4 := gpio.Pin RMT-OUT2 // Just test that we can allocate 4 different rmt resources. diff --git a/tests/hw/esp32/rmt-test.toit b/tests/hw/esp32/rmt-test.toit index fb56d0f08..3fcccd209 100644 --- a/tests/hw/esp32/rmt-test.toit +++ b/tests/hw/esp32/rmt-test.toit @@ -5,12 +5,7 @@ /** Tests a simple pulse from the RMT peripheral. -Setup: -Connect pin 18 and 19 with a 330 Ohm resistor. The resistor isn't - strictly necessary but can prevent accidental short circuiting. - -Similarly, connect pin 21 to pin 19 with a 330 Ohm resistor. We will - use that one to pull the line high. +For the setup see the comment near $Variant.rmt-pin1. */ import rmt @@ -19,10 +14,11 @@ import monitor import expect show * import .test +import .variants -RMT-PIN-1 ::= 18 -RMT-PIN-2 ::= 19 -RMT-PIN-3 ::= 21 +RMT-PIN-1 ::= Variant.CURRENT.rmt-pin1 +RMT-PIN-2 ::= Variant.CURRENT.rmt-pin2 +RMT-PIN-3 ::= Variant.CURRENT.rmt-pin3 // Because of the resistors and a weak pull-up, the reading isn't fully precise. // We allow 5us error. @@ -89,32 +85,38 @@ test-resource pin/gpio.Pin: channel.close in-parallel fun1/Lambda fun2/Lambda: - ready-semaphore := monitor.Semaphore + idle-level-semaphore := monitor.Semaphore + reader-ready-semaphore := monitor.Semaphore done-semaphore := monitor.Semaphore task:: fun1.call - :: ready-semaphore.down + :: idle-level-semaphore.up + :: reader-ready-semaphore.down :: done-semaphore.up - fun2.call:: ready-semaphore.up + fun2.call + :: idle-level-semaphore.down + :: reader-ready-semaphore.up done-semaphore.down test-simple-pulse pin-in/gpio.Pin pin-out/gpio.Pin: PULSE-LENGTH ::= 50 in-parallel - :: | wait-for-ready done | - wait-for-ready.call + :: | idle-level-is-ready wait-for-reader-ready done | out := rmt.Channel pin-out --output --idle-level=0 + idle-level-is-ready.call + wait-for-reader-ready.call signals := rmt.Signals 1 signals.set 0 --level=1 --period=PULSE-LENGTH out.write signals out.close done.call - :: | ready | + :: | wait-for-level-ready reader-is-ready | in := rmt.Channel pin-in --input --idle-threshold=120 + wait-for-level-ready.call in.start-reading - ready.call + reader-is-ready.call signals := in.read in.stop-reading in.close @@ -129,18 +131,20 @@ test-multiple-pulses pin-in/gpio.Pin pin-out/gpio.Pin: SIGNAL-COUNT ::= 11 in-parallel - :: | wait-for-ready done | - wait-for-ready.call + :: | idle-level-is-ready wait-for-reader-ready done | out := rmt.Channel pin-out --output --idle-level=0 + idle-level-is-ready.call + wait-for-reader-ready.call signals := rmt.Signals.alternating SIGNAL-COUNT --first-level=1: PULSE-LENGTH signals.set 0 --level=1 --period=PULSE-LENGTH out.write signals out.close done.call - :: | ready | + :: | wait-for-level-ready reader-is-ready | in := rmt.Channel pin-in --input --idle-threshold=120 + wait-for-level-ready.call in.start-reading - ready.call + reader-is-ready.call signals := in.read in.stop-reading in.close @@ -159,15 +163,16 @@ test-long-sequence pin-in/gpio.Pin pin-out/gpio.Pin: SIGNAL-COUNT ::= 128 * 6 in-parallel - :: | wait-for-ready done | - wait-for-ready.call + :: | idle-level-is-ready wait-for-reader-ready done | out := rmt.Channel pin-out --output --idle-level=0 + idle-level-is-ready.call + wait-for-reader-ready.call signals := rmt.Signals.alternating SIGNAL-COUNT --first-level=1: PULSE-LENGTH signals.set 0 --level=1 --period=PULSE-LENGTH out.write signals out.close done.call - :: | ready | + :: | wait-for-level-ready reader-is-ready | // Note that we need a second memory block as the internal buffer would otherwise // overflow. On the serial port we would see the following message: // E (726) rmt: RMT RX BUFFER FULL @@ -176,8 +181,9 @@ test-long-sequence pin-in/gpio.Pin pin-out/gpio.Pin: // 2 bytes per signal. Twice for the ring-buffer. And some extra for bookkeeping. buffer-size := SIGNAL-COUNT * 2 * 2 + 20 in := rmt.Channel pin-in --input --idle-threshold=120 --memory-block-count=6 --buffer-size=buffer-size + wait-for-level-ready.call in.start-reading - ready.call + reader-is-ready.call signals := in.read in.stop-reading in.close @@ -194,8 +200,9 @@ test-bidirectional pin1/gpio.Pin pin2/gpio.Pin: PULSE-LENGTH ::= 50 in-parallel - :: | wait-for-ready done | + :: | idle-level-is-ready wait-for-ready done | out := rmt.Channel pin1 --output --idle-level=1 + idle-level-is-ready.call in := rmt.Channel pin1 --input // We actually don't need the bidirectionality here, but by // making the channel bidirectional it switches to open drain. @@ -214,8 +221,9 @@ test-bidirectional pin1/gpio.Pin pin2/gpio.Pin: out.close done.call - :: | ready | + :: | wait-for-level-ready reader-is-ready | out := rmt.Channel pin2 --output --idle-level=1 + wait-for-level-ready.call in := rmt.Channel pin2 --input --idle-threshold=5_000 --memory-block-count=4 rmt.Channel.make-bidirectional --in=in --out=out @@ -228,7 +236,7 @@ test-bidirectional pin1/gpio.Pin pin2/gpio.Pin: sleep --ms=2_000 */ in.start-reading - ready.call // Overlap the signals from the other pin. + reader-is-ready.call // Overlap the signals from the other pin. out.write signals in-signals := in.read in.stop-reading @@ -307,15 +315,15 @@ test-multiple-sequences pin-in/gpio.Pin pin-out/gpio.Pin: in.stop-reading SECOND-PULSE-PERIOD ::= 13 in-parallel - :: | wait-for-ready done | - wait-for-ready.call + :: | _ wait-for-reader-ready done | + wait-for-reader-ready.call sleep --ms=200 second-out-signals := rmt.Signals 1 second-out-signals.set 0 --level=1 --period=SECOND-PULSE-PERIOD out.write second-out-signals done.call - :: | ready | - ready.call + :: | _ reader-is-ready | + reader-is-ready.call in-signals := in.read expect 1 <= in-signals.size <= 2 expect-equals 1 (in-signals.level 0) @@ -342,5 +350,3 @@ test: pin1.close pin2.close - - print "all tests done" diff --git a/tests/hw/esp32/spi-keep-active-test.toit b/tests/hw/esp32/spi-keep-active-test.toit index f747447cf..4d16a8f7d 100644 --- a/tests/hw/esp32/spi-keep-active-test.toit +++ b/tests/hw/esp32/spi-keep-active-test.toit @@ -5,12 +5,7 @@ /** Tests the '--keep-cs-active' flag of the SPI transfer. -Setup: -Connect pin 19 and 21 with a 330 Ohm resistor. The resistor isn't - strictly necessary but can prevent accidental short circuiting. - -Make sure that pins 12, 13, and 14 are not connected to anything important. They - are used as output. +For the setup see the comment near $Variant.spi-keep-active-cs-pin. */ import expect show * @@ -19,13 +14,14 @@ import gpio import monitor import .test +import .variants -CS ::= 21 -MISO ::= 12 -MOSI ::= 13 -SCK ::= 14 +CS ::= Variant.CURRENT.spi-keep-active-cs-pin +MISO ::= Variant.CURRENT.unconnected-pin1 +MOSI ::= Variant.CURRENT.unconnected-pin2 +SCK ::= Variant.CURRENT.unconnected-pin3 -IN-CS /int ::= 19 +IN-CS ::= Variant.CURRENT.spi-keep-active-in-cs-pin class DebugChannel: channel_ := monitor.Channel 1 diff --git a/tests/hw/esp32/touch.toit b/tests/hw/esp32/touch.toit index a694f481f..ca627a892 100644 --- a/tests/hw/esp32/touch.toit +++ b/tests/hw/esp32/touch.toit @@ -5,9 +5,7 @@ /** Tests the wakeup functionality of the touch pad. -Setup: -Optionally connect a jumper wire to pin 2. -Do the same for pin 4. +For the setup see the comment near $Variant.touch-pin1. Start the program, and let the device go into deep sleep. Touch pin 4. The device should *not* wake up, as the pin was closed. @@ -18,8 +16,10 @@ import gpio import gpio.touch as gpio import esp32 -TOUCH-PIN1 ::= 2 -TOUCH-PIN2 ::= 4 +import .variants + +TOUCH-PIN1 ::= Variant.CURRENT.touch-pin1 +TOUCH-PIN2 ::= Variant.CURRENT.touch-pin2 calibrate touch/gpio.Touch: CALIBRATION-ITERATIONS ::= 16 @@ -30,28 +30,30 @@ calibrate touch/gpio.Touch: touch.threshold = sum * 2 / (3 * CALIBRATION-ITERATIONS) main: + pin1-desc := "$TOUCH-PIN1 (yellow)" + pin2-desc := "$TOUCH-PIN2 (green)" if esp32.wakeup-cause == esp32.WAKEUP-TOUCHPAD: print "Woken up from touchpad" print esp32.touchpad-wakeup-status else: touch1 := gpio.Touch (gpio.Pin TOUCH-PIN1) calibrate touch1 - print "pin $TOUCH-PIN1: $touch1.threshold $(touch1.read --raw)" + print "pin $pin1-desc: $touch1.threshold $(touch1.read --raw)" touch2 := gpio.Touch (gpio.Pin TOUCH-PIN2) calibrate touch2 - print "pin $TOUCH-PIN2: $touch2.threshold $(touch2.read --raw)" + print "pin $pin2-desc: $touch2.threshold $(touch2.read --raw)" - print "waiting for touch on pin $TOUCH-PIN1" + print "waiting for touch on pin $pin1-desc" while not touch1.get: sleep --ms=1 - print "waiting for touch on pin $TOUCH-PIN2" + print "waiting for touch on pin $pin2-desc" while not touch2.get: sleep --ms=1 touch2.close print "going into deep sleep" sleep --ms=500 - print "ESP32 should not wake up from pin $TOUCH-PIN2, but should wake up from pin $TOUCH-PIN1" + print "ESP32 should not wake up from pin $pin2-desc, but should wake up from pin $pin1-desc" esp32.enable-touchpad-wakeup esp32.deep-sleep (Duration --s=10) diff --git a/tests/hw/esp32/uart-baud-rate-test.toit b/tests/hw/esp32/uart-baud-rate-test.toit index 2bd27e04e..8f7c6e8b1 100644 --- a/tests/hw/esp32/uart-baud-rate-test.toit +++ b/tests/hw/esp32/uart-baud-rate-test.toit @@ -1,13 +1,11 @@ -/* */// Copyright (C) 2022 Toitware ApS. +// Copyright (C) 2022 Toitware ApS. // Use of this source code is governed by a Zero-Clause BSD license that can // be found in the tests/LICENSE file. /** Tests reading and writing of the UART baud rate. -Setup: -Connect pin 18 to pin 19, optionally with a 330 Ohm resistor to avoid short circuits. -Connect pin 26 to pin 33, optionally with a resistor. +For the setup see the comment near $Variant.uart-baud-rate-in1. */ import expect show * @@ -15,11 +13,14 @@ import gpio import uart import .test +import .variants -RX1 := 18 -TX1 := 26 -RX2 := 33 -TX2 := 19 +// Not that RX1 goes to TX2 and TX1 goes to RX2. +RX1 ::= Variant.CURRENT.uart-baud-rate-in2 +TX1 ::= Variant.CURRENT.uart-baud-rate-out1 + +RX2 ::= Variant.CURRENT.uart-baud-rate-in1 +TX2 ::= Variant.CURRENT.uart-baud-rate-out2 expect-baud expected/int actual/int: // Baudrate is not 100% accurate, so we can't just test for equality to $expected. diff --git a/tests/hw/esp32/uart-big-data-shared.toit b/tests/hw/esp32/uart-big-data-shared.toit index 46358c221..cbbafef7e 100644 --- a/tests/hw/esp32/uart-big-data-shared.toit +++ b/tests/hw/esp32/uart-big-data-shared.toit @@ -5,25 +5,23 @@ /** Tests sending bigger chunks. -Setup: -Connect GND of one ESP32 to GND of another ESP32. -Connect pin 22 of the first ESP32 to pin 23 of the second ESP32. -Connect pin 23 of the first ESP32 to pin 22 of the second ESP32. - Run uart-big-data-board1.toit on one ESP32 and uart-big-data-board2.toit on the other. For the host-test, use a flasher and connect GND to GND of the flasher. -Connect pin 22 of the ESP32 to the RX pin of the flasher. -Connect pin 23 of the ESP32 to the TX pin of the flasher. +Connect pin $RX of the ESP32 to the RX pin of the flasher. +Connect pin $TX of the ESP32 to the TX pin of the flasher. If necessary, adjust the $UART-PATH. */ import expect show * +import .variants + TEST-ITERATIONS := 10 -RX ::= 22 -TX ::= 23 +RX ::= Variant.CURRENT.board-connection-pin1 +TX ::= Variant.CURRENT.board-connection-pin2 + UART-PATH ::= "/dev/ttyUSB1" BAUD-RATE ::= 115200 diff --git a/tests/hw/esp32/uart-flush-test.toit b/tests/hw/esp32/uart-flush-test.toit index a2e906f3a..1917c6552 100644 --- a/tests/hw/esp32/uart-flush-test.toit +++ b/tests/hw/esp32/uart-flush-test.toit @@ -5,9 +5,7 @@ /** Tests reading and writing of the UART baud rate. -Setup: -Connect pin 18 to pin 19, optionally with a 330 Ohm resistor to avoid short circuits. -Connect pin 26 to pin 33, optionally with a resistor. +For the setup see the comment near $Variant.uart-flush-in1. */ import expect show * @@ -15,11 +13,15 @@ import gpio import uart import .test +import .variants + +// Not that RX1 goes to TX2 and TX1 goes to RX2. +RX1 ::= Variant.CURRENT.uart-baud-rate-in2 +TX1 ::= Variant.CURRENT.uart-baud-rate-out1 + +RX2 ::= Variant.CURRENT.uart-baud-rate-in1 +TX2 ::= Variant.CURRENT.uart-baud-rate-out2 -RX1 := 18 -TX1 := 26 -RX2 := 33 -TX2 := 19 main: run-test: test diff --git a/tests/hw/esp32/uart-flush2-board1.toit b/tests/hw/esp32/uart-flush2-board1.toit index 8891c9aca..980038c43 100644 --- a/tests/hw/esp32/uart-flush2-board1.toit +++ b/tests/hw/esp32/uart-flush2-board1.toit @@ -5,11 +5,6 @@ /** Tests that the UART flush is working. -Setup: -Connect GND of one ESP32 to GND of another ESP32. -Connect pin 22 of the first ESP32 to pin 23 of the second ESP32. -Connect pin 23 of the first ESP32 to pin 22 of the second ESP32. - Run uart-flush2-board1.toit on one ESP32 and uart-flush2-board2.toit on the other. */ @@ -17,9 +12,10 @@ import gpio import uart import .test +import .variants -RX ::= 22 -SIGNAL ::= 23 +RX ::= Variant.CURRENT.board-connection-pin1 +SIGNAL ::= Variant.CURRENT.board-connection-pin2 main: run-test: test diff --git a/tests/hw/esp32/uart-flush2-board2.toit b/tests/hw/esp32/uart-flush2-board2.toit index bca2e69de..f7a3e7174 100644 --- a/tests/hw/esp32/uart-flush2-board2.toit +++ b/tests/hw/esp32/uart-flush2-board2.toit @@ -10,9 +10,10 @@ import gpio import uart import .test +import .variants -TX ::= 23 -SIGNAL ::= 22 +TX ::= Variant.CURRENT.board-connection-pin1 +SIGNAL ::= Variant.CURRENT.board-connection-pin2 main: run-test: test diff --git a/tests/hw/esp32/uart-io-data-shared.toit b/tests/hw/esp32/uart-io-data-shared.toit index 1761efbcc..40c8f17d9 100644 --- a/tests/hw/esp32/uart-io-data-shared.toit +++ b/tests/hw/esp32/uart-io-data-shared.toit @@ -5,11 +5,6 @@ /** Tests sending io.Data to the UART. -Setup: -Connect GND of one ESP32 to GND of another ESP32. -Connect pin 22 of the first ESP32 to pin 23 of the second ESP32. -Connect pin 23 of the first ESP32 to pin 22 of the second ESP32. - Run uart-io-data-board1.toit on one ESP32 and uart-io-data-board2.toit on the other. */ @@ -23,9 +18,10 @@ import system.firmware import uart import .test +import .variants -RX ::= 22 -TX ::= 23 +RX ::= Variant.CURRENT.board-connection-pin1 +TX ::= Variant.CURRENT.board-connection-pin2 BAUD-RATE ::= 115200 class FwData implements io.Data: diff --git a/tests/hw/esp32/uart-no-garbage-rs485-test.toit b/tests/hw/esp32/uart-no-garbage-rs485-test.toit index 7d4389a45..b3bd3f940 100644 --- a/tests/hw/esp32/uart-no-garbage-rs485-test.toit +++ b/tests/hw/esp32/uart-no-garbage-rs485-test.toit @@ -7,22 +7,19 @@ import gpio import uart import .test +import .variants /** Tests that the UART buffer doesn't start with garbage in it when initialized as rs485 half-duplex. - -Setup: - Uses pin 16 and 23. They should stay unconnected or connected to - a high-impedance pin. */ main: run-test: test test: - rx := gpio.Pin 16 - rts := gpio.Pin 23 + rx := gpio.Pin Variant.CURRENT.unconnected-pin1 + rts := gpio.Pin Variant.CURRENT.unconnected-pin2 port := uart.Port --rx=rx --tx=null diff --git a/tests/hw/esp32/uart-no-garbage-test.toit b/tests/hw/esp32/uart-no-garbage-test.toit index becb6023c..dec1798bc 100644 --- a/tests/hw/esp32/uart-no-garbage-test.toit +++ b/tests/hw/esp32/uart-no-garbage-test.toit @@ -7,20 +7,17 @@ import gpio import uart import .test +import .variants /** Tests that the UART buffer doesn't start with garbage in it. - -Setup: - Uses pin 16. The pin should stay unconnected or connected to - a high-impedance pin. */ main: run-test: test test: - rx := gpio.Pin 16 + rx := gpio.Pin Variant.CURRENT.unconnected-pin1 port := uart.Port --rx=rx --tx=null --baud-rate=9600 expect-throw DEADLINE-EXCEEDED-ERROR: with-timeout --ms=200: diff --git a/tests/hw/esp32/uart-no-garbage500-test.toit b/tests/hw/esp32/uart-no-garbage500-test.toit index 6880345bf..e95cc25a5 100644 --- a/tests/hw/esp32/uart-no-garbage500-test.toit +++ b/tests/hw/esp32/uart-no-garbage500-test.toit @@ -7,20 +7,17 @@ import gpio import uart import .test +import .variants /** Tests that the UART buffer doesn't start with garbage in it. - -Setup: - Uses pin 16. The pin should stay unconnected or connected to - a high-impedance pin. */ main: run-test: test test: - rx := gpio.Pin 16 + rx := gpio.Pin Variant.CURRENT.unconnected-pin1 port := uart.Port --rx=rx --tx=null --baud-rate=500 expect-throw DEADLINE-EXCEEDED-ERROR: with-timeout --ms=200: diff --git a/tests/hw/esp32/uart-rs485-board1.toit b/tests/hw/esp32/uart-rs485-board1.toit index 7a7b34199..69fa5e019 100644 --- a/tests/hw/esp32/uart-rs485-board1.toit +++ b/tests/hw/esp32/uart-rs485-board1.toit @@ -10,9 +10,10 @@ import uart import .test import .uart-rs485-shared +import .variants -RTS ::= 22 -TX ::= 23 +RTS ::= Variant.CURRENT.board-connection-pin1 +TX ::= Variant.CURRENT.board-connection-pin2 main: run-test: test diff --git a/tests/hw/esp32/uart-rs485-board2.toit b/tests/hw/esp32/uart-rs485-board2.toit index f43a4afc6..cd8c648d6 100644 --- a/tests/hw/esp32/uart-rs485-board2.toit +++ b/tests/hw/esp32/uart-rs485-board2.toit @@ -7,20 +7,16 @@ import uart import .test import .uart-rs485-shared +import .variants /** Tests that the uart in rs485-half-duplex can receive data as soon as the RTS bit is cleared. - -Setup: - Connect pin 23 of board 1 to pin 22 of board 2. - Connect pin 22 of board 1 to pin 23 of board 2. - Keep pin 16 of board 2 unconnected. */ -RTS ::= 23 -RX ::= 22 -TX ::= 16 // Unused. +RTS ::= Variant.CURRENT.board-connection-pin1 +RX ::= Variant.CURRENT.board-connection-pin2 +TX ::= Variant.CURRENT.unconnected-pin1 main: run-test: test diff --git a/tests/hw/esp32/uart-small-data-shared.toit b/tests/hw/esp32/uart-small-data-shared.toit index 4cfb924d4..c36e9e196 100644 --- a/tests/hw/esp32/uart-small-data-shared.toit +++ b/tests/hw/esp32/uart-small-data-shared.toit @@ -5,11 +5,6 @@ /** Tests sending small data. -Setup: -Connect GND of one ESP32 to GND of another ESP32. -Connect pin 22 of the first ESP32 to pin 23 of the second ESP32. -Connect pin 23 of the first ESP32 to pin 22 of the second ESP32. - Run uart-small-data-board1.toit on one ESP32 and uart-small-data-board2.toit on the other. */ @@ -23,9 +18,10 @@ import system.firmware import uart import .test +import .variants -RX ::= 22 -TX ::= 23 +RX ::= Variant.CURRENT.board-connection-pin1 +TX ::= Variant.CURRENT.board-connection-pin2 BAUD-RATE ::= 115200 REPETITIONS ::= 1 diff --git a/tests/hw/esp32/ultrasound-board2.toit b/tests/hw/esp32/ultrasound-board2.toit index 709f20161..744b79208 100644 --- a/tests/hw/esp32/ultrasound-board2.toit +++ b/tests/hw/esp32/ultrasound-board2.toit @@ -7,17 +7,19 @@ import gpio import hc-sr04 import .test +import .variants main: run-test: test test: - echo := gpio.Pin.in 19 - trigger := gpio.Pin.out 18 + echo := gpio.Pin.in Variant.CURRENT.board2-hc-sr04-echo-pin + trigger := gpio.Pin.out Variant.CURRENT.board2-hc-sr04-trigger-pin driver := hc-sr04.Driver --echo=echo --trigger=trigger 5.repeat: distance := driver.read-distance + print distance // Requires the board to be pointing towards a wall with at most 1m distance. expect 0 < distance < 1000 sleep --ms=200 diff --git a/tests/hw/esp32/variants.toit b/tests/hw/esp32/variants.toit new file mode 100644 index 000000000..92665ab31 --- /dev/null +++ b/tests/hw/esp32/variants.toit @@ -0,0 +1,485 @@ +// Copyright (C) 2025 Toitware ApS. +// Use of this source code is governed by a Zero-Clause BSD license that can +// be found in the tests/LICENSE file. + +import system + +VARIANTS ::= { + system.ARCHITECTURE-ESP32: Esp32, + system.ARCHITECTURE-ESP32S3: Esp32s3, +} + +/** +An ESP32 variant. + +This class defines the pins for the ESP32 variants. +*/ +abstract class Variant: + static CURRENT/Variant ::= VARIANTS[system.architecture] + + /** + The amount of pulse-counter channels this variant has. + */ + abstract pulse-counter-channel-count -> int + + /** + A voltage divider consisting of three 330 Ohm resistors in series. + The resistors must go from start->adc1->adc2->end. + The adc1 pin must be an ADC pin of ADC1. + The adc2 pin must be an ADC pin of ADC2 (if there is one). + */ + abstract voltage-divider-start-pin -> int + abstract voltage-divider-adc1-pin -> int + abstract voltage-divider-adc2-pin -> int + abstract voltage-divider-end-pin -> int + + /** + A chain of 4 connected pins: + GND - $chain2-to-gnd-pin - $chain2-pin2 - $chain2-pin3. + + GND and $chain2-to-gnd-pin are connected with a 1MOhm resistor. + $chain2-to-gnd-pin is connected to $chain2-pin2 without any resistor. + $chain2-pin2 is connected to $chain2-pin3 with a 330Ohm resistor. + */ + abstract chain2-to-gnd-pin -> int + abstract chain2-pin2 -> int + abstract chain2-pin3 -> int + + /** + Two pins that are connected with a 330 Ohm resistor. + + It is probably OK to use the $chain2-pin2 and $chain2-pin3 pins for + this, but often there is a more suitable connection available that + isn't transitively connected to GND. + */ + abstract connected1-pin1 -> int + abstract connected1-pin2 -> int + + /** + Two more pins that are connected with a 330 Ohm resistor. + */ + connected2-pin1 -> int: return voltage-divider-start-pin + connected2-pin2 -> int: return voltage-divider-end-pin + + /** + A pin that is restricted. + */ + abstract restricted-pin -> int + + /** + An unconnected pin. + + $unconnected-pin1 and $unconnected-pin2 are set to the touch pins by + default, since these should not be connected to anything while the + touch test isn't running. + */ + unconnected-pin1 -> int: return touch-pin1 + unconnected-pin2 -> int: return touch-pin2 + abstract unconnected-pin3 -> int + + /** + Touch pins. + + Connect a jumper wire to the touch pins. These should otherwise be + unconnected. + $touch-pin1 should be yellow. + $touch-pin2 should be green. + + # Inheritance + If the board does not have touch pins, then the $unconnected-pin1 and + $unconnected-pin2 must be overridden, since these default to the touch pins. + */ + abstract touch-pin1 -> int + abstract touch-pin2 -> int + + /** + Distinct service UUIDs for each ble test. + */ + abstract ble1-service -> string + abstract ble1-service2 -> string + + abstract ble2-service -> string + + abstract ble3-first-service -> string + + abstract ble4-service -> string + + abstract ble5-service -> string + + abstract ble6-service -> string + + /** + The ESP-NOW channel and password. + + Different for each variant. + */ + abstract espnow-channel -> int + abstract espnow-password -> string + + /** + I2C pins. + + On board 2. + Typically, scl is yellow and sda is blue. + */ + abstract board2-i2c-scl-pin -> int + abstract board2-i2c-sda-pin -> int + + /** + HC-SR04 pins. + + Since the HC-SR04 is a 5V device, the echo pin should not be connected + directly to the ESP32. Instead, it should be connected through a voltage + divider or an LED (or through a level shifter). + */ + abstract board2-hc-sr04-trigger-pin -> int + abstract board2-hc-sr04-echo-pin -> int + + /* + DS18B20 pins. + */ + abstract board2-ds18b20-pin -> int + + /** + DHT11 pins. + */ + abstract board2-dht11-pin -> int + + /** + Board connections. + + Pins that are connected between the two boards. + These are crossed, so that the same pin number can be used as RX/TX on + both boards. + */ + abstract board-connection-pin1 -> int + abstract board-connection-pin2 -> int + + /* + ADC. + + The $adc-control-pin and $adc-v33-pin are connected through + two resistors (each of the same value). At each connection + point we have one of the adc pins. The $adc1-pin is closer to + the 3.3V pin and the $adc2-pin is closer to the ground pin. + */ + adc-control-pin -> int: return voltage-divider-start-pin + adc1-pin -> int: return voltage-divider-adc1-pin + adc2-pin -> int: return voltage-divider-adc2-pin + adc-v33-pin -> int: return voltage-divider-end-pin + + /** + Digital-analog conversions pins. + + Connect a DAC pin as $dac-out1-pin to $dac-in1-pin with a 330Ohm resistor. + Connect a DAC pin as $dac-out2-pin to $dac-in2-pin with a 330Ohm resistor. + */ + abstract dac-out1-pin -> int + abstract dac-in1-pin -> int + + abstract dac-out2-pin -> int + abstract dac-in2-pin -> int + + /* + Open drain test pins. + + The $open-drain-test-pin is connected to the $open-drain-level-pin + through a 330Ohm resistor. + The $open-drain-test-pin and $open-drain-measure-pin are connected + without any resistor. + The $open-drain-test-pin or $open-drain-measure-pin is connected to GND + through a 1MOhm resistor. + */ + open-drain-measure-pin -> int: return chain2-to-gnd-pin + open-drain-test-pin -> int: return chain2-pin2 + open-drain-level-pin -> int: return chain2-pin3 + + /* + GPIO pins. + + Connect $gpio-pin1 to $gpio-pin2 with a 330Ohm resistor. + Set the $gpio-pin-restricted to a pin that is restricted. + */ + gpio-pin1 -> int: return connected1-pin1 + gpio-pin2 -> int: return connected1-pin2 + gpio-pin-restricted -> int: return restricted-pin + + /** + I2C pullup test pins. + + $i2c-pullup-test-pin is connected to $i2c-pullup-measure-pin without any + resistor. + $i2c-pullup-measure-pin is connected to GND through a 1MOhm resistor. + Also uses $unconnected-pin1. + */ + i2c-pullup-measure-pin -> int: return chain2-to-gnd-pin + i2c-pullup-test-pin -> int: return chain2-pin2 + i2c-pullup-other-pin -> int: return unconnected-pin1 + + /** + Pulse counter pins. + + Connect $pulse-counter1-in1 to $pulse-counter1-out1 with a 330Ohm resistor. + Connect $pulse-counter1-in2 to $pulse-counter1-out2 with a 330Ohm resistor. + */ + pulse-counter1-in1 -> int: return connected1-pin1 + pulse-counter1-out1 -> int: return connected1-pin2 + + pulse-counter1-in2 -> int: return connected2-pin1 + pulse-counter1-out2 -> int: return connected2-pin2 + + /** + PWM pins. + + Connect $pwm-in1 to $pwm-out1 with a 330Ohm resistor. + Connect $pwm-in2 to $pwm-out2 with a 330Ohm resistor. + */ + pwm-in1 -> int: return connected1-pin1 + pwm-out1 -> int: return connected1-pin2 + + pwm-in2 -> int: return connected2-pin1 + pwm-out2 -> int: return connected2-pin2 + + /** + RMT pull-up test pins. + + Same as $open-drain-test-pin and $open-drain-level-pin. + */ + rmt-drain-pullup-measure-pin -> int: return chain2-to-gnd-pin + rmt-drain-pullup-test-pin -> int: return chain2-pin2 + rmt-drain-pullup-level-pin -> int: return chain2-pin3 + + /** + RMT many test pins. + + Connect $rmt-many-in1 to $rmt-many-out1 with a 330Ohm resistor. + Connect $rmt-many-in2 to $rmt-many-out2 with a 330Ohm resistor. + */ + rmt-many-in1 -> int: return connected1-pin1 + rmt-many-out1 -> int: return connected1-pin2 + + rmt-many-in2 -> int: return connected2-pin1 + rmt-many-out2 -> int: return connected2-pin2 + + /** + RMT pins. + + Connect $rmt-pin1 to $rmt-pin2 with a 330Ohm resistor. + Connect $rmt-pin2 to $rmt-pin3 with a 330Ohm resistor. + */ + rmt-pin1 -> int: return voltage-divider-start-pin + rmt-pin2 -> int: return voltage-divider-adc1-pin + rmt-pin3 -> int: return voltage-divider-adc2-pin + + /** + SPI keep-active pins. + + Connect $spi-keep-active-cs-pin to $spi-keep-active-in-cs-pin with a 330Ohm resistor. + */ + spi-keep-active-cs-pin -> int: return connected1-pin1 + spi-keep-active-in-cs-pin -> int: return connected1-pin2 + + /** + Uart baud-rate pins. + + Connect $uart-baud-rate-in1 to $uart-baud-rate-out1 with a 330Ohm resistor. + Connect $uart-baud-rate-in2 to $uart-baud-rate-out2 with a 330Ohm resistor. + */ + uart-baud-rate-in1 -> int: return connected1-pin1 + uart-baud-rate-out1 -> int: return connected1-pin2 + + uart-baud-rate-in2 -> int: return connected2-pin1 + uart-baud-rate-out2 -> int: return connected2-pin2 + + /** + Uart flush test pins. + + Connect $uart-flush-in1 to $uart-flush-out1 with a 330Ohm resistor. + Connect $uart-flush-in2 to $uart-flush-out2 with a 330Ohm resistor. + */ + uart-flush-in1 -> int: return connected1-pin1 + uart-flush-out1 -> int: return connected1-pin2 + + uart-flush-in2 -> int: return connected2-pin1 + uart-flush-out2 -> int: return connected2-pin2 + + /** + Wait-for-close test pins. + + The $wait-for-close-pin should be connected to GND with a 1MOhm resistor. + */ + wait-for-close-pin -> int: return chain2-to-gnd-pin + +/* +A configuration for the ESP32. + +On board 1 connect as follows: +- a voltage divider consisting of 4 pins each connected with a + 330Ohm resistor. + IO27 (start) - IO32 (ADC1_4) - IO26 (ADC2_9/DAC_2) - IO14 (end) +- IO25 (DAC1) - IO33 with 330Ohm +- The following pins in a row: GND - IO21 - IO19 - IO18 + * IO21 to GND with a 1MOhm resistor. + * IO21 to IO19 without any resistor. + * IO19 to IO18 with a 330Ohm resistor. + +IO2, IO4, and IO16 must stay unconnected. +Pins IO4 and IO2 are used for touch tests. + +On board2: +- IO19 -> HC-SR04 Echo. Ideally through a voltage divider or an LED. +- IO18 -> HC-SR04 Trig +- IO14 -> DHT11 Data +- IO15 -> DS18B20 Data +- IO32 -> bme280 SCL (yellow) +- IO33 -> bme280 SDA (blue) + +IO2, IO4, and IO16 must stay unconnected. + +Connect the two boards. +- GND (board1) - GND (board2) +- IO22 (board1) - IO23 (board2) +- IO23 (board1) - IO22 (board2) +*/ +class Esp32 extends Variant: + pulse-counter-channel-count ::= 8 + + voltage-divider-start-pin ::= 27 + voltage-divider-adc1-pin ::= 32 + voltage-divider-adc2-pin ::= 26 + voltage-divider-end-pin ::= 14 + + chain2-to-gnd-pin ::= 21 + chain2-pin2 ::= 19 + chain2-pin3 ::= 18 + + connected1-pin1 ::= 25 + connected1-pin2 ::= 33 + + dac-out1-pin ::= 25 + dac-in1-pin ::= 33 + + dac-out2-pin ::= 26 + dac-in2-pin ::= 32 + + restricted-pin ::= 7 + + touch-pin1 ::= 2 + touch-pin2 ::= 4 + unconnected-pin3 ::= 16 + + ble1-service ::= "df451d2d-e899-4346-a8fd-bca9cbfebc0b" + ble1-service2 ::= "94a11d6a-fa23-4a09-aa6f-2ca0b7cdbb70" + + ble2-service ::= "a1bcf0ba-7557-4968-91f8-6b0f187af2b5" + + ble3-first-service ::= "ffe21239-d8a2-4536-b751-0881a9f2e3de" + + ble4-service ::= "650a73d3-d7fd-4d08-b734-d11e25b0856d" + + ble5-service ::= "e5c245a3-1b7e-44cf-bc37-7040b719fe46" + + ble6-service ::= "eede145e-b6a6-4d61-8156-ed10d5b75903" + + espnow-channel ::= 1 + espnow-password ::= "pmk-esp32-123456" + + board2-i2c-scl-pin ::= 32 + board2-i2c-sda-pin ::= 33 + + board2-hc-sr04-trigger-pin ::= 18 + board2-hc-sr04-echo-pin ::= 19 + + board2-ds18b20-pin ::= 15 + + board2-dht11-pin ::= 14 + + board-connection-pin1 ::= 22 + board-connection-pin2 ::= 23 + +/** +A configuration for the ESP32-S3. + +On board 1 connect as follows: +- a voltage divider consisting of 4 pins each connected with a + 330Ohm resistor. + IO13 (start) - IO09 (ADC1) - IO12 (ADC2) - IO10 (end) +- IO19 - IO21 with 330Ohm +- The following pins in a row: GND - IO1 - IO2 - IO42 + * IO1 to GND with a 1MOhm resistor. + * IO1 to IO2 without any resistor. + * IO2 to IO42 with a 330Ohm resistor. + +IO6, IO7, and IO8 must stay unconnected. +Pins IO6 and IO7 are used for touch tests. + +On board2: +- IO01 -> bme280 SCL (yello) +- IO02 -> bme280 SDA (blue) +- IO13 -> HC-SR04 Echo. Ideally through a voltage divider or an LED. +- IO14 -> HC-SR04 Trig +- IO42 -> DS18B20 Data + +IO6, IO7, and IO8 must stay unconnected. + +Connect the two boards. +- GND (board1) - GND (board2) +- IO04 (board1) - IO05 (board2) +- IO05 (board1) - IO04 (board2) +*/ +class Esp32s3 extends Variant: + pulse-counter-channel-count ::= 4 + + voltage-divider-start-pin ::= 13 + voltage-divider-adc1-pin ::= 9 + voltage-divider-adc2-pin ::= 12 + voltage-divider-end-pin ::= 10 + + dac-out1-pin -> int: return unconnected-pin1 + dac-in1-pin -> int: return unconnected-pin2 + + dac-out2-pin -> int: return unconnected-pin1 + dac-in2-pin -> int: return unconnected-pin3 + + chain2-to-gnd-pin ::= 1 + chain2-pin2 ::= 2 + chain2-pin3 ::= 42 + + connected1-pin1 ::= 19 + connected1-pin2 ::= 21 + + restricted-pin ::= 33 + + touch-pin1 ::= 6 + touch-pin2 ::= 7 + unconnected-pin3 ::= 8 + + ble1-service ::= "94a11d6a-fa23-4a09-aa6f-2ca0b7cdbb70" + ble1-service2 ::= "a479c6fc-e650-484b-a4e6-1c5bc4e02f25" + + ble2-service ::= "509070b2-011a-4568-8753-24a2f00ea25c" + + ble3-first-service ::= "f88e954e-1cb6-4e79-ab19-ed2b20015044" + + ble4-service ::= "9a657aaf-5b98-4e5b-bc21-872b09e6a243" + + ble5-service ::= "ef738562-e999-482d-88a1-16ea26fa18d3" + + ble6-service ::= "eed6e6d2-6f4f-46e4-9ed2-116515189eba" + + espnow-channel ::= 5 + espnow-password ::= "pmk-esp32s3-1234" + + board2-i2c-scl-pin ::= 1 + board2-i2c-sda-pin ::= 2 + + board2-hc-sr04-trigger-pin ::= 14 + board2-hc-sr04-echo-pin ::= 13 + + board2-ds18b20-pin ::= 42 + + // We currently don't have any DHT11 sensor connected to this board. + board2-dht11-pin -> int: return unconnected-pin1 + + board-connection-pin1 ::= 4 + board-connection-pin2 ::= 5 diff --git a/tests/hw/esp32/wait-for-close-test.toit b/tests/hw/esp32/wait-for-close-test.toit index 968c4153e..af4b0512e 100644 --- a/tests/hw/esp32/wait-for-close-test.toit +++ b/tests/hw/esp32/wait-for-close-test.toit @@ -5,16 +5,16 @@ import gpio import .test +import .variants /** Tests the $gpio.Pin.wait-for functionality while a parallel task closes the pin. -# Setup -- Connect IO34 to GND with a 330+ Ohm resistor. 1MOhm is fine. +For the setup see the comment near $Variant.wait-for-close-pin. */ -PIN-IN ::= 34 +PIN-IN ::= Variant.CURRENT.wait-for-close-pin main: run-test: test diff --git a/tests/hw/esp32/wait-for1-shared.toit b/tests/hw/esp32/wait-for1-shared.toit index 03d932ad9..db4387ff4 100644 --- a/tests/hw/esp32/wait-for1-shared.toit +++ b/tests/hw/esp32/wait-for1-shared.toit @@ -2,23 +2,19 @@ // Use of this source code is governed by a Zero-Clause BSD license that can // be found in the tests/LICENSE file. -import gpio - /** Tests the $gpio.Pin.wait-for functionality. -# Setup -You need two boards. -- Connect GND of board1 to GND of board2. -- Connect pin 22 of board1 to pin 23 of board2. -- Connect pin 23 of board1 to pin 22 of board2. - Run `wait-for-board1.toit` on board1. Once that one is running, run `wait-for-board2.toit` on board2. */ -PIN-IN ::= 22 -PIN-OUT ::= 23 +import gpio + +import .variants + +PIN-IN ::= Variant.CURRENT.board-connection-pin1 +PIN-OUT ::= Variant.CURRENT.board-connection-pin2 ITERATIONS ::= 10_000 MEDIUM-PULSE-ITERATIONS ::= 50 diff --git a/tests/hw/pi/CMakeLists.txt b/tests/hw/pi/CMakeLists.txt index dc0205a13..299cb25d5 100644 --- a/tests/hw/pi/CMakeLists.txt +++ b/tests/hw/pi/CMakeLists.txt @@ -22,16 +22,20 @@ add_custom_target( ) foreach(file ${TOIT_TESTS}) - get_filename_component(name ${file} NAME_WE) set(toit_file ${CMAKE_CURRENT_SOURCE_DIR}/${file}) - set(test_name ${name}) + set(test_name ${file}) add_test( - NAME ${file} + NAME ${test_name} COMMAND ${TOIT_EXE_HW} ${toit_file} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURATIONS pi hw ) - set_tests_properties(${file} PROPERTIES TIMEOUT 40) + set_tests_properties(${test_name} PROPERTIES TIMEOUT 40) + # Don't run pi tests in parallel with other tests. + # This can be changed as long as: + # - resource-locking is added. + # - the Raspberry Pi is replaced with a more powerful version. + set_tests_properties(${test_name} PROPERTIES RUN_SERIAL TRUE) endforeach()