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
cd91d3ef
Unverified
Commit
cd91d3ef
authored
Aug 24, 2021
by
Pontus Oldberg
Committed by
GitHub
Aug 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added minimal HW support for onboard WiFi modem. (#287)
parent
02e8577f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
143 additions
and
0 deletions
+143
-0
variants/challenger_2040_wifi/ChallengerWiFi.cpp
variants/challenger_2040_wifi/ChallengerWiFi.cpp
+107
-0
variants/challenger_2040_wifi/ChallengerWiFi.h
variants/challenger_2040_wifi/ChallengerWiFi.h
+36
-0
No files found.
variants/challenger_2040_wifi/ChallengerWiFi.cpp
0 → 100644
View file @
cd91d3ef
/*
ESP8285 helper class for the Challenger RP2040 WiFi boards
Copyright (c) 2021 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
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#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
}
// Do a HW reset by applying a low pulse to the reset line for 1mSec
void
Challenger2040WiFiClass
::
doHWReset
()
{
digitalWrite
(
PIN_ESP8285_RST
,
LOW
);
// Hold ESP8285 in reset
delay
(
1
);
digitalWrite
(
PIN_ESP8285_RST
,
HIGH
);
// Release ESP8285 reset
}
// Set the mode flag high to indicate normal run operation and do a HW
// reset.
void
Challenger2040WiFiClass
::
runReset
()
{
// Prepare ESP8285 for normal op
digitalWrite
(
PIN_ESP8285_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 ESP8285 for flashing
digitalWrite
(
PIN_ESP8285_MODE
,
LOW
);
// Prepare for normal start
doHWReset
();
}
// Wait for the modem to reply with a "ready" prompt. This can be done
// after a sw or hw reset have been performed to ensure that the AT
// interpreter is up and running.
bool
Challenger2040WiFiClass
::
waitForReady
()
{
int
timeout
=
20
;
// Aprox max 2 sec
Serial2
.
begin
(
DEFAULT_ESP8285_BAUDRATE
);
Serial2
.
setTimeout
(
100
);
String
rdy
=
Serial2
.
readStringUntil
(
'\n'
);
while
(
!
rdy
.
startsWith
(
"ready"
)
&&
timeout
--
)
{
rdy
=
Serial2
.
readStringUntil
(
'\n'
);
}
Serial2
.
setTimeout
(
1000
);
// Reset default timeout to 1000
if
(
timeout
)
return
true
;
return
false
;
}
// Reset the ESP8285 and wait for the "ready" prompt to be returned.
bool
Challenger2040WiFiClass
::
reset
()
{
runReset
();
return
waitForReady
();
}
// Checks to see if the modem responds to the "AT" poll command.
bool
Challenger2040WiFiClass
::
isAlive
()
{
int
timeout
=
5
;
Serial2
.
setTimeout
(
250
);
Serial2
.
println
(
F
(
"AT"
));
String
rdy
=
Serial2
.
readStringUntil
(
'\n'
);
while
(
!
rdy
.
startsWith
(
F
(
"OK"
))
&&
timeout
--
)
{
rdy
=
Serial2
.
readStringUntil
(
'\n'
);
}
Serial2
.
setTimeout
(
1000
);
if
(
timeout
)
return
true
;
return
false
;
}
// Change the baud rate of the ESP8285 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 ESP8285 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"
));
delay
(
100
);
Serial2
.
end
();
Serial2
.
begin
(
baud
);
return
isAlive
();
}
Challenger2040WiFiClass
Challenger2040WiFi
;
variants/challenger_2040_wifi/ChallengerWiFi.h
0 → 100644
View file @
cd91d3ef
/*
ESP8285 helper class for the Challenger RP2040 WiFi boards
Copyright (c) 2021 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
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
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
class
Challenger2040WiFiClass
{
public:
Challenger2040WiFiClass
();
void
doHWReset
();
void
runReset
();
void
flashReset
();
bool
waitForReady
();
bool
reset
();
bool
isAlive
();
bool
changeBaudRate
(
int
baud
);
};
extern
Challenger2040WiFiClass
Challenger2040WiFi
;
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