From 4dd485cf22540454dbd2eedf5129b1da542114f5 Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 6 Dec 2024 12:34:40 +0100 Subject: [PATCH 1/4] Create example for ibus on RP2040 This commit adds an example how to use an ibus receiver with a RP2040 mcu. --- examples/rp2040/ibus_basic/ibus_basic.ino | 55 +++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 examples/rp2040/ibus_basic/ibus_basic.ino diff --git a/examples/rp2040/ibus_basic/ibus_basic.ino b/examples/rp2040/ibus_basic/ibus_basic.ino new file mode 100644 index 0000000..9a6127a --- /dev/null +++ b/examples/rp2040/ibus_basic/ibus_basic.ino @@ -0,0 +1,55 @@ +/*! + * @file crsf_basic.ino + */ +/* +# Sample platformio.ini file: +# --------------------------- +[platformio] +default_envs = ws-rp2040-zero + +[env:ws-rp2040-zero] +platform = https://github.com/maxgerhardt/platform-raspberrypi.git +board = waveshare_rp2040_pizero +framework = arduino +board_build.core = earlephilhower +monitor_speed = 115200 + +lib_deps = + https://github.com/Witty-Wizard/SerialIO +*/ +#include + +#define SBUS_TX_PIN 0 +#define SBUS_RX_PIN 1 + +rc_channels_t rcdata; +ibus receiver(&Serial1, SBUS_RX_PIN, SBUS_TX_PIN, true); // RP2040 requires the TX_PIN so to not hang up the mcu + +void setup() +{ + // setup sbus receiver + Serial1.setInvertRX(true); // will only work with the earlephilhower core + Serial1.setInvertTX(true); + receiver.begin(); + + Serial.begin(115200); +} + +void loop() +{ + static unsigned long last_millis = millis(); + + receiver.processIncoming(); + receiver.getChannel(&rcdata); + + if (millis() > last_millis + 100) + { + Serial.printf("RC: %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d", + rcdata.channel1, rcdata.channel2, rcdata.channel3, rcdata.channel4, + rcdata.channel5, rcdata.channel6, rcdata.channel7, rcdata.channel8, + rcdata.channel9, rcdata.channel10, rcdata.channel11, rcdata.channel12, + rcdata.channel13, rcdata.channel14); + Serial.println(); + last_millis = millis(); + } +} From 708d26fd07e43c70f8c661476a9c10b1afa34de7 Mon Sep 17 00:00:00 2001 From: Witty-Wizard Date: Sat, 7 Dec 2024 13:21:00 +0530 Subject: [PATCH 2/4] Added: yml file to ignore the CI for rp2040 --- examples/rp2040/ibus_basic/.arduino-ci.yml | 2 ++ examples/rp2040/ibus_basic/ibus_basic.ino | 23 +++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 examples/rp2040/ibus_basic/.arduino-ci.yml diff --git a/examples/rp2040/ibus_basic/.arduino-ci.yml b/examples/rp2040/ibus_basic/.arduino-ci.yml new file mode 100644 index 0000000..64f423a --- /dev/null +++ b/examples/rp2040/ibus_basic/.arduino-ci.yml @@ -0,0 +1,2 @@ +skip_files: + - ibus_basic.ino \ No newline at end of file diff --git a/examples/rp2040/ibus_basic/ibus_basic.ino b/examples/rp2040/ibus_basic/ibus_basic.ino index 9a6127a..80f6006 100644 --- a/examples/rp2040/ibus_basic/ibus_basic.ino +++ b/examples/rp2040/ibus_basic/ibus_basic.ino @@ -1,7 +1,8 @@ /*! - * @file crsf_basic.ino + * @file ibus_basic.ino */ /* + # Sample platformio.ini file: # --------------------------- [platformio] @@ -17,16 +18,17 @@ monitor_speed = 115200 lib_deps = https://github.com/Witty-Wizard/SerialIO */ + #include #define SBUS_TX_PIN 0 #define SBUS_RX_PIN 1 rc_channels_t rcdata; -ibus receiver(&Serial1, SBUS_RX_PIN, SBUS_TX_PIN, true); // RP2040 requires the TX_PIN so to not hang up the mcu +ibus receiver(&Serial1, SBUS_RX_PIN, SBUS_TX_PIN, + true); // RP2040 requires the TX_PIN so to not hang up the mcu -void setup() -{ +void setup() { // setup sbus receiver Serial1.setInvertRX(true); // will only work with the earlephilhower core Serial1.setInvertTX(true); @@ -35,19 +37,18 @@ void setup() Serial.begin(115200); } -void loop() -{ +void loop() { static unsigned long last_millis = millis(); receiver.processIncoming(); receiver.getChannel(&rcdata); - if (millis() > last_millis + 100) - { + if (millis() > last_millis + 100) { Serial.printf("RC: %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d", - rcdata.channel1, rcdata.channel2, rcdata.channel3, rcdata.channel4, - rcdata.channel5, rcdata.channel6, rcdata.channel7, rcdata.channel8, - rcdata.channel9, rcdata.channel10, rcdata.channel11, rcdata.channel12, + rcdata.channel1, rcdata.channel2, rcdata.channel3, + rcdata.channel4, rcdata.channel5, rcdata.channel6, + rcdata.channel7, rcdata.channel8, rcdata.channel9, + rcdata.channel10, rcdata.channel11, rcdata.channel12, rcdata.channel13, rcdata.channel14); Serial.println(); last_millis = millis(); From ac2d9c80a2eae7a553087a7be9d1bfeae541f4ca Mon Sep 17 00:00:00 2001 From: Witty-Wizard Date: Sat, 7 Dec 2024 13:27:33 +0530 Subject: [PATCH 3/4] Added: earlephilehower core --- examples/rp2040/ibus_basic/.arduino-ci.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/examples/rp2040/ibus_basic/.arduino-ci.yml b/examples/rp2040/ibus_basic/.arduino-ci.yml index 64f423a..f08632d 100644 --- a/examples/rp2040/ibus_basic/.arduino-ci.yml +++ b/examples/rp2040/ibus_basic/.arduino-ci.yml @@ -1,2 +1,18 @@ -skip_files: - - ibus_basic.ino \ No newline at end of file +platforms: + rpipico: + board: rp2040:rp2040:rpipico + package: rp2040:rp2040 + gcc: + features: + defines: + - ARDUINO_ARCH_RP2040 + warnings: + flags: + +packages: + rp2040:rp2040: + url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + +compile: + platforms: + - rpipico From 20a809972bee5c0fa7e7aa177dee9589c9a3bdf1 Mon Sep 17 00:00:00 2001 From: Witty-Wizard Date: Sat, 7 Dec 2024 13:31:54 +0530 Subject: [PATCH 4/4] Removed: invert statement, as handled in the begin function --- examples/rp2040/ibus_basic/ibus_basic.ino | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/rp2040/ibus_basic/ibus_basic.ino b/examples/rp2040/ibus_basic/ibus_basic.ino index 80f6006..931e9b4 100644 --- a/examples/rp2040/ibus_basic/ibus_basic.ino +++ b/examples/rp2040/ibus_basic/ibus_basic.ino @@ -30,8 +30,6 @@ ibus receiver(&Serial1, SBUS_RX_PIN, SBUS_TX_PIN, void setup() { // setup sbus receiver - Serial1.setInvertRX(true); // will only work with the earlephilhower core - Serial1.setInvertTX(true); receiver.begin(); Serial.begin(115200);