From a97baa6fc2a32dc44c93e7ce5d451d111e9b7376 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 18 May 2023 21:57:24 +0200 Subject: [PATCH] [CI] Updated SX1261 autotest --- extras/test/SX126x/PiHal.h | 14 +++++++------- extras/test/SX126x/main.cpp | 10 +++++++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/extras/test/SX126x/PiHal.h b/extras/test/SX126x/PiHal.h index 4c9c7bef..5a94fe8d 100644 --- a/extras/test/SX126x/PiHal.h +++ b/extras/test/SX126x/PiHal.h @@ -2,7 +2,7 @@ #define PI_HAL_H // include RadioLib -#include +#include // include the library for Raspberry GPIO pins #include "pigpio.h" @@ -107,17 +107,17 @@ class PiHal : public RadioLibHal { return(0); } - gpioSetMode(pin, PI_INPUT); - uint32_t start = gpioTick(); - uint32_t curtick = gpioTick(); + this->pinMode(pin, PI_INPUT); + uint32_t start = this->micros(); + uint32_t curtick = this->micros(); - while(gpioRead(pin) == state) { - if((gpioTick() - curtick) > timeout) { + while(this->digitalRead(pin) == state) { + if((this->micros() - curtick) > timeout) { return(0); } } - return(gpioTick() - start); + return(this->micros() - start); } void spiBegin() { diff --git a/extras/test/SX126x/main.cpp b/extras/test/SX126x/main.cpp index 40e8bfeb..4b88d443 100644 --- a/extras/test/SX126x/main.cpp +++ b/extras/test/SX126x/main.cpp @@ -4,8 +4,10 @@ #include #include "PiHal.h" +#define RADIOLIB_TEST_ASSERT(STATEVAR) { if((STATEVAR) != RADIOLIB_ERR_NONE) { return(-1*(STATEVAR)); } } + PiHal* hal = new PiHal(1); -SX1261 radio = new Module(hal, 7, 17, 22, 4); +SX1261 radio = new Module(hal, 7, 17, 22, RADIOLIB_NC); // the entry point for the program int main(int argc, char** argv) { @@ -13,9 +15,11 @@ int main(int argc, char** argv) { state = radio.begin(); printf("[SX1261] Test:begin() = %d\n", state); + RADIOLIB_TEST_ASSERT(state); - //state = radio.transmit("Hello World!"); - //printf("[SX1261] Test:transmit() = %d\n", state); + state = radio.transmit("Hello World!"); + printf("[SX1261] Test:transmit() = %d\n", state); + RADIOLIB_TEST_ASSERT(state); hal->term(); return(0);