Skip to content

Commit f106035

Browse files
authored
Adds support for Challenger NB RP2040 WiFi board and RPICO32 module (#366)
1 parent 21f49d0 commit f106035

File tree

9 files changed

+1421
-0
lines changed

9 files changed

+1421
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ See https://arduino-pico.readthedocs.io/en/latest/ along with the examples for m
2121
* Cytron Maker Pi RP2040
2222
* Cytron Maker Nano RP2040
2323
* Invector Labs Challenger RP2040 WiFi
24+
* Invector Labs Challenger NB RP2040 WiFi
2425
* Invector Labs Challenger RP2040 LTE
26+
* Invector Labs RPICO32
2527
* Melopero Shake RP2040
2628
* SparkFun ProMicro RP2040
2729
* uPesy RP2040 DevKit

boards.txt

Lines changed: 974 additions & 0 deletions
Large diffs are not rendered by default.

tools/makeboards.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ def MakeBoard(name, vendor_name, product_name, vid, pid, boarddefine, flashsizem
163163
MakeBoard("generic", "Generic", "RP2040", "0x2e8a", "0xf00a", "GENERIC_RP2040", 16, "boot2_generic_03h_4_padded_checksum")
164164
MakeBoard("challenger_2040_wifi", "iLabs", "Challenger 2040 WiFi", "0x2e8a", "0x1006", "CHALLENGER_2040_WIFI_RP2040", 8, "boot2_w25q080_2_padded_checksum")
165165
MakeBoard("challenger_2040_lte", "iLabs", "Challenger 2040 LTE", "0x2e8a", "0x100b", "CHALLENGER_2040_LTE_RP2040", 8, "boot2_w25q080_2_padded_checksum")
166+
MakeBoard("challenger_nb_2040_wifi", "iLabs", "Challenger NB 2040 WiFi", "0x2e8a", "0x100b", "CHALLENGER_2040_LTE_RP2040", 8, "boot2_w25q080_2_padded_checksum")
167+
MakeBoard("ilabs_rpico32", "iLabs", "RPICO32", "0x2e8a", "0x1010", "ILABS_2040_RPICO32_RP2040", 8, "boot2_w25q080_2_padded_checksum")
166168
MakeBoard("melopero_shake_rp2040", "Melopero", "Shake RP2040", "0x2e8a", "0x1005", "MELOPERO_SHAKE_RP2040", 16, "boot2_w25q080_2_padded_checksum")
167169
MakeBoard("upesy_rp2040_devkit", "uPesy", "RP2040 DevKit", "0x2e8a", "0x1007", "UPESY_RP2040_DEVKIT", 2, "boot2_w25q080_2_padded_checksum")
168170
MakeBoard("wiznet_5100s_evb_pico", "WIZnet", "W5100S-EVB-Pico", "0x2e8a", "0x1008", "WIZNET_5100S_EVB_PICO", 2, "boot2_w25q080_2_padded_checksum")
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
ESP8285 helper class for the Challenger RP2040 WiFi boards
3+
4+
Copyright (c) 2021 P. Oldberg <[email protected]>
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
21+
#include <Arduino.h>
22+
#include <ChallengerWiFi.h>
23+
24+
Challenger2040WiFiClass::Challenger2040WiFiClass() {
25+
pinMode(PIN_ESP8285_RST, OUTPUT);
26+
digitalWrite(PIN_ESP8285_RST, LOW); // Hold ESP8285 in reset
27+
pinMode(PIN_ESP8285_MODE, OUTPUT);
28+
digitalWrite(PIN_ESP8285_MODE, HIGH); // Prepare for normal start
29+
}
30+
31+
// Do a HW reset by applying a low pulse to the reset line for 1mSec
32+
void Challenger2040WiFiClass::doHWReset() {
33+
digitalWrite(PIN_ESP8285_RST, LOW); // Hold ESP8285 in reset
34+
delay(1);
35+
digitalWrite(PIN_ESP8285_RST, HIGH); // Release ESP8285 reset
36+
}
37+
38+
// Set the mode flag high to indicate normal run operation and do a HW
39+
// reset.
40+
void Challenger2040WiFiClass::runReset() { // Prepare ESP8285 for normal op
41+
digitalWrite(PIN_ESP8285_MODE, HIGH); // Prepare for normal start
42+
doHWReset();
43+
}
44+
45+
// Set the mode flag low to indicate flash operation and do a HW
46+
// reset.
47+
void Challenger2040WiFiClass::flashReset() { // Prepare ESP8285 for flashing
48+
digitalWrite(PIN_ESP8285_MODE, LOW); // Prepare for normal start
49+
doHWReset();
50+
}
51+
52+
// Wait for the modem to reply with a "ready" prompt. This can be done
53+
// after a sw or hw reset have been performed to ensure that the AT
54+
// interpreter is up and running.
55+
bool Challenger2040WiFiClass::waitForReady() {
56+
int timeout = 20; // Aprox max 2 sec
57+
58+
Serial2.begin(DEFAULT_ESP8285_BAUDRATE);
59+
Serial2.setTimeout(100);
60+
String rdy = Serial2.readStringUntil('\n');
61+
while(!rdy.startsWith("ready") && timeout--) {
62+
rdy = Serial2.readStringUntil('\n');
63+
}
64+
Serial2.setTimeout(1000); // Reset default timeout to 1000
65+
if (timeout)
66+
return true;
67+
return false;
68+
}
69+
70+
// Reset the ESP8285 and wait for the "ready" prompt to be returned.
71+
bool Challenger2040WiFiClass::reset() {
72+
runReset();
73+
return waitForReady();
74+
}
75+
76+
// Checks to see if the modem responds to the "AT" poll command.
77+
bool Challenger2040WiFiClass::isAlive() {
78+
int timeout = 5;
79+
80+
Serial2.setTimeout(250);
81+
Serial2.println(F("AT"));
82+
String rdy = Serial2.readStringUntil('\n');
83+
while(!rdy.startsWith(F("OK")) && timeout--) {
84+
rdy = Serial2.readStringUntil('\n');
85+
}
86+
Serial2.setTimeout(1000);
87+
88+
if (timeout)
89+
return true;
90+
return false;
91+
}
92+
93+
// Change the baud rate of the ESP8285 as well as the local UART.
94+
// No checking is done on the input baud rate so the user must know what
95+
// baud rates are valid. The function ends by checking if the ESP8285 is
96+
// reachable by doing an "AT" poll.
97+
bool Challenger2040WiFiClass::changeBaudRate(int baud) {
98+
Serial2.print(F("AT+UART_CUR="));
99+
Serial2.print(baud);
100+
Serial2.println(F(",8,1,0,0"));
101+
delay(100);
102+
Serial2.end();
103+
Serial2.begin(baud);
104+
return isAlive();
105+
}
106+
107+
Challenger2040WiFiClass Challenger2040WiFi;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
ESP8285 helper class for the Challenger RP2040 WiFi boards
3+
4+
Copyright (c) 2021 P. Oldberg <[email protected]>
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
#pragma once
21+
22+
#define DEFAULT_ESP8285_BAUDRATE 115200
23+
24+
class Challenger2040WiFiClass {
25+
public:
26+
Challenger2040WiFiClass();
27+
void doHWReset();
28+
void runReset();
29+
void flashReset();
30+
bool waitForReady();
31+
bool reset();
32+
bool isAlive();
33+
bool changeBaudRate(int baud);
34+
};
35+
36+
extern Challenger2040WiFiClass Challenger2040WiFi;
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#pragma once
2+
3+
#include <ChallengerWiFi.h>
4+
5+
#define PINS_COUNT (24u)
6+
#define NUM_DIGITAL_PINS (24u)
7+
#define NUM_ANALOG_INPUTS (4u)
8+
#define NUM_ANALOG_OUTPUTS (0u)
9+
#define ADC_RESOLUTION (12u)
10+
11+
// LEDs
12+
#define PIN_LED (12u)
13+
14+
// Serial
15+
#define PIN_SERIAL1_TX (16u)
16+
#define PIN_SERIAL1_RX (17u)
17+
18+
// Connected to ESP8285
19+
#define PIN_SERIAL2_TX (4u)
20+
#define PIN_SERIAL2_RX (5u)
21+
#define PIN_ESP8285_RST (19u)
22+
#define PIN_ESP8285_MODE (13u)
23+
24+
// SPI
25+
#define PIN_SPI0_MISO (24u)
26+
#define PIN_SPI0_MOSI (23u)
27+
#define PIN_SPI0_SCK (22u)
28+
#define PIN_SPI0_SS (21u)
29+
30+
// Not pinned out
31+
#define PIN_SPI1_MISO (31u)
32+
#define PIN_SPI1_MOSI (31u)
33+
#define PIN_SPI1_SCK (31u)
34+
#define PIN_SPI1_SS (31u)
35+
36+
// Wire
37+
#define PIN_WIRE0_SDA (0u)
38+
#define PIN_WIRE0_SCL (1u)
39+
40+
// Not pinned out
41+
#define PIN_WIRE1_SDA (31u)
42+
#define PIN_WIRE1_SCL (31u)
43+
44+
#define SERIAL_HOWMANY (2u)
45+
#define SPI_HOWMANY (1u)
46+
#define WIRE_HOWMANY (1u)
47+
48+
#define LED_BUILTIN PIN_LED
49+
#define NEOPIXEL (11u)
50+
51+
static const uint8_t D0 = (16u);
52+
static const uint8_t D1 = (17u);
53+
static const uint8_t D2 = (24u);
54+
static const uint8_t D3 = (23u);
55+
static const uint8_t D4 = (22u);
56+
static const uint8_t D5 = (2u);
57+
static const uint8_t D6 = (3u);
58+
static const uint8_t D7 = (0u);
59+
static const uint8_t D8 = (1u);
60+
static const uint8_t D9 = (6u);
61+
static const uint8_t D10 = (7u);
62+
static const uint8_t D11 = (8u);
63+
static const uint8_t D12 = (9u);
64+
static const uint8_t D13 = (10u);
65+
static const uint8_t D14 = (14u);
66+
static const uint8_t D15 = (15u);
67+
static const uint8_t D16 = (18u);
68+
static const uint8_t D17 = (20u);
69+
70+
static const uint8_t A0 = (26u);
71+
static const uint8_t A1 = (27u);
72+
static const uint8_t A2 = (28u);
73+
static const uint8_t A3 = (29u);
74+
static const uint8_t A4 = (25u);
75+
static const uint8_t A5 = (21u);
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
ESP8285 helper class for the Challenger RP2040 WiFi boards
3+
4+
Copyright (c) 2021 P. Oldberg <[email protected]>
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
21+
#include <Arduino.h>
22+
#include <Ilabs2040WiFiClass.h>
23+
24+
Ilabs2040WiFiClass::Ilabs2040WiFiClass() {
25+
pinMode(PIN_ESP_RESET, OUTPUT);
26+
digitalWrite(PIN_ESP_RESET, LOW); // Hold ESP8285 in reset
27+
pinMode(PIN_ESP_MODE, OUTPUT);
28+
digitalWrite(PIN_ESP_MODE, HIGH); // Prepare for normal start
29+
}
30+
31+
// Do a HW reset by applying a low pulse to the reset line for 1mSec
32+
void Ilabs2040WiFiClass::doHWReset() {
33+
digitalWrite(PIN_ESP_RESET, LOW); // Hold ESP8285 in reset
34+
delay(1);
35+
digitalWrite(PIN_ESP_RESET, HIGH); // Release ESP8285 reset
36+
}
37+
38+
// Set the mode flag high to indicate normal run operation and do a HW
39+
// reset.
40+
void Ilabs2040WiFiClass::runReset() { // Prepare ESP8285 for normal op
41+
digitalWrite(PIN_ESP_MODE, HIGH); // Prepare for normal start
42+
doHWReset();
43+
}
44+
45+
// Set the mode flag low to indicate flash operation and do a HW
46+
// reset.
47+
void Ilabs2040WiFiClass::flashReset() { // Prepare ESP8285 for flashing
48+
digitalWrite(PIN_ESP_MODE, LOW); // Prepare for normal start
49+
doHWReset();
50+
}
51+
52+
// Wait for the modem to reply with a "ready" prompt. This can be done
53+
// after a sw or hw reset have been performed to ensure that the AT
54+
// interpreter is up and running.
55+
bool Ilabs2040WiFiClass::waitForReady() {
56+
int timeout = 20; // Aprox max 2 sec
57+
58+
ESP_SERIAL_PORT.begin(DEFAULT_ESP8285_BAUDRATE);
59+
ESP_SERIAL_PORT.setTimeout(100);
60+
String rdy = ESP_SERIAL_PORT.readStringUntil('\n');
61+
while(!rdy.startsWith("ready") && timeout--) {
62+
rdy = ESP_SERIAL_PORT.readStringUntil('\n');
63+
}
64+
ESP_SERIAL_PORT.setTimeout(1000); // Reset default timeout to 1000
65+
if (timeout)
66+
return true;
67+
return false;
68+
}
69+
70+
// Reset the ESP8285 and wait for the "ready" prompt to be returned.
71+
bool Ilabs2040WiFiClass::reset() {
72+
runReset();
73+
return waitForReady();
74+
}
75+
76+
// Checks to see if the modem responds to the "AT" poll command.
77+
bool Ilabs2040WiFiClass::isAlive() {
78+
int timeout = 5;
79+
80+
ESP_SERIAL_PORT.setTimeout(250);
81+
ESP_SERIAL_PORT.println(F("AT"));
82+
String rdy = ESP_SERIAL_PORT.readStringUntil('\n');
83+
while(!rdy.startsWith(F("OK")) && timeout--) {
84+
rdy = ESP_SERIAL_PORT.readStringUntil('\n');
85+
}
86+
ESP_SERIAL_PORT.setTimeout(1000);
87+
88+
if (timeout)
89+
return true;
90+
return false;
91+
}
92+
93+
// Change the baud rate of the ESP8285 as well as the local UART.
94+
// No checking is done on the input baud rate so the user must know what
95+
// baud rates are valid. The function ends by checking if the ESP8285 is
96+
// reachable by doing an "AT" poll.
97+
bool Ilabs2040WiFiClass::changeBaudRate(int baud) {
98+
ESP_SERIAL_PORT.print(F("AT+UART_CUR="));
99+
ESP_SERIAL_PORT.print(baud);
100+
ESP_SERIAL_PORT.println(F(",8,1,0,0"));
101+
delay(100);
102+
ESP_SERIAL_PORT.end();
103+
ESP_SERIAL_PORT.begin(baud);
104+
return isAlive();
105+
}
106+
107+
Ilabs2040WiFiClass Ilabs2040WiFi;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
ESP8285 helper class for the Challenger RP2040 WiFi boards
3+
4+
Copyright (c) 2021 P. Oldberg <[email protected]>
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
#pragma once
21+
22+
#define DEFAULT_ESP8285_BAUDRATE 115200
23+
24+
class Ilabs2040WiFiClass {
25+
public:
26+
Ilabs2040WiFiClass();
27+
void doHWReset();
28+
void runReset();
29+
void flashReset();
30+
bool waitForReady();
31+
bool reset();
32+
bool isAlive();
33+
bool changeBaudRate(int baud);
34+
};
35+
36+
extern Ilabs2040WiFiClass Ilabs2040WiFi;

0 commit comments

Comments
 (0)