Skip to content

Commit a9b2482

Browse files
authored
Updated PID for WiFi/BLE board and other changes (earlephilhower#595)
1 parent fc55e1e commit a9b2482

File tree

9 files changed

+173
-84
lines changed

9 files changed

+173
-84
lines changed

boards.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7449,8 +7449,8 @@ challenger_2040_ltepicodebug.menu.usbstack.nousb.build.usbstack_flags="-DNO_USB
74497449
# -----------------------------------
74507450
challenger_2040_wifi_ble.name=iLabs Challenger 2040 WiFi/BLE
74517451
challenger_2040_wifi_ble.vid.0=0x2e8a
7452-
challenger_2040_wifi_ble.pid.0=0x1101
7453-
challenger_2040_wifi_ble.build.usbpid=-DSERIALUSB_PID=0x1101
7452+
challenger_2040_wifi_ble.pid.0=0x102C
7453+
challenger_2040_wifi_ble.build.usbpid=-DSERIALUSB_PID=0x102C
74547454
challenger_2040_wifi_ble.build.usbpwr=-DUSBD_MAX_POWER_MA=500
74557455
challenger_2040_wifi_ble.build.board=CHALLENGER_2040_WIFI_BLE_RP2040
74567456
challenger_2040_wifi_ble.build.mcu=cortex-m0plus
@@ -7469,7 +7469,7 @@ challenger_2040_wifi_ble.build.ldscript=memmap_default.ld
74697469
challenger_2040_wifi_ble.build.ram_length=256k
74707470
challenger_2040_wifi_ble.build.boot2=boot2_w25q080_2_padded_checksum
74717471
challenger_2040_wifi_ble.build.vid=0x2e8a
7472-
challenger_2040_wifi_ble.build.pid=0x1101
7472+
challenger_2040_wifi_ble.build.pid=0x102C
74737473
challenger_2040_wifi_ble.build.usb_manufacturer="iLabs"
74747474
challenger_2040_wifi_ble.build.usb_product="Challenger 2040 WiFi/BLE"
74757475
challenger_2040_wifi_ble.menu.flash.8388608_0=8MB (no FS)
@@ -7613,7 +7613,7 @@ challenger_2040_wifi_ble.menu.usbstack.tinyusb.build.usbstack_flags=-DUSE_TINYUS
76137613
challenger_2040_wifi_blepicoprobe.name=iLabs Challenger 2040 WiFi/BLE (Picoprobe)
76147614
challenger_2040_wifi_blepicoprobe.vid.0=0x2e8a
76157615
challenger_2040_wifi_blepicoprobe.pid.0=0x0004
7616-
challenger_2040_wifi_blepicoprobe.build.usbpid=-DSERIALUSB_PID=0x1101
7616+
challenger_2040_wifi_blepicoprobe.build.usbpid=-DSERIALUSB_PID=0x102C
76177617
challenger_2040_wifi_blepicoprobe.build.usbpwr=-DUSBD_MAX_POWER_MA=500
76187618
challenger_2040_wifi_blepicoprobe.build.board=CHALLENGER_2040_WIFI_BLE_RP2040
76197619
challenger_2040_wifi_blepicoprobe.build.mcu=cortex-m0plus
@@ -7632,7 +7632,7 @@ challenger_2040_wifi_blepicoprobe.build.ldscript=memmap_default.ld
76327632
challenger_2040_wifi_blepicoprobe.build.ram_length=256k
76337633
challenger_2040_wifi_blepicoprobe.build.boot2=boot2_w25q080_2_padded_checksum
76347634
challenger_2040_wifi_blepicoprobe.build.vid=0x2e8a
7635-
challenger_2040_wifi_blepicoprobe.build.pid=0x1101
7635+
challenger_2040_wifi_blepicoprobe.build.pid=0x102C
76367636
challenger_2040_wifi_blepicoprobe.build.usb_manufacturer="iLabs"
76377637
challenger_2040_wifi_blepicoprobe.build.usb_product="Challenger 2040 WiFi/BLE (Picoprobe)"
76387638
challenger_2040_wifi_blepicoprobe.menu.flash.8388608_0=8MB (no FS)
@@ -7776,7 +7776,7 @@ challenger_2040_wifi_blepicoprobe.menu.usbstack.tinyusb.build.usbstack_flags=-DU
77767776
challenger_2040_wifi_blepicodebug.name=iLabs Challenger 2040 WiFi/BLE (pico-debug)
77777777
challenger_2040_wifi_blepicodebug.vid.0=0x1209
77787778
challenger_2040_wifi_blepicodebug.pid.0=0x2488
7779-
challenger_2040_wifi_blepicodebug.build.usbpid=-DSERIALUSB_PID=0x1101
7779+
challenger_2040_wifi_blepicodebug.build.usbpid=-DSERIALUSB_PID=0x102C
77807780
challenger_2040_wifi_blepicodebug.build.usbpwr=-DUSBD_MAX_POWER_MA=500
77817781
challenger_2040_wifi_blepicodebug.build.board=CHALLENGER_2040_WIFI_BLE_RP2040
77827782
challenger_2040_wifi_blepicodebug.build.mcu=cortex-m0plus
@@ -7795,7 +7795,7 @@ challenger_2040_wifi_blepicodebug.build.ldscript=memmap_default.ld
77957795
challenger_2040_wifi_blepicodebug.build.ram_length=240k
77967796
challenger_2040_wifi_blepicodebug.build.boot2=boot2_w25q080_2_padded_checksum
77977797
challenger_2040_wifi_blepicodebug.build.vid=0x2e8a
7798-
challenger_2040_wifi_blepicodebug.build.pid=0x1101
7798+
challenger_2040_wifi_blepicodebug.build.pid=0x102C
77997799
challenger_2040_wifi_blepicodebug.build.usb_manufacturer="iLabs"
78007800
challenger_2040_wifi_blepicodebug.build.usb_product="Challenger 2040 WiFi/BLE (pico-debug)"
78017801
challenger_2040_wifi_blepicodebug.menu.flash.8388608_0=8MB (no FS)

tools/json/challenger_2040_wifi_ble.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"variant": "challenger_2040_wifi_ble",
1717
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
1818
"usb_vid": "0x2e8a",
19-
"usb_pid": "0x1101",
19+
"usb_pid": "0x102C",
2020
"usb_manufacturer": "iLabs",
2121
"usb_product": "Challenger 2040 WiFi/BLE"
2222
}

