Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc54eeb8d0 | ||
|
|
3a2a7f8cf1 | ||
|
|
52a22e5185 | ||
|
|
cae8c70e51 | ||
|
|
513bd81810 | ||
|
|
891f653ead | ||
|
|
5b270aab61 | ||
|
|
6591da9acf |
@@ -146,6 +146,7 @@ The RP2040 PIO state machines (SMs) are used to generate jitter-free:
|
||||
* Servos
|
||||
* Tones
|
||||
* I2S Output
|
||||
* Software UARTs (Serial ports)
|
||||
|
||||
# Tutorials from Across the Web
|
||||
Here are some links to coverage and additional tutorials for using `arduino-pico`
|
||||
|
||||
@@ -91,7 +91,7 @@ void __not_in_flash_func(SerialPIO::_handleIRQ)() {
|
||||
if (_rx == NOPIN) {
|
||||
return;
|
||||
}
|
||||
while ((!pio_sm_is_rx_fifo_empty(_rxPIO, _rxSM)) && ((_writer + 1) % sizeof(_queue) != _reader)) {
|
||||
while (!pio_sm_is_rx_fifo_empty(_rxPIO, _rxSM)) {
|
||||
uint32_t decode = _rxPIO->rxf[_rxSM];
|
||||
decode >>= 32 - _rxBits;
|
||||
uint32_t val = 0;
|
||||
@@ -114,9 +114,13 @@ void __not_in_flash_func(SerialPIO::_handleIRQ)() {
|
||||
}
|
||||
}
|
||||
|
||||
_queue[_writer] = val & ((1 << _bits) - 1);
|
||||
asm volatile("" ::: "memory"); // Ensure the queue is written before the written count advances
|
||||
_writer = (_writer + 1) % sizeof(_queue);
|
||||
if ((_writer + 1) % sizeof(_queue) != _reader) {
|
||||
_queue[_writer] = val & ((1 << _bits) - 1);
|
||||
asm volatile("" ::: "memory"); // Ensure the queue is written before the written count advances
|
||||
_writer = (_writer + 1) % sizeof(_queue);
|
||||
} else {
|
||||
// TODO: Overflow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +199,7 @@ void SerialPIO::begin(unsigned long baud, uint16_t config) {
|
||||
_writer = 0;
|
||||
_reader = 0;
|
||||
|
||||
_rxBits = 2 * (_bits + _stop + (_parity != UART_PARITY_NONE ? 1 : 0) + 1);
|
||||
_rxBits = 2 * (_bits + _stop + (_parity != UART_PARITY_NONE ? 1 : 0) + 1) - 1;
|
||||
_rxPgm = _getRxProgram(_rxBits);
|
||||
int off;
|
||||
if (!_rxPgm->prepare(&_rxPIO, &_rxSM, &off)) {
|
||||
@@ -213,6 +217,9 @@ void SerialPIO::begin(unsigned long baud, uint16_t config) {
|
||||
pio_sm_put_blocking(_rxPIO, _rxSM, clock_get_hz(clk_sys) / (_baud * 2) - 2);
|
||||
pio_sm_exec(_rxPIO, _rxSM, pio_encode_pull(false, false));
|
||||
|
||||
// Join the TX FIFO to the RX one now that we don't need it
|
||||
_rxPIO->sm[_rxSM].shiftctrl |= 0x80000000;
|
||||
|
||||
// Enable interrupts on rxfifo
|
||||
switch (_rxSM) {
|
||||
case 0: pio_set_irq0_source_enabled(_rxPIO, pis_sm0_rx_fifo_not_empty, true); break;
|
||||
|
||||
@@ -248,10 +248,15 @@ void arduino::serialEvent2Run(void) {
|
||||
// IRQ handler, called when FIFO > 1/4 full or when it had held unread data for >32 bit times
|
||||
void __not_in_flash_func(SerialUART::_handleIRQ)() {
|
||||
uart_get_hw(_uart)->icr |= UART_UARTICR_RTIC_BITS | UART_UARTICR_RXIC_BITS;
|
||||
while ((uart_is_readable(_uart)) && ((_writer + 1) % sizeof(_queue) != _reader)) {
|
||||
_queue[_writer] = uart_getc(_uart);
|
||||
asm volatile("" ::: "memory"); // Ensure the queue is written before the written count advances
|
||||
_writer = (_writer + 1) % sizeof(_queue);
|
||||
while (uart_is_readable(_uart)) {
|
||||
auto val = uart_getc(_uart);
|
||||
if ((_writer + 1) % sizeof(_queue) != _reader) {
|
||||
_queue[_writer] = val;
|
||||
asm volatile("" ::: "memory"); // Ensure the queue is written before the written count advances
|
||||
_writer = (_writer + 1) % sizeof(_queue);
|
||||
} else {
|
||||
// TODO: Overflow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "framework-arduinopico",
|
||||
"version": "1.10910.0",
|
||||
"version": "1.10912.0",
|
||||
"description": "Arduino Wiring-based Framework (RPi Pico RP2040)",
|
||||
"keywords": [
|
||||
"framework",
|
||||
|
||||
@@ -142,7 +142,8 @@ def configure_usb_flags(cpp_defines):
|
||||
("USB_PID", usb_pid),
|
||||
("USB_MANUFACTURER", '\\"%s\\"' % usb_manufacturer),
|
||||
("USB_PRODUCT", '\\"%s\\"' % usb_product),
|
||||
("SERIALUSB_PID", usb_pid)
|
||||
("SERIALUSB_PID", usb_pid),
|
||||
("USBD_MAX_POWER_MA", 250)
|
||||
])
|
||||
|
||||
# use vidtouse and pidtouse
|
||||
|
||||
@@ -38,4 +38,10 @@
|
||||
#define SPI_HOWMANY (1u)
|
||||
#define WIRE_HOWMANY (2u)
|
||||
|
||||
// Pin overrides specific to the QT Py RP2040
|
||||
#define __PIN_A0 (29u)
|
||||
#define __PIN_A1 (28u)
|
||||
#define __PIN_A2 (27u)
|
||||
#define __PIN_A3 (26u)
|
||||
|
||||
#include "../generic/common.h"
|
||||
|
||||
@@ -56,19 +56,19 @@ static const uint8_t A5 = (13u);
|
||||
#define PIN_SPI0_MISO (D12)
|
||||
#define PIN_SPI0_MOSI (D11)
|
||||
#define PIN_SPI0_SCK (D13)
|
||||
#define PIN_SPI0_SS (13u)//(D10)
|
||||
#define PIN_SPI0_SS (D10)
|
||||
|
||||
#define PIN_SPI1_MISO (D25)
|
||||
#define PIN_SPI1_MOSI (D28)
|
||||
#define PIN_SPI1_SCK (D29)
|
||||
#define PIN_SPI1_SS (13u)
|
||||
#define PIN_SPI1_SS (D10)
|
||||
|
||||
// Wire
|
||||
#define PIN_WIRE0_SDA (D18)
|
||||
#define PIN_WIRE0_SCL (D19)
|
||||
|
||||
#define PIN_WIRE1_SDA (26u) //Non c'è
|
||||
#define PIN_WIRE1_SCL (27u) //Non c'è
|
||||
#define PIN_WIRE1_SDA (D14)
|
||||
#define PIN_WIRE1_SCL (D15)
|
||||
|
||||
#define SERIAL_HOWMANY (3u)
|
||||
#define SPI_HOWMANY (2u)
|
||||
@@ -95,7 +95,7 @@ static const uint8_t SCK = PIN_SPI0_SCK;
|
||||
#define SerialHCI Serial2
|
||||
|
||||
//#define NINA_GPIOIRQ (21u) // LEDG pin (GPIO26 on NINA)
|
||||
#define NINA_GPIO0 (20u) // real GPIO0 on NINA
|
||||
#define NINA_GPIO0 (D20) // (2u), real GPIO0 on NINA
|
||||
|
||||
#define SPIWIFI_SS (D26)
|
||||
#define SPIWIFI_ACK (D27)
|
||||
|
||||
@@ -39,12 +39,34 @@ 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);
|
||||
#ifdef __PIN_A0
|
||||
static const uint8_t A0 = __PIN_A0;
|
||||
#else
|
||||
static const uint8_t A0 = (26u);
|
||||
#endif
|
||||
|
||||
#ifdef __PIN_A1
|
||||
static const uint8_t A1 = __PIN_A1;
|
||||
#else
|
||||
static const uint8_t A1 = (27u);
|
||||
#endif
|
||||
|
||||
#ifdef __PIN_A2
|
||||
static const uint8_t A2 = __PIN_A2;
|
||||
#else
|
||||
static const uint8_t A2 = (28u);
|
||||
#endif
|
||||
|
||||
#ifdef __PIN_A3
|
||||
static const uint8_t A3 = __PIN_A3;
|
||||
#else
|
||||
static const uint8_t A3 = (29u);
|
||||
#endif
|
||||
|
||||
static const uint8_t SS = PIN_SPI0_SS;
|
||||
static const uint8_t MOSI = PIN_SPI0_MOSI;
|
||||
static const uint8_t MISO = PIN_SPI0_MISO;
|
||||
static const uint8_t SCK = PIN_SPI0_SCK;
|
||||
|
||||
static const uint8_t SDA = PIN_WIRE0_SDA;
|
||||
static const uint8_t SCL = PIN_WIRE0_SCL;
|
||||
|
||||
Reference in New Issue
Block a user