mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-11-20 15:52:12 +01:00
feat: support headless LILYGO T-Embed CC1101 Plus
Configure the integrated radio power, shared SPI selects, RF path and fixed wiring without changing generic boards. Preload output latches for Arduino 3 and publish radio availability only after register and RX checks succeed. Reuse the existing partition table and protect integrated, USB and PSRAM pins across configuration and GPIO output paths. Exercise production setup, RX and queue admission methods in a hardware-boundary host harness, run it in CI and document the opt-in build. Keep restore policy, security corrections and release tooling outside this board-only change.
This commit is contained in:
parent
e873dc8309
commit
fdf840a236
22 changed files with 715 additions and 31 deletions
26
tests/board-profile/Arduino.h
Normal file
26
tests/board-profile/Arduino.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
using byte = uint8_t;
|
||||
class String;
|
||||
|
||||
constexpr int LOW = 0;
|
||||
constexpr int HIGH = 1;
|
||||
constexpr int INPUT = 0x01;
|
||||
constexpr int OUTPUT = 0x03;
|
||||
void pinMode(uint8_t pin, uint8_t mode);
|
||||
void digitalWrite(uint8_t pin, uint8_t value);
|
||||
int digitalRead(uint8_t pin);
|
||||
unsigned long millis();
|
||||
void delay(unsigned long duration);
|
||||
|
||||
struct TestSerial {
|
||||
template <typename... Args> void printf(const char *, Args...) {}
|
||||
void println(const char *) {}
|
||||
};
|
||||
extern TestSerial Serial;
|
||||
struct TestESP {
|
||||
unsigned int getFlashChipSize() { return 16777216; }
|
||||
unsigned int getPsramSize() { return 8388608; }
|
||||
};
|
||||
extern TestESP ESP;
|
||||
2
tests/board-profile/ArduinoJson.h
Normal file
2
tests/board-profile/ArduinoJson.h
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#pragma once
|
||||
class JsonObject;
|
||||
8
tests/board-profile/Preferences.h
Normal file
8
tests/board-profile/Preferences.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
extern bool testRadioInit;
|
||||
struct Preferences {
|
||||
void begin(const char *) {}
|
||||
bool getBool(const char *, bool) { return testRadioInit; }
|
||||
void putBool(const char *, bool value) { testRadioInit = value; }
|
||||
void end() {}
|
||||
};
|
||||
11
tests/board-profile/SPI.h
Normal file
11
tests/board-profile/SPI.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
struct TestSPI {
|
||||
bool active = false;
|
||||
unsigned int starts = 0;
|
||||
unsigned int stops = 0;
|
||||
void begin(int8_t sck, int8_t miso, int8_t mosi, int8_t cs);
|
||||
void end();
|
||||
};
|
||||
extern TestSPI SPI;
|
||||
95
tests/board-profile/board-profile-test.cpp
Normal file
95
tests/board-profile/board-profile-test.cpp
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "BoardProfile.h"
|
||||
#include "SPI.h"
|
||||
#include <driver/gpio.h>
|
||||
|
||||
TestSerial Serial;
|
||||
TestESP ESP;
|
||||
TestSPI SPI;
|
||||
void TestSPI::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t cs) {
|
||||
assert(sck == 11 && miso == 10 && mosi == 9 && cs == 12);
|
||||
assert(!active);
|
||||
active = true;
|
||||
starts++;
|
||||
}
|
||||
void TestSPI::end() { active = false; stops++; }
|
||||
static int levels[49] = {};
|
||||
static int modes[49] = {};
|
||||
static unsigned long clockMs = 0;
|
||||
static bool stuckMiso = false;
|
||||
static unsigned int powerTransitions = 0;
|
||||
|
||||
void pinMode(uint8_t pin, uint8_t mode) {
|
||||
// Arduino 3 must release SPI ownership before preflight changes its pins.
|
||||
if(pin == 9 || pin == 10 || pin == 11) assert(!SPI.active);
|
||||
if(mode == OUTPUT) {
|
||||
// Initial output enable must already have the safe level latched.
|
||||
const bool high = pin == 12 || pin == 13 || pin == 15 || pin == 41 ||
|
||||
pin == 44 || pin == 47 || pin == 48;
|
||||
assert(levels[pin] == (high ? HIGH : LOW));
|
||||
}
|
||||
modes[pin] = mode;
|
||||
}
|
||||
int gpio_set_level(gpio_num_t pin, uint32_t value) {
|
||||
if(pin == 15 && value == HIGH) {
|
||||
// No other SPI device may drive MISO when the rail comes up.
|
||||
assert(levels[12] == HIGH && levels[13] == HIGH);
|
||||
assert(levels[41] == HIGH && levels[44] == HIGH);
|
||||
assert(levels[43] == LOW && levels[21] == LOW);
|
||||
assert(levels[47] == HIGH && levels[48] == HIGH);
|
||||
const uint8_t controls[] = {12, 13, 21, 41, 43, 44, 47, 48};
|
||||
for(auto control : controls) assert(modes[control] == OUTPUT);
|
||||
powerTransitions++;
|
||||
}
|
||||
levels[pin] = value;
|
||||
return 0;
|
||||
}
|
||||
void digitalWrite(uint8_t pin, uint8_t value) {
|
||||
// Arduino 3 only accepts writes after pinMode establishes GPIO ownership.
|
||||
if(modes[pin] == OUTPUT) gpio_set_level(pin, value);
|
||||
}
|
||||
int digitalRead(uint8_t pin) {
|
||||
if(pin == 10) return stuckMiso ? HIGH : LOW;
|
||||
return levels[pin];
|
||||
}
|
||||
unsigned long millis() { return clockMs; }
|
||||
void delay(unsigned long duration) { clockMs += duration; }
|
||||
|
||||
int main() {
|
||||
BoardProfile::begin();
|
||||
if(BoardProfile::integratedRadio) {
|
||||
assert(powerTransitions == 1);
|
||||
assert(modes[15] == OUTPUT);
|
||||
assert(BoardProfile::prepareRadio(433.42f));
|
||||
assert(SPI.active && SPI.starts == 1);
|
||||
assert(modes[10] == INPUT && modes[9] == OUTPUT && modes[11] == OUTPUT);
|
||||
assert(levels[12] == HIGH); // Release CS after readiness probe.
|
||||
assert(BoardProfile::prepareRadio(433.42f)); // Reconfigure a running bus safely.
|
||||
assert(SPI.active && SPI.starts == 2 && SPI.stops == 2);
|
||||
assert(!BoardProfile::prepareRadio(868.0f));
|
||||
assert(!BoardProfile::prepareRadio(0.0f / 0.0f));
|
||||
stuckMiso = true;
|
||||
auto started = millis();
|
||||
assert(!BoardProfile::prepareRadio(433.42f));
|
||||
assert(millis() - started <= 25); // Fail safely instead of hanging in SmartRC.
|
||||
assert(levels[12] == HIGH);
|
||||
assert(!SPI.active); // A failed preflight must not initialize SPI.
|
||||
stuckMiso = false;
|
||||
assert(BoardProfile::prepareRadio(433.42f));
|
||||
assert(powerTransitions == 1); // Retrying must not power-cycle shared devices.
|
||||
const uint8_t reserved[] = {3, 9, 10, 11, 12, 13, 15, 21, 38, 41, 43, 44, 47, 48};
|
||||
for(auto pin : reserved) assert(BoardProfile::usesPin(pin));
|
||||
assert(BoardProfile::usesPin(19) && BoardProfile::usesPin(20));
|
||||
for(uint8_t pin = 26; pin <= 37; pin++) assert(BoardProfile::usesPin(pin));
|
||||
assert(!BoardProfile::usesPin(255));
|
||||
assert(!BoardProfile::usesPin(16));
|
||||
}
|
||||
else {
|
||||
assert(powerTransitions == 0);
|
||||
assert(!SPI.active && SPI.starts == 0 && SPI.stops == 0);
|
||||
assert(BoardProfile::prepareRadio(868.0f));
|
||||
for(uint8_t pin = 0; pin < 49; pin++) assert(!BoardProfile::usesPin(pin));
|
||||
}
|
||||
puts("Board profile checks passed");
|
||||
}
|
||||
4
tests/board-profile/driver/gpio.h
Normal file
4
tests/board-profile/driver/gpio.h
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
using gpio_num_t = int;
|
||||
int gpio_set_level(gpio_num_t pin, uint32_t value);
|
||||
9
tests/board-profile/esp_log.h
Normal file
9
tests/board-profile/esp_log.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
// Keep the test logger a function call so unused firmware format arguments are
|
||||
// still type-checked and the production TAG is referenced.
|
||||
template <typename... Args> inline void testLog(const char *, const char *, Args...) {}
|
||||
#define ESP_LOGD(...) testLog(__VA_ARGS__)
|
||||
|
||||
#define ESP_LOGE(...) testLog(__VA_ARGS__)
|
||||
#define ESP_LOGW(...) testLog(__VA_ARGS__)
|
||||
#define ESP_LOGI(...) testLog(__VA_ARGS__)
|
||||
29
tests/board-profile/extract-radio-setup.py
Normal file
29
tests/board-profile/extract-radio-setup.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"""Compile selected production methods without the unrelated RTOS/network code."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
source = Path(sys.argv[1]).read_text()
|
||||
names = [
|
||||
'static bool checkBoardRadio(',
|
||||
'void transceiver_config_t::applyBoardPins(',
|
||||
'void transceiver_config_t::apply(',
|
||||
'void Transceiver::setConfig(',
|
||||
'bool Transceiver::usesPin(',
|
||||
'void Transceiver::enableReceive(',
|
||||
'bool Transceiver::startReceive(',
|
||||
'void Transceiver::disableReceive(',
|
||||
'uint32_t Transceiver::submitTx(',
|
||||
]
|
||||
methods = []
|
||||
for name in names:
|
||||
assert source.count(name) == 1, f'Production setup method changed: {name}'
|
||||
start = source.index(name)
|
||||
brace = source.index('{', start)
|
||||
depth = 1
|
||||
end = brace + 1
|
||||
while depth:
|
||||
assert end < len(source), f'Unterminated method: {name}'
|
||||
depth += (source[end] == '{') - (source[end] == '}')
|
||||
end += 1
|
||||
methods.append(source[start:end])
|
||||
Path(sys.argv[2]).write_text('\n\n'.join(methods) + '\n')
|
||||
162
tests/board-profile/radio-setup-test.cpp
Normal file
162
tests/board-profile/radio-setup-test.cpp
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
// Exercise the actual radio setup, RX and queue-admission methods, replacing
|
||||
// only hardware/RTOS boundaries. The script extracts those definitions from
|
||||
// Transceiver.cpp so the test cannot silently exercise a copy of the logic.
|
||||
#include <assert.h>
|
||||
#include <new>
|
||||
#include <initializer_list>
|
||||
#include <stdio.h>
|
||||
#include "Transceiver.h"
|
||||
#include "SPI.h"
|
||||
#include "esp_log.h"
|
||||
#include <driver/gpio.h>
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
|
||||
TestSerial Serial;
|
||||
TestESP ESP;
|
||||
TestSPI SPI;
|
||||
void TestSPI::begin(int8_t, int8_t, int8_t, int8_t) { active = true; }
|
||||
void TestSPI::end() { active = false; }
|
||||
static int levels[49] = {};
|
||||
static bool stuckMiso;
|
||||
static unsigned long clockMs;
|
||||
void pinMode(uint8_t, uint8_t) {}
|
||||
void digitalWrite(uint8_t pin, uint8_t value) { levels[pin] = value; }
|
||||
int digitalRead(uint8_t pin) { return pin == 10 && stuckMiso ? HIGH : levels[pin]; }
|
||||
int gpio_set_level(gpio_num_t pin, uint32_t value) { levels[pin] = value; return 0; }
|
||||
unsigned long millis() { return clockMs; }
|
||||
void delay(unsigned long ms) { clockMs += ms; }
|
||||
static unsigned int attached;
|
||||
static unsigned int rxStarts;
|
||||
static unsigned int initializations;
|
||||
static unsigned int saves;
|
||||
static bool observedReadyDuringRx;
|
||||
static uint32_t queuedDuringRx;
|
||||
int digitalPinToInterrupt(uint8_t pin) { return pin; }
|
||||
constexpr int CHANGE = 1;
|
||||
void attachInterrupt(int, void (*)(), int) { attached++; }
|
||||
void detachInterrupt(int) { attached = 0; }
|
||||
static const char *TAG = "Somfy";
|
||||
static uint8_t rxmode;
|
||||
static int interruptPin;
|
||||
uint8_t radioBitLength;
|
||||
bool testRadioInit = true;
|
||||
struct { Transceiver transceiver; } somfy;
|
||||
struct RadioLock { RadioLock(int = 0, bool = false) {} };
|
||||
struct TxQueueLock { ~TxQueueLock() {} };
|
||||
constexpr int portMAX_DELAY = 0;
|
||||
static bool scanEmitPending;
|
||||
static void *txTaskHandle = reinterpret_cast<void *>(1);
|
||||
void xTaskNotifyGive(void *) {}
|
||||
void Transceiver::handleReceive() {}
|
||||
void Transceiver::resumeTx(uint8_t) {}
|
||||
static void warnBootPin(const char *, uint8_t) {}
|
||||
void transceiver_config_t::save() {
|
||||
saves++;
|
||||
if(BoardProfile::integratedRadio)
|
||||
assert(SCKPin == 11 && MISOPin == 10 && MOSIPin == 9 && CSNPin == 12 && TXPin == 3 && RXPin == 38);
|
||||
}
|
||||
|
||||
ELECHOUSE_CC1101 ELECHOUSE_cc1101;
|
||||
static bool detected;
|
||||
static uint8_t part, version, gdo0, gdo2, packet, modem, rxState;
|
||||
static uint32_t frequencyWord;
|
||||
void ELECHOUSE_CC1101::Init() { initializations++; }
|
||||
bool ELECHOUSE_CC1101::getCC1101() { return detected; }
|
||||
byte ELECHOUSE_CC1101::SpiReadStatus(byte addr) {
|
||||
if(addr == CC1101_PARTNUM) return part;
|
||||
if(addr == CC1101_VERSION) return version;
|
||||
if(addr == CC1101_MARCSTATE) return rxState;
|
||||
assert(false); return 0;
|
||||
}
|
||||
byte ELECHOUSE_CC1101::SpiReadReg(byte addr) {
|
||||
if(addr == CC1101_IOCFG0) return gdo0;
|
||||
if(addr == CC1101_IOCFG2) return gdo2;
|
||||
if(addr == CC1101_PKTCTRL0) return packet;
|
||||
if(addr == CC1101_MDMCFG2) return modem;
|
||||
if(addr == CC1101_FREQ2) return frequencyWord >> 16;
|
||||
if(addr == CC1101_FREQ1) return frequencyWord >> 8;
|
||||
if(addr == CC1101_FREQ0) return frequencyWord;
|
||||
assert(false); return 0;
|
||||
}
|
||||
void ELECHOUSE_CC1101::setSpiPin(byte sck, byte miso, byte mosi, byte cs) {
|
||||
if(BoardProfile::integratedRadio) assert(sck == 11 && miso == 10 && mosi == 9 && cs == 12);
|
||||
}
|
||||
void ELECHOUSE_CC1101::SetRx() {
|
||||
rxStarts++;
|
||||
observedReadyDuringRx = somfy.transceiver.available();
|
||||
somfy_tx_job_t job;
|
||||
queuedDuringRx = somfy.transceiver.submitTx(job);
|
||||
}
|
||||
void ELECHOUSE_CC1101::setSidle() {}
|
||||
void ELECHOUSE_CC1101::setGDO(byte, byte) {}
|
||||
void ELECHOUSE_CC1101::setGDO0(byte) {}
|
||||
#define NOOP(name, type) void ELECHOUSE_CC1101::name(type) {}
|
||||
NOOP(setCCMode, bool) NOOP(setMHZ, float) NOOP(setRxBW, float)
|
||||
NOOP(setDeviation, float) NOOP(setPA, int) NOOP(setModulation, byte)
|
||||
NOOP(setManchester, bool) NOOP(setPktFormat, byte) NOOP(setDcFilterOff, bool)
|
||||
NOOP(setCrc, bool) NOOP(setCRC_AF, bool) NOOP(setSyncMode, byte) NOOP(setAdrChk, byte)
|
||||
|
||||
#include "radio-setup-methods.inc"
|
||||
|
||||
static void reset() {
|
||||
somfy.transceiver.~Transceiver();
|
||||
new (&somfy.transceiver) Transceiver;
|
||||
detected = true; part = 0; version = 0x14;
|
||||
gdo0 = gdo2 = 0x0D; packet = 0x32; modem = 0x3C;
|
||||
frequencyWord = 0x10AB85; rxState = 0x0D;
|
||||
attached = rxStarts = initializations = saves = 0;
|
||||
observedReadyDuringRx = false; queuedDuringRx = 0;
|
||||
testRadioInit = true; stuckMiso = false; rxmode = 0; clockMs = 0;
|
||||
}
|
||||
static void assertUnavailable() {
|
||||
auto &radio = somfy.transceiver;
|
||||
assert(!radio.available() && !radio.config.radioInit && attached == 0);
|
||||
somfy_tx_job_t job;
|
||||
assert(radio.submitTx(job) == 0);
|
||||
radio.enableReceive();
|
||||
assert(attached == 0);
|
||||
}
|
||||
int main() {
|
||||
reset(); auto &radio = somfy.transceiver;
|
||||
if(BoardProfile::integratedRadio) {
|
||||
radio.config.SCKPin = radio.config.TXPin = radio.config.RXPin = 16;
|
||||
radio.config.apply();
|
||||
assert(radio.available() && radio.config.radioInit && attached == 1);
|
||||
assert(!observedReadyDuringRx && queuedDuringRx == 0);
|
||||
assert(radio.config.TXPin == 3 && radio.config.RXPin == 38 && radio.config.SCKPin == 11);
|
||||
somfy_tx_job_t job; assert(radio.submitTx(job) != 0);
|
||||
stuckMiso = true; radio.config.apply(); assertUnavailable();
|
||||
stuckMiso = false; radio.config.apply(); assert(radio.available());
|
||||
transceiver_config_t next = radio.config;
|
||||
next.enabled = false;
|
||||
next.SCKPin = next.MOSIPin = next.MISOPin = next.CSNPin = next.TXPin = next.RXPin = 16;
|
||||
radio.setConfig(next); assertUnavailable(); assert(saves == 1);
|
||||
for(uint8_t pin : {uint8_t(3), uint8_t(12), uint8_t(19), uint8_t(33), uint8_t(48)}) assert(radio.usesPin(pin));
|
||||
assert(!radio.usesPin(16));
|
||||
reset(); stuckMiso = true; radio.config.apply(); assertUnavailable(); assert(initializations == 0);
|
||||
reset(); testRadioInit = false; radio.config.apply(); assertUnavailable(); assert(initializations == 0);
|
||||
reset(); detected = false; radio.config.apply(); assertUnavailable(); assert(rxStarts == 0);
|
||||
reset(); part = 1; radio.config.apply(); assertUnavailable();
|
||||
reset(); version = 0; radio.config.apply(); assertUnavailable();
|
||||
reset(); version = 0xFF; radio.config.apply(); assertUnavailable(); assert(rxStarts == 0);
|
||||
reset(); gdo0 = 0; radio.config.apply(); assertUnavailable();
|
||||
reset(); gdo2 = 0; radio.config.apply(); assertUnavailable();
|
||||
reset(); packet = 0; radio.config.apply(); assertUnavailable();
|
||||
reset(); modem = 0; radio.config.apply(); assertUnavailable();
|
||||
reset(); frequencyWord = 0; radio.config.apply(); assertUnavailable();
|
||||
reset(); rxState = 0; radio.config.apply(); assertUnavailable(); assert(rxStarts == 1 && millis() <= 25);
|
||||
rxState = 0x0D; radio.config.apply(); assert(radio.available() && attached == 1);
|
||||
} else {
|
||||
// Generic radios retain upstream's enabled-based availability and queue
|
||||
// admission behavior, including when disabled or detection fails.
|
||||
radio.config.apply();
|
||||
somfy_tx_job_t job; assert(radio.submitTx(job) != 0);
|
||||
radio.config.enabled = true; detected = false; radio.config.apply();
|
||||
assert(radio.available() && !radio.config.radioInit);
|
||||
radio.config.apply(); // Still no Plus-specific register gating.
|
||||
detected = true; rxState = 0; radio.config.apply();
|
||||
assert(radio.available() && radio.config.radioInit && attached == 1);
|
||||
assert(observedReadyDuringRx && queuedDuringRx != 0);
|
||||
}
|
||||
puts("Radio readiness and RX/queue gating checks passed");
|
||||
}
|
||||
76
tests/board-profile/shade-gpio-test.cpp
Normal file
76
tests/board-profile/shade-gpio-test.cpp
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "BoardProfile.h"
|
||||
#include <driver/gpio.h>
|
||||
#include "SomfyFrame.h"
|
||||
#include "ShadeSettings.h"
|
||||
|
||||
// Substitute only the shade model/storage boundary. The GPIO methods below
|
||||
// are compiled from the production ShadeGpio.cpp and observe real board policy.
|
||||
#define SOMFY_H
|
||||
enum class gpio_flags_t : byte { LowLevelTrigger = 0x01 };
|
||||
struct SomfyRemote {
|
||||
void triggerGPIOs(somfy_frame_t &frame);
|
||||
};
|
||||
struct SomfyShade : SomfyRemote, ShadeSettings {
|
||||
radio_proto proto = radio_proto::GP_Relay;
|
||||
uint8_t gpioFlags = 0;
|
||||
int8_t gpioDir = 0;
|
||||
uint8_t gpioUp = 16, gpioDown = 17, gpioMy = 18;
|
||||
uint32_t gpioRelease = 0;
|
||||
struct State { int8_t direction = -1, tiltDirection = 0; float currentPos = 0; } position;
|
||||
const State &state() const { return position; }
|
||||
bool isToggle() { return isToggleShade(shadeType); }
|
||||
void setGPIOs();
|
||||
void triggerGPIOs(somfy_frame_t &frame);
|
||||
bool usesPin(uint8_t pin);
|
||||
};
|
||||
#include "ShadeGpio.cpp"
|
||||
|
||||
TestSerial Serial;
|
||||
TestESP ESP;
|
||||
static unsigned int writes = 0;
|
||||
static int levels[49] = {};
|
||||
int gpio_set_level(gpio_num_t pin, uint32_t value) { levels[pin] = value; return 0; }
|
||||
void pinMode(uint8_t, uint8_t) {}
|
||||
void digitalWrite(uint8_t pin, uint8_t value) { writes++; levels[pin] = value; }
|
||||
int digitalRead(uint8_t pin) { return levels[pin]; }
|
||||
unsigned long millis() { return 100; }
|
||||
void delay(unsigned long) {}
|
||||
// BoardProfile preflight is linked but this test never starts the hardware.
|
||||
#include "SPI.h"
|
||||
TestSPI SPI;
|
||||
void TestSPI::begin(int8_t, int8_t, int8_t, int8_t) {}
|
||||
void TestSPI::end() {}
|
||||
|
||||
int main() {
|
||||
SomfyShade shade;
|
||||
shade.setGPIOs();
|
||||
assert(writes == 2 && levels[16] == HIGH && levels[17] == LOW);
|
||||
somfy_frame_t frame;
|
||||
frame.cmd = somfy_commands::Down;
|
||||
frame.repeats = 2;
|
||||
shade.proto = radio_proto::GP_Remote;
|
||||
shade.triggerGPIOs(frame);
|
||||
assert(writes == 5 && levels[17] == HIGH);
|
||||
const unsigned int before = writes;
|
||||
// These assignments can arrive from an old backup with the radio disabled.
|
||||
// Test every reserved pad in each output slot, including USB/flash pads.
|
||||
for(uint8_t pin = 0; pin < 49; pin++) {
|
||||
if(!BoardProfile::usesPin(pin)) continue;
|
||||
for(uint8_t slot = 0; slot < 3; slot++) {
|
||||
shade.gpioUp = slot == 0 ? pin : 16;
|
||||
shade.gpioDown = slot == 1 ? pin : 17;
|
||||
shade.gpioMy = slot == 2 ? pin : 18;
|
||||
shade.proto = radio_proto::GP_Remote;
|
||||
shade.triggerGPIOs(frame);
|
||||
shade.setGPIOs();
|
||||
if(slot != 2) {
|
||||
shade.proto = radio_proto::GP_Relay;
|
||||
shade.setGPIOs();
|
||||
}
|
||||
assert(writes == before);
|
||||
}
|
||||
}
|
||||
puts("Reserved shade GPIO checks passed");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue