Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-pico
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-pico
Commits
a9b24827
Unverified
Commit
a9b24827
authored
May 24, 2022
by
Pontus Oldberg
Committed by
GitHub
May 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated PID for WiFi/BLE board and other changes (#595)
parent
fc55e1e7
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
173 additions
and
84 deletions
+173
-84
boards.txt
boards.txt
+7
-7
tools/json/challenger_2040_wifi_ble.json
tools/json/challenger_2040_wifi_ble.json
+1
-1
tools/makeboards.py
tools/makeboards.py
+1
-1
variants/challenger_2040_wifi/ChallengerWiFi.cpp
variants/challenger_2040_wifi/ChallengerWiFi.cpp
+63
-32
variants/challenger_2040_wifi/ChallengerWiFi.h
variants/challenger_2040_wifi/ChallengerWiFi.h
+12
-5
variants/challenger_2040_wifi/pins_arduino.h
variants/challenger_2040_wifi/pins_arduino.h
+7
-0
variants/challenger_2040_wifi_ble/ChallengerWiFi.cpp
variants/challenger_2040_wifi_ble/ChallengerWiFi.cpp
+63
-32
variants/challenger_2040_wifi_ble/ChallengerWiFi.h
variants/challenger_2040_wifi_ble/ChallengerWiFi.h
+11
-4
variants/challenger_2040_wifi_ble/pins_arduino.h
variants/challenger_2040_wifi_ble/pins_arduino.h
+8
-2
No files found.
boards.txt
View file @
a9b24827
...
...
@@ -7449,8 +7449,8 @@ challenger_2040_ltepicodebug.menu.usbstack.nousb.build.usbstack_flags="-DNO_USB
# -----------------------------------
challenger_2040_wifi_ble.name=iLabs Challenger 2040 WiFi/BLE
challenger_2040_wifi_ble.vid.0=0x2e8a
challenger_2040_wifi_ble.pid.0=0x1
101
challenger_2040_wifi_ble.build.usbpid=-DSERIALUSB_PID=0x1
101
challenger_2040_wifi_ble.pid.0=0x1
02C
challenger_2040_wifi_ble.build.usbpid=-DSERIALUSB_PID=0x1
02C
challenger_2040_wifi_ble.build.usbpwr=-DUSBD_MAX_POWER_MA=500
challenger_2040_wifi_ble.build.board=CHALLENGER_2040_WIFI_BLE_RP2040
challenger_2040_wifi_ble.build.mcu=cortex-m0plus
...
...
@@ -7469,7 +7469,7 @@ challenger_2040_wifi_ble.build.ldscript=memmap_default.ld
challenger_2040_wifi_ble.build.ram_length=256k
challenger_2040_wifi_ble.build.boot2=boot2_w25q080_2_padded_checksum
challenger_2040_wifi_ble.build.vid=0x2e8a
challenger_2040_wifi_ble.build.pid=0x1
101
challenger_2040_wifi_ble.build.pid=0x1
02C
challenger_2040_wifi_ble.build.usb_manufacturer="iLabs"
challenger_2040_wifi_ble.build.usb_product="Challenger 2040 WiFi/BLE"
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
challenger_2040_wifi_blepicoprobe.name=iLabs Challenger 2040 WiFi/BLE (Picoprobe)
challenger_2040_wifi_blepicoprobe.vid.0=0x2e8a
challenger_2040_wifi_blepicoprobe.pid.0=0x0004
challenger_2040_wifi_blepicoprobe.build.usbpid=-DSERIALUSB_PID=0x1
101
challenger_2040_wifi_blepicoprobe.build.usbpid=-DSERIALUSB_PID=0x1
02C
challenger_2040_wifi_blepicoprobe.build.usbpwr=-DUSBD_MAX_POWER_MA=500
challenger_2040_wifi_blepicoprobe.build.board=CHALLENGER_2040_WIFI_BLE_RP2040
challenger_2040_wifi_blepicoprobe.build.mcu=cortex-m0plus
...
...
@@ -7632,7 +7632,7 @@ challenger_2040_wifi_blepicoprobe.build.ldscript=memmap_default.ld
challenger_2040_wifi_blepicoprobe.build.ram_length=256k
challenger_2040_wifi_blepicoprobe.build.boot2=boot2_w25q080_2_padded_checksum
challenger_2040_wifi_blepicoprobe.build.vid=0x2e8a
challenger_2040_wifi_blepicoprobe.build.pid=0x1
101
challenger_2040_wifi_blepicoprobe.build.pid=0x1
02C
challenger_2040_wifi_blepicoprobe.build.usb_manufacturer="iLabs"
challenger_2040_wifi_blepicoprobe.build.usb_product="Challenger 2040 WiFi/BLE (Picoprobe)"
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
challenger_2040_wifi_blepicodebug.name=iLabs Challenger 2040 WiFi/BLE (pico-debug)
challenger_2040_wifi_blepicodebug.vid.0=0x1209
challenger_2040_wifi_blepicodebug.pid.0=0x2488
challenger_2040_wifi_blepicodebug.build.usbpid=-DSERIALUSB_PID=0x1
101
challenger_2040_wifi_blepicodebug.build.usbpid=-DSERIALUSB_PID=0x1
02C
challenger_2040_wifi_blepicodebug.build.usbpwr=-DUSBD_MAX_POWER_MA=500
challenger_2040_wifi_blepicodebug.build.board=CHALLENGER_2040_WIFI_BLE_RP2040
challenger_2040_wifi_blepicodebug.build.mcu=cortex-m0plus
...
...
@@ -7795,7 +7795,7 @@ challenger_2040_wifi_blepicodebug.build.ldscript=memmap_default.ld
challenger_2040_wifi_blepicodebug.build.ram_length=240k
challenger_2040_wifi_blepicodebug.build.boot2=boot2_w25q080_2_padded_checksum
challenger_2040_wifi_blepicodebug.build.vid=0x2e8a
challenger_2040_wifi_blepicodebug.build.pid=0x1
101
challenger_2040_wifi_blepicodebug.build.pid=0x1
02C
challenger_2040_wifi_blepicodebug.build.usb_manufacturer="iLabs"
challenger_2040_wifi_blepicodebug.build.usb_product="Challenger 2040 WiFi/BLE (pico-debug)"
challenger_2040_wifi_blepicodebug.menu.flash.8388608_0=8MB (no FS)
...
...
tools/json/challenger_2040_wifi_ble.json
View file @
a9b24827
...
...
@@ -16,7 +16,7 @@
"variant"
:
"challenger_2040_wifi_ble"
,
"boot2_source"
:
"boot2_w25q080_2_padded_checksum.S"
,
"usb_vid"
:
"0x2e8a"
,
"usb_pid"
:
"0x1
101
"
,
"usb_pid"
:
"0x1
02C
"
,
"usb_manufacturer"
:
"iLabs"
,
"usb_product"
:
"Challenger 2040 WiFi/BLE"
}
...
...
tools/makeboards.py
View file @
a9b24827
...
...
@@ -251,7 +251,7 @@ MakeBoard("dfrobot_beetle_rp2040", "DFRobot", "Beetle RP2040", "0x3343", "0x4253
MakeBoard
(
"challenger_2040_lora"
,
"iLabs"
,
"Challenger 2040 LoRa"
,
"0x2e8a"
,
"0x1023"
,
250
,
"CHALLENGER_2040_LORA_RP2040"
,
8
,
"boot2_w25q080_2_padded_checksum"
)
MakeBoard
(
"challenger_2040_wifi"
,
"iLabs"
,
"Challenger 2040 WiFi"
,
"0x2e8a"
,
"0x1006"
,
250
,
"CHALLENGER_2040_WIFI_RP2040"
,
8
,
"boot2_w25q080_2_padded_checksum"
)
MakeBoard
(
"challenger_2040_lte"
,
"iLabs"
,
"Challenger 2040 LTE"
,
"0x2e8a"
,
"0x100b"
,
500
,
"CHALLENGER_2040_LTE_RP2040"
,
8
,
"boot2_w25q080_2_padded_checksum"
)
MakeBoard
(
"challenger_2040_wifi_ble"
,
"iLabs"
,
"Challenger 2040 WiFi/BLE"
,
"0x2e8a"
,
"0x1
101
"
,
500
,
"CHALLENGER_2040_WIFI_BLE_RP2040"
,
8
,
"boot2_w25q080_2_padded_checksum"
)
MakeBoard
(
"challenger_2040_wifi_ble"
,
"iLabs"
,
"Challenger 2040 WiFi/BLE"
,
"0x2e8a"
,
"0x1
02C
"
,
500
,
"CHALLENGER_2040_WIFI_BLE_RP2040"
,
8
,
"boot2_w25q080_2_padded_checksum"
)
MakeBoard
(
"challenger_nb_2040_wifi"
,
"iLabs"
,
"Challenger NB 2040 WiFi"
,
"0x2e8a"
,
"0x100b"
,
500
,
"CHALLENGER_NB_2040_WIFI_RP2040"
,
8
,
"boot2_w25q080_2_padded_checksum"
)
MakeBoard
(
"ilabs_rpico32"
,
"iLabs"
,
"RPICO32"
,
"0x2e8a"
,
"0x1010"
,
250
,
"ILABS_2040_RPICO32_RP2040"
,
8
,
"boot2_w25q080_2_padded_checksum"
)
...
...
variants/challenger_2040_wifi/ChallengerWiFi.cpp
View file @
a9b24827
/*
ESP8285
helper class for the Challenger RP2040 WiFi
boards
ESP8285
/ESP32C3 helper class for the Challenger RP2040 WiFi enabled
boards
Copyright (c) 2021 P. Oldberg <pontus@ilabs.se>
Copyright (c) 2021
,2022
P. Oldberg <pontus@ilabs.se>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
...
...
@@ -21,31 +21,33 @@
#include <Arduino.h>
#include <ChallengerWiFi.h>
Challenger2040WiFiClass
::
Challenger2040WiFiClass
()
{
pinMode
(
PIN_ESP8285_RST
,
OUTPUT
);
digitalWrite
(
PIN_ESP8285_RST
,
LOW
);
// Hold ESP8285 in reset
pinMode
(
PIN_ESP8285_MODE
,
OUTPUT
);
digitalWrite
(
PIN_ESP8285_MODE
,
HIGH
);
// Prepare for normal start
Challenger2040WiFiClass
::
Challenger2040WiFiClass
(
HardwareSerial
*
serial
)
{
_serial
=
serial
;
pinMode
(
PIN_ESP_RST
,
OUTPUT
);
digitalWrite
(
PIN_ESP_RST
,
LOW
);
// Hold ESP in reset
pinMode
(
PIN_ESP_MODE
,
OUTPUT
);
digitalWrite
(
PIN_ESP_MODE
,
HIGH
);
// Prepare for normal start
}
// Do a HW reset by applying a low pulse to the reset line for 1mSec
void
Challenger2040WiFiClass
::
doHWReset
()
{
digitalWrite
(
PIN_ESP
8285_RST
,
LOW
);
// Hold ESP8285
in reset
digitalWrite
(
PIN_ESP
_RST
,
LOW
);
// Hold ESP
in reset
delay
(
1
);
digitalWrite
(
PIN_ESP
8285_RST
,
HIGH
);
// Release ESP8285
reset
digitalWrite
(
PIN_ESP
_RST
,
HIGH
);
// Release ESP
reset
}
// Set the mode flag high to indicate normal run operation and do a HW
// reset.
void
Challenger2040WiFiClass
::
runReset
()
{
// Prepare ESP
8285
for normal op
digitalWrite
(
PIN_ESP
8285
_MODE
,
HIGH
);
// Prepare for normal start
void
Challenger2040WiFiClass
::
runReset
()
{
// Prepare ESP for normal op
digitalWrite
(
PIN_ESP_MODE
,
HIGH
);
// Prepare for normal start
doHWReset
();
}
// Set the mode flag low to indicate flash operation and do a HW
// reset.
void
Challenger2040WiFiClass
::
flashReset
()
{
// Prepare ESP
8285
for flashing
digitalWrite
(
PIN_ESP
8285
_MODE
,
LOW
);
// Prepare for normal start
void
Challenger2040WiFiClass
::
flashReset
()
{
// Prepare ESP for flashing
digitalWrite
(
PIN_ESP_MODE
,
LOW
);
// Prepare for normal start
doHWReset
();
}
...
...
@@ -55,53 +57,82 @@ void Challenger2040WiFiClass::flashReset() { // Prepare ESP8285 for flashing
bool
Challenger2040WiFiClass
::
waitForReady
()
{
int
timeout
=
20
;
// Aprox max 2 sec
Serial2
.
begin
(
DEFAULT_ESP8285_BAUDRATE
);
Serial2
.
setTimeout
(
100
);
String
rdy
=
Serial2
.
readStringUntil
(
'\n'
);
_serial
->
setTimeout
(
100
);
String
rdy
=
_serial
->
readStringUntil
(
'\n'
);
while
(
!
rdy
.
startsWith
(
"ready"
)
&&
timeout
--
)
{
rdy
=
Serial2
.
readStringUntil
(
'\n'
);
rdy
=
_serial
->
readStringUntil
(
'\n'
);
}
Serial2
.
setTimeout
(
1000
);
// Reset default timeout to 1000
_serial
->
setTimeout
(
1000
);
// Reset default timeout to 1000
if
(
timeout
)
return
true
;
return
false
;
}
// Reset the ESP
8285
and wait for the "ready" prompt to be returned.
// Reset the ESP and wait for the "ready" prompt to be returned.
bool
Challenger2040WiFiClass
::
reset
()
{
runReset
();
_serial
->
begin
(
DEFAULT_ESP_BAUDRATE
);
return
waitForReady
();
}
// Checks to see if the modem responds to the "AT" poll command.
bool
Challenger2040WiFiClass
::
isAlive
()
{
int
timeout
=
5
;
int
timeout
=
100
;
Serial2
.
setTimeout
(
250
);
Serial2
.
println
(
F
(
"AT"
));
String
rdy
=
Serial2
.
readStringUntil
(
'\n'
);
_serial
->
setTimeout
(
250
);
_serial
->
println
(
F
(
"AT"
));
String
rdy
=
_serial
->
readStringUntil
(
'\n'
);
while
(
!
rdy
.
startsWith
(
F
(
"OK"
))
&&
timeout
--
)
{
rdy
=
Serial2
.
readStringUntil
(
'\n'
);
_serial
->
println
(
F
(
"AT"
));
rdy
=
_serial
->
readStringUntil
(
'\n'
);
}
Serial2
.
setTimeout
(
1000
);
_serial
->
setTimeout
(
1000
);
if
(
timeout
)
return
true
;
return
false
;
}
// Change the baud rate of the ESP
8285
as well as the local UART.
// Change the baud rate of the ESP
device
as well as the local UART.
// No checking is done on the input baud rate so the user must know what
// baud rates are valid. The function ends by checking if the ESP
8285
is
// baud rates are valid. The function ends by checking if the ESP is
// reachable by doing an "AT" poll.
bool
Challenger2040WiFiClass
::
changeBaudRate
(
int
baud
)
{
Serial2
.
print
(
F
(
"AT+UART_CUR="
));
Serial2
.
print
(
baud
);
Serial2
.
println
(
F
(
",8,1,0,0"
));
_serial
->
print
(
F
(
"AT+UART_CUR="
));
_serial
->
print
(
baud
);
_serial
->
println
(
F
(
",8,1,0,0"
));
delay
(
100
);
Serial2
.
end
();
Serial2
.
begin
(
baud
);
_serial
->
end
();
_serial
->
begin
(
baud
);
return
isAlive
();
}
// This method should be called id the builtin object isn't needed any more
// It basically just releases the UART pins for other use.
void
Challenger2040WiFiClass
::
release
()
{
_serial
->
end
();
}
// We can assign a new hardware serial port to accommodate the ESP device here.
// The function will release the previously used serial port and assign the
// new port. The ESP will be left in a reset state ready to start normal
// operation when exiting the function.
// This function is useful for when using the PIO serial ports to communicate
// with the ESP instead of the built in hardware serial port.
void
Challenger2040WiFiClass
::
setSerial
(
HardwareSerial
*
serial
)
{
release
();
_serial
=
serial
;
pinMode
(
PIN_ESP_RST
,
OUTPUT
);
digitalWrite
(
PIN_ESP_RST
,
LOW
);
// Hold ESP in reset
pinMode
(
PIN_ESP_MODE
,
OUTPUT
);
digitalWrite
(
PIN_ESP_MODE
,
HIGH
);
// Prepare for normal start
}
// Return the current serial object
HardwareSerial
*
Challenger2040WiFiClass
::
getSerial
()
{
return
_serial
;
}
Challenger2040WiFiClass
Challenger2040WiFi
;
variants/challenger_2040_wifi/ChallengerWiFi.h
View file @
a9b24827
/*
ESP8285
helper class for the Challenger RP2040 WiFi
boards
ESP8285
/ESP32C3 helper class for the Challenger RP2040 WiFi enabled
boards
Copyright (c) 2021 P. Oldberg <pontus@ilabs.se>
Copyright (c) 2021
,2022
P. Oldberg <pontus@ilabs.se>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
...
...
@@ -17,20 +17,27 @@
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#define DEFAULT_ESP8285_BAUDRATE 115200
#define DEFAULT_ESP32_BAUDRATE 115200
#define DEFAULT_ESP_BAUDRATE DEFAULT_ESP32_BAUDRATE
class
Challenger2040WiFiClass
{
public:
Challenger2040WiFiClass
();
Challenger2040WiFiClass
(
HardwareSerial
*
=
&
ESP_SERIAL_PORT
);
void
doHWReset
();
void
runReset
();
void
flashReset
();
bool
waitForReady
();
bool
reset
();
bool
isAlive
();
bool
changeBaudRate
(
int
baud
);
bool
changeBaudRate
(
int
);
void
release
();
void
setSerial
(
HardwareSerial
*
);
HardwareSerial
*
getSerial
();
private:
HardwareSerial
*
_serial
;
};
extern
Challenger2040WiFiClass
Challenger2040WiFi
;
variants/challenger_2040_wifi/pins_arduino.h
View file @
a9b24827
...
...
@@ -18,6 +18,13 @@
#define PIN_SERIAL2_RX (5u)
#define PIN_ESP8285_RST (19u)
#define PIN_ESP8285_MODE (13u)
#define ESP8285_SERIAL Serial2
// Uart define esp serial abstraction pins
#define PIN_ESP_TX PIN_SERIAL2_TX
#define PIN_ESP_RX PIN_SERIAL2_RX
#define PIN_ESP_RST PIN_ESP8285_RST
#define PIN_ESP_MODE PIN_ESP8285_MODE
#define ESP_SERIAL_PORT ESP8285_SERIAL
// SPI
#define PIN_SPI0_MISO (24u)
...
...
variants/challenger_2040_wifi_ble/ChallengerWiFi.cpp
View file @
a9b24827
/*
ESP
32 helper class for the Challenger RP2040 WiFi
boards
ESP
8285/ESP32C3 helper class for the Challenger RP2040 WiFi enabled
boards
Copyright (c) 2021 P. Oldberg <pontus@ilabs.se>
Copyright (c) 2021
,2022
P. Oldberg <pontus@ilabs.se>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
...
...
@@ -21,31 +21,33 @@
#include <Arduino.h>
#include <ChallengerWiFi.h>
Challenger2040WiFiClass
::
Challenger2040WiFiClass
()
{
pinMode
(
PIN_ESP32_RST
,
OUTPUT
);
digitalWrite
(
PIN_ESP32_RST
,
LOW
);
// Hold ESP32 in reset
pinMode
(
PIN_ESP32_MODE
,
OUTPUT
);
digitalWrite
(
PIN_ESP32_MODE
,
HIGH
);
// Prepare for normal start
Challenger2040WiFiClass
::
Challenger2040WiFiClass
(
HardwareSerial
*
serial
)
{
_serial
=
serial
;
pinMode
(
PIN_ESP_RST
,
OUTPUT
);
digitalWrite
(
PIN_ESP_RST
,
LOW
);
// Hold ESP in reset
pinMode
(
PIN_ESP_MODE
,
OUTPUT
);
digitalWrite
(
PIN_ESP_MODE
,
HIGH
);
// Prepare for normal start
}
// Do a HW reset by applying a low pulse to the reset line for 1mSec
void
Challenger2040WiFiClass
::
doHWReset
()
{
digitalWrite
(
PIN_ESP
32_RST
,
LOW
);
// Hold ESP32
in reset
digitalWrite
(
PIN_ESP
_RST
,
LOW
);
// Hold ESP
in reset
delay
(
1
);
digitalWrite
(
PIN_ESP
32_RST
,
HIGH
);
// Release ESP32
reset
digitalWrite
(
PIN_ESP
_RST
,
HIGH
);
// Release ESP
reset
}
// Set the mode flag high to indicate normal run operation and do a HW
// reset.
void
Challenger2040WiFiClass
::
runReset
()
{
// Prepare ESP
32
for normal op
digitalWrite
(
PIN_ESP
32
_MODE
,
HIGH
);
// Prepare for normal start
void
Challenger2040WiFiClass
::
runReset
()
{
// Prepare ESP for normal op
digitalWrite
(
PIN_ESP_MODE
,
HIGH
);
// Prepare for normal start
doHWReset
();
}
// Set the mode flag low to indicate flash operation and do a HW
// reset.
void
Challenger2040WiFiClass
::
flashReset
()
{
// Prepare ESP
32
for flashing
digitalWrite
(
PIN_ESP
32
_MODE
,
LOW
);
// Prepare for normal start
void
Challenger2040WiFiClass
::
flashReset
()
{
// Prepare ESP for flashing
digitalWrite
(
PIN_ESP_MODE
,
LOW
);
// Prepare for normal start
doHWReset
();
}
...
...
@@ -55,53 +57,82 @@ void Challenger2040WiFiClass::flashReset() { // Prepare ESP32 for flashing
bool
Challenger2040WiFiClass
::
waitForReady
()
{
int
timeout
=
20
;
// Aprox max 2 sec
Serial2
.
begin
(
DEFAULT_ESP32_BAUDRATE
);
Serial2
.
setTimeout
(
100
);
String
rdy
=
Serial2
.
readStringUntil
(
'\n'
);
_serial
->
setTimeout
(
100
);
String
rdy
=
_serial
->
readStringUntil
(
'\n'
);
while
(
!
rdy
.
startsWith
(
"ready"
)
&&
timeout
--
)
{
rdy
=
Serial2
.
readStringUntil
(
'\n'
);
rdy
=
_serial
->
readStringUntil
(
'\n'
);
}
Serial2
.
setTimeout
(
1000
);
// Reset default timeout to 1000
_serial
->
setTimeout
(
1000
);
// Reset default timeout to 1000
if
(
timeout
)
return
true
;
return
false
;
}
// Reset the ESP
32
and wait for the "ready" prompt to be returned.
// Reset the ESP and wait for the "ready" prompt to be returned.
bool
Challenger2040WiFiClass
::
reset
()
{
runReset
();
_serial
->
begin
(
DEFAULT_ESP_BAUDRATE
);
return
waitForReady
();
}
// Checks to see if the modem responds to the "AT" poll command.
bool
Challenger2040WiFiClass
::
isAlive
()
{
int
timeout
=
5
;
int
timeout
=
100
;
Serial2
.
setTimeout
(
250
);
Serial2
.
println
(
F
(
"AT"
));
String
rdy
=
Serial2
.
readStringUntil
(
'\n'
);
_serial
->
setTimeout
(
250
);
_serial
->
println
(
F
(
"AT"
));
String
rdy
=
_serial
->
readStringUntil
(
'\n'
);
while
(
!
rdy
.
startsWith
(
F
(
"OK"
))
&&
timeout
--
)
{
rdy
=
Serial2
.
readStringUntil
(
'\n'
);
_serial
->
println
(
F
(
"AT"
));
rdy
=
_serial
->
readStringUntil
(
'\n'
);
}
Serial2
.
setTimeout
(
1000
);
_serial
->
setTimeout
(
1000
);
if
(
timeout
)
return
true
;
return
false
;
}
// Change the baud rate of the ESP
32
as well as the local UART.
// Change the baud rate of the ESP
device
as well as the local UART.
// No checking is done on the input baud rate so the user must know what
// baud rates are valid. The function ends by checking if the ESP
32
is
// baud rates are valid. The function ends by checking if the ESP is
// reachable by doing an "AT" poll.
bool
Challenger2040WiFiClass
::
changeBaudRate
(
int
baud
)
{
Serial2
.
print
(
F
(
"AT+UART_CUR="
));
Serial2
.
print
(
baud
);
Serial2
.
println
(
F
(
",8,1,0,0"
));
_serial
->
print
(
F
(
"AT+UART_CUR="
));
_serial
->
print
(
baud
);
_serial
->
println
(
F
(
",8,1,0,0"
));
delay
(
100
);
Serial2
.
end
();
Serial2
.
begin
(
baud
);
_serial
->
end
();
_serial
->
begin
(
baud
);
return
isAlive
();
}
// This method should be called id the builtin object isn't needed any more
// It basically just releases the UART pins for other use.
void
Challenger2040WiFiClass
::
release
()
{
_serial
->
end
();
}
// We can assign a new hardware serial port to accommodate the ESP device here.
// The function will release the previously used serial port and assign the
// new port. The ESP will be left in a reset state ready to start normal
// operation when exiting the function.
// This function is useful for when using the PIO serial ports to communicate
// with the ESP instead of the built in hardware serial port.
void
Challenger2040WiFiClass
::
setSerial
(
HardwareSerial
*
serial
)
{
release
();
_serial
=
serial
;
pinMode
(
PIN_ESP_RST
,
OUTPUT
);
digitalWrite
(
PIN_ESP_RST
,
LOW
);
// Hold ESP in reset
pinMode
(
PIN_ESP_MODE
,
OUTPUT
);
digitalWrite
(
PIN_ESP_MODE
,
HIGH
);
// Prepare for normal start
}
// Return the current serial object
HardwareSerial
*
Challenger2040WiFiClass
::
getSerial
()
{
return
_serial
;
}
Challenger2040WiFiClass
Challenger2040WiFi
;
variants/challenger_2040_wifi_ble/ChallengerWiFi.h
View file @
a9b24827
/*
ESP8285
helper class for the Challenger RP2040 WiFi
boards
ESP8285
/ESP32C3 helper class for the Challenger RP2040 WiFi enabled
boards
Copyright (c) 2021 P. Oldberg <pontus@ilabs.se>
Copyright (c) 2021
,2022
P. Oldberg <pontus@ilabs.se>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
...
...
@@ -17,20 +17,27 @@
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#define DEFAULT_ESP32_BAUDRATE 115200
#define DEFAULT_ESP_BAUDRATE DEFAULT_ESP32_BAUDRATE
class
Challenger2040WiFiClass
{
public:
Challenger2040WiFiClass
();
Challenger2040WiFiClass
(
HardwareSerial
*
=
&
ESP_SERIAL_PORT
);
void
doHWReset
();
void
runReset
();
void
flashReset
();
bool
waitForReady
();
bool
reset
();
bool
isAlive
();
bool
changeBaudRate
(
int
baud
);
bool
changeBaudRate
(
int
);
void
release
();
void
setSerial
(
HardwareSerial
*
);
HardwareSerial
*
getSerial
();
private:
HardwareSerial
*
_serial
;
};
extern
Challenger2040WiFiClass
Challenger2040WiFi
;
variants/challenger_2040_wifi_ble/pins_arduino.h
View file @
a9b24827
...
...
@@ -18,7 +18,13 @@
#define PIN_SERIAL2_RX (5u)
#define PIN_ESP32_RST (19u)
#define PIN_ESP32_MODE (24u)
#define ESP32_SERIAL 1
#define ESP32_SERIAL Serial2
// Uart define esp serial abstraction pins
#define PIN_ESP_TX PIN_SERIAL2_TX
#define PIN_ESP_RX PIN_SERIAL2_RX
#define PIN_ESP_RST PIN_ESP32_RST
#define PIN_ESP_MODE PIN_ESP32_MODE
#define ESP_SERIAL_PORT ESP32_SERIAL
// SPI
#define PIN_SPI0_MISO (24u)
...
...
@@ -33,7 +39,7 @@
#define PIN_SPI1_SS (13u)
// Handshake signal from ESP32C3
#define ESP32_HS (18u)
#define ESP32_SPI 1
#define ESP32_SPI
SPI
1
// Wire
#define PIN_WIRE0_SDA (0u)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment