Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1dc348ec7 | ||
|
|
a0dac52e0e | ||
|
|
010039578f | ||
|
|
f8a2f38fe7 | ||
|
|
39d1a286a8 | ||
|
|
7dc0aa16ec | ||
|
|
b504feaa50 | ||
|
|
fa982c8dd0 | ||
|
|
f1f62264fe | ||
|
|
1de1d04fb4 | ||
|
|
af8b548e29 | ||
|
|
0550fe75b2 |
@@ -22,3 +22,6 @@
|
||||
[submodule "libraries/Mouse"]
|
||||
path = libraries/Mouse
|
||||
url = https://github.com/earlephilhower/Mouse
|
||||
[submodule "libraries/Adafruit_TinyUSB_Arduino"]
|
||||
path = libraries/Adafruit_TinyUSB_Arduino
|
||||
url = https://github.com/adafruit/Adafruit_TinyUSB_Arduino.git
|
||||
|
||||
@@ -7,6 +7,13 @@ This is a port of the RP2040 (Raspberry Pi Pico processor) to the Arduino ecosys
|
||||
# Documentation
|
||||
See https://arduino-pico.readthedocs.io/en/latest/ along with the examples for more detailed usage information.
|
||||
|
||||
# Supported Boards
|
||||
* Raspberry Pi Pico
|
||||
* Adafruit Feather RP2040
|
||||
* Adafruit ItsyBitsy RP2040
|
||||
* Adafruit QTPy RP2040
|
||||
* Generic (configurable flash, I/O pins)
|
||||
|
||||
# Installing via Arduino Boards Manager
|
||||
**Windows Users**: Please do not use the Windows Store version of the actual Arduino application
|
||||
because it has issues detecting attached Pico boards. Use the "Windows ZIP" or plain "Windows"
|
||||
@@ -15,7 +22,6 @@ drivers it suggests. Otherwise the Pico board may not be detected. Also, if tr
|
||||
2.0 beta Arduino please install the release 1.8 version beforehand to ensure needed device drivers
|
||||
are present. (See #20 for more details.)
|
||||
|
||||
|
||||
Open up the Arduino IDE and go to File->Preferences.
|
||||
|
||||
In the dialog that pops up, enter the following URL in the "Additional Boards Manager URLs" field:
|
||||
@@ -92,24 +98,14 @@ Once Picoprobe permissions are set up properly, then select the board "Raspberry
|
||||
# Debugging with Picoprobe, OpenOCD, and GDB
|
||||
The installed tools include a version of OpenOCD (in the pqt-openocd directory) and GDB (in the pqt-gcc directory). These may be used to run GDB in an interactive window as documented in the Pico Getting Started manuals from the Raspberry Pi Foundation.
|
||||
|
||||
# Status of Port
|
||||
Relatively stable and very functional, but bug reports and PRs always accepted.
|
||||
* USB Keyboard and Mouse emulation
|
||||
* Multicore support (setup1() and loop1())
|
||||
* digitalWrite/Read
|
||||
* shiftIn/Out
|
||||
* SPI master
|
||||
* analogWrite/PWM
|
||||
* tone/noTone
|
||||
* Wire/I2C Master and Slave
|
||||
* EEPROM
|
||||
* USB Serial(ACM) w/automatic reboot-to-UF2 upload)
|
||||
* Hardware UART
|
||||
* Servo, glitchless
|
||||
* Overclocking and underclocking from the menus
|
||||
* analogRead and Pico chip temperature
|
||||
# Features
|
||||
* Adafruit TinyUSB Arduino (USB mouse, keyboard, flash drive, generic HID, CDC Serial, MIDI, WebUSB, others)
|
||||
* Generic Arduino USB Serial, Keyboard, and Mouse emulation
|
||||
* Filesystems (LittleFS and SD/SDFS)
|
||||
* I2S audio output
|
||||
* Multicore support (setup1() and loop1())
|
||||
* Overclocking and underclocking from the menus
|
||||
* digitalWrite/Read, shiftIn/Out, tone, analogWrite(PWM)/Read, temperature
|
||||
* Peripherals: SPI master, Wire(I2C) master/slave, dual UART, emulated EEPROM, I2S audio output, Servo
|
||||
* printf (i.e. debug) output over USB serial
|
||||
|
||||
The RP2040 PIO state machines (SMs) are used to generate jitter-free:
|
||||
|
||||
+925
-268
File diff suppressed because it is too large
Load Diff
+13
-1
@@ -40,6 +40,11 @@
|
||||
extern "C"{
|
||||
#endif // __cplusplus
|
||||
|
||||
// For compatibility to many platforms and libraries
|
||||
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
|
||||
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
|
||||
#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
|
||||
|
||||
// Disable/reenable all interrupts. Safely handles nested disables
|
||||
void interrupts();
|
||||
void noInterrupts();
|
||||
@@ -90,7 +95,14 @@ unsigned long millis();
|
||||
#define HAVE_HWSERIAL2
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "SerialUSB.h"
|
||||
|
||||
#ifdef USE_TINYUSB
|
||||
// Needed for declaring Serial
|
||||
#include "Adafruit_USBD_CDC.h"
|
||||
#else
|
||||
#include "SerialUSB.h"
|
||||
#endif
|
||||
|
||||
#include "SerialUART.h"
|
||||
#include "RP2040.h"
|
||||
#include "Bootsel.h"
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef USE_TINYUSB
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "CoreMutex.h"
|
||||
#include "RP2040USB.h"
|
||||
@@ -317,3 +319,5 @@ void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uin
|
||||
(void) bufsize;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef USE_TINYUSB
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "CoreMutex.h"
|
||||
|
||||
@@ -189,3 +191,5 @@ void arduino::serialEventRun(void)
|
||||
serialEvent();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +1 @@
|
||||
#include "api/String.h"
|
||||
#include "api/Stream.h"
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018, hathach for Adafruit
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _TUSB_CONFIG_H_
|
||||
#define _TUSB_CONFIG_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// COMMON CONFIGURATION
|
||||
//--------------------------------------------------------------------
|
||||
#ifdef USE_TINYUSB
|
||||
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
|
||||
#else
|
||||
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE
|
||||
#endif
|
||||
|
||||
//#ifndef CFG_TUSB_MCU
|
||||
// #define CFG_TUSB_MCU OPT_MCU_RP2040
|
||||
//#endif
|
||||
#define CFG_TUSB_OS OPT_OS_PICO
|
||||
|
||||
#define CFG_TUSB_DEBUG 0
|
||||
//#if CFG_TUSB_DEBUG
|
||||
// #define tu_printf serial1_printf
|
||||
// extern int serial1_printf(const char *__restrict __format, ...);
|
||||
//#endif
|
||||
|
||||
#define CFG_TUSB_MEM_SECTION
|
||||
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// DEVICE CONFIGURATION
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
#define CFG_TUD_ENDOINT0_SIZE 64
|
||||
|
||||
//------------- CLASS -------------//
|
||||
#define CFG_TUD_CDC 1
|
||||
#define CFG_TUD_MSC 1
|
||||
#define CFG_TUD_HID 1
|
||||
#define CFG_TUD_MIDI 1
|
||||
#define CFG_TUD_VENDOR 1
|
||||
|
||||
// CDC FIFO size of TX and RX
|
||||
#define CFG_TUD_CDC_RX_BUFSIZE 256
|
||||
#define CFG_TUD_CDC_TX_BUFSIZE 256
|
||||
|
||||
// MSC Buffer size of Device Mass storage
|
||||
#define CFG_TUD_MSC_BUFSIZE 512
|
||||
|
||||
// HID buffer size Should be sufficient to hold ID (if any) + Data
|
||||
#define CFG_TUD_HID_BUFSIZE 64
|
||||
|
||||
// MIDI FIFO size of TX and RX
|
||||
#define CFG_TUD_MIDI_RX_BUFSIZE 128
|
||||
#define CFG_TUD_MIDI_TX_BUFSIZE 128
|
||||
|
||||
// Vendor FIFO size of TX and RX
|
||||
#define CFG_TUD_VENDOR_RX_BUFSIZE 64
|
||||
#define CFG_TUD_VENDOR_TX_BUFSIZE 64
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TUSB_CONFIG_H_ */
|
||||
+18
-6
@@ -21,7 +21,14 @@
|
||||
#include <pico.h>
|
||||
#include <pico/time.h>
|
||||
|
||||
extern "C" void delay( unsigned long ms ) {
|
||||
#ifdef USE_TINYUSB
|
||||
#include "Adafruit_TinyUSB_API.h"
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
void delay( unsigned long ms ) {
|
||||
if (!ms) {
|
||||
return;
|
||||
}
|
||||
@@ -29,22 +36,27 @@ extern "C" void delay( unsigned long ms ) {
|
||||
sleep_ms(ms);
|
||||
}
|
||||
|
||||
extern "C" void delayMicroseconds( unsigned int usec ) {
|
||||
void delayMicroseconds( unsigned int usec ) {
|
||||
if (!usec) {
|
||||
return;
|
||||
}
|
||||
sleep_us(usec);
|
||||
}
|
||||
|
||||
extern "C" void yield() {
|
||||
// NOOP
|
||||
void yield() {
|
||||
#ifdef USE_TINYUSB
|
||||
TinyUSB_Device_Task();
|
||||
TinyUSB_Device_FlushCDC();
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" uint32_t millis() {
|
||||
|
||||
uint32_t millis() {
|
||||
return to_ms_since_boot(get_absolute_time());
|
||||
}
|
||||
|
||||
extern "C" uint32_t micros() {
|
||||
uint32_t micros() {
|
||||
return to_us_since_boot(get_absolute_time());
|
||||
}
|
||||
|
||||
} // extern C
|
||||
|
||||
+12
-127
@@ -60,11 +60,17 @@ extern "C" int main() {
|
||||
|
||||
mutex_init(&_pioMutex);
|
||||
initVariant();
|
||||
|
||||
#ifdef USE_TINYUSB
|
||||
TinyUSB_Device_Init(0);
|
||||
|
||||
#else
|
||||
__USBStart();
|
||||
|
||||
#ifndef DISABLE_USB_SERIAL
|
||||
#ifndef DISABLE_USB_SERIAL
|
||||
// Enable serial port for reset/upload always
|
||||
Serial.begin();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined DEBUG_RP2040_PORT
|
||||
@@ -82,6 +88,11 @@ extern "C" int main() {
|
||||
setup();
|
||||
while (true) {
|
||||
loop();
|
||||
|
||||
#ifdef USE_TINYUSB
|
||||
yield();
|
||||
#endif
|
||||
|
||||
if (arduino::serialEventRun) {
|
||||
arduino::serialEventRun();
|
||||
}
|
||||
@@ -94,129 +105,3 @@ extern "C" int main() {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* NEWLIB syscall overloads, so we can ::print() and ::getc() using our objects */
|
||||
/* Placed here to ensure this compilation unit will be present when it's time */
|
||||
/* to link newlib.a. */
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <_syslist.h>
|
||||
#include <sys/times.h>
|
||||
#include <bits/stdc++.h>
|
||||
#undef errno
|
||||
|
||||
|
||||
// TODO - check the fd, create a VFS, etc.
|
||||
|
||||
extern "C" int errno;
|
||||
|
||||
extern "C" ssize_t _write(int fd, const void *buf, size_t count) {
|
||||
#if defined DEBUG_RP2040_PORT
|
||||
return DEBUG_RP2040_PORT.write((const char *)buf, count);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" int _chown (const char *path, uid_t owner, gid_t group) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _close (int fildes) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _execve (char *name, char **argv, char **env) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _fork (void) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _fstat (int fildes, struct stat *st) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _getpid (void) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct timeval;
|
||||
|
||||
extern "C" int _gettimeofday (struct timeval *ptimeval, void *ptimezone)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _isatty (int file) {
|
||||
errno = ENOSYS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int _kill (int pid, int sig) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _link (char *existing, char *newlink) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _lseek (int file, int ptr, int dir) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _open (char *file, int flags, int mode) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _read (int file, char *ptr, int len)
|
||||
{
|
||||
// return Serial.read(ptr, len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _readlink (const char *path, char *buf, size_t bufsize) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _stat (const char *file, struct stat *st) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _symlink (const char *path1, const char *path2) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" clock_t _times (struct tms *buf) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _unlink (char *name) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _wait (int *status) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" void __sync_synchronize() { /* noop */ }
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* NEWLIB syscall implementations
|
||||
*
|
||||
* Copyright (c) 2021 Earle F. Philhower, III <earlephilhower@yahoo.com>
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <_syslist.h>
|
||||
#include <sys/times.h>
|
||||
#include <pico/stdlib.h>
|
||||
#include <pico/multicore.h>
|
||||
|
||||
#undef errno
|
||||
|
||||
|
||||
// TODO - check the fd, create a VFS, etc.
|
||||
|
||||
extern "C" int errno;
|
||||
|
||||
extern "C" ssize_t _write(int fd, const void *buf, size_t count) {
|
||||
#if defined DEBUG_RP2040_PORT
|
||||
return DEBUG_RP2040_PORT.write((const char *)buf, count);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" int _chown (const char *path, uid_t owner, gid_t group) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _close (int fildes) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _execve (char *name, char **argv, char **env) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _fork (void) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _fstat (int fildes, struct stat *st) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _getpid (void) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int64_t __timedelta_us = 0.0;
|
||||
|
||||
extern "C" int _gettimeofday (struct timeval *tv, void *tz) {
|
||||
uint64_t now_us = to_us_since_boot(get_absolute_time()) + __timedelta_us;
|
||||
if (tv) {
|
||||
tv->tv_sec = now_us / 1000000L;
|
||||
tv->tv_usec = now_us % 1000000L;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int settimeofday (const struct timeval *tv, const struct timezone *tz) {
|
||||
uint64_t now_us = to_us_since_boot(get_absolute_time());
|
||||
if (tv) {
|
||||
uint64_t newnow_us;
|
||||
newnow_us = tv->tv_sec * 1000000L;
|
||||
newnow_us += tv->tv_usec;
|
||||
__timedelta_us = newnow_us - now_us;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int _isatty (int file) {
|
||||
errno = ENOSYS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int _kill (int pid, int sig) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _link (char *existing, char *newlink) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _lseek (int file, int ptr, int dir) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _open (char *file, int flags, int mode) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _read (int file, char *ptr, int len)
|
||||
{
|
||||
// return Serial.read(ptr, len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _readlink (const char *path, char *buf, size_t bufsize) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _stat (const char *file, struct stat *st) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _symlink (const char *path1, const char *path2) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" clock_t _times (struct tms *buf) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _unlink (char *name) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" int _wait (int *status) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
## Welcome to Arduino-Pico
|
||||
|
||||
Please go to https://arduino-pico.readthedocs.io/en/latest/ for the
|
||||
Please go to [https://arduino-pico.readthedocs.io/en/latest/](https://arduino-pico.readthedocs.io/en/latest/) for the
|
||||
latest documentation.
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ For the latest version, always check https://github.com/earlephilhower/arduino-p
|
||||
SPI <spi>
|
||||
Wire(I2C) <wire>
|
||||
File Systems (SD, SDFS, LittleFS) <fs>
|
||||
USB Keyboard/Mouse <usb>
|
||||
USB (Arduino and Adafruit_TinyUSB) <usb>
|
||||
Multicore Processing <multicore>
|
||||
|
||||
Ported/Optimized Libraries <libraries>
|
||||
|
||||
+24
-3
@@ -1,7 +1,17 @@
|
||||
USB Keyboard and Mouse
|
||||
======================
|
||||
USB (Arduino and Adafruit_TinyUSB)
|
||||
==================================
|
||||
|
||||
The Arduino-Pico core includes ported versions of the standard Arduino
|
||||
Two USB stacks are present in the core. Users can choose the simpler
|
||||
Pico-SDK version or the more powerful Adafruit TinyUSB library.
|
||||
Use the ``Tools->USB Stack`` menu to select between the two.
|
||||
|
||||
Pico SDK USB Support
|
||||
--------------------
|
||||
This is the default mode and automatically includes a USB-based
|
||||
serial port, ``Serial`` as well as supporting automatic reset-to-upload
|
||||
from the IDE.
|
||||
|
||||
The Arduino-Pico core includes ported versions of the basic Arduino
|
||||
``Keyboard`` and ``Mouse`` libraries. These libraries allow you to
|
||||
emulate a keyboard or mouse with the Pico in your sketches.
|
||||
|
||||
@@ -9,3 +19,14 @@ See the examples and Arduino Reference at
|
||||
https://www.arduino.cc/reference/en/language/functions/usb/keyboard/
|
||||
and
|
||||
https://www.arduino.cc/reference/en/language/functions/usb/mouse
|
||||
|
||||
Adafruit TinyUSB Arduino Support
|
||||
--------------------------------
|
||||
Examples are provided in the Adafruit_TinyUSB_Arduino for the more
|
||||
advanced USB stack.
|
||||
|
||||
Please note that this stack requires sketches to manually call
|
||||
``Serial.begin(115200)`` to enable the USB serial port and automatic
|
||||
sketch upload from the IDE. If a sketch is run without this command
|
||||
in ``setup()``, the user will need to use the standard "hold BOOTSEL
|
||||
and plug in USB" method to enter program upload mode.
|
||||
|
||||
Submodule
+1
Submodule libraries/Adafruit_TinyUSB_Arduino added at 1b8b9c9b07
@@ -19,7 +19,7 @@
|
||||
|
||||
// The normal, core0 setup
|
||||
void setup() {
|
||||
Serial.begin();
|
||||
Serial.begin(115200);
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/* Simple demonstration of setting and printing the current time */
|
||||
/* The initial time will need to come from an RTC, NTP, or user */
|
||||
|
||||
/* Released to the public domain by Earle F. Philhower, III <earlephilhower@yahoo.com> */
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(5000);
|
||||
struct timeval tv;
|
||||
|
||||
tv.tv_sec = 1611198855; // Jan 21, 2021 3:14:15AM ...RPi Pico Release;
|
||||
tv.tv_usec = 0;
|
||||
settimeofday(&tv, nullptr);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
time_t now;
|
||||
struct tm *info;
|
||||
char buff[80];
|
||||
|
||||
time(&now);
|
||||
strftime(buff, sizeof(buff), "%c", localtime(&now));
|
||||
Serial.println(buff);
|
||||
delay(1000);
|
||||
}
|
||||
+14
-7
@@ -38,15 +38,16 @@ compiler.warning_flags.default=
|
||||
compiler.warning_flags.more=-Wall
|
||||
compiler.warning_flags.all=-Wall -Wextra
|
||||
|
||||
compiler.defines={build.led}
|
||||
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.wrap="@{runtime.platform.path}/lib/platform_wrap.txt"
|
||||
compiler.libpico="{runtime.platform.path}/lib/libpico.a"
|
||||
|
||||
compiler.c.cmd=arm-none-eabi-gcc
|
||||
compiler.c.flags=-c {compiler.defines} {compiler.flags} {compiler.includes} -std=gnu17 -g
|
||||
compiler.c.elf.cmd=arm-none-eabi-g++
|
||||
compiler.c.elf.flags={compiler.defines} {compiler.flags} -Wl,--gc-sections -u _printf_float -u _scanf_float
|
||||
compiler.c.elf.flags={compiler.defines} {compiler.flags} -u _printf_float -u _scanf_float
|
||||
compiler.S.cmd=arm-none-eabi-gcc
|
||||
compiler.S.flags=-c -g -x assembler-with-cpp -MMD {compiler.includes} -g
|
||||
compiler.cpp.cmd=arm-none-eabi-g++
|
||||
@@ -80,6 +81,7 @@ build.flash_length=
|
||||
build.eeprom_start=
|
||||
build.fs_start=
|
||||
build.fs_end=
|
||||
build.usbstack_flags=
|
||||
|
||||
build.boot2=boot2_generic_03h_4_padded_checksum
|
||||
|
||||
@@ -91,22 +93,27 @@ discovery.rp2040.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.pl
|
||||
# ----------------
|
||||
|
||||
## 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} -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} -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}"
|
||||
|
||||
## 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} -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} -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}"
|
||||
|
||||
## 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} -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} -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
|
||||
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}"
|
||||
|
||||
## Combine gc-sections, archives, and objects
|
||||
## 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}
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-Wl,--script={build.path}/memmap_default.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nosys.specs -Wl,--start-group {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "{runtime.platform.path}/lib/libpico.a" -lm "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include/" "-I{runtime.platform.path}/pico-sdk/src/common/pico_binary_info/include" "{runtime.platform.path}/assembly/{build.boot2}.S" -lc -lstdc++ -Wl,--end-group
|
||||
|
||||
## 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}/assembly/{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
|
||||
|
||||
## 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"
|
||||
|
||||
+27
-8
@@ -44,9 +44,20 @@ def BuildBoot(name):
|
||||
print("%s.menu.boot2.%s=%s" % (name, l[1], l[0]))
|
||||
print("%s.menu.boot2.%s.build.boot2=%s" % (name, l[1], l[1]))
|
||||
|
||||
def BuildHeader(name, prettyname, pidtouse, pid, boarddefine, variant, uploadtool, flashsize, boot2):
|
||||
def BuildUSBStack(name):
|
||||
print("%s.menu.usbstack.picosdk=Pico SDK" % (name))
|
||||
print("%s.menu.usbstack.picosdk.build.usbstack_flags=" % (name))
|
||||
print("%s.menu.usbstack.tinyusb=Adafruit TinyUSB" % (name))
|
||||
print('%s.menu.usbstack.tinyusb.build.usbstack_flags=-DUSE_TINYUSB "-I{build.core.path}/TinyUSB" "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"' % (name))
|
||||
|
||||
def BuildHeader(name, vendor_name, product_name, pidtouse, vid, pid, boarddefine, variant, uploadtool, flashsize, boot2):
|
||||
prettyname = vendor_name + " " + product_name
|
||||
print()
|
||||
print("# -----------------------------------")
|
||||
print("# %s" % (prettyname))
|
||||
print("# -----------------------------------")
|
||||
print("%s.name=%s" % (name, prettyname))
|
||||
print("%s.vid.0=0x2e8a" % (name))
|
||||
print("%s.vid.0=%s" % (name, vid))
|
||||
print("%s.pid.0=%s" % (name, pidtouse))
|
||||
print("%s.build.usbpid=-DSERIALUSB_PID=%s" % (name, pid))
|
||||
print("%s.build.board=%s" % (name, boarddefine))
|
||||
@@ -65,6 +76,10 @@ def BuildHeader(name, prettyname, pidtouse, pid, boarddefine, variant, uploadtoo
|
||||
print("%s.build.mcu=rp2040" % (name))
|
||||
print("%s.build.ldscript=memmap_default.ld" % (name))
|
||||
print("%s.build.boot2=%s" % (name, boot2))
|
||||
print("%s.build.vid=%s" % (name, vid))
|
||||
print("%s.build.pid=%s" % (name, pid))
|
||||
print('%s.build.usb_manufacturer="%s"' % (name, vendor_name))
|
||||
print('%s.build.usb_product="%s"' % (name, product_name))
|
||||
|
||||
def BuildGlobalMenuList():
|
||||
print("menu.BoardModel=Model")
|
||||
@@ -73,12 +88,13 @@ def BuildGlobalMenuList():
|
||||
print("menu.dbgport=Debug Port")
|
||||
print("menu.dbglvl=Debug Level")
|
||||
print("menu.boot2=Boot Stage 2")
|
||||
print("menu.usbstack=USB Stack")
|
||||
|
||||
|
||||
def MakeBoard(name, prettyname, pid, boarddefine, flashsizemb, boot2):
|
||||
def MakeBoard(name, vendor_name, product_name, vid, pid, boarddefine, flashsizemb, boot2):
|
||||
for a, b, c in [ ["", "", "uf2conv"], ["picoprobe", " (Picoprobe)", "picoprobe"]]:
|
||||
n = name + a
|
||||
p = prettyname + b
|
||||
p = product_name + b
|
||||
fssizelist = [ 0, 64 * 1024, 128 * 1024, 256 * 1024, 512 * 1024 ]
|
||||
for i in range(1, flashsizemb):
|
||||
fssizelist.append(i * 1024 * 1024)
|
||||
@@ -86,7 +102,7 @@ def MakeBoard(name, prettyname, pid, boarddefine, flashsizemb, boot2):
|
||||
pidtouse = '0x0004'
|
||||
else:
|
||||
pidtouse = pid
|
||||
BuildHeader(n, p, pidtouse, pid, boarddefine, name, c, flashsizemb * 1024 * 1024, boot2)
|
||||
BuildHeader(n, vendor_name, p, pidtouse, vid, pid, boarddefine, name, c, flashsizemb * 1024 * 1024, boot2)
|
||||
if name == "generic":
|
||||
BuildFlashMenu(n, 2*1024*1024, [0, 1*1024*1024])
|
||||
BuildFlashMenu(n, 4*1024*1024, [0, 2*1024*1024])
|
||||
@@ -97,12 +113,15 @@ def MakeBoard(name, prettyname, pid, boarddefine, flashsizemb, boot2):
|
||||
BuildFreq(n)
|
||||
BuildDebugPort(n)
|
||||
BuildDebugLevel(n)
|
||||
BuildUSBStack(n)
|
||||
if name == "generic":
|
||||
BuildBoot(n)
|
||||
|
||||
|
||||
BuildGlobalMenuList()
|
||||
MakeBoard("rpipico", "Raspberry Pi Pico", "0x000a", "RASPBERRY_PI_PICO", 2, "boot2_w25q080_2_padded_checksum")
|
||||
MakeBoard("adafruitfeather", "Adafruit Feather RP2040", "0x000b", "ADAFRUIT_FEATHER_RP2040", 8, "boot2_w25x10cl_4_padded_checksum")
|
||||
MakeBoard("generic", "Generic RP2040", "0xf00a", "GENERIC_RP2040", 16, "boot2_generic_03h_4_padded_checksum")
|
||||
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("generic", "Generic", "RP2040", "0x2e8a", "0xf00a", "GENERIC_RP2040", 16, "boot2_generic_03h_4_padded_checksum")
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
// Pin definitions taken from:
|
||||
// https://learn.adafruit.com/assets/100337
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED (11u)
|
||||
|
||||
// Serial
|
||||
#define PIN_SERIAL1_TX (0u)
|
||||
#define PIN_SERIAL1_RX (1u)
|
||||
|
||||
// Not pinned out
|
||||
#define PIN_SERIAL2_TX (31u)
|
||||
#define PIN_SERIAL2_RX (31u)
|
||||
|
||||
// SPI
|
||||
#define PIN_SPI0_MISO (20u)
|
||||
#define PIN_SPI0_MOSI (19u)
|
||||
#define PIN_SPI0_SCK (18u)
|
||||
#define PIN_SPI0_SS (31u) // not pinned out
|
||||
|
||||
// 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 (2u)
|
||||
#define PIN_WIRE0_SCL (3u)
|
||||
|
||||
// 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)
|
||||
|
||||
#include "../generic/common.h"
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
// Pin definitions taken from:
|
||||
// https://learn.adafruit.com/assets/100337
|
||||
|
||||
// LEDs not pinned out
|
||||
#define PIN_LED (31u)
|
||||
|
||||
// Serial
|
||||
#define PIN_SERIAL1_TX (20u)
|
||||
#define PIN_SERIAL1_RX (5u)
|
||||
|
||||
// Not pinned out
|
||||
#define PIN_SERIAL2_TX (31u)
|
||||
#define PIN_SERIAL2_RX (31u)
|
||||
|
||||
// SPI
|
||||
#define PIN_SPI0_MISO (4u)
|
||||
#define PIN_SPI0_MOSI (3u)
|
||||
#define PIN_SPI0_SCK (6u)
|
||||
#define PIN_SPI0_SS (31u) // not pinned out
|
||||
|
||||
// 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 (24u)
|
||||
#define PIN_WIRE0_SCL (25u)
|
||||
|
||||
// Wire1 is connected to StemmaQT connector
|
||||
#define PIN_WIRE1_SDA (22u)
|
||||
#define PIN_WIRE1_SCL (23u)
|
||||
|
||||
#define SERIAL_HOWMANY (2u)
|
||||
#define SPI_HOWMANY (1u)
|
||||
#define WIRE_HOWMANY (2u)
|
||||
|
||||
#include "../generic/common.h"
|
||||
Reference in New Issue
Block a user