tools/makeboards.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def MakeBoardJSON(name, vendor_name, product_name, vid, pid, pwr, boarddefine, f
251251
MakeBoard("challenger_2040_lora", "iLabs", "Challenger 2040 LoRa", "0x2e8a", "0x1023", 250, "CHALLENGER_2040_LORA_RP2040", 8, "boot2_w25q080_2_padded_checksum")
252252
MakeBoard("challenger_2040_wifi", "iLabs", "Challenger 2040 WiFi", "0x2e8a", "0x1006", 250, "CHALLENGER_2040_WIFI_RP2040", 8, "boot2_w25q080_2_padded_checksum")
253253
MakeBoard("challenger_2040_lte", "iLabs", "Challenger 2040 LTE", "0x2e8a", "0x100b", 500, "CHALLENGER_2040_LTE_RP2040", 8, "boot2_w25q080_2_padded_checksum")
254-
MakeBoard("challenger_2040_wifi_ble", "iLabs", "Challenger 2040 WiFi/BLE", "0x2e8a", "0x1101", 500, "CHALLENGER_2040_WIFI_BLE_RP2040", 8, "boot2_w25q080_2_padded_checksum")
254+
MakeBoard("challenger_2040_wifi_ble", "iLabs", "Challenger 2040 WiFi/BLE", "0x2e8a", "0x102C", 500, "CHALLENGER_2040_WIFI_BLE_RP2040", 8, "boot2_w25q080_2_padded_checksum")
255255
MakeBoard("challenger_nb_2040_wifi", "iLabs", "Challenger NB 2040 WiFi", "0x2e8a", "0x100b", 500, "CHALLENGER_NB_2040_WIFI_RP2040", 8, "boot2_w25q080_2_padded_checksum")
256256
MakeBoard("ilabs_rpico32", "iLabs", "RPICO32", "0x2e8a", "0x1010", 250, "ILABS_2040_RPICO32_RP2040", 8, "boot2_w25q080_2_padded_checksum")
257257

Lines changed: 63 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
ESP8285 helper class for the Challenger RP2040 WiFi boards
2+
ESP8285/ESP32C3 helper class for the Challenger RP2040 WiFi enabled boards
33
4-
Copyright (c) 2021 P. Oldberg <[email protected]>
4+
Copyright (c) 2021,2022 P. Oldberg <[email protected]>
55
66
This library is free software; you can redistribute it and/or
77
modify it under the terms of the GNU Lesser General Public
@@ -21,31 +21,33 @@
2121
#include <Arduino.h>
2222
#include <ChallengerWiFi.h>
2323

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
24+
Challenger2040WiFiClass::Challenger2040WiFiClass(HardwareSerial* serial) {
25+
_serial = serial;
26+
27+
pinMode(PIN_ESP_RST, OUTPUT);
28+
digitalWrite(PIN_ESP_RST, LOW); // Hold ESP in reset
29+
pinMode(PIN_ESP_MODE, OUTPUT);
30+
digitalWrite(PIN_ESP_MODE, HIGH); // Prepare for normal start
2931
}
3032

3133
// Do a HW reset by applying a low pulse to the reset line for 1mSec
3234
void Challenger2040WiFiClass::doHWReset() {
33-
digitalWrite(PIN_ESP8285_RST, LOW); // Hold ESP8285 in reset
35+
digitalWrite(PIN_ESP_RST, LOW); // Hold ESP in reset
3436
delay(1);
35-
digitalWrite(PIN_ESP8285_RST, HIGH); // Release ESP8285 reset
37+
digitalWrite(PIN_ESP_RST, HIGH); // Release ESP reset
3638
}
3739

3840
// Set the mode flag high to indicate normal run operation and do a HW
3941
// reset.
40-
void Challenger2040WiFiClass::runReset() { // Prepare ESP8285 for normal op
41-
digitalWrite(PIN_ESP8285_MODE, HIGH); // Prepare for normal start
42+
void Challenger2040WiFiClass::runReset() { // Prepare ESP for normal op
43+
digitalWrite(PIN_ESP_MODE, HIGH); // Prepare for normal start
4244
doHWReset();
4345
}
4446

4547
// Set the mode flag low to indicate flash operation and do a HW
4648
// reset.
47-
void Challenger2040WiFiClass::flashReset() { // Prepare ESP8285 for flashing
48-
digitalWrite(PIN_ESP8285_MODE, LOW); // Prepare for normal start
49+
void Challenger2040WiFiClass::flashReset() { // Prepare ESP for flashing
50+
digitalWrite(PIN_ESP_MODE, LOW); // Prepare for normal start
4951
doHWReset();
5052
}
5153

@@ -55,53 +57,82 @@ void Challenger2040WiFiClass::flashReset() { // Prepare ESP8285 for flashing
5557
bool Challenger2040WiFiClass::waitForReady() {
5658
int timeout = 20; // Aprox max 2 sec
5759

58-
Serial2.begin(DEFAULT_ESP8285_BAUDRATE);
59-
Serial2.setTimeout(100);
60-
String rdy = Serial2.readStringUntil('\n');
60+
_serial->setTimeout(100);
61+
String rdy = _serial->readStringUntil('\n');
6162
while(!rdy.startsWith("ready") && timeout--) {
62-
rdy = Serial2.readStringUntil('\n');
63+
rdy = _serial->readStringUntil('\n');
6364
}
64-
Serial2.setTimeout(1000); // Reset default timeout to 1000
65+
_serial->setTimeout(1000); // Reset default timeout to 1000
6566
if (timeout)
6667
return true;
6768
return false;
6869
}
6970

70-
// Reset the ESP8285 and wait for the "ready" prompt to be returned.
71+
// Reset the ESP and wait for the "ready" prompt to be returned.
7172
bool Challenger2040WiFiClass::reset() {
7273
runReset();
74+
_serial->begin(DEFAULT_ESP_BAUDRATE);
7375
return waitForReady();
7476
}
7577

7678
// Checks to see if the modem responds to the "AT" poll command.
7779
bool Challenger2040WiFiClass::isAlive() {
78-
int timeout = 5;
80+
int timeout = 100;
7981

80-
Serial2.setTimeout(250);
81-
Serial2.println(F("AT"));
82-
String rdy = Serial2.readStringUntil('\n');
82+
_serial->setTimeout(250);
83+
_serial->println(F("AT"));
84+
String rdy = _serial->readStringUntil('\n');
8385
while(!rdy.startsWith(F("OK")) && timeout--) {
84-
rdy = Serial2.readStringUntil('\n');
86+
_serial->println(F("AT"));
87+
rdy = _serial->readStringUntil('\n');
8588
}
86-
Serial2.setTimeout(1000);
89+
_serial->setTimeout(1000);
8790

8891
if (timeout)
8992
return true;
9093
return false;
9194
}
9295

93-
// Change the baud rate of the ESP8285 as well as the local UART.
96+
// Change the baud rate of the ESP device as well as the local UART.
9497
// 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
98+
// baud rates are valid. The function ends by checking if the ESP is
9699
// reachable by doing an "AT" poll.
97100
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+
_serial->print(F("AT+UART_CUR="));
102+
_serial->print(baud);
103+
_serial->println(F(",8,1,0,0"));
101104
delay(100);
102-
Serial2.end();
103-
Serial2.begin(baud);
105+
_serial->end();
106+
_serial->begin(baud);
104107
return isAlive();
105108
}
106109

110+
// This method should be called id the builtin object isn't needed any more
111+
// It basically just releases the UART pins for other use.
112+
void Challenger2040WiFiClass::release() {
113+
_serial->end();
114+
}
115+
116+
// We can assign a new hardware serial port to accommodate the ESP device here.
117+
// The function will release the previously used serial port and assign the
118+
// new port. The ESP will be left in a reset state ready to start normal
119+
// operation when exiting the function.
120+
// This function is useful for when using the PIO serial ports to communicate
121+
// with the ESP instead of the built in hardware serial port.
122+
void Challenger2040WiFiClass::setSerial(HardwareSerial* serial) {
123+
124+
release();
125+
_serial = serial;
126+
127+
pinMode(PIN_ESP_RST, OUTPUT);
128+
digitalWrite(PIN_ESP_RST, LOW); // Hold ESP in reset
129+
pinMode(PIN_ESP_MODE, OUTPUT);
130+
digitalWrite(PIN_ESP_MODE, HIGH); // Prepare for normal start
131+
}
132+
133+
// Return the current serial object
134+
HardwareSerial* Challenger2040WiFiClass::getSerial() {
135+
return _serial;
136+
}
137+
107138
Challenger2040WiFiClass Challenger2040WiFi;

variants/challenger_2040_wifi/ChallengerWiFi.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
ESP8285 helper class for the Challenger RP2040 WiFi boards
2+
ESP8285/ESP32C3 helper class for the Challenger RP2040 WiFi enabled boards
33
4-
Copyright (c) 2021 P. Oldberg <[email protected]>
4+
Copyright (c) 2021,2022 P. Oldberg <[email protected]>
55
66
This library is free software; you can redistribute it and/or
77
modify it under the terms of the GNU Lesser General Public
@@ -17,20 +17,27 @@
1717
License along with this library; if not, write to the Free Software
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
20+
2021
#pragma once
2122

22-
#define DEFAULT_ESP8285_BAUDRATE 115200
23+
#define DEFAULT_ESP32_BAUDRATE 115200
24+
#define DEFAULT_ESP_BAUDRATE DEFAULT_ESP32_BAUDRATE
2325

2426
class Challenger2040WiFiClass {
2527
public:
26-
Challenger2040WiFiClass();
28+
Challenger2040WiFiClass(HardwareSerial* = &ESP_SERIAL_PORT);
2729
void doHWReset();
2830
void runReset();
2931
void flashReset();
3032
bool waitForReady();
3133
bool reset();
3234
bool isAlive();
33-
bool changeBaudRate(int baud);
35+
bool changeBaudRate(int);
36+
void release();
37+
void setSerial(HardwareSerial*);
38+
HardwareSerial* getSerial();
39+
private:
40+
HardwareSerial* _serial;
3441
};
3542

3643
extern Challenger2040WiFiClass Challenger2040WiFi;

variants/challenger_2040_wifi/pins_arduino.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
#define PIN_SERIAL2_RX (5u)
1919
#define PIN_ESP8285_RST (19u)
2020
#define PIN_ESP8285_MODE (13u)
21+
#define ESP8285_SERIAL Serial2
22+
// Uart define esp serial abstraction pins
23+
#define PIN_ESP_TX PIN_SERIAL2_TX
24+
#define PIN_ESP_RX PIN_SERIAL2_RX
25+
#define PIN_ESP_RST PIN_ESP8285_RST
26+
#define PIN_ESP_MODE PIN_ESP8285_MODE
27+
#define ESP_SERIAL_PORT ESP8285_SERIAL
2128

2229
// SPI
2330
#define PIN_SPI0_MISO (24u)

0 commit comments

Comments
 (0)