Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cc9835303 | ||
|
|
48877984b7 | ||
|
|
a58f49018a | ||
|
|
7120a1508c | ||
|
|
a808f4ae6a | ||
|
|
4d1f5baa7e | ||
|
|
f106035100 | ||
|
|
21f49d032b | ||
|
|
341307cb8d | ||
|
|
85990ff51d | ||
|
|
238a6c83db | ||
|
|
77f03a44b6 | ||
|
|
29756de336 | ||
|
|
1afbbaba63 | ||
|
|
52b3120448 | ||
|
|
b7d76bd51d | ||
|
|
c0411eefeb | ||
|
|
3d821f73a4 | ||
|
|
1726f56a27 | ||
|
|
a305b30d90 | ||
|
|
9bed59858b | ||
|
|
cf63040c5a | ||
|
|
e8ec79290b | ||
|
|
0c22150fdb | ||
|
|
423476dc87 | ||
|
|
bfa3819b0d | ||
|
|
adf1c88c27 | ||
|
|
ad905ae992 | ||
|
|
608a5da480 | ||
|
|
3df3f0741a | ||
|
|
3585c58688 | ||
|
|
a8121f31d4 | ||
|
|
38c005c208 | ||
|
|
cd91d3ef0f | ||
|
|
02e8577f45 | ||
|
|
8451bc21ec | ||
|
|
28fe90e504 | ||
|
|
2c29314578 | ||
|
|
e196db9645 | ||
|
|
733aca5ac3 | ||
|
|
177a2d03a1 | ||
|
|
fec3ea882d | ||
|
|
580970cd72 | ||
|
|
c13bb1ec2b | ||
|
|
c777dd1657 | ||
|
|
cb9931f3e8 | ||
|
|
6b6254e84a | ||
|
|
61c6305aa8 | ||
|
|
b43056cd73 | ||
|
|
e4c144829c | ||
|
|
05356da2c5 |
@@ -37,6 +37,8 @@ jobs:
|
||||
- name: Check boards.txt was not edited after makeboards.py
|
||||
run: |
|
||||
./tools/makeboards.py > boards.txt
|
||||
# If anything changed, GIT should return an error and fail the test
|
||||
git diff --exit-code
|
||||
- name: Run astyle on all code/examples
|
||||
run: |
|
||||
sudo apt update
|
||||
|
||||
@@ -18,7 +18,16 @@ See https://arduino-pico.readthedocs.io/en/latest/ along with the examples for m
|
||||
* Adafruit STEMMA Friend RP2040
|
||||
* 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
|
||||
* WIZnet W5100S-EVB-Pico
|
||||
* Generic (configurable flash, I/O pins)
|
||||
|
||||
# Installing via Arduino Boards Manager
|
||||
|
||||
+4614
-33
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
|
||||
|
||||
+50
-32
@@ -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)
|
||||
@@ -122,32 +121,48 @@ int __USBGetMouseReportID() {
|
||||
}
|
||||
|
||||
static uint8_t *GetDescHIDReport(int *len) {
|
||||
static uint8_t *report = nullptr;
|
||||
int report_len = 0;
|
||||
|
||||
if (report) {
|
||||
free(report);
|
||||
report = nullptr;
|
||||
}
|
||||
|
||||
if (__USBInstallKeyboard && __USBInstallMouse) {
|
||||
static uint8_t desc_hid_report[] = {
|
||||
uint8_t desc_hid_report[] = {
|
||||
TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(1)),
|
||||
TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(2))
|
||||
};
|
||||
if (len) {
|
||||
*len = sizeof(desc_hid_report);
|
||||
report_len = sizeof(desc_hid_report);
|
||||
report = (uint8_t *)malloc(report_len);
|
||||
if (report) {
|
||||
memcpy(report, desc_hid_report, report_len);
|
||||
}
|
||||
return desc_hid_report;
|
||||
} else if (__USBInstallKeyboard && ! __USBInstallMouse) {
|
||||
static uint8_t desc_hid_report[] = {
|
||||
uint8_t desc_hid_report[] = {
|
||||
TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(1))
|
||||
};
|
||||
if (len) {
|
||||
*len = sizeof(desc_hid_report);
|
||||
report_len = sizeof(desc_hid_report);
|
||||
report = (uint8_t *)malloc(report_len);
|
||||
if (report) {
|
||||
memcpy(report, desc_hid_report, report_len);
|
||||
}
|
||||
return desc_hid_report;
|
||||
} else { // if (!__USBInstallKeyboard && __USBInstallMouse) {
|
||||
static uint8_t desc_hid_report[] = {
|
||||
uint8_t desc_hid_report[] = {
|
||||
TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(1))
|
||||
};
|
||||
if (len) {
|
||||
*len = sizeof(desc_hid_report);
|
||||
report_len = sizeof(desc_hid_report);
|
||||
report = (uint8_t *)malloc(report_len);
|
||||
if (report) {
|
||||
memcpy(report, desc_hid_report, report_len);
|
||||
}
|
||||
return desc_hid_report;
|
||||
}
|
||||
|
||||
if (len) {
|
||||
*len = report_len;
|
||||
}
|
||||
return report;
|
||||
}
|
||||
|
||||
// Invoked when received GET HID REPORT DESCRIPTOR
|
||||
@@ -161,14 +176,14 @@ uint8_t const * tud_hid_descriptor_report_cb(uint8_t instance) {
|
||||
|
||||
const uint8_t *tud_descriptor_configuration_cb(uint8_t index) {
|
||||
(void)index;
|
||||
static uint8_t *usbd_desc_cfg = NULL;
|
||||
static uint8_t *usbd_desc_cfg = nullptr;
|
||||
|
||||
if (!usbd_desc_cfg) {
|
||||
bool hasHID = __USBInstallKeyboard || __USBInstallMouse;
|
||||
|
||||
uint8_t interface_count = (__USBInstallSerial ? 2 : 0) + (hasHID ? 1 : 0) + (__USBInstallMIDI ? 2 : 0);
|
||||
|
||||
static uint8_t cdc_desc[TUD_CDC_DESC_LEN] = {
|
||||
uint8_t cdc_desc[TUD_CDC_DESC_LEN] = {
|
||||
// Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval
|
||||
TUD_CDC_DESCRIPTOR(USBD_ITF_CDC, USBD_STR_CDC, USBD_CDC_EP_CMD, USBD_CDC_CMD_MAX_SIZE, USBD_CDC_EP_OUT, USBD_CDC_EP_IN, USBD_CDC_IN_OUT_MAX_SIZE)
|
||||
};
|
||||
@@ -176,40 +191,42 @@ const uint8_t *tud_descriptor_configuration_cb(uint8_t index) {
|
||||
int hid_report_len;
|
||||
GetDescHIDReport(&hid_report_len);
|
||||
uint8_t hid_itf = __USBInstallSerial ? 2 : 0;
|
||||
static uint8_t hid_desc[TUD_HID_DESC_LEN] = {
|
||||
uint8_t hid_desc[TUD_HID_DESC_LEN] = {
|
||||
// Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval
|
||||
TUD_HID_DESCRIPTOR(hid_itf, 0, HID_ITF_PROTOCOL_NONE, hid_report_len, EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 10)
|
||||
};
|
||||
|
||||
uint8_t midi_itf = hid_itf + (hasHID ? 1 : 0);
|
||||
static uint8_t midi_desc[TUD_MIDI_DESC_LEN] = {
|
||||
uint8_t midi_desc[TUD_MIDI_DESC_LEN] = {
|
||||
// Interface number, string index, EP Out & EP In address, EP size
|
||||
TUD_MIDI_DESCRIPTOR(midi_itf, 0, EPNUM_MIDI, 0x80 | EPNUM_MIDI, 64)
|
||||
};
|
||||
|
||||
int usbd_desc_len = TUD_CONFIG_DESC_LEN + (__USBInstallSerial ? sizeof(cdc_desc) : 0) + (hasHID ? sizeof(hid_desc) : 0) + (__USBInstallMIDI ? sizeof(midi_desc) : 0);
|
||||
|
||||
static uint8_t tud_cfg_desc[TUD_CONFIG_DESC_LEN] = {
|
||||
uint8_t tud_cfg_desc[TUD_CONFIG_DESC_LEN] = {
|
||||
// Config number, interface count, string index, total length, attribute, power in mA
|
||||
TUD_CONFIG_DESCRIPTOR(1, interface_count, USBD_STR_0, usbd_desc_len, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, USBD_MAX_POWER_MA)
|
||||
};
|
||||
|
||||
// Combine to one descriptor
|
||||
usbd_desc_cfg = (uint8_t *)malloc(usbd_desc_len);
|
||||
bzero(usbd_desc_cfg, usbd_desc_len);
|
||||
uint8_t *ptr = usbd_desc_cfg;
|
||||
memcpy(ptr, tud_cfg_desc, sizeof(tud_cfg_desc));
|
||||
ptr += sizeof(tud_cfg_desc);
|
||||
if (__USBInstallSerial) {
|
||||
memcpy(ptr, cdc_desc, sizeof(cdc_desc));
|
||||
ptr += sizeof(cdc_desc);
|
||||
}
|
||||
if (hasHID) {
|
||||
memcpy(ptr, hid_desc, sizeof(hid_desc));
|
||||
ptr += sizeof(hid_desc);
|
||||
}
|
||||
if (__USBInstallMIDI) {
|
||||
memcpy(ptr, midi_desc, sizeof(midi_desc));
|
||||
if (usbd_desc_cfg) {
|
||||
bzero(usbd_desc_cfg, usbd_desc_len);
|
||||
uint8_t *ptr = usbd_desc_cfg;
|
||||
memcpy(ptr, tud_cfg_desc, sizeof(tud_cfg_desc));
|
||||
ptr += sizeof(tud_cfg_desc);
|
||||
if (__USBInstallSerial) {
|
||||
memcpy(ptr, cdc_desc, sizeof(cdc_desc));
|
||||
ptr += sizeof(cdc_desc);
|
||||
}
|
||||
if (hasHID) {
|
||||
memcpy(ptr, hid_desc, sizeof(hid_desc));
|
||||
ptr += sizeof(hid_desc);
|
||||
}
|
||||
if (__USBInstallMIDI) {
|
||||
memcpy(ptr, midi_desc, sizeof(midi_desc));
|
||||
}
|
||||
}
|
||||
}
|
||||
return usbd_desc_cfg;
|
||||
@@ -277,6 +294,7 @@ void __USBStart() {
|
||||
}
|
||||
|
||||
mutex_init(&__usb_mutex);
|
||||
|
||||
tusb_init();
|
||||
|
||||
irq_set_exclusive_handler(USB_TASK_IRQ, usb_irq);
|
||||
|
||||
+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
|
||||
|
||||
@@ -76,7 +76,7 @@ extern "C" int main() {
|
||||
#endif
|
||||
|
||||
#if defined DEBUG_RP2040_PORT
|
||||
DEBUG_RP2040_PORT.begin();
|
||||
DEBUG_RP2040_PORT.begin(115200);
|
||||
#endif
|
||||
|
||||
#ifndef NO_USB
|
||||
|
||||
@@ -30,6 +30,8 @@ static uint32_t analogScale = 255;
|
||||
static uint16_t analogFreq = 1000;
|
||||
static bool pwmInitted = false;
|
||||
static bool adcInitted = false;
|
||||
static uint16_t analogWritePseudoScale = 1;
|
||||
static uint16_t analogWriteSlowScale = 1;
|
||||
|
||||
auto_init_mutex(_dacMutex);
|
||||
|
||||
@@ -77,6 +79,21 @@ extern "C" void analogWrite(pin_size_t pin, int val) {
|
||||
return;
|
||||
}
|
||||
if (!pwmInitted) {
|
||||
// For low frequencies, we need to scale the output max value up to achieve lower periods
|
||||
analogWritePseudoScale = 1;
|
||||
while (((clock_get_hz(clk_sys) / (float)(analogScale * analogFreq)) > 255.0) && (analogScale < 32678)) {
|
||||
analogWritePseudoScale++;
|
||||
analogScale *= 2;
|
||||
DEBUGCORE("Adjusting analogWrite values PS=%d, scale=%d\n", analogWritePseudoScale, analogScale);
|
||||
}
|
||||
// For high frequencies, we need to scale the output max value down to actually hit the frequency target
|
||||
analogWriteSlowScale = 1;
|
||||
while (((clock_get_hz(clk_sys) / (float)(analogScale * analogFreq)) < 2.0) && (analogScale > 32)) {
|
||||
analogWriteSlowScale++;
|
||||
analogScale /= 2;
|
||||
DEBUGCORE("Adjusting analogWrite values SS=%d, scale=%d\n", analogWriteSlowScale, analogScale);
|
||||
}
|
||||
|
||||
pwm_config c = pwm_get_default_config();
|
||||
pwm_config_set_clkdiv(&c, clock_get_hz(clk_sys) / (float)(analogScale * analogFreq));
|
||||
pwm_config_set_wrap(&c, analogScale);
|
||||
@@ -86,6 +103,9 @@ extern "C" void analogWrite(pin_size_t pin, int val) {
|
||||
pwmInitted = true;
|
||||
}
|
||||
|
||||
val <<= analogWritePseudoScale;
|
||||
val >>= analogWriteSlowScale;
|
||||
|
||||
if (val < 0) {
|
||||
val = 0;
|
||||
} else if ((uint32_t)val > analogScale) {
|
||||
@@ -101,7 +121,10 @@ auto_init_mutex(_adcMutex);
|
||||
extern "C" int analogRead(pin_size_t pin) {
|
||||
CoreMutex m(&_adcMutex);
|
||||
|
||||
if ((pin < A0) || (pin > A3) || !m) {
|
||||
pin_size_t maxPin = max(A0, A3);
|
||||
pin_size_t minPin = min(A0, A3);
|
||||
|
||||
if ((pin < minPin) || (pin > maxPin) || !m) {
|
||||
DEBUGCORE("ERROR: Illegal analogRead pin (%d)\n", pin);
|
||||
return 0;
|
||||
}
|
||||
@@ -109,7 +132,7 @@ extern "C" int analogRead(pin_size_t pin) {
|
||||
adc_init();
|
||||
}
|
||||
adc_gpio_init(pin);
|
||||
adc_select_input(pin - A0);
|
||||
adc_select_input(pin - minPin);
|
||||
return adc_read();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ extern "C" void pinMode(pin_size_t ulPin, PinMode ulMode) {
|
||||
case INPUT:
|
||||
gpio_init(ulPin);
|
||||
gpio_set_dir(ulPin, false);
|
||||
gpio_disable_pulls(ulPin);
|
||||
break;
|
||||
case INPUT_PULLUP:
|
||||
gpio_init(ulPin);
|
||||
|
||||
@@ -38,7 +38,7 @@ extern "C" unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeo
|
||||
}
|
||||
|
||||
// Wait for assert
|
||||
while ((!!gpio_get(pin) != !state) && (time_us_64() < abort));
|
||||
while ((!!gpio_get(pin) != !!state) && (time_us_64() < abort));
|
||||
uint64_t begin = time_us_64();
|
||||
if (begin >= abort) {
|
||||
return 0;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 93 KiB |
@@ -20,6 +20,8 @@ For the latest version, always check https://github.com/earlephilhower/arduino-p
|
||||
Installation <install>
|
||||
IDE Menus <ide>
|
||||
|
||||
Platform.IO Integration <platformio>
|
||||
|
||||
Pin (Re)Assignment <pins>
|
||||
|
||||
Analog I/O <analog>
|
||||
|
||||
@@ -33,6 +33,7 @@ SPI (SPI0), SPI1 (SPI1)
|
||||
.. code:: cpp
|
||||
|
||||
::setSCK(pin)
|
||||
::setCS(pin)
|
||||
::setRX(pin)
|
||||
::setTX(pin)
|
||||
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
Using this core with PlatformIO
|
||||
===============================
|
||||
|
||||
What is PlatformIO?
|
||||
-------------------
|
||||
|
||||
`PlatformIO <https://platformio.org/>`__ is a free, open-source build-tool written in Python, which also integrates into VSCode code as an extension.
|
||||
|
||||
PlatformIO significantly simplifies writing embedded software by offering a unified build system, yet being able to create project files for many different IDEs, including VSCode, Eclipse, CLion, etc.
|
||||
Through this, PlatformIO can offer extensive features such as IntelliSense (autocomplete), debugging, unit testing etc., which not available in the standard Arduino IDE.
|
||||
|
||||
The Arduino IDE experience:
|
||||
|
||||
.. image:: images/the_arduinoide_experience.png
|
||||
|
||||
The PlatformIO experience:
|
||||
|
||||
.. image:: images/the_platformio_experience.png
|
||||
|
||||
Refer to the general documentation at https://docs.platformio.org/.
|
||||
|
||||
Especially useful is the `Getting started with VSCode + PlatformIO <https://docs.platformio.org/en/latest/integration/ide/vscode.html#installation), [CLI reference](https://docs.platformio.org/en/latest/core/index.html) and [platformio.ini options](https://docs.platformio.org/en/latest/projectconf/index.html)>`__ page.
|
||||
|
||||
Hereafter it is assumed that you have a basic understanding of PlatformIO in regards to project creation, project file structure and building and uploading PlatformIO projects, through reading the above pages.
|
||||
|
||||
Current state of development
|
||||
----------------------------
|
||||
|
||||
At the time of writing, PlatformIO integration for this core is a work-in-progress and not yet merged into mainline PlatformIO. This is subject to change soon.
|
||||
|
||||
If you want to use the PlatformIO integration right now, make sure you first create a standard Raspberry Pi Pico + Arduino project within PlatformIO.
|
||||
This will give you a project with the ``platformio.ini``
|
||||
|
||||
.. code:: ini
|
||||
|
||||
[env:pico]
|
||||
platform = raspberrypi
|
||||
board = pico
|
||||
framework = arduino
|
||||
|
||||
Here, you need to change the `platform` to take advantage of the features described hereunder.
|
||||
You *also* need to inject two PlatformIO packages, one for the compiler toolchain and one for the Arduino core package.
|
||||
|
||||
.. code:: ini
|
||||
|
||||
[env:pico]
|
||||
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
|
||||
board = pico
|
||||
framework = arduino
|
||||
; note that download link for toolchain is specific for OS. see https://github.com/earlephilhower/pico-quick-toolchain/releases.
|
||||
platform_packages =
|
||||
maxgerhardt/framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git
|
||||
maxgerhardt/toolchain-pico@https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.3.1-a/x86_64-w64-mingw32.arm-none-eabi-7855b0c.210706.zip
|
||||
|
||||
When the support for this core has been merged into mainline PlatformIO, this notice will be removed and a standard `platformio.ini` as shown above will work as a base.
|
||||
|
||||
Selecting the new core
|
||||
----------------------
|
||||
|
||||
Prerequisite for using this core is to tell PlatformIO to switch to it.
|
||||
There will be board definition files where the Earle-Philhower core will
|
||||
be the default since it's a board that only exists in this core (and not
|
||||
the other https://github.com/arduino/ArduinoCore-mbed). To switch boards
|
||||
for which this is not the default core (e.g. the standard
|
||||
``board = pico``), the directive
|
||||
|
||||
.. code:: ini
|
||||
|
||||
board_build.core = earlephilhower
|
||||
|
||||
must be added to the ``platformio.ini``. This controls the `core
|
||||
switching
|
||||
logic <https://github.com/maxgerhardt/platform-raspberrypi/blob/77e0d3a29d1dbf00fd3ec3271104e3bf4820869c/builder/frameworks/arduino/arduino.py#L27-L32>`__.
|
||||
|
||||
Flash size
|
||||
----------
|
||||
|
||||
Controlled via specifying the size allocated for the filesystem.
|
||||
Available sketch size is calculated accordingly by using (as in
|
||||
``makeboards.py``) that number and the (constant) EEPROM size (4096
|
||||
bytes) and the total flash size as known to PlatformIO via the board
|
||||
definition file. The expression on the right can involve "b","k","m"
|
||||
(bytes/kilobytes/megabytes) and floating point numbers. This makes it
|
||||
actually more flexible than in the Arduino IDE where there is a finite
|
||||
list of choices. Calculations happen in `the
|
||||
platform <https://github.com/maxgerhardt/platform-raspberrypi/blob/77e0d3a29d1dbf00fd3ec3271104e3bf4820869c/builder/main.py#L118-L184>`__.
|
||||
|
||||
.. code:: ini
|
||||
|
||||
; in reference to a board = pico config (2MB flash)
|
||||
; Flash Size: 2MB (Sketch: 1MB, FS:1MB)
|
||||
board_build.filesystem_size = 1m
|
||||
; Flash Size: 2MB (No FS)
|
||||
board_build.filesystem_size = 0m
|
||||
; Flash Size: 2MB (Sketch: 0.5MB, FS:1.5MB)
|
||||
board_build.filesystem_size = 1.5m
|
||||
|
||||
CPU Speed
|
||||
---------
|
||||
|
||||
As for all other PlatformIO platforms, the ``f_cpu`` macro value (which
|
||||
is passed to the core) can be changed as
|
||||
`documented <https://docs.platformio.org/en/latest/boards/raspberrypi/pico.html#configuration>`__
|
||||
|
||||
.. code:: ini
|
||||
|
||||
; 133MHz
|
||||
board_build.f_cpu = 133000000L
|
||||
|
||||
Debug Port
|
||||
----------
|
||||
|
||||
Via
|
||||
`build_flags <https://docs.platformio.org/en/latest/projectconf/section_env_build.html#build-flags>`__
|
||||
as done for many other cores
|
||||
(`example <https://docs.platformio.org/en/latest/platforms/ststm32.html#configuration>`__).
|
||||
|
||||
.. code:: ini
|
||||
|
||||
; Debug Port: Serial
|
||||
build_flags = -DDEBUG_RP2040_PORT=Serial
|
||||
; Debug Port: Serial 1
|
||||
build_flags = -DDEBUG_RP2040_PORT=Serial1
|
||||
; Debug Port: Serial 2
|
||||
build_flags = -DDEBUG_RP2040_PORT=Serial2
|
||||
|
||||
Debug Level
|
||||
-----------
|
||||
|
||||
Done again by directly adding the needed `build
|
||||
flags <https://github.com/earlephilhower/arduino-pico/blob/05356da2c5552413a442f742e209c6fa92823666/boards.txt#L104-L114>`__.
|
||||
When wanting to define multiple build flags, they must be accumulated in
|
||||
either a sing line or a newline-separated expression.
|
||||
|
||||
.. code:: ini
|
||||
|
||||
; Debug level: Core
|
||||
build_flags = -DDEBUG_RP2040_CORE
|
||||
; Debug level: SPI
|
||||
build_flags = -DDEBUG_RP2040_SPI
|
||||
; Debug level: Wire
|
||||
build_flags = -DDEBUG_RP2040_WIRE
|
||||
; Debug level: All
|
||||
build_flags = -DDEBUG_RP2040_WIRE -DDEBUG_RP2040_SPI -DDEBUG_RP2040_CORE
|
||||
; Debug level: NDEBUG
|
||||
build_flags = -DNDEBUG
|
||||
|
||||
; example: Debug port on serial 2 and all debug output
|
||||
build_flags = -DDEBUG_RP2040_WIRE -DDEBUG_RP2040_SPI -DDEBUG_RP2040_CORE -DDEBUG_RP2040_PORT=Serial2
|
||||
; equivalent to above
|
||||
build_flags =
|
||||
-DDEBUG_RP2040_WIRE
|
||||
-DDEBUG_RP2040_SPI
|
||||
-DDEBUG_RP2040_CORE
|
||||
-DDEBUG_RP2040_PORT=Serial2
|
||||
|
||||
USB Stack
|
||||
---------
|
||||
|
||||
Not specifying any special build flags regarding this gives one the
|
||||
default Pico SDK USB stack. To change it, add
|
||||
|
||||
.. code:: ini
|
||||
|
||||
; Adafruit TinyUSB
|
||||
build_flags = -DUSE_TINYUSB
|
||||
; No USB stack
|
||||
build_flags = -DPIO_FRAMEWORK_ARDUINO_NO_USB
|
||||
|
||||
Note that the special "No USB" setting is also supported, through the
|
||||
shortcut-define ``PIO_FRAMEWORK_ARDUINO_NO_USB``.
|
||||
|
||||
|
||||
Selecting a different core version
|
||||
----------------------------------
|
||||
|
||||
If you wish to use a different version of the core, e.g., the latest git
|
||||
``master`` version, you can use a
|
||||
`platform_packages <https://docs.platformio.org/en/latest/projectconf/section_env_platform.html#platform-packages>`__
|
||||
directive to do so. Simply specify that the framework package
|
||||
(``framework-arduinopico``) comes from a different source.
|
||||
|
||||
.. code:: ini
|
||||
|
||||
platform_packages =
|
||||
framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master
|
||||
|
||||
Whereas the ``#master`` can also be replaced by a ``#branchname`` or a
|
||||
``#commithash``. If left out, it will pull the default branch, which is ``master``.
|
||||
|
||||
The ``file://`` pseudo-protocol can also be used instead of ``https://`` to point to a
|
||||
local copy of the core (with e.g. some modifications) on disk.
|
||||
|
||||
Note that this can only be done for versions that have the PlatformIO
|
||||
builder script it in, so versions before 1.9.2 are not supported.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
The following example ``platformio.ini`` can be used for a Raspberry Pi Pico
|
||||
and 0.5MByte filesystem.
|
||||
|
||||
.. code:: ini
|
||||
|
||||
[env:pico]
|
||||
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
|
||||
board = pico
|
||||
framework = arduino
|
||||
board_build.core = earlephilhower
|
||||
board_build.filesystem_size = 0.5m
|
||||
; note that download link for toolchain is specific for OS. see https://github.com/earlephilhower/pico-quick-toolchain/releases.
|
||||
platform_packages =
|
||||
maxgerhardt/framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git
|
||||
maxgerhardt/toolchain-pico@https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.3.1-a/x86_64-w64-mingw32.arm-none-eabi-7855b0c.210706.zip
|
||||
|
||||
|
||||
The initial project structure should be generated just creating a new
|
||||
project for the Pico and the Arduino framework, after which the
|
||||
auto-generated ``platformio.ini`` can be adapted per above.
|
||||
Binary file not shown.
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
|
||||
@@ -26,6 +29,7 @@
|
||||
-iwithprefixbefore/pico-sdk/src/rp2_common/hardware_gpio/include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2_common/hardware_i2c/include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2_common/hardware_irq/include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2_common/hardware_rtc/include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2_common/hardware_pio/include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2_common/hardware_pll/include
|
||||
-iwithprefixbefore/pico-sdk/src/rp2_common/hardware_pwm/include
|
||||
|
||||
@@ -176,6 +176,9 @@ public:
|
||||
}
|
||||
|
||||
bool begin() override {
|
||||
if (_mounted) {
|
||||
return true;
|
||||
}
|
||||
if (_size <= 0) {
|
||||
DEBUGV("LittleFS size is <= zero");
|
||||
return false;
|
||||
|
||||
@@ -135,8 +135,8 @@ public:
|
||||
size_t size() {
|
||||
uint64_t sz = size64();
|
||||
#ifdef DEBUG_ESP_PORT
|
||||
if (sz > (uint64_t)SIZE_MAX) {
|
||||
DEBUG_ESP_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld>= 4GB). Please update source to use size64().\n"), sz);
|
||||
if (sz > std::numeric_limits<uint32_t>::max()) {
|
||||
DEBUG_ESP_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld >= 4GB). Please update source to use size64().\n"), (long long)sz);
|
||||
}
|
||||
#endif
|
||||
return (size_t)sz;
|
||||
@@ -191,9 +191,6 @@ private:
|
||||
|
||||
|
||||
// Expose FatStructs.h helpers for MS-DOS date/time for use with dateTimeCallback
|
||||
static inline uint16_t FAT_DATE(uint16_t year, uint8_t month, uint8_t day) {
|
||||
return (year - 1980) << 9 | month << 5 | day;
|
||||
}
|
||||
static inline uint16_t FAT_YEAR(uint16_t fatDate) {
|
||||
return 1980 + (fatDate >> 9);
|
||||
}
|
||||
@@ -203,9 +200,6 @@ static inline uint8_t FAT_MONTH(uint16_t fatDate) {
|
||||
static inline uint8_t FAT_DAY(uint16_t fatDate) {
|
||||
return fatDate & 0X1F;
|
||||
}
|
||||
static inline uint16_t FAT_TIME(uint8_t hour, uint8_t minute, uint8_t second) {
|
||||
return hour << 11 | minute << 5 | second >> 1;
|
||||
}
|
||||
static inline uint8_t FAT_HOUR(uint16_t fatTime) {
|
||||
return fatTime >> 11;
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ FileImplPtr SDFSImpl::open(const char* path, OpenMode openMode, AccessMode acces
|
||||
}
|
||||
free(pathStr);
|
||||
}
|
||||
sdfat::File32 fd = _fs.open(path, flags);
|
||||
File32 fd = _fs.open(path, flags);
|
||||
if (!fd) {
|
||||
DEBUGV("SDFSImpl::openFile: fd=%p path=`%s` openMode=%d accessMode=%d",
|
||||
&fd, path, openMode, accessMode);
|
||||
return FileImplPtr();
|
||||
}
|
||||
auto sharedFd = std::make_shared<sdfat::File32>(fd);
|
||||
auto sharedFd = std::make_shared<File32>(fd);
|
||||
return std::make_shared<SDFSFileImpl>(this, sharedFd, path);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ DirImplPtr SDFSImpl::openDir(const char* path)
|
||||
}
|
||||
// At this point we have a name of "/blah/blah/blah" or "blah" or ""
|
||||
// If that references a directory, just open it and we're done.
|
||||
sdfat::File32 dirFile;
|
||||
File32 dirFile;
|
||||
const char *filter = "";
|
||||
if (!pathStr[0]) {
|
||||
// openDir("") === openDir("/")
|
||||
@@ -135,7 +135,7 @@ DirImplPtr SDFSImpl::openDir(const char* path)
|
||||
DEBUGV("SDFSImpl::openDir: path=`%s`\n", path);
|
||||
return DirImplPtr();
|
||||
}
|
||||
auto sharedDir = std::make_shared<sdfat::File32>(dirFile);
|
||||
auto sharedDir = std::make_shared<File32>(dirFile);
|
||||
auto ret = std::make_shared<SDFSDirImpl>(filter, this, sharedDir, pathStr);
|
||||
free(pathStr);
|
||||
return ret;
|
||||
@@ -145,12 +145,12 @@ bool SDFSImpl::format() {
|
||||
if (_mounted) {
|
||||
return false;
|
||||
}
|
||||
sdfat::SdCardFactory cardFactory;
|
||||
sdfat::SdCard* card = cardFactory.newCard(sdfat::SdSpiConfig(_cfg._csPin, DEDICATED_SPI, _cfg._spiSettings));
|
||||
SdCardFactory cardFactory;
|
||||
SdCard* card = cardFactory.newCard(SdSpiConfig(_cfg._csPin, DEDICATED_SPI, _cfg._spiSettings));
|
||||
if (!card || card->errorCode()) {
|
||||
return false;
|
||||
}
|
||||
sdfat::FatFormatter fatFormatter;
|
||||
FatFormatter fatFormatter;
|
||||
uint8_t *sectorBuffer = new uint8_t[512];
|
||||
bool ret = fatFormatter.format(card, sectorBuffer, nullptr);
|
||||
delete[] sectorBuffer;
|
||||
|
||||
+34
-33
@@ -96,11 +96,11 @@ public:
|
||||
return false;
|
||||
}
|
||||
info.maxOpenFiles = 999; // TODO - not valid
|
||||
info.blockSize = _fs.vol()->sectorsPerCluster() * _fs.vol()->bytesPerSector();
|
||||
info.blockSize = _fs.vol()->bytesPerCluster();
|
||||
info.pageSize = 0; // TODO ?
|
||||
info.maxPathLength = 255; // TODO ?
|
||||
info.totalBytes =_fs.vol()->clusterCount() * info.blockSize;
|
||||
info.usedBytes = info.totalBytes - (_fs.vol()->freeClusterCount() * _fs.vol()->sectorsPerCluster() * _fs.vol()->bytesPerSector());
|
||||
info.usedBytes = info.totalBytes - (_fs.vol()->freeClusterCount() * _fs.vol()->bytesPerCluster());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -114,9 +114,9 @@ public:
|
||||
info.maxOpenFiles = i.maxOpenFiles;
|
||||
info.maxPathLength = i.maxPathLength;
|
||||
#ifdef DEBUG_ESP_PORT
|
||||
if (i.totalBytes > (uint64_t)SIZE_MAX) {
|
||||
if (i.totalBytes > std::numeric_limits<uint32_t>::max()) {
|
||||
// This catches both total and used cases, since used must always be < total.
|
||||
DEBUG_ESP_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld>= 4GB). Please update source to use info64().\n"), i.totalBytes);
|
||||
DEBUG_ESP_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld >= 4GB). Please update source to use info64().\n"), (long long)i.totalBytes);
|
||||
}
|
||||
#endif
|
||||
info.totalBytes = (size_t)i.totalBytes;
|
||||
@@ -148,14 +148,14 @@ public:
|
||||
|
||||
bool begin() override {
|
||||
if (_mounted) {
|
||||
end();
|
||||
return true;
|
||||
}
|
||||
_mounted = _fs.begin(_cfg._csPin, _cfg._spiSettings);
|
||||
if (!_mounted && _cfg._autoFormat) {
|
||||
format();
|
||||
_mounted = _fs.begin(_cfg._csPin, _cfg._spiSettings);
|
||||
}
|
||||
sdfat::FsDateTime::setCallback(dateTimeCB);
|
||||
FsDateTime::setCallback(dateTimeCB);
|
||||
return _mounted;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ public:
|
||||
return (totalClusters() / blocksPerCluster());
|
||||
}
|
||||
size_t clusterSize() {
|
||||
return blocksPerCluster() * _fs.vol()->bytesPerSector();
|
||||
return _fs.vol()->bytesPerCluster();
|
||||
}
|
||||
size_t size() {
|
||||
return (clusterSize() * totalClusters());
|
||||
@@ -228,7 +228,7 @@ protected:
|
||||
friend class SDFileImpl;
|
||||
friend class SDFSDirImpl;
|
||||
|
||||
sdfat::SdFat* getFs()
|
||||
SdFat* getFs()
|
||||
{
|
||||
return &_fs;
|
||||
}
|
||||
@@ -245,16 +245,17 @@ protected:
|
||||
if (openMode & OM_TRUNCATE) {
|
||||
mode |= O_TRUNC;
|
||||
}
|
||||
if (accessMode & AM_READ) {
|
||||
if ((accessMode & (AM_READ | AM_WRITE)) == (AM_READ | AM_WRITE)) {
|
||||
mode |= O_RDWR;
|
||||
} else if (accessMode & AM_READ) {
|
||||
mode |= O_READ;
|
||||
}
|
||||
if (accessMode & AM_WRITE) {
|
||||
} else if (accessMode & AM_WRITE) {
|
||||
mode |= O_WRITE;
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
sdfat::SdFat _fs;
|
||||
SdFat _fs;
|
||||
SDFSConfig _cfg;
|
||||
bool _mounted;
|
||||
};
|
||||
@@ -263,7 +264,7 @@ protected:
|
||||
class SDFSFileImpl : public FileImpl
|
||||
{
|
||||
public:
|
||||
SDFSFileImpl(SDFSImpl *fs, std::shared_ptr<sdfat::File32> fd, const char *name)
|
||||
SDFSFileImpl(SDFSImpl *fs, std::shared_ptr<File32> fd, const char *name)
|
||||
: _fs(fs), _fd(fd), _opened(true)
|
||||
{
|
||||
_name = std::shared_ptr<char>(new char[strlen(name) + 1], std::default_delete<char[]>());
|
||||
@@ -379,7 +380,7 @@ public:
|
||||
time_t getLastWrite() override {
|
||||
time_t ftime = 0;
|
||||
if (_opened && _fd) {
|
||||
sdfat::DirFat_t tmp;
|
||||
DirFat_t tmp;
|
||||
if (_fd.get()->dirEntry(&tmp)) {
|
||||
ftime = SDFSImpl::FatToTimeT(*(uint16_t*)tmp.modifyDate, *(uint16_t*)tmp.modifyTime);
|
||||
}
|
||||
@@ -390,7 +391,7 @@ public:
|
||||
time_t getCreationTime() override {
|
||||
time_t ftime = 0;
|
||||
if (_opened && _fd) {
|
||||
sdfat::DirFat_t tmp;
|
||||
DirFat_t tmp;
|
||||
if (_fd.get()->dirEntry(&tmp)) {
|
||||
ftime = SDFSImpl::FatToTimeT(*(uint16_t*)tmp.createDate, *(uint16_t*)tmp.createTime);
|
||||
}
|
||||
@@ -399,16 +400,16 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
SDFSImpl* _fs;
|
||||
std::shared_ptr<sdfat::File32> _fd;
|
||||
std::shared_ptr<char> _name;
|
||||
bool _opened;
|
||||
SDFSImpl* _fs;
|
||||
std::shared_ptr<File32> _fd;
|
||||
std::shared_ptr<char> _name;
|
||||
bool _opened;
|
||||
};
|
||||
|
||||
class SDFSDirImpl : public DirImpl
|
||||
{
|
||||
public:
|
||||
SDFSDirImpl(const String& pattern, SDFSImpl* fs, std::shared_ptr<sdfat::File32> dir, const char *dirPath = nullptr)
|
||||
SDFSDirImpl(const String& pattern, SDFSImpl* fs, std::shared_ptr<File32> dir, const char *dirPath = nullptr)
|
||||
: _pattern(pattern), _fs(fs), _dir(dir), _valid(false), _dirPath(nullptr)
|
||||
{
|
||||
if (dirPath) {
|
||||
@@ -483,14 +484,14 @@ public:
|
||||
{
|
||||
const int n = _pattern.length();
|
||||
do {
|
||||
sdfat::File32 file;
|
||||
File32 file;
|
||||
file.openNext(_dir.get(), O_READ);
|
||||
if (file) {
|
||||
_valid = 1;
|
||||
_size = file.fileSize();
|
||||
_isFile = file.isFile();
|
||||
_isDirectory = file.isDir();
|
||||
sdfat::DirFat_t tmp;
|
||||
DirFat_t tmp;
|
||||
if (file.dirEntry(&tmp)) {
|
||||
_time = SDFSImpl::FatToTimeT(*(uint16_t*)tmp.modifyDate, *(uint16_t*)tmp.modifyTime);
|
||||
_creation = SDFSImpl::FatToTimeT(*(uint16_t*)tmp.createDate, *(uint16_t*)tmp.createTime);
|
||||
@@ -515,17 +516,17 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
String _pattern;
|
||||
SDFSImpl* _fs;
|
||||
std::shared_ptr<sdfat::File32> _dir;
|
||||
bool _valid;
|
||||
char _lfn[64];
|
||||
time_t _time;
|
||||
time_t _creation;
|
||||
std::shared_ptr<char> _dirPath;
|
||||
uint32_t _size;
|
||||
bool _isFile;
|
||||
bool _isDirectory;
|
||||
String _pattern;
|
||||
SDFSImpl* _fs;
|
||||
std::shared_ptr<File32> _dir;
|
||||
bool _valid;
|
||||
char _lfn[64];
|
||||
time_t _time;
|
||||
time_t _creation;
|
||||
std::shared_ptr<char> _dirPath;
|
||||
uint32_t _size;
|
||||
bool _isFile;
|
||||
bool _isDirectory;
|
||||
};
|
||||
|
||||
}; // namespace sdfs
|
||||
|
||||
+1
-1
Submodule libraries/SdFat updated: 3f50e5547d...3a6b688b1b
@@ -181,6 +181,8 @@ void TwoWire::end() {
|
||||
return;
|
||||
}
|
||||
i2c_deinit(_i2c);
|
||||
pinMode(_sda, INPUT);
|
||||
pinMode(_scl, INPUT);
|
||||
_running = false;
|
||||
_txBegun = false;
|
||||
}
|
||||
@@ -192,6 +194,7 @@ void TwoWire::beginTransmission(uint8_t addr) {
|
||||
}
|
||||
_addr = addr;
|
||||
_buffLen = 0;
|
||||
_buffOff = 0;
|
||||
_txBegun = true;
|
||||
}
|
||||
|
||||
@@ -200,7 +203,10 @@ size_t TwoWire::requestFrom(uint8_t address, size_t quantity, bool stopBit) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
_buffLen = i2c_read_blocking_until(_i2c, address, _buff, quantity, !stopBit, make_timeout_time_ms(50));
|
||||
_buffLen = i2c_read_blocking_until(_i2c, address, _buff, quantity, !stopBit, make_timeout_time_ms(_timeout));
|
||||
if (_buffLen == PICO_ERROR_GENERIC) {
|
||||
_buffLen = 0;
|
||||
}
|
||||
_buffOff = 0;
|
||||
return _buffLen;
|
||||
}
|
||||
@@ -288,7 +294,7 @@ uint8_t TwoWire::endTransmission(bool stopBit) {
|
||||
return _probe(_addr, _sda, _scl, _clkHz) ? 0 : 2;
|
||||
} else {
|
||||
auto len = _buffLen;
|
||||
auto ret = i2c_write_blocking_until(_i2c, _addr, _buff, _buffLen, !stopBit, make_timeout_time_ms(50));
|
||||
auto ret = i2c_write_blocking_until(_i2c, _addr, _buff, _buffLen, !stopBit, make_timeout_time_ms(_timeout));
|
||||
_buffLen = 0;
|
||||
return (ret == len) ? 0 : 4;
|
||||
}
|
||||
+15
-4
@@ -1,6 +1,17 @@
|
||||
{
|
||||
"name": "framework-arduinopico",
|
||||
"description": "Arduino Wiring-based Framework (RPi Pico RP2040)",
|
||||
"url": "https://github.com/esrlephilhower/arduino-pico",
|
||||
"version": "0.9.2"
|
||||
"name": "framework-arduinopico",
|
||||
"version": "1.10909.0",
|
||||
"description": "Arduino Wiring-based Framework (RPi Pico RP2040)",
|
||||
"keywords": [
|
||||
"framework",
|
||||
"arduino",
|
||||
"Cortex-M",
|
||||
"Raspberry Pi",
|
||||
"RP2040"
|
||||
],
|
||||
"homepage": "https://arduino-pico.readthedocs.io/en/latest/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/earlephilhower/arduino-pico"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,21 @@
|
||||
{
|
||||
"name": "Arduino Nano RP2040 Connect"
|
||||
},
|
||||
{
|
||||
"name": "Cytron Maker Nano RP2040"
|
||||
},
|
||||
{
|
||||
"name": "Cytron Maker Pi RP2040"
|
||||
},
|
||||
{
|
||||
"name": "SparkFun ProMicro RP2040"
|
||||
},
|
||||
{
|
||||
"name": "Melopero Shake RP2040"
|
||||
},
|
||||
{
|
||||
"name": "uPesy RP2040 DevKit"
|
||||
},
|
||||
{
|
||||
"name": "Generic RP2040 Module"
|
||||
}
|
||||
|
||||
+1
-1
Submodule pico-extras updated: ccd88d320f...77eae28366
+1
-1
Submodule pico-sdk updated: bfcbefafc5...2062372d20
+17
-12
@@ -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
|
||||
# -----------------
|
||||
|
||||
@@ -40,18 +42,19 @@ compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-ignored-qualif
|
||||
|
||||
compiler.defines={build.led} {build.usbstack_flags} -DCFG_TUSB_MCU=OPT_MCU_RP2040 -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
|
||||
compiler.includes="-iprefix{runtime.platform.path}/" "@{runtime.platform.path}/lib/platform_inc.txt"
|
||||
compiler.flags=-Os -march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections -fno-exceptions
|
||||
compiler.flags=-march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections -fno-exceptions
|
||||
compiler.wrap="@{runtime.platform.path}/lib/platform_wrap.txt"
|
||||
compiler.libpico="{runtime.platform.path}/lib/libpico.a"
|
||||
compiler.libstdcpp="-lstdc++"
|
||||
|
||||
compiler.c.cmd=arm-none-eabi-gcc
|
||||
compiler.c.flags=-c {compiler.warning_flags} {compiler.defines} {compiler.flags} {compiler.includes} -std=gnu17 -g
|
||||
compiler.c.elf.cmd=arm-none-eabi-g++
|
||||
compiler.c.elf.flags={compiler.warning_flags} {compiler.defines} {compiler.flags} -u _printf_float -u _scanf_float
|
||||
compiler.c.elf.flags={compiler.warning_flags} {compiler.defines} {compiler.flags} {build.flags.optimize} -u _printf_float -u _scanf_float
|
||||
compiler.S.cmd=arm-none-eabi-gcc
|
||||
compiler.S.flags=-c {compiler.warning_flags} -g -x assembler-with-cpp -MMD {compiler.includes} -g
|
||||
compiler.cpp.cmd=arm-none-eabi-g++
|
||||
compiler.cpp.flags=-c {compiler.warning_flags} {compiler.defines} {compiler.flags} {compiler.includes} -fno-rtti -std=gnu++17 -g
|
||||
compiler.cpp.flags=-c {compiler.warning_flags} {compiler.defines} {compiler.flags} {compiler.includes} {build.flags.rtti} -std=gnu++17 -g
|
||||
|
||||
compiler.ar.cmd=arm-none-eabi-ar
|
||||
compiler.ar.flags=rcs
|
||||
@@ -79,6 +82,8 @@ compiler.elf2hex.extra_flags=
|
||||
# Board configuration, set in boards.txt. Present here to ensure substitution works
|
||||
build.flash_length=
|
||||
build.eeprom_start=
|
||||
build.flags.optimize=-Os
|
||||
build.flags.rtti=-fno-rtti
|
||||
build.fs_start=
|
||||
build.fs_end=
|
||||
build.usbstack_flags=
|
||||
@@ -86,20 +91,20 @@ build.usbstack_flags=
|
||||
build.boot2=boot2_generic_03h_4_padded_checksum
|
||||
|
||||
# Allow Pico boards do be auto-discovered by the IDE
|
||||
discovery.rp2040.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/discovery.py"
|
||||
discovery.rp2040.pattern="{runtime.tools.pqt-python3.path}/python3" -I "{runtime.platform.path}/tools/discovery.py"
|
||||
|
||||
|
||||
# Compile patterns
|
||||
# ----------------
|
||||
|
||||
## 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} {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} {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
|
||||
@@ -107,13 +112,13 @@ archive_file_path={build.path}/{archive_file}
|
||||
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
|
||||
|
||||
## Generate the linker map with specific flash sizes/locations
|
||||
recipe.hooks.linking.prelink.1.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/simplesub.py" --input "{runtime.platform.path}/lib/memmap_default.ld" --out "{build.path}/memmap_default.ld" --sub __FLASH_LENGTH__ {build.flash_length} --sub __EEPROM_START__ {build.eeprom_start} --sub __FS_START__ {build.fs_start} --sub __FS_END__ {build.fs_end} --sub __RAM_LENGTH__ {build.ram_length}
|
||||
recipe.hooks.linking.prelink.1.pattern="{runtime.tools.pqt-python3.path}/python3" -I "{runtime.platform.path}/tools/simplesub.py" --input "{runtime.platform.path}/lib/memmap_default.ld" --out "{build.path}/memmap_default.ld" --sub __FLASH_LENGTH__ {build.flash_length} --sub __EEPROM_START__ {build.eeprom_start} --sub __FS_START__ {build.fs_start} --sub __FS_END__ {build.fs_end} --sub __RAM_LENGTH__ {build.ram_length}
|
||||
|
||||
## Compile the boot stage 2 blob
|
||||
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 -lstdc++ -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"
|
||||
@@ -138,7 +143,7 @@ tools.uf2conv.cmd={runtime.platform.path}/system/python3/python3
|
||||
tools.uf2conv.upload.protocol=uf2
|
||||
tools.uf2conv.upload.params.verbose=
|
||||
tools.uf2conv.upload.params.quiet=
|
||||
tools.uf2conv.upload.pattern="{cmd}" "{runtime.platform.path}/tools/uf2conv.py" --serial "{serial.port}" --family RP2040 --deploy "{build.path}/{build.project_name}.uf2"
|
||||
tools.uf2conv.upload.pattern="{cmd}" -I "{runtime.platform.path}/tools/uf2conv.py" --serial "{serial.port}" --family RP2040 --deploy "{build.path}/{build.project_name}.uf2"
|
||||
|
||||
|
||||
#tools.picoprobe.cmd={runtime.tools.pqt-openocd.path}
|
||||
@@ -146,10 +151,10 @@ tools.picoprobe.cmd={runtime.platform.path}/system/openocd
|
||||
tools.picoprobe.upload.protocol=picoprobe
|
||||
tools.picoprobe.upload.params.verbose=
|
||||
tools.picoprobe.upload.params.quiet=
|
||||
tools.picoprobe.upload.pattern="{cmd}/bin/openocd" -f "interface/picoprobe.cfg" -f "target/rp2040.cfg" -s "{cmd}/share/openocd/scripts" -c "program {build.path}/{build.project_name}.elf verify reset exit"
|
||||
tools.picoprobe.upload.pattern="{cmd}/bin/openocd" -f "interface/picoprobe.cfg" -f "target/rp2040.cfg" -s "{cmd}/share/openocd/scripts" -c "program {{build.path}/{build.project_name}.elf} verify reset exit"
|
||||
|
||||
tools.picodebug.cmd={runtime.platform.path}/system/openocd
|
||||
tools.picodebug.upload.protocol=pico-debug
|
||||
tools.picodebug.upload.params.verbose=
|
||||
tools.picodebug.upload.params.quiet=
|
||||
tools.picodebug.upload.pattern="{cmd}/bin/openocd" -f "board/pico-debug.cfg" -s "{cmd}/share/openocd/scripts" -c "program {build.path}/{build.project_name}.elf verify reset exit"
|
||||
tools.picodebug.upload.pattern="{cmd}/bin/openocd" -f "board/pico-debug.cfg" -s "{cmd}/share/openocd/scripts" -c "program {{build.path}/{build.project_name}.elf} verify reset exit"
|
||||
|
||||
+2
-5
@@ -9,16 +9,13 @@ function skip_ino()
|
||||
read -d '' skiplist << EOL || true
|
||||
/#attic/
|
||||
/AvrAdcLogger/
|
||||
/BackwardCompatibility/
|
||||
/examplesV1/
|
||||
/ExFatFormatter/
|
||||
/ExFatLogger/
|
||||
/ExFatUnicodeTest/
|
||||
/RtcTimestampTest/
|
||||
/SoftwareSpi/
|
||||
/STM32Test/
|
||||
/TeensyDmaAdcLogger/
|
||||
/TeensyRtcTimestamp/
|
||||
/TeensySdioDemo/
|
||||
/TeensySdioLogger/
|
||||
/UserChipSelectFunction/
|
||||
/UserSPIDriver/
|
||||
/Adafruit_TinyUSB_Arduino/
|
||||
|
||||
@@ -13,9 +13,11 @@ pico_sdk_init()
|
||||
|
||||
add_library(pico STATIC)
|
||||
|
||||
# Use a longer XOSC startup time, to accommodate Adafruit and other boards that may need it.
|
||||
target_compile_definitions(pico PUBLIC
|
||||
PICO_PRINTF_ALWAYS_INCLUDED=1
|
||||
PICO_FLASH_SIZE_BYTES=16777216
|
||||
PICO_XOSC_STARTUP_DELAY_MULTIPLIER=64
|
||||
)
|
||||
|
||||
target_compile_options(pico PUBLIC
|
||||
@@ -25,7 +27,7 @@ target_compile_options(pico PUBLIC
|
||||
|
||||
include_directories(BEFORE ${PICO_SDK_PATH}/../tools/libpico)
|
||||
|
||||
target_link_libraries(pico
|
||||
target_link_libraries(pico
|
||||
boot_stage2
|
||||
hardware_adc
|
||||
hardware_base
|
||||
@@ -51,6 +53,7 @@ target_link_libraries(pico
|
||||
hardware_vreg
|
||||
hardware_watchdog
|
||||
hardware_xosc
|
||||
cmsis
|
||||
pico_bit_ops
|
||||
pico_bootrom
|
||||
pico_bootsel_via_double_reset
|
||||
@@ -68,8 +71,9 @@ target_link_libraries(pico
|
||||
pico_standard_link
|
||||
pico_stdlib
|
||||
pico_unique_id
|
||||
pico_util
|
||||
tinyusb
|
||||
tinyusb_device_unmarked
|
||||
tinyusb_device_unmarked
|
||||
pico_audio
|
||||
pico_audio_i2s
|
||||
)
|
||||
|
||||
@@ -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})
|
||||
|
||||
+46
-16
@@ -36,6 +36,18 @@ def BuildFreq(name):
|
||||
print("%s.menu.freq.%s=%s MHz%s" % (name, f, f, warn))
|
||||
print("%s.menu.freq.%s.build.f_cpu=%dL" % (name, f, f * 1000000))
|
||||
|
||||
def BuildOptimize(name):
|
||||
for l in [ ("Small", "Small", "-Os", " (standard)"), ("Optimize", "Optimize", "-O", ""), ("Optimize2", "Optimize More", "-O2", ""),
|
||||
("Optimize3", "Optimize Even More", "-O3", ""), ("Fast", "Fast", "-Ofast", " (maybe slower)"), ("Debug", "Debug", "-Og", "") ]:
|
||||
print("%s.menu.opt.%s=%s (%s)%s" % (name, l[0], l[1], l[2], l[3]))
|
||||
print("%s.menu.opt.%s.build.flags.optimize=%s" % (name, l[0], l[2]))
|
||||
|
||||
def BuildRTTI(name):
|
||||
print("%s.menu.rtti.Disabled=Disabled" % (name))
|
||||
print("%s.menu.rtti.Disabled.build.flags.rtti=-fno-rtti" % (name))
|
||||
print("%s.menu.rtti.Enabled=Enabled" % (name))
|
||||
print("%s.menu.rtti.Enabled.build.flags.rtti=" % (name))
|
||||
|
||||
def BuildBoot(name):
|
||||
for l in [ ("Generic SPI /2", "boot2_generic_03h_2_padded_checksum"), ("Generic SPI /4", "boot2_generic_03h_4_padded_checksum"),
|
||||
("IS25LP080 QSPI /2", "boot2_is25lp080_2_padded_checksum"), ("IS25LP080 QSPI /4", "boot2_is25lp080_4_padded_checksum"),
|
||||
@@ -54,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("# -----------------------------------")
|
||||
@@ -64,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))
|
||||
@@ -77,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))
|
||||
@@ -86,17 +98,25 @@ 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")
|
||||
print("menu.freq=CPU Speed")
|
||||
print("menu.opt=Optimize")
|
||||
print("menu.rtti=RTTI")
|
||||
print("menu.dbgport=Debug Port")
|
||||
print("menu.dbglvl=Debug Level")
|
||||
print("menu.boot2=Boot Stage 2")
|
||||
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
|
||||
@@ -113,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])
|
||||
@@ -122,6 +142,8 @@ def MakeBoard(name, vendor_name, product_name, vid, pid, boarddefine, flashsizem
|
||||
else:
|
||||
BuildFlashMenu(n, flashsizemb * 1024 * 1024, fssizelist)
|
||||
BuildFreq(n)
|
||||
BuildOptimize(n)
|
||||
BuildRTTI(n)
|
||||
BuildDebugPort(n)
|
||||
BuildDebugLevel(n)
|
||||
if a == "picodebug":
|
||||
@@ -131,16 +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_generic_03h_4_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("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("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,228 @@
|
||||
# Copyright 2021-present Maximilian Gerhardt <maximilian.gerhardt@rub.de>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os, re, sys
|
||||
from SCons.Script import DefaultEnvironment, Builder, AlwaysBuild
|
||||
|
||||
env = DefaultEnvironment()
|
||||
platform = env.PioPlatform()
|
||||
board = env.BoardConfig()
|
||||
upload_protocol = env.subst("$UPLOAD_PROTOCOL") or "picotool"
|
||||
ram_size = board.get("upload.maximum_ram_size")
|
||||
|
||||
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinopico")
|
||||
assert os.path.isdir(FRAMEWORK_DIR)
|
||||
|
||||
# update progsize expression to also check for bootloader.
|
||||
env.Replace(
|
||||
SIZEPROGREGEXP=r"^(?:\.boot2|\.text|\.data|\.rodata|\.text.align|\.ARM.exidx)\s+(\d+).*"
|
||||
)
|
||||
|
||||
env.Append(
|
||||
ASFLAGS=env.get("CCFLAGS", [])[:],
|
||||
|
||||
CCFLAGS=[
|
||||
"-Werror=return-type",
|
||||
"-march=armv6-m",
|
||||
"-mcpu=cortex-m0plus",
|
||||
"-mthumb",
|
||||
"-ffunction-sections",
|
||||
"-fdata-sections",
|
||||
"-iprefix" + os.path.join(FRAMEWORK_DIR),
|
||||
"@%s" % os.path.join(FRAMEWORK_DIR, "lib", "platform_inc.txt")
|
||||
],
|
||||
|
||||
CFLAGS=[
|
||||
"-std=gnu17"
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-std=gnu++17",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
("ARDUINO", 10810),
|
||||
"ARDUINO_ARCH_RP2040",
|
||||
("F_CPU", "$BOARD_F_CPU"),
|
||||
("BOARD_NAME", '\\"%s\\"' % env.subst("$BOARD")),
|
||||
],
|
||||
|
||||
CPPPATH=[
|
||||
os.path.join(FRAMEWORK_DIR, "cores", "rp2040"),
|
||||
os.path.join(FRAMEWORK_DIR, "cores", "rp2040", "api", "deprecated"),
|
||||
os.path.join(FRAMEWORK_DIR, "cores", "rp2040",
|
||||
"api", "deprecated-avr-comp")
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-march=armv6-m",
|
||||
"-mcpu=cortex-m0plus",
|
||||
"-mthumb",
|
||||
"@%s" % os.path.join(FRAMEWORK_DIR, "lib", "platform_wrap.txt"),
|
||||
"-u_printf_float",
|
||||
"-u_scanf_float",
|
||||
# no cross-reference table, heavily spams the output
|
||||
# "-Wl,--cref",
|
||||
"-Wl,--check-sections",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,--unresolved-symbols=report-all",
|
||||
"-Wl,--warn-common"
|
||||
],
|
||||
|
||||
LIBSOURCE_DIRS=[os.path.join(FRAMEWORK_DIR, "libraries")],
|
||||
|
||||
LIBPATH=[
|
||||
os.path.join(FRAMEWORK_DIR, "lib")
|
||||
],
|
||||
|
||||
# link lib/libpico.a
|
||||
LIBS=["pico", "m", "c", "stdc++", "c"]
|
||||
)
|
||||
|
||||
|
||||
def configure_usb_flags(cpp_defines):
|
||||
global ram_size
|
||||
if "USE_TINYUSB" in cpp_defines:
|
||||
env.Append(CPPPATH=[os.path.join(
|
||||
FRAMEWORK_DIR, "libraries", "Adafruit_TinyUSB_Arduino", "src", "arduino")])
|
||||
elif "PIO_FRAMEWORK_ARDUINO_NO_USB" in cpp_defines:
|
||||
env.Append(
|
||||
CPPPATH=[os.path.join(FRAMEWORK_DIR, "tools", "libpico")],
|
||||
CPPDEFINES=[
|
||||
"NO_USB",
|
||||
"DISABLE_USB_SERIAL"
|
||||
]
|
||||
)
|
||||
# do not further add more USB flags or update sizes. no USB used.
|
||||
return
|
||||
else:
|
||||
# standard Pico SDK USB stack used.
|
||||
env.Append(CPPPATH=[os.path.join(FRAMEWORK_DIR, "tools", "libpico")])
|
||||
# in any case, add standard flags
|
||||
# preferably use USB information from arduino.earlephilhower section,
|
||||
# but fallback to sensible values derived from other parts otherwise.
|
||||
usb_pid = board.get("build.arduino.earlephilhower.usb_pid",
|
||||
board.get("build.hwids", [[0, 0]])[0][1])
|
||||
usb_vid = board.get("build.arduino.earlephilhower.usb_vid",
|
||||
board.get("build.hwids", [[0, 0]])[0][0])
|
||||
usb_manufacturer = board.get(
|
||||
"build.arduino.earlephilhower.usb_manufacturer", board.get("vendor", "Raspberry Pi"))
|
||||
usb_product = board.get(
|
||||
"build.arduino.earlephilhower.usb_product", board.get("name", "Pico"))
|
||||
|
||||
# Copy logic from makeboards.py.
|
||||
# Depending on whether a certain upload / debug method is used, change
|
||||
# the PID/VID.
|
||||
# https://github.com/earlephilhower/arduino-pico/blob/master/tools/makeboards.py
|
||||
vidtouse = usb_vid
|
||||
pidtouse = usb_pid
|
||||
if upload_protocol == "picoprobe":
|
||||
pidtouse = '0x0004'
|
||||
elif upload_protocol == "picodebug":
|
||||
vidtouse = '0x1209'
|
||||
pidtouse = '0x2488'
|
||||
ram_size = 240 * 1024
|
||||
|
||||
env.Append(CPPDEFINES=[
|
||||
("CFG_TUSB_MCU", "OPT_MCU_RP2040"),
|
||||
("USB_VID", usb_vid),
|
||||
("USB_PID", usb_pid),
|
||||
("USB_MANUFACTURER", '\\"%s\\"' % usb_manufacturer),
|
||||
("USB_PRODUCT", '\\"%s\\"' % usb_product),
|
||||
("SERIALUSB_PID", usb_pid)
|
||||
])
|
||||
|
||||
# use vidtouse and pidtouse
|
||||
# for USB PID/VID autodetection
|
||||
hw_ids = board.get("build.hwids", [["0x2E8A", "0x00C0"]])
|
||||
hw_ids[0][0] = vidtouse
|
||||
hw_ids[0][1] = pidtouse
|
||||
board.update("build.hwids", hw_ids)
|
||||
board.update("upload.maximum_ram_size", ram_size)
|
||||
|
||||
#
|
||||
# Process configuration flags
|
||||
#
|
||||
cpp_defines = env.Flatten(env.get("CPPDEFINES", []))
|
||||
|
||||
configure_usb_flags(cpp_defines)
|
||||
|
||||
# info about the filesystem is already parsed by the platform's main.py
|
||||
# script. We can just use the info here
|
||||
|
||||
linkerscript_cmd = env.Command(
|
||||
os.path.join("$BUILD_DIR", "memmap_default.ld"), # $TARGET
|
||||
os.path.join(FRAMEWORK_DIR, "lib", "memmap_default.ld"), # $SOURCE
|
||||
env.VerboseAction(" ".join([
|
||||
'"$PYTHONEXE" "%s"' % os.path.join(
|
||||
FRAMEWORK_DIR, "tools", "simplesub.py"),
|
||||
"--input", "$SOURCE",
|
||||
"--out", "$TARGET",
|
||||
"--sub", "__FLASH_LENGTH__", "$PICO_FLASH_LENGTH",
|
||||
"--sub", "__EEPROM_START__", "$PICO_EEPROM_START",
|
||||
"--sub", "__FS_START__", "$FS_START",
|
||||
"--sub", "__FS_END__", "$FS_END",
|
||||
"--sub", "__RAM_LENGTH__", "%dk" % (ram_size // 1024),
|
||||
]), "Generating linkerscript $BUILD_DIR/memmap_default.ld")
|
||||
)
|
||||
|
||||
# if no custom linker script is provided, we use the command that we prepared to generate one.
|
||||
if not board.get("build.ldscript", ""):
|
||||
# execute fetch filesystem info stored in env to alawys have that info ready
|
||||
env["fetch_fs_size"](env)
|
||||
env.Depends("$BUILD_DIR/${PROGNAME}.elf", linkerscript_cmd)
|
||||
env.Replace(LDSCRIPT_PATH=os.path.join("$BUILD_DIR", "memmap_default.ld"))
|
||||
|
||||
libs = []
|
||||
|
||||
variant = board.get("build.arduino.earlephilhower.variant", board.get("build.variant", None))
|
||||
|
||||
if variant is not None:
|
||||
env.Append(CPPPATH=[
|
||||
os.path.join(FRAMEWORK_DIR, "variants", variant)
|
||||
])
|
||||
|
||||
libs.append(
|
||||
env.BuildLibrary(
|
||||
os.path.join("$BUILD_DIR", "FrameworkArduinoVariant"),
|
||||
os.path.join(FRAMEWORK_DIR, "variants", variant)))
|
||||
|
||||
libs.append(
|
||||
env.BuildLibrary(
|
||||
os.path.join("$BUILD_DIR", "FrameworkArduino"),
|
||||
os.path.join(FRAMEWORK_DIR, "cores", "rp2040")))
|
||||
|
||||
bootloader_src_file = board.get(
|
||||
"build.arduino.earlephilhower.boot2_source", "boot2_generic_03h_2_padded_checksum.S")
|
||||
|
||||
# Add bootloader file (boot2.o)
|
||||
# Only build the needed .S file, exclude all others via src_filter.
|
||||
env.BuildSources(
|
||||
os.path.join("$BUILD_DIR", "FrameworkArduinoBootloader"),
|
||||
os.path.join(FRAMEWORK_DIR, "boot2"),
|
||||
"-<*> +<%s>" % bootloader_src_file,
|
||||
)
|
||||
# Add include flags for all .S assembly file builds
|
||||
env.Append(
|
||||
ASFLAGS=[
|
||||
"-I", os.path.join(FRAMEWORK_DIR, "pico-sdk", "src",
|
||||
"rp2040", "hardware_regs", "include"),
|
||||
"-I", os.path.join(FRAMEWORK_DIR, "pico-sdk", "src",
|
||||
"common", "pico_binary_info", "include")
|
||||
]
|
||||
)
|
||||
|
||||
env.Prepend(LIBS=libs)
|
||||
@@ -27,12 +27,10 @@
|
||||
#define PIN_SPI1_SS (31u)
|
||||
|
||||
// Wire
|
||||
#define PIN_WIRE0_SDA (2u)
|
||||
#define PIN_WIRE0_SCL (3u)
|
||||
|
||||
// Not pinned out
|
||||
#define PIN_WIRE1_SDA (31u)
|
||||
#define PIN_WIRE1_SCL (31u)
|
||||
#define PIN_WIRE0_SDA (24u)
|
||||
#define PIN_WIRE0_SCL (25u)
|
||||
#define PIN_WIRE1_SDA (2u)
|
||||
#define PIN_WIRE1_SCL (3u)
|
||||
|
||||
#define SERIAL_HOWMANY (2u)
|
||||
#define SPI_HOWMANY (1u)
|
||||
|
||||
@@ -27,15 +27,13 @@
|
||||
#define PIN_SPI1_SS (31u)
|
||||
|
||||
// Wire
|
||||
#define PIN_WIRE0_SDA (2u)
|
||||
#define PIN_WIRE0_SCL (3u)
|
||||
|
||||
// Not pinned out
|
||||
#define PIN_WIRE1_SDA (31u)
|
||||
#define PIN_WIRE1_SCL (31u)
|
||||
#define PIN_WIRE0_SDA (24u)
|
||||
#define PIN_WIRE0_SCL (25u)
|
||||
#define PIN_WIRE1_SDA (2u)
|
||||
#define PIN_WIRE1_SCL (3u)
|
||||
|
||||
#define SERIAL_HOWMANY (2u)
|
||||
#define SPI_HOWMANY (1u)
|
||||
#define WIRE_HOWMANY (1u)
|
||||
#define WIRE_HOWMANY (2u)
|
||||
|
||||
#include "../generic/common.h"
|
||||
|
||||
@@ -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;
|
||||
@@ -0,0 +1,76 @@
|
||||
#pragma once
|
||||
|
||||
#define PINS_COUNT (28u)
|
||||
#define NUM_DIGITAL_PINS (28u)
|
||||
#define NUM_ANALOG_INPUTS (4u)
|
||||
#define NUM_ANALOG_OUTPUTS (0u)
|
||||
#define ADC_RESOLUTION (12u)
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED (19u)
|
||||
|
||||
// Serial1 (User serial port)
|
||||
#define PIN_SERIAL1_TX (16u)
|
||||
#define PIN_SERIAL1_RX (17u)
|
||||
|
||||
// Serial2, connected to SARA-R4XX modem
|
||||
#define PIN_SERIAL2_TX (4u)
|
||||
#define PIN_SERIAL2_RX (5u)
|
||||
#define PIN_SERIAL2_CTS (6u)
|
||||
#define PIN_SERIAL2_RTS (7u)
|
||||
#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)
|
||||
#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
|
||||
|
||||
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 = (12u);
|
||||
static const uint8_t D10 = (11u);
|
||||
static const uint8_t D11 = (10u);
|
||||
static const uint8_t D12 = (9u);
|
||||
static const uint8_t D13 = (8u);
|
||||
static const uint8_t D14 = (13u);
|
||||
static const uint8_t D15 = (14u);
|
||||
static const uint8_t D16 = (15u);
|
||||
static const uint8_t D17 = (19u);
|
||||
|
||||
static const uint8_t A0 = (29u);
|
||||
static const uint8_t A1 = (28u);
|
||||
static const uint8_t A2 = (27u);
|
||||
static const uint8_t A3 = (26u);
|
||||
static const uint8_t A4 = (25u);
|
||||
static const uint8_t A5 = (21u);
|
||||
@@ -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,73 @@
|
||||
#pragma once
|
||||
|
||||
#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 = (11u);
|
||||
static const uint8_t D15 = (12u);
|
||||
static const uint8_t D16 = (13u);
|
||||
static const uint8_t D17 = (19u);
|
||||
|
||||
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,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,57 @@
|
||||
#pragma once
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED (3u)
|
||||
|
||||
// Neopixel
|
||||
#define PIN_NEOPIXEL (18u)
|
||||
#define NUM_NEOPIXEL (2u)
|
||||
#define PIN_RGB PIN_NEOPIXEL
|
||||
|
||||
// Buzzer
|
||||
#define PIN_BUZZER (22u)
|
||||
|
||||
// Motor Driver
|
||||
#define PIN_M1A (8u)
|
||||
#define PIN_M1B (9u)
|
||||
#define PIN_M2A (10u)
|
||||
#define PIN_M2B (11u)
|
||||
|
||||
// Voltage Monitor
|
||||
#define PIN_VBATT (29u)
|
||||
#define PIN_VOLTAGE_MONITOR PIN_VBATT
|
||||
|
||||
|
||||
|
||||
// Serial
|
||||
#define PIN_SERIAL1_TX (0u)
|
||||
#define PIN_SERIAL1_RX (1u)
|
||||
|
||||
#define PIN_SERIAL2_TX (4u)
|
||||
#define PIN_SERIAL2_RX (5u)
|
||||
|
||||
// SPI (Not pinned out)
|
||||
#define PIN_SPI0_MISO (31u)
|
||||
#define PIN_SPI0_MOSI (31u)
|
||||
#define PIN_SPI0_SCK (31u)
|
||||
#define PIN_SPI0_SS (31u)
|
||||
|
||||
#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 (16u)
|
||||
#define PIN_WIRE0_SCL (17u)
|
||||
|
||||
#define PIN_WIRE1_SDA (2u)
|
||||
#define PIN_WIRE1_SCL (3u)
|
||||
|
||||
|
||||
|
||||
#define SERIAL_HOWMANY (2u)
|
||||
#define SPI_HOWMANY (0u)
|
||||
#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);
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
// Pin definitions taken from:
|
||||
// https://datasheets.raspberrypi.org/pico/pico-datasheet.pdf
|
||||
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED (25u)
|
||||
|
||||
// Serial
|
||||
#define PIN_SERIAL1_TX (0u)
|
||||
#define PIN_SERIAL1_RX (1u)
|
||||
|
||||
#define PIN_SERIAL2_TX (8u)
|
||||
#define PIN_SERIAL2_RX (9u)
|
||||
|
||||
// SPI
|
||||
#define PIN_SPI0_MISO (20u)
|
||||
#define PIN_SPI0_MOSI (19u)
|
||||
#define PIN_SPI0_SCK (18u)
|
||||
#define PIN_SPI0_SS (1u)
|
||||
|
||||
#define PIN_SPI1_MISO (12u)
|
||||
#define PIN_SPI1_MOSI (11u)
|
||||
#define PIN_SPI1_SCK (10u)
|
||||
#define PIN_SPI1_SS (13u)
|
||||
|
||||
// Wire
|
||||
#define PIN_WIRE0_SDA (8u)
|
||||
#define PIN_WIRE0_SCL (9u)
|
||||
|
||||
#define PIN_WIRE1_SDA (2u)
|
||||
#define PIN_WIRE1_SCL (3u)
|
||||
|
||||
#define SERIAL_HOWMANY (3u)
|
||||
#define SPI_HOWMANY (2u)
|
||||
#define WIRE_HOWMANY (2u)
|
||||
|
||||
#include "../generic/common.h"
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
// Pin definitions taken from:
|
||||
// https://datasheets.raspberrypi.org/pico/pico-datasheet.pdf
|
||||
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED (25u)
|
||||
|
||||
// Serial
|
||||
#define PIN_SERIAL1_TX (0u)
|
||||
#define PIN_SERIAL1_RX (1u)
|
||||
|
||||
#define PIN_SERIAL2_TX (8u)
|
||||
#define PIN_SERIAL2_RX (9u)
|
||||
|
||||
// SPI
|
||||
#define PIN_SPI0_MISO (16u)
|
||||
#define PIN_SPI0_MOSI (19u)
|
||||
#define PIN_SPI0_SCK (18u)
|
||||
#define PIN_SPI0_SS (17u)
|
||||
|
||||
#define PIN_SPI1_MISO (12u)
|
||||
#define PIN_SPI1_MOSI (15u)
|
||||
#define PIN_SPI1_SCK (14u)
|
||||
#define PIN_SPI1_SS (13u)
|
||||
|
||||
// Wire
|
||||
#define PIN_WIRE0_SDA (4u)
|
||||
#define PIN_WIRE0_SCL (5u)
|
||||
|
||||
#define PIN_WIRE1_SDA (22u)
|
||||
#define PIN_WIRE1_SCL (23u)
|
||||
|
||||
#define SERIAL_HOWMANY (3u)
|
||||
#define SPI_HOWMANY (2u)
|
||||
#define WIRE_HOWMANY (2u)
|
||||
|
||||
#include "../generic/common.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../generic/pins_arduino.h"
|
||||
Reference in New Issue
Block a user