Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cc9835303 | ||
|
|
48877984b7 | ||
|
|
a58f49018a | ||
|
|
7120a1508c | ||
|
|
a808f4ae6a | ||
|
|
4d1f5baa7e | ||
|
|
f106035100 | ||
|
|
21f49d032b | ||
|
|
341307cb8d | ||
|
|
85990ff51d |
@@ -19,8 +19,11 @@ See https://arduino-pico.readthedocs.io/en/latest/ along with the examples for m
|
||||
* Adafruit Trinkey RP2040 QT
|
||||
* Arduino Nano RP2040 Connect (preliminary)
|
||||
* Cytron Maker Pi RP2040
|
||||
* Cytron Maker Nano RP2040
|
||||
* Invector Labs Challenger RP2040 WiFi
|
||||
* Invector Labs Challenger NB RP2040 WiFi
|
||||
* Invector Labs Challenger RP2040 LTE
|
||||
* Invector Labs RPICO32
|
||||
* Melopero Shake RP2040
|
||||
* SparkFun ProMicro RP2040
|
||||
* uPesy RP2040 DevKit
|
||||
|
||||
+1405
-48
File diff suppressed because it is too large
Load Diff
@@ -30,6 +30,7 @@
|
||||
#include <pins_arduino.h>
|
||||
#include "hardware/gpio.h" // Required for the port*Register macros
|
||||
#include "debug_internal.h"
|
||||
#include <RP2040.h> // CMSIS
|
||||
|
||||
// Try and make the best of the old Arduino abs() macro. When in C++, use
|
||||
// the sane std::abs() call, but for C code use their macro since stdlib abs()
|
||||
@@ -95,7 +96,7 @@ void analogWriteResolution(int res);
|
||||
#endif
|
||||
|
||||
#include "SerialUART.h"
|
||||
#include "RP2040.h"
|
||||
#include "RP2040Support.h"
|
||||
#include "Bootsel.h"
|
||||
|
||||
// Template which will evaluate at *compile time* to a single 32b number
|
||||
|
||||
@@ -52,7 +52,6 @@ mutex_t __usb_mutex;
|
||||
#endif
|
||||
|
||||
#define USBD_DESC_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN)
|
||||
#define USBD_MAX_POWER_MA (250)
|
||||
|
||||
#define USBD_ITF_CDC (0) // needs 2 interfaces
|
||||
#define USBD_ITF_MAX (2)
|
||||
|
||||
+32
-13
@@ -96,7 +96,9 @@ void SerialUART::begin(unsigned long baud, uint16_t config) {
|
||||
gpio_set_function(_tx, GPIO_FUNC_UART);
|
||||
gpio_set_function(_rx, GPIO_FUNC_UART);
|
||||
_running = true;
|
||||
_peek = -1;
|
||||
while (!_swFIFO.empty()) {
|
||||
(void)_swFIFO.pop(); // Just throw out anything in our old FIFO
|
||||
}
|
||||
}
|
||||
|
||||
void SerialUART::end() {
|
||||
@@ -107,20 +109,30 @@ void SerialUART::end() {
|
||||
_running = false;
|
||||
}
|
||||
|
||||
// Transfers any data in the HW FIFO into our SW one, up to 32 bytes
|
||||
void SerialUART::_pumpFIFO() {
|
||||
while ((_swFIFO.size() < 32) && (uart_is_readable(_uart))) {
|
||||
_swFIFO.push(uart_getc(_uart));
|
||||
}
|
||||
}
|
||||
|
||||
int SerialUART::peek() {
|
||||
CoreMutex m(&_mutex);
|
||||
if (!_running || !m) {
|
||||
return -1;
|
||||
}
|
||||
if (_peek >= 0) {
|
||||
return _peek;
|
||||
_pumpFIFO();
|
||||
// If there's something in the FIFO now, just peek at it
|
||||
if (_swFIFO.size()) {
|
||||
return _swFIFO.front();
|
||||
}
|
||||
// The SW FIFO is empty, read the HW one until the timeout
|
||||
if (uart_is_readable_within_us(_uart, _timeout * 1000)) {
|
||||
_peek = uart_getc(_uart);
|
||||
} else {
|
||||
_peek = -1; // Timeout
|
||||
// We got one char, put it in the FIFO (which will now have exactly 1 byte) and return it
|
||||
_swFIFO.push(uart_getc(_uart));
|
||||
return _swFIFO.front();
|
||||
}
|
||||
return _peek;
|
||||
return -1; // Nothing available before timeout
|
||||
}
|
||||
|
||||
int SerialUART::read() {
|
||||
@@ -128,16 +140,18 @@ int SerialUART::read() {
|
||||
if (!_running || !m) {
|
||||
return -1;
|
||||
}
|
||||
if (_peek >= 0) {
|
||||
int ret = _peek;
|
||||
_peek = -1;
|
||||
_pumpFIFO();
|
||||
if (_swFIFO.size()) {
|
||||
auto ret = _swFIFO.front();
|
||||
_swFIFO.pop();
|
||||
return ret;
|
||||
}
|
||||
// The SW FIFO is empty, read the HW one until the timeout
|
||||
if (uart_is_readable_within_us(_uart, _timeout * 1000)) {
|
||||
// We got one char, return it (FIFO will still be empty
|
||||
return uart_getc(_uart);
|
||||
} else {
|
||||
return -1; // Timeout
|
||||
}
|
||||
return -1; // Timeout
|
||||
}
|
||||
|
||||
int SerialUART::available() {
|
||||
@@ -145,7 +159,8 @@ int SerialUART::available() {
|
||||
if (!_running || !m) {
|
||||
return 0;
|
||||
}
|
||||
return (uart_is_readable(_uart)) ? 1 : 0;
|
||||
_pumpFIFO();
|
||||
return _swFIFO.size();
|
||||
}
|
||||
|
||||
int SerialUART::availableForWrite() {
|
||||
@@ -153,6 +168,7 @@ int SerialUART::availableForWrite() {
|
||||
if (!_running || !m) {
|
||||
return 0;
|
||||
}
|
||||
_pumpFIFO();
|
||||
return (uart_is_writable(_uart)) ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -161,6 +177,7 @@ void SerialUART::flush() {
|
||||
if (!_running || !m) {
|
||||
return;
|
||||
}
|
||||
_pumpFIFO();
|
||||
uart_tx_wait_blocking(_uart);
|
||||
}
|
||||
|
||||
@@ -169,6 +186,7 @@ size_t SerialUART::write(uint8_t c) {
|
||||
if (!_running || !m) {
|
||||
return 0;
|
||||
}
|
||||
_pumpFIFO();
|
||||
uart_putc_raw(_uart, c);
|
||||
return 1;
|
||||
}
|
||||
@@ -178,6 +196,7 @@ size_t SerialUART::write(const uint8_t *p, size_t len) {
|
||||
if (!_running || !m) {
|
||||
return 0;
|
||||
}
|
||||
_pumpFIFO();
|
||||
size_t cnt = len;
|
||||
while (cnt) {
|
||||
uart_putc_raw(_uart, *p);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <Arduino.h>
|
||||
#include "api/HardwareSerial.h"
|
||||
#include <stdarg.h>
|
||||
#include <queue>
|
||||
#include "CoreMutex.h"
|
||||
|
||||
extern "C" typedef struct uart_inst uart_inst_t;
|
||||
@@ -61,8 +62,10 @@ private:
|
||||
uart_inst_t *_uart;
|
||||
pin_size_t _tx, _rx;
|
||||
int _baud;
|
||||
int _peek;
|
||||
mutex_t _mutex;
|
||||
|
||||
void _pumpFIFO();
|
||||
std::queue<uint8_t> _swFIFO;
|
||||
};
|
||||
|
||||
extern SerialUART Serial1; // HW UART 0
|
||||
|
||||
Binary file not shown.
@@ -12,8 +12,8 @@
|
||||
#define _PICO_VERSION_H
|
||||
|
||||
#define PICO_SDK_VERSION_MAJOR 1
|
||||
#define PICO_SDK_VERSION_MINOR 2
|
||||
#define PICO_SDK_VERSION_MINOR 3
|
||||
#define PICO_SDK_VERSION_REVISION 0
|
||||
#define PICO_SDK_VERSION_STRING "1.2.0"
|
||||
#define PICO_SDK_VERSION_STRING "1.3.0"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
-iwithprefixbefore/pico-sdk/src/common/pico_util/include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2040/hardware_regs/include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2040/hardware_structs/include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2_common/cmsis/include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2_common/cmsis/stub/CMSIS/Core/Include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2_common/cmsis/stub/CMSIS/Device/RaspberryPi/RP2040/Include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2_common/hardware_adc/include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2_common/hardware_base/include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2_common/hardware_claim/include
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "framework-arduinopico",
|
||||
"version": "1.10905.0",
|
||||
"version": "1.10909.0",
|
||||
"description": "Arduino Wiring-based Framework (RPi Pico RP2040)",
|
||||
"keywords": [
|
||||
"framework",
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
{
|
||||
"name": "Arduino Nano RP2040 Connect"
|
||||
},
|
||||
{
|
||||
"name": "Cytron Maker Nano RP2040"
|
||||
},
|
||||
{
|
||||
"name": "Cytron Maker Pi RP2040"
|
||||
},
|
||||
|
||||
+1
-1
Submodule pico-extras updated: ccd88d320f...77eae28366
+1
-1
Submodule pico-sdk updated: bfcbefafc5...2062372d20
+6
-4
@@ -29,6 +29,8 @@ runtime.tools.pqt-elf2uf2.path={runtime.platform.path}/system/elf2uf2
|
||||
|
||||
compiler.path={runtime.tools.pqt-gcc.path}/bin/
|
||||
|
||||
compiler.libraries.ldflags=
|
||||
|
||||
# Compile variables
|
||||
# -----------------
|
||||
|
||||
@@ -96,13 +98,13 @@ discovery.rp2040.pattern="{runtime.tools.pqt-python3.path}/python3" -I "{runtime
|
||||
# ----------------
|
||||
|
||||
## Compile c files
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {build.flags.optimize} {includes} "{source_file}" -o "{object_file}"
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} {build.usbpid} {build.usbpwr} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {build.flags.optimize} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile c++ files
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {build.flags.optimize} {includes} "{source_file}" -o "{object_file}"
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {build.usbpid} {build.usbpwr} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {build.flags.optimize} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile S files
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} {build.usbpid} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}"
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} {build.usbpid} {build.usbpwr} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.debug_port} {build.debug_level} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Create archives
|
||||
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
|
||||
@@ -116,7 +118,7 @@ recipe.hooks.linking.prelink.1.pattern="{runtime.tools.pqt-python3.path}/python3
|
||||
recipe.hooks.linking.prelink.2.pattern="{compiler.path}{compiler.S.cmd}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -c "{runtime.platform.path}/boot2/{build.boot2}.S" "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include/" "-I{runtime.platform.path}/pico-sdk/src/common/pico_binary_info/include" -o "{build.path}/boot2.o"
|
||||
|
||||
## Combine gc-sections, archives, and objects
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} {compiler.ldflags} "-Wl,--script={build.path}/memmap_default.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" -o "{build.path}/{build.project_name}.elf" -Wl,--start-group {object_files} "{build.path}/{archive_file}" "{build.path}/boot2.o" {compiler.libpico} -lm -lc {compiler.libstdcpp} -lc -Wl,--end-group
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} {compiler.ldflags} "-Wl,--script={build.path}/memmap_default.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" -o "{build.path}/{build.project_name}.elf" -Wl,--start-group {object_files} "{build.path}/{archive_file}" "{build.path}/boot2.o" {compiler.libraries.ldflags} {compiler.libpico} -lm -lc {compiler.libstdcpp} -lc -Wl,--end-group
|
||||
|
||||
## Create output (UF2 file)
|
||||
recipe.objcopy.uf2.pattern="{runtime.tools.pqt-elf2uf2.path}/elf2uf2" "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.uf2"
|
||||
|
||||
@@ -53,6 +53,7 @@ target_link_libraries(pico
|
||||
hardware_vreg
|
||||
hardware_watchdog
|
||||
hardware_xosc
|
||||
cmsis
|
||||
pico_bit_ops
|
||||
pico_bootrom
|
||||
pico_bootsel_via_double_reset
|
||||
|
||||
@@ -23,6 +23,7 @@ for type in boot2_generic_03h boot2_is25lp080 boot2_w25q080 boot2_w25x10cl; do
|
||||
arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 \
|
||||
-DNDEBUG -DPICO_FLASH_SPI_CLKDIV=$div \
|
||||
-c "$PICO_SDK_PATH/src/rp2_common/boot_stage2/$type.S" \
|
||||
-I "$PICO_SDK_PATH/src/boards/include/boards/" \
|
||||
-I "$PICO_SDK_PATH/src/rp2040/hardware_regs/include/" \
|
||||
-I "$PICO_SDK_PATH/src/rp2_common/pico_platform/include/" \
|
||||
-I "$PICO_SDK_PATH/src/rp2_common/boot_stage2/asminclude/" \
|
||||
|
||||
@@ -26,14 +26,14 @@ if (NOT PICO_EXTRAS_PATH)
|
||||
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_EXTRAS_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
|
||||
endif ()
|
||||
FetchContent_Declare(
|
||||
PICO_EXTRAS
|
||||
pico_extras
|
||||
GIT_REPOSITORY https://github.com/raspberrypi/pico-extras
|
||||
GIT_TAG master
|
||||
)
|
||||
if (NOT PICO_EXTRAS)
|
||||
message("Downloading PICO EXTRAS")
|
||||
FetchContent_Populate(PICO_EXTRAS)
|
||||
set(PICO_EXTRAS_PATH ${PICO_EXTRAS_SOURCE_DIR})
|
||||
if (NOT pico_extras)
|
||||
message("Downloading Raspberry Pi Pico Extras")
|
||||
FetchContent_Populate(pico_extras)
|
||||
set(PICO_EXTRAS_PATH ${pico_extras_SOURCE_DIR})
|
||||
endif ()
|
||||
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
|
||||
else ()
|
||||
@@ -59,4 +59,4 @@ endif ()
|
||||
|
||||
set(PICO_EXTRAS_PATH ${PICO_EXTRAS_PATH} CACHE PATH "Path to the PICO EXTRAS" FORCE)
|
||||
|
||||
add_subdirectory(${PICO_EXTRAS_PATH} pico_extras)
|
||||
add_subdirectory(${PICO_EXTRAS_PATH} pico_extras)
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
# This can be dropped into an external project to help locate this SDK
|
||||
# It should be include()ed prior to project()
|
||||
|
||||
# todo document
|
||||
|
||||
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
|
||||
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
|
||||
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
|
||||
@@ -20,8 +18,8 @@ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_P
|
||||
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
|
||||
endif ()
|
||||
|
||||
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the PICO SDK")
|
||||
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of PICO SDK from git if not otherwise locatable")
|
||||
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
|
||||
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable")
|
||||
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
|
||||
|
||||
if (NOT PICO_SDK_PATH)
|
||||
@@ -37,14 +35,14 @@ if (NOT PICO_SDK_PATH)
|
||||
GIT_TAG master
|
||||
)
|
||||
if (NOT pico_sdk)
|
||||
message("Downloading PICO SDK")
|
||||
message("Downloading Raspberry Pi Pico SDK")
|
||||
FetchContent_Populate(pico_sdk)
|
||||
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
|
||||
endif ()
|
||||
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
|
||||
else ()
|
||||
message(FATAL_ERROR
|
||||
"PICO SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
|
||||
"SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
@@ -56,9 +54,9 @@ endif ()
|
||||
|
||||
set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake)
|
||||
if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE})
|
||||
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the PICO SDK")
|
||||
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK")
|
||||
endif ()
|
||||
|
||||
set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the PICO SDK" FORCE)
|
||||
set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
|
||||
|
||||
include(${PICO_SDK_INIT_CMAKE_FILE})
|
||||
|
||||
+30
-21
@@ -66,7 +66,7 @@ def BuildWithoutUSBStack(name):
|
||||
print("%s.menu.usbstack.nousb=No USB" % (name))
|
||||
print('%s.menu.usbstack.nousb.build.usbstack_flags="-DNO_USB -DDISABLE_USB_SERIAL -I{runtime.platform.path}/tools/libpico"' % (name))
|
||||
|
||||
def BuildHeader(name, vendor_name, product_name, vidtouse, pidtouse, vid, pid, boarddefine, variant, uploadtool, flashsize, ramsize, boot2):
|
||||
def BuildHeader(name, vendor_name, product_name, vidtouse, pidtouse, vid, pid, pwr, boarddefine, variant, uploadtool, flashsize, ramsize, boot2):
|
||||
prettyname = vendor_name + " " + product_name
|
||||
print()
|
||||
print("# -----------------------------------")
|
||||
@@ -76,6 +76,7 @@ def BuildHeader(name, vendor_name, product_name, vidtouse, pidtouse, vid, pid, b
|
||||
print("%s.vid.0=%s" % (name, vidtouse))
|
||||
print("%s.pid.0=%s" % (name, pidtouse))
|
||||
print("%s.build.usbpid=-DSERIALUSB_PID=%s" % (name, pid))
|
||||
print("%s.build.usbpwr=-DUSBD_MAX_POWER_MA=%s" % (name, pwr))
|
||||
print("%s.build.board=%s" % (name, boarddefine))
|
||||
print("%s.build.mcu=cortex-m0plus" % (name))
|
||||
print("%s.build.variant=%s" % (name, variant))
|
||||
@@ -89,7 +90,6 @@ def BuildHeader(name, vendor_name, product_name, vidtouse, pidtouse, vid, pid, b
|
||||
print("%s.build.f_cpu=125000000" % (name))
|
||||
print("%s.build.led=" % (name))
|
||||
print("%s.build.core=rp2040" % (name))
|
||||
print("%s.build.mcu=rp2040" % (name))
|
||||
print("%s.build.ldscript=memmap_default.ld" % (name))
|
||||
print("%s.build.ram_length=%dk" % (name, ramsize / 1024))
|
||||
print("%s.build.boot2=%s" % (name, boot2))
|
||||
@@ -98,6 +98,12 @@ def BuildHeader(name, vendor_name, product_name, vidtouse, pidtouse, vid, pid, b
|
||||
print('%s.build.usb_manufacturer="%s"' % (name, vendor_name))
|
||||
print('%s.build.usb_product="%s"' % (name, product_name))
|
||||
|
||||
def WriteWarning():
|
||||
print("# WARNING - DO NOT EDIT THIS FILE, IT IS MACHINE GENERATED")
|
||||
print("# To change something here, edit tools/makeboards.py and")
|
||||
print("# run 'python3 makeboards.py > ../boards.txt' to regenerate")
|
||||
print()
|
||||
|
||||
def BuildGlobalMenuList():
|
||||
print("menu.BoardModel=Model")
|
||||
print("menu.flash=Flash Size")
|
||||
@@ -110,7 +116,7 @@ def BuildGlobalMenuList():
|
||||
print("menu.usbstack=USB Stack")
|
||||
|
||||
|
||||
def MakeBoard(name, vendor_name, product_name, vid, pid, boarddefine, flashsizemb, boot2):
|
||||
def MakeBoard(name, vendor_name, product_name, vid, pid, pwr, boarddefine, flashsizemb, boot2):
|
||||
for a, b, c in [ ["", "", "uf2conv"], ["picoprobe", " (Picoprobe)", "picoprobe"], ["picodebug", " (pico-debug)", "picodebug"]]:
|
||||
n = name + a
|
||||
p = product_name + b
|
||||
@@ -127,7 +133,7 @@ def MakeBoard(name, vendor_name, product_name, vid, pid, boarddefine, flashsizem
|
||||
ramsizekb = 240;
|
||||
else:
|
||||
pidtouse = pid
|
||||
BuildHeader(n, vendor_name, p, vidtouse, pidtouse, vid, pid, boarddefine, name, c, flashsizemb * 1024 * 1024, ramsizekb * 1024, boot2)
|
||||
BuildHeader(n, vendor_name, p, vidtouse, pidtouse, vid, pid, pwr, boarddefine, name, c, flashsizemb * 1024 * 1024, ramsizekb * 1024, boot2)
|
||||
if name == "generic":
|
||||
BuildFlashMenu(n, 2*1024*1024, [0, 1*1024*1024])
|
||||
BuildFlashMenu(n, 4*1024*1024, [0, 2*1024*1024])
|
||||
@@ -147,21 +153,24 @@ def MakeBoard(name, vendor_name, product_name, vid, pid, boarddefine, flashsizem
|
||||
if name == "generic":
|
||||
BuildBoot(n)
|
||||
|
||||
|
||||
WriteWarning()
|
||||
BuildGlobalMenuList()
|
||||
MakeBoard("rpipico", "Raspberry Pi", "Pico", "0x2e8a", "0x000a", "RASPBERRY_PI_PICO", 2, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("adafruit_feather", "Adafruit", "Feather RP2040", "0x239a", "0x80f1", "ADAFRUIT_FEATHER_RP2040", 8, "boot2_w25x10cl_4_padded_checksum")
|
||||
MakeBoard("adafruit_itsybitsy", "Adafruit", "ItsyBitsy RP2040", "0x239a", "0x80fd", "ADAFRUIT_ITSYBITSY_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("adafruit_qtpy", "Adafruit", "QT Py RP2040", "0x239a", "0x80f7", "ADAFRUIT_QTPY_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("adafruit_stemmafriend", "Adafruit", "STEMMA Friend RP2040", "0x239a", "0x80e3", "ADAFRUIT_STEMMAFRIEND_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("adafruit_trinkeyrp2040qt", "Adafruit", "Trinkey RP2040 QT", "0x239a", "0x8109", "ADAFRUIT_TRINKEYQT_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("adafruit_macropad2040", "Adafruit", "MacroPad RP2040", "0x239a", "0x8107", "ADAFRUIT_MACROPAD_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("arduino_nano_connect", "Arduino", "Nano RP2040 Connect", "0x2341", "0x0058", "ARDUINO_NANO_RP2040_CONNECT", 16, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("cytron_maker_pi_rp2040", "Cytron", "Maker Pi RP2040", "0x2e8a", "0x1000", "CYTRON_MAKER_PI_RP2040", 2, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("sparkfun_promicrorp2040", "SparkFun", "ProMicro RP2040", "0x1b4f", "0x0026", "SPARKFUN_PROMICRO_RP2040", 16, "boot2_generic_03h_4_padded_checksum")
|
||||
MakeBoard("generic", "Generic", "RP2040", "0x2e8a", "0xf00a", "GENERIC_RP2040", 16, "boot2_generic_03h_4_padded_checksum")
|
||||
MakeBoard("challenger_2040_wifi", "iLabs", "Challenger 2040 WiFi", "0x2e8a", "0x1006", "CHALLENGER_2040_WIFI_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("challenger_2040_lte", "iLabs", "Challenger 2040 LTE", "0x2e8a", "0x100b", "CHALLENGER_2040_LTE_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("melopero_shake_rp2040", "Melopero", "Shake RP2040", "0x2e8a", "0x1005", "MELOPERO_SHAKE_RP2040", 16, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("upesy_rp2040_devkit", "uPesy", "RP2040 DevKit", "0x2e8a", "0x1007", "UPESY_RP2040_DEVKIT", 2, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("wiznet_5100s_evb_pico", "WIZnet", "W5100S-EVB-Pico", "0x2e8a", "0x1008", "WIZNET_5100S_EVB_PICO", 2, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("rpipico", "Raspberry Pi", "Pico", "0x2e8a", "0x000a", 250, "RASPBERRY_PI_PICO", 2, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("adafruit_feather", "Adafruit", "Feather RP2040", "0x239a", "0x80f1", 250, "ADAFRUIT_FEATHER_RP2040", 8, "boot2_w25x10cl_4_padded_checksum")
|
||||
MakeBoard("adafruit_itsybitsy", "Adafruit", "ItsyBitsy RP2040", "0x239a", "0x80fd", 250, "ADAFRUIT_ITSYBITSY_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("adafruit_qtpy", "Adafruit", "QT Py RP2040", "0x239a", "0x80f7", 250, "ADAFRUIT_QTPY_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("adafruit_stemmafriend", "Adafruit", "STEMMA Friend RP2040", "0x239a", "0x80e3", 250, "ADAFRUIT_STEMMAFRIEND_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("adafruit_trinkeyrp2040qt", "Adafruit", "Trinkey RP2040 QT", "0x239a", "0x8109", 250, "ADAFRUIT_TRINKEYQT_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("adafruit_macropad2040", "Adafruit", "MacroPad RP2040", "0x239a", "0x8107", 250, "ADAFRUIT_MACROPAD_RP2040", 8, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("arduino_nano_connect", "Arduino", "Nano RP2040 Connect", "0x2341", "0x0058", 250, "ARDUINO_NANO_RP2040_CONNECT", 16, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("cytron_maker_nano_rp2040", "Cytron", "Maker Nano RP2040", "0x2e8a", "0x100f", 250, "CYTRON_MAKER_NANO_RP2040", 2, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("cytron_maker_pi_rp2040", "Cytron", "Maker Pi RP2040", "0x2e8a", "0x1000", 250, "CYTRON_MAKER_PI_RP2040", 2, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("sparkfun_promicrorp2040", "SparkFun", "ProMicro RP2040", "0x1b4f", "0x0026", 250, "SPARKFUN_PROMICRO_RP2040", 16, "boot2_generic_03h_4_padded_checksum")
|
||||
MakeBoard("generic", "Generic", "RP2040", "0x2e8a", "0xf00a", 250, "GENERIC_RP2040", 16, "boot2_generic_03h_4_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_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")
|
||||
MakeBoard("melopero_shake_rp2040", "Melopero", "Shake RP2040", "0x2e8a", "0x1005", 250, "MELOPERO_SHAKE_RP2040", 16, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("upesy_rp2040_devkit", "uPesy", "RP2040 DevKit", "0x2e8a", "0x1007", 250, "UPESY_RP2040_DEVKIT", 2, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("wiznet_5100s_evb_pico", "WIZnet", "W5100S-EVB-Pico", "0x2e8a", "0x1008", 250, "WIZNET_5100S_EVB_PICO", 2, "boot2_w25q080_2_padded_checksum")
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
UBlox SARA helper class for the Challenger RP2040 LTE 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 <ChallengerLTE.h>
|
||||
|
||||
Challenger2040LTEClass::Challenger2040LTEClass() {
|
||||
pinMode(PIN_SARA_ON, OUTPUT);
|
||||
digitalWrite(PIN_SARA_ON, LOW); // Output register must always be low
|
||||
pinMode(PIN_SARA_ON, INPUT_PULLUP);
|
||||
|
||||
pinMode(PIN_SARA_RST, INPUT_PULLUP); // Keep as input for now
|
||||
|
||||
pinMode(PIN_SARA_PWR, OUTPUT);
|
||||
digitalWrite(PIN_SARA_PWR, LOW); // No power to SARA yet
|
||||
serialPortConfigured = false;
|
||||
}
|
||||
|
||||
// Do a HW reset by applying a low pulse to the reset line for 1mSec
|
||||
bool Challenger2040LTEClass::doPowerOn() {
|
||||
bool ret;
|
||||
digitalWrite(PIN_SARA_PWR, HIGH); // Make sure LDO is on
|
||||
delay(100); // let the power stabilize
|
||||
pinMode(PIN_SARA_ON, OUTPUT); // Pull power on control low
|
||||
delay(150); // For 150mS
|
||||
pinMode(PIN_SARA_ON, INPUT_PULLUP); // before releasing it again.
|
||||
delay(1000); // Now wait for 1 second
|
||||
SARA_SERIAL_PORT.begin(DEFAULT_SARA_BAUDRATE);
|
||||
serialPortConfigured = true;
|
||||
ret = isAlive(); // Makie sure the modem is
|
||||
// up and running
|
||||
|
||||
delay(250); // Allow for any extra characters
|
||||
// before flushing the input buffer
|
||||
while(SARA_SERIAL_PORT.available()) SARA_SERIAL_PORT.read();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Checks to see if the modem responds to the "AT" poll command.
|
||||
bool Challenger2040LTEClass::isAlive(uint32_t timeout) {
|
||||
SARA_SERIAL_PORT.setTimeout(100);
|
||||
SARA_SERIAL_PORT.println(F("AT"));
|
||||
String rdy = SARA_SERIAL_PORT.readStringUntil('\n');
|
||||
while(!rdy.startsWith(F("OK")) && --timeout) {
|
||||
SARA_SERIAL_PORT.println(F("AT"));
|
||||
rdy = SARA_SERIAL_PORT.readStringUntil('\n');
|
||||
//Serial.println(rdy);
|
||||
}
|
||||
SARA_SERIAL_PORT.setTimeout(1000); // Restore serial timeout
|
||||
if (timeout)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return the current MNO profile
|
||||
// Returns -1 if the serial port is not yet setup or the number of the current
|
||||
// MNO profile setting from the modem.
|
||||
int Challenger2040LTEClass::getMNOProfile() {
|
||||
if (!serialPortConfigured)
|
||||
return -1;
|
||||
SARA_SERIAL_PORT.println(F("AT+UMNOPROF?"));
|
||||
String resp = getResponse();
|
||||
return resp.substring(resp.indexOf("+UMNOPROF: ") + 11).toInt();
|
||||
}
|
||||
|
||||
// Set a new MNO profile
|
||||
// Returns false if the serial port is not yet setup
|
||||
bool Challenger2040LTEClass::setMNOProfile(int profile) {
|
||||
if (!serialPortConfigured)
|
||||
return false;
|
||||
String cmd = "AT+UMNOPROF=" + String(profile) + ",1";
|
||||
SARA_SERIAL_PORT.println(cmd);
|
||||
|
||||
if (!getResponse().endsWith("OK")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Disable power save features
|
||||
bool Challenger2040LTEClass::enablePS(bool enable) {
|
||||
if (!serialPortConfigured)
|
||||
return false;
|
||||
if (enable)
|
||||
SARA_SERIAL_PORT.println(F("AT+CPSMS=1"));
|
||||
else
|
||||
SARA_SERIAL_PORT.println(F("AT+CPSMS=0"));
|
||||
|
||||
if (!getResponse().endsWith("OK")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get a response from SARA
|
||||
// A default serial timeout of 2 seconds allow for reading really slow
|
||||
// responses which should accommodate most replies. Replies are then trimmed
|
||||
// from control characters and appended with a tab character as a separator.
|
||||
//
|
||||
String Challenger2040LTEClass::getResponse(int timeout) {
|
||||
SARA_SERIAL_PORT.setTimeout(2000); // allow for really slow responses
|
||||
|
||||
String resp = SARA_SERIAL_PORT.readStringUntil('\n');
|
||||
resp.trim();
|
||||
String acc = resp;
|
||||
while(resp.indexOf("OK") == -1 && resp.indexOf("ERROR") == -1 && --timeout) {
|
||||
resp = SARA_SERIAL_PORT.readStringUntil('\n');
|
||||
resp.trim();
|
||||
if (resp.length())
|
||||
acc += "\t" + resp;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
Challenger2040LTEClass Challenger2040LTE;
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
UBlox SARA helper class for the Challenger RP2040 LTE 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_SARA_BAUDRATE 115200
|
||||
|
||||
class Challenger2040LTEClass {
|
||||
public:
|
||||
Challenger2040LTEClass();
|
||||
bool doPowerOn();
|
||||
bool isAlive(uint32_t timeout = 50);
|
||||
int getMNOProfile();
|
||||
bool setMNOProfile(int profile);
|
||||
bool enablePS(bool enable = true);
|
||||
String getResponse(int timeout = 5);
|
||||
|
||||
private:
|
||||
bool serialPortConfigured;
|
||||
};
|
||||
|
||||
extern Challenger2040LTEClass Challenger2040LTE;
|
||||
@@ -21,6 +21,7 @@
|
||||
#define PIN_SARA_ON (13u)
|
||||
#define PIN_SARA_RST (14u)
|
||||
#define PIN_SARA_PWR (15u)
|
||||
#define SARA_SERIAL_PORT Serial2
|
||||
|
||||
// SPI
|
||||
#define PIN_SPI0_MISO (24u)
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
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;
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
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;
|
||||
@@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
|
||||
#include <ChallengerWiFi.h>
|
||||
|
||||
#define PINS_COUNT (24u)
|
||||
#define NUM_DIGITAL_PINS (24u)
|
||||
#define NUM_ANALOG_INPUTS (4u)
|
||||
#define NUM_ANALOG_OUTPUTS (0u)
|
||||
#define ADC_RESOLUTION (12u)
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED (12u)
|
||||
|
||||
// Serial
|
||||
#define PIN_SERIAL1_TX (16u)
|
||||
#define PIN_SERIAL1_RX (17u)
|
||||
|
||||
// Connected to ESP8285
|
||||
#define PIN_SERIAL2_TX (4u)
|
||||
#define PIN_SERIAL2_RX (5u)
|
||||
#define PIN_ESP8285_RST (19u)
|
||||
#define PIN_ESP8285_MODE (13u)
|
||||
|
||||
// SPI
|
||||
#define PIN_SPI0_MISO (24u)
|
||||
#define PIN_SPI0_MOSI (23u)
|
||||
#define PIN_SPI0_SCK (22u)
|
||||
#define PIN_SPI0_SS (21u)
|
||||
|
||||
// Not pinned out
|
||||
#define PIN_SPI1_MISO (31u)
|
||||
#define PIN_SPI1_MOSI (31u)
|
||||
#define PIN_SPI1_SCK (31u)
|
||||
#define PIN_SPI1_SS (31u)
|
||||
|
||||
// Wire
|
||||
#define PIN_WIRE0_SDA (0u)
|
||||
#define PIN_WIRE0_SCL (1u)
|
||||
|
||||
// Not pinned out
|
||||
#define PIN_WIRE1_SDA (31u)
|
||||
#define PIN_WIRE1_SCL (31u)
|
||||
|
||||
#define SERIAL_HOWMANY (2u)
|
||||
#define SPI_HOWMANY (1u)
|
||||
#define WIRE_HOWMANY (1u)
|
||||
|
||||
#define LED_BUILTIN PIN_LED
|
||||
#define NEOPIXEL (11u)
|
||||
|
||||
static const uint8_t D0 = (16u);
|
||||
static const uint8_t D1 = (17u);
|
||||
static const uint8_t D2 = (24u);
|
||||
static const uint8_t D3 = (23u);
|
||||
static const uint8_t D4 = (22u);
|
||||
static const uint8_t D5 = (2u);
|
||||
static const uint8_t D6 = (3u);
|
||||
static const uint8_t D7 = (0u);
|
||||
static const uint8_t D8 = (1u);
|
||||
static const uint8_t D9 = (6u);
|
||||
static const uint8_t D10 = (7u);
|
||||
static const uint8_t D11 = (8u);
|
||||
static const uint8_t D12 = (9u);
|
||||
static const uint8_t D13 = (10u);
|
||||
static const uint8_t D14 = (14u);
|
||||
static const uint8_t D15 = (15u);
|
||||
static const uint8_t D16 = (18u);
|
||||
static const uint8_t D17 = (20u);
|
||||
|
||||
static const uint8_t A0 = (26u);
|
||||
static const uint8_t A1 = (27u);
|
||||
static const uint8_t A2 = (28u);
|
||||
static const uint8_t A3 = (29u);
|
||||
static const uint8_t A4 = (25u);
|
||||
static const uint8_t A5 = (21u);
|
||||
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED (2u)
|
||||
|
||||
// Neopixel
|
||||
#define PIN_NEOPIXEL (11u)
|
||||
#define NUM_NEOPIXEL (2u)
|
||||
#define PIN_RGB PIN_NEOPIXEL
|
||||
|
||||
// Buzzer
|
||||
#define PIN_BUZZER (22u)
|
||||
|
||||
// Button
|
||||
#define PIN_BUTTON (20u)
|
||||
|
||||
|
||||
|
||||
// Serial 1
|
||||
#define PIN_SERIAL1_TX (0u)
|
||||
#define PIN_SERIAL1_RX (1u)
|
||||
|
||||
// Serial 2 (Not pinned out)
|
||||
#define PIN_SERIAL2_TX (31u)
|
||||
#define PIN_SERIAL2_RX (31u)
|
||||
|
||||
// SPI 0
|
||||
#define PIN_SPI0_MISO (16u)
|
||||
#define PIN_SPI0_MOSI (19u)
|
||||
#define PIN_SPI0_SCK (18u)
|
||||
#define PIN_SPI0_SS (17u)
|
||||
|
||||
// SPI 1 (Not pinned out)
|
||||
#define PIN_SPI1_MISO (31u)
|
||||
#define PIN_SPI1_MOSI (31u)
|
||||
#define PIN_SPI1_SCK (31u)
|
||||
#define PIN_SPI1_SS (31u)
|
||||
|
||||
// Wire
|
||||
#define PIN_WIRE0_SDA (0u)
|
||||
#define PIN_WIRE0_SCL (1u)
|
||||
|
||||
#define PIN_WIRE1_SDA (26u)
|
||||
#define PIN_WIRE1_SCL (27u)
|
||||
|
||||
|
||||
|
||||
#define SERIAL_HOWMANY (1u)
|
||||
#define SPI_HOWMANY (1u)
|
||||
#define WIRE_HOWMANY (2u)
|
||||
|
||||
#include "../generic/common.h"
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
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 <Ilabs2040WiFiClass.h>
|
||||
|
||||
Ilabs2040WiFiClass::Ilabs2040WiFiClass() {
|
||||
pinMode(PIN_ESP_RESET, OUTPUT);
|
||||
digitalWrite(PIN_ESP_RESET, LOW); // Hold ESP8285 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 Ilabs2040WiFiClass::doHWReset() {
|
||||
digitalWrite(PIN_ESP_RESET, LOW); // Hold ESP8285 in reset
|
||||
delay(1);
|
||||
digitalWrite(PIN_ESP_RESET, HIGH); // Release ESP8285 reset
|
||||
}
|
||||
|
||||
// Set the mode flag high to indicate normal run operation and do a HW
|
||||
// reset.
|
||||
void Ilabs2040WiFiClass::runReset() { // Prepare ESP8285 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 Ilabs2040WiFiClass::flashReset() { // Prepare ESP8285 for flashing
|
||||
digitalWrite(PIN_ESP_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 Ilabs2040WiFiClass::waitForReady() {
|
||||
int timeout = 20; // Aprox max 2 sec
|
||||
|
||||
ESP_SERIAL_PORT.begin(DEFAULT_ESP8285_BAUDRATE);
|
||||
ESP_SERIAL_PORT.setTimeout(100);
|
||||
String rdy = ESP_SERIAL_PORT.readStringUntil('\n');
|
||||
while(!rdy.startsWith("ready") && timeout--) {
|
||||
rdy = ESP_SERIAL_PORT.readStringUntil('\n');
|
||||
}
|
||||
ESP_SERIAL_PORT.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 Ilabs2040WiFiClass::reset() {
|
||||
runReset();
|
||||
return waitForReady();
|
||||
}
|
||||
|
||||
// Checks to see if the modem responds to the "AT" poll command.
|
||||
bool Ilabs2040WiFiClass::isAlive() {
|
||||
int timeout = 5;
|
||||
|
||||
ESP_SERIAL_PORT.setTimeout(250);
|
||||
ESP_SERIAL_PORT.println(F("AT"));
|
||||
String rdy = ESP_SERIAL_PORT.readStringUntil('\n');
|
||||
while(!rdy.startsWith(F("OK")) && timeout--) {
|
||||
rdy = ESP_SERIAL_PORT.readStringUntil('\n');
|
||||
}
|
||||
ESP_SERIAL_PORT.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 Ilabs2040WiFiClass::changeBaudRate(int baud) {
|
||||
ESP_SERIAL_PORT.print(F("AT+UART_CUR="));
|
||||
ESP_SERIAL_PORT.print(baud);
|
||||
ESP_SERIAL_PORT.println(F(",8,1,0,0"));
|
||||
delay(100);
|
||||
ESP_SERIAL_PORT.end();
|
||||
ESP_SERIAL_PORT.begin(baud);
|
||||
return isAlive();
|
||||
}
|
||||
|
||||
Ilabs2040WiFiClass Ilabs2040WiFi;
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
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 Ilabs2040WiFiClass {
|
||||
public:
|
||||
Ilabs2040WiFiClass();
|
||||
void doHWReset();
|
||||
void runReset();
|
||||
void flashReset();
|
||||
bool waitForReady();
|
||||
bool reset();
|
||||
bool isAlive();
|
||||
bool changeBaudRate(int baud);
|
||||
};
|
||||
|
||||
extern Ilabs2040WiFiClass Ilabs2040WiFi;
|
||||
@@ -0,0 +1,82 @@
|
||||
#pragma once
|
||||
|
||||
#include <Ilabs2040WiFiClass.h>
|
||||
|
||||
#define PINS_COUNT (26u)
|
||||
#define NUM_DIGITAL_PINS (26u)
|
||||
#define NUM_ANALOG_INPUTS (4u)
|
||||
#define NUM_ANALOG_OUTPUTS (0u)
|
||||
#define ADC_RESOLUTION (12u)
|
||||
|
||||
// Connected to ESP8285
|
||||
#define PIN_SERIAL1_TX (0u)
|
||||
#define PIN_SERIAL1_RX (1u)
|
||||
#define PIN_ESP_RESET (2u)
|
||||
#define PIN_ESP_MODE (3u)
|
||||
#define PIN_ESP_TXD PIN_SERIAL1_TX
|
||||
#define PIN_ESP_RXD PIN_SERIAL1_RX
|
||||
#define ESP_SERIAL_PORT Serial1
|
||||
|
||||
// Serial
|
||||
#define PIN_SERIAL2_TX (8u)
|
||||
#define PIN_SERIAL2_RX (9u)
|
||||
|
||||
// SPI
|
||||
#define PIN_SPI0_MISO (24u)
|
||||
#define PIN_SPI0_MOSI (23u)
|
||||
#define PIN_SPI0_SCK (22u)
|
||||
#define PIN_SPI0_SS (21u)
|
||||
|
||||
// Not pinned out
|
||||
#define PIN_SPI1_MISO (31u)
|
||||
#define PIN_SPI1_MOSI (31u)
|
||||
#define PIN_SPI1_SCK (31u)
|
||||
#define PIN_SPI1_SS (31u)
|
||||
|
||||
// Wire
|
||||
#define PIN_WIRE0_SDA (4u)
|
||||
#define PIN_WIRE0_SCL (5u)
|
||||
|
||||
// Not pinned out
|
||||
#define PIN_WIRE1_SDA (31u)
|
||||
#define PIN_WIRE1_SCL (31u)
|
||||
|
||||
#define SERIAL_HOWMANY (2u)
|
||||
#define SPI_HOWMANY (1u)
|
||||
#define WIRE_HOWMANY (1u)
|
||||
|
||||
static const uint8_t D0 = (0u); // Internal to the board
|
||||
static const uint8_t D1 = (1u); // Internal to the board
|
||||
static const uint8_t D2 = (2u); // Internal to the board
|
||||
static const uint8_t D3 = (3u); // Internal to the board
|
||||
static const uint8_t D4 = (4u);
|
||||
static const uint8_t D5 = (5u);
|
||||
static const uint8_t D6 = (6u);
|
||||
static const uint8_t D7 = (7u);
|
||||
static const uint8_t D8 = (8u);
|
||||
static const uint8_t D9 = (9u);
|
||||
static const uint8_t D10 = (10u);
|
||||
static const uint8_t D11 = (11u);
|
||||
static const uint8_t D12 = (12u);
|
||||
static const uint8_t D13 = (13u);
|
||||
static const uint8_t D14 = (14u);
|
||||
static const uint8_t D15 = (15u);
|
||||
static const uint8_t D16 = (16u);
|
||||
static const uint8_t D17 = (17u);
|
||||
static const uint8_t D18 = (18u);
|
||||
static const uint8_t D19 = (19u);
|
||||
static const uint8_t D20 = (20u);
|
||||
static const uint8_t D21 = (21u);
|
||||
static const uint8_t D22 = (22u);
|
||||
static const uint8_t D23 = (23u);
|
||||
static const uint8_t D24 = (24u);
|
||||
static const uint8_t D25 = (25u);
|
||||
static const uint8_t D26 = (26u);
|
||||
static const uint8_t D27 = (27u);
|
||||
static const uint8_t D28 = (28u);
|
||||
static const uint8_t D29 = (29u);
|
||||
|
||||
static const uint8_t A0 = (26u);
|
||||
static const uint8_t A1 = (27u);
|
||||
static const uint8_t A2 = (28u);
|
||||
static const uint8_t A3 = (29u);
|
||||
Reference in New Issue
Block a user