Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-pico
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-pico
Commits
28d7818c
Commit
28d7818c
authored
Feb 23, 2022
by
Earle F. Philhower, III
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/earlephilhower/arduino-pico
parents
6561310d
f8e8a7b7
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1819 additions
and
1721 deletions
+1819
-1721
boards.txt
boards.txt
+1699
-1699
cores/rp2040/SerialUART.cpp
cores/rp2040/SerialUART.cpp
+42
-0
cores/rp2040/SerialUART.h
cores/rp2040/SerialUART.h
+4
-0
docs/pins.rst
docs/pins.rst
+2
-1
libraries/PDM/src/PDM.h
libraries/PDM/src/PDM.h
+6
-0
libraries/PDM/src/rp2040/PDM.cpp
libraries/PDM/src/rp2040/PDM.cpp
+24
-18
libraries/PDM/src/rp2040/pdm.pio
libraries/PDM/src/rp2040/pdm.pio
+1
-0
libraries/PDM/src/rp2040/pdm.pio.h
libraries/PDM/src/rp2040/pdm.pio.h
+1
-0
tools/makeboards.py
tools/makeboards.py
+32
-3
variants/challenger_2040_lora/pins_arduino.h
variants/challenger_2040_lora/pins_arduino.h
+8
-0
No files found.
boards.txt
View file @
28d7818c
This source diff could not be displayed because it is too large. You can
view the blob
instead.
cores/rp2040/SerialUART.cpp
View file @
28d7818c
...
...
@@ -65,6 +65,39 @@ bool SerialUART::setTX(pin_size_t pin) {
return
false
;
}
bool
SerialUART
::
setRTS
(
pin_size_t
pin
)
{
constexpr
uint32_t
valid
[
2
]
=
{
__bitset
({
3
,
15
,
19
})
/* UART0 */
,
__bitset
({
7
,
11
,
23
,
27
})
/* UART1 */
};
if
((
!
_running
)
&&
((
1
<<
pin
)
&
valid
[
uart_get_index
(
_uart
)]))
{
_rts
=
pin
;
return
true
;
}
if
(
_running
)
{
panic
(
"FATAL: Attempting to set Serial%d.RTS while running"
,
uart_get_index
(
_uart
)
+
1
);
}
else
{
panic
(
"FATAL: Attempting to set Serial%d.RTS to illegal pin %d"
,
uart_get_index
(
_uart
)
+
1
,
pin
);
}
return
false
;
}
bool
SerialUART
::
setCTS
(
pin_size_t
pin
)
{
constexpr
uint32_t
valid
[
2
]
=
{
__bitset
({
2
,
14
,
18
})
/* UART0 */
,
__bitset
({
6
,
10
,
22
,
26
})
/* UART1 */
};
if
((
!
_running
)
&&
((
1
<<
pin
)
&
valid
[
uart_get_index
(
_uart
)]))
{
_cts
=
pin
;
return
true
;
}
if
(
_running
)
{
panic
(
"FATAL: Attempting to set Serial%d.CTS while running"
,
uart_get_index
(
_uart
)
+
1
);
}
else
{
panic
(
"FATAL: Attempting to set Serial%d.CTS to illegal pin %d"
,
uart_get_index
(
_uart
)
+
1
,
pin
);
}
return
false
;
}
bool
SerialUART
::
setPollingMode
(
bool
mode
)
{
if
(
_running
)
{
return
false
;
...
...
@@ -85,6 +118,8 @@ SerialUART::SerialUART(uart_inst_t *uart, pin_size_t tx, pin_size_t rx) {
_uart
=
uart
;
_tx
=
tx
;
_rx
=
rx
;
_rts
=
UART_PIN_NOT_DEFINED
;
_cts
=
UART_PIN_NOT_DEFINED
;
mutex_init
(
&
_mutex
);
}
...
...
@@ -133,6 +168,13 @@ void SerialUART::begin(unsigned long baud, uint16_t config) {
uart_set_format
(
_uart
,
bits
,
stop
,
parity
);
gpio_set_function
(
_tx
,
GPIO_FUNC_UART
);
gpio_set_function
(
_rx
,
GPIO_FUNC_UART
);
if
(
_rts
!=
UART_PIN_NOT_DEFINED
)
{
gpio_set_function
(
_rts
,
GPIO_FUNC_UART
);
}
if
(
_cts
!=
UART_PIN_NOT_DEFINED
)
{
gpio_set_function
(
_cts
,
GPIO_FUNC_UART
);
}
uart_set_hw_flow
(
_uart
,
_rts
!=
UART_PIN_NOT_DEFINED
,
_cts
!=
UART_PIN_NOT_DEFINED
);
_writer
=
0
;
_reader
=
0
;
...
...
cores/rp2040/SerialUART.h
View file @
28d7818c
...
...
@@ -28,6 +28,7 @@
extern
"C"
typedef
struct
uart_inst
uart_inst_t
;
#define UART_PIN_NOT_DEFINED (255u)
class
SerialUART
:
public
HardwareSerial
{
public:
SerialUART
(
uart_inst_t
*
uart
,
pin_size_t
tx
,
pin_size_t
rx
);
...
...
@@ -35,6 +36,8 @@ public:
// Select the pinout. Call before .begin()
bool
setRX
(
pin_size_t
pin
);
bool
setTX
(
pin_size_t
pin
);
bool
setRTS
(
pin_size_t
pin
);
bool
setCTS
(
pin_size_t
pin
);
bool
setPinout
(
pin_size_t
tx
,
pin_size_t
rx
)
{
bool
ret
=
setRX
(
rx
);
ret
&=
setTX
(
tx
);
...
...
@@ -66,6 +69,7 @@ private:
bool
_running
=
false
;
uart_inst_t
*
_uart
;
pin_size_t
_tx
,
_rx
;
pin_size_t
_rts
,
_cts
;
int
_baud
;
mutex_t
_mutex
;
bool
_polling
=
false
;
...
...
docs/pins.rst
View file @
28d7818c
...
...
@@ -26,6 +26,8 @@ Serial1 (UART0), Serial2 (UART1)
::setRX(pin)
::setTX(pin)
::setRTS(pin)
::setCTS(pin)
SPI (SPI0), SPI1 (SPI1)
-----------------------
...
...
@@ -58,4 +60,3 @@ it use a non-default pinout with a simple call
SPI.setCS(5);
SD.begin(5);
}
libraries/PDM/src/PDM.h
View file @
28d7818c
...
...
@@ -58,6 +58,12 @@ private:
int
_gain
;
int
_init
;
// Hardware peripherals used
uint
_dmaChannel
;
PIO
_pio
;
int
_smIdx
;
int
_pgmOffset
;
PDMDoubleBuffer
_doubleBuffer
;
void
(
*
_onReceive
)(
void
);
...
...
libraries/PDM/src/rp2040/PDM.cpp
View file @
28d7818c
...
...
@@ -11,11 +11,7 @@ extern "C" {
}
#include "hardware/sync.h"
#include "pdm.pio.h"
// Hardware peripherals used
uint
dmaChannel
=
0
;
PIO
pio
=
pio0
;
uint
sm
=
0
;
static
PIOProgram
_pdmPgm
(
&
pdm_pio_program
);
// raw buffers contain PDM data
#define RAW_BUFFER_SIZE 512 // should be a multiple of (decimation / 8)
...
...
@@ -49,7 +45,11 @@ PDMClass::PDMClass(int dinPin, int clkPin, int pwrPin) :
_gain
(
-
1
),
_channels
(
-
1
),
_samplerate
(
-
1
),
_init
(
-
1
)
_init
(
-
1
),
_dmaChannel
(
0
),
_pio
(
nullptr
),
_smIdx
(
-
1
),
_pgmOffset
(
-
1
)
{
}
...
...
@@ -89,29 +89,35 @@ int PDMClass::begin(int channels, int sampleRate)
// Configure PIO state machine
float
clkDiv
=
(
float
)
clock_get_hz
(
clk_sys
)
/
sampleRate
/
decimation
/
2
;
uint
offset
=
pio_add_program
(
pio
,
&
pdm_pio_program
);
pdm_pio_program_init
(
pio
,
sm
,
offset
,
_clkPin
,
_dinPin
,
clkDiv
);
if
(
!
_pdmPgm
.
prepare
(
&
_pio
,
&
_smIdx
,
&
_pgmOffset
))
{
// ERROR, no free slots
return
-
1
;
}
pdm_pio_program_init
(
_pio
,
_smIdx
,
_pgmOffset
,
_clkPin
,
_dinPin
,
clkDiv
);
// Wait for microphone
delay
(
100
);
// Configure DMA for transferring PIO rx buffer to raw buffers
dma_channel_config
c
=
dma_channel_get_default_config
(
dmaChannel
);
_dmaChannel
=
dma_claim_unused_channel
(
false
);
dma_channel_config
c
=
dma_channel_get_default_config
(
_dmaChannel
);
channel_config_set_read_increment
(
&
c
,
false
);
channel_config_set_write_increment
(
&
c
,
true
);
channel_config_set_dreq
(
&
c
,
pio_get_dreq
(
pio
,
sm
,
false
));
channel_config_set_dreq
(
&
c
,
pio_get_dreq
(
_pio
,
_smIdx
,
false
));
channel_config_set_transfer_data_size
(
&
c
,
DMA_SIZE_8
);
// Clear DMA interrupts
dma_hw
->
ints0
=
1u
<<
dmaChannel
;
dma_hw
->
ints0
=
1u
<<
_
dmaChannel
;
// Enable DMA interrupts
dma_channel_set_irq0_enabled
(
dmaChannel
,
true
);
irq_set_exclusive_handler
(
DMA_IRQ_0
,
dmaHandler
);
dma_channel_set_irq0_enabled
(
_dmaChannel
,
true
);
// Share but allocate a high priority to the interrupt
irq_add_shared_handler
(
DMA_IRQ_0
,
dmaHandler
,
0
);
irq_set_enabled
(
DMA_IRQ_0
,
true
);
dma_channel_configure
(
dmaChannel
,
&
c
,
dma_channel_configure
(
_
dmaChannel
,
&
c
,
rawBuffer
[
rawBufferIndex
],
// Destinatinon pointer
&
pio
->
rxf
[
sm
],
// Source pointer
&
_pio
->
rxf
[
_smIdx
],
// Source pointer
RAW_BUFFER_SIZE
,
// Number of transfers
true
// Start immediately
);
...
...
@@ -123,7 +129,7 @@ int PDMClass::begin(int channels, int sampleRate)
void
PDMClass
::
end
()
{
dma_channel_abort
(
dmaChannel
);
dma_channel_abort
(
_
dmaChannel
);
pinMode
(
_clkPin
,
INPUT
);
}
...
...
@@ -171,10 +177,10 @@ void PDMClass::IrqHandler(bool halftranfer)
static
int
cutSamples
=
100
;
// Clear the interrupt request.
dma_hw
->
ints0
=
1u
<<
dmaChannel
;
dma_hw
->
ints0
=
1u
<<
_
dmaChannel
;
// Restart dma pointing to the other buffer
int
shadowIndex
=
rawBufferIndex
^
1
;
dma_channel_set_write_addr
(
dmaChannel
,
rawBuffer
[
shadowIndex
],
true
);
dma_channel_set_write_addr
(
_
dmaChannel
,
rawBuffer
[
shadowIndex
],
true
);
if
(
_doubleBuffer
.
available
())
{
// buffer overflow, stop
...
...
libraries/PDM/src/rp2040/pdm.pio
View file @
28d7818c
...
...
@@ -26,6 +26,7 @@ static inline void pdm_pio_program_init(PIO pio, uint sm, uint offset, uint clkP
sm_config_set_in_pins(&c, dataPin);
sm_config_set_sideset_pins(&c, clkPin);
sm_config_set_clkdiv(&c, clkDiv);
sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_RX);
pio_sm_set_consecutive_pindirs(pio, sm, dataPin, 1, false);
pio_sm_set_consecutive_pindirs(pio, sm, clkPin, 1, true);
...
...
libraries/PDM/src/rp2040/pdm.pio.h
View file @
28d7818c
...
...
@@ -43,6 +43,7 @@ static inline void pdm_pio_program_init(PIO pio, uint sm, uint offset, uint clkP
sm_config_set_in_pins
(
&
c
,
dataPin
);
sm_config_set_sideset_pins
(
&
c
,
clkPin
);
sm_config_set_clkdiv
(
&
c
,
clkDiv
);
sm_config_set_fifo_join
(
&
c
,
PIO_FIFO_JOIN_RX
);
pio_sm_set_consecutive_pindirs
(
pio
,
sm
,
dataPin
,
1
,
false
);
pio_sm_set_consecutive_pindirs
(
pio
,
sm
,
clkPin
,
1
,
true
);
pio_sm_set_pins_with_mask
(
pio
,
sm
,
0
,
(
1u
<<
clkPin
)
);
...
...
tools/makeboards.py
View file @
28d7818c
...
...
@@ -217,7 +217,15 @@ def MakeBoardJSON(name, vendor_name, product_name, vid, pid, pwr, boarddefine, f
sys
.
stdout
=
open
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
+
"/../boards.txt"
,
"w"
)
WriteWarning
()
BuildGlobalMenuList
()
# Note to new board manufacturers: Please add your board so that it sorts
# alphabetically starting with the company name and then the board name.
# Otherwise it is difficult to find a specific board in the menu.
# Raspberry Pi
MakeBoard
(
"rpipico"
,
"Raspberry Pi"
,
"Pico"
,
"0x2e8a"
,
"0x000a"
,
250
,
"RASPBERRY_PI_PICO"
,
2
,
"boot2_w25q080_2_padded_checksum"
)
# Adafruit
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"
)
...
...
@@ -225,19 +233,40 @@ MakeBoard("adafruit_stemmafriend", "Adafruit", "STEMMA Friend RP2040", "0x239a",
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
(
"adafruit_kb2040"
,
"Adafruit"
,
"KB2040"
,
"0x239a"
,
"0x8105"
,
250
,
"ADAFRUIT_KB2040_RP2040"
,
8
,
"boot2_w25q080_2_padded_checksum"
)
# Arduino
MakeBoard
(
"arduino_nano_connect"
,
"Arduino"
,
"Nano RP2040 Connect"
,
"0x2341"
,
"0x0058"
,
250
,
"NANO_RP2040_CONNECT"
,
16
,
"boot2_w25q080_2_padded_checksum"
)
# Cytron
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"
)
# DeRuiLab
MakeBoard
(
"flyboard2040_core"
,
"DeRuiLab"
,
"FlyBoard2040Core"
,
"0x2e8a"
,
"0x008a"
,
500
,
"FLYBOARD2040_CORE"
,
4
,
"boot2_generic_03h_4_padded_checksum"
)
# iLabs
MakeBoard
(
"challenger_2040_lora"
,
"iLabs"
,
"Challenger 2040 LoRa"
,
"0x2e8a"
,
"0x1023"
,
250
,
"CHALLENGER_2040_LORA_RP2040"
,
8
,
"boot2_w25q080_2_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"
)
# Melopera
MakeBoard
(
"melopero_shake_rp2040"
,
"Melopero"
,
"Shake RP2040"
,
"0x2e8a"
,
"0x1005"
,
250
,
"MELOPERO_SHAKE_RP2040"
,
16
,
"boot2_w25q080_2_padded_checksum"
)
# Solder Party
MakeBoard
(
"solderparty_rp2040_stamp"
,
"Solder Party"
,
"RP2040 Stamp"
,
"0x1209"
,
"0xa182"
,
500
,
"SOLDERPARTY_RP2040_STAMP"
,
8
,
"boot2_generic_03h_4_padded_checksum"
)
# SparkFun
MakeBoard
(
"sparkfun_promicrorp2040"
,
"SparkFun"
,
"ProMicro RP2040"
,
"0x1b4f"
,
"0x0026"
,
250
,
"SPARKFUN_PROMICRO_RP2040"
,
16
,
"boot2_generic_03h_4_padded_checksum"
)
# Upesy
MakeBoard
(
"upesy_rp2040_devkit"
,
"uPesy"
,
"RP2040 DevKit"
,
"0x2e8a"
,
"0x1007"
,
250
,
"UPESY_RP2040_DEVKIT"
,
2
,
"boot2_w25q080_2_padded_checksum"
)
# WIZnet
MakeBoard
(
"wiznet_5100s_evb_pico"
,
"WIZnet"
,
"W5100S-EVB-Pico"
,
"0x2e8a"
,
"0x1008"
,
250
,
"WIZNET_5100S_EVB_PICO"
,
2
,
"boot2_w25q080_2_padded_checksum"
)
MakeBoard
(
"flyboard2040_core"
,
"DeRuiLab"
,
"FlyBoard2040Core"
,
"0x2e8a"
,
"0x008a"
,
500
,
"FLYBOARD2040_CORE"
,
4
,
"boot2_generic_03h_4_padded_checksum"
)
# Generic
MakeBoard
(
"generic"
,
"Generic"
,
"RP2040"
,
"0x2e8a"
,
"0xf00a"
,
250
,
"GENERIC_RP2040"
,
16
,
"boot2_generic_03h_4_padded_checksum"
)
sys
.
stdout
.
close
()
variants/challenger_2040_lora/pins_arduino.h
View file @
28d7818c
...
...
@@ -24,6 +24,12 @@
#define PIN_SPI1_MOSI (11u)
#define PIN_SPI1_SCK (10u)
#define PIN_SPI1_SS (9u)
#define RFM95W_SS (9u)
#define RFM95W_DIO0 (14u)
#define RFM95W_DIO1 (15u)
#define RFM95W_DIO2 (18u)
#define RFM95W_RST (13u)
#define RFM95W_SPI SPI1
// Wire
#define PIN_WIRE0_SDA (0u)
...
...
@@ -32,6 +38,8 @@
// Not pinned out
#define PIN_WIRE1_SDA (31u)
#define PIN_WIRE1_SCL (31u)
#define PIN_SERIAL2_RX (31u)
#define PIN_SERIAL2_TX (31u)
#define SERIAL_HOWMANY (1u)
#define SPI_HOWMANY (2u)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment