Skip to content

Commit 848243c

Browse files
authored
Merge pull request #9901 from jepler/rp3250b-pio
raspberrypi: support PIO on high pins
2 parents 800802e + a0a86f8 commit 848243c

File tree

17 files changed

+351
-192
lines changed

17 files changed

+351
-192
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@
345345
url = https://github.com/adafruit/Adafruit_CircuitPython_Wave.git
346346
[submodule "ports/raspberrypi/lib/Pico-PIO-USB"]
347347
path = ports/raspberrypi/lib/Pico-PIO-USB
348-
url = https://github.com/sekigon-gonnoc/Pico-PIO-USB.git
348+
url = https://github.com/adafruit/Pico-PIO-USB.git
349349
[submodule "lib/micropython-lib"]
350350
path = lib/micropython-lib
351351
url = https://github.com/micropython/micropython-lib.git

locale/circuitpython.pot

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ msgstr ""
218218
#: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c
219219
#: shared-bindings/bitmapfilter/__init__.c shared-bindings/canio/CAN.c
220220
#: shared-bindings/digitalio/Pull.c shared-bindings/supervisor/__init__.c
221-
#: shared-module/synthio/Synthesizer.c
221+
#: shared-module/synthio/Biquad.c shared-module/synthio/Synthesizer.c
222222
msgid "%q must be of type %q or %q, not %q"
223223
msgstr ""
224224

@@ -795,6 +795,10 @@ msgstr ""
795795
msgid "Cannot subclass slice"
796796
msgstr ""
797797

798+
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
799+
msgid "Cannot use GPIO0..15 together with GPIO32..47"
800+
msgstr ""
801+
798802
#: ports/nordic/common-hal/alarm/pin/PinAlarm.c
799803
msgid "Cannot wake on pin edge, only level"
800804
msgstr ""
@@ -3383,10 +3387,6 @@ msgstr ""
33833387
msgid "label redefined"
33843388
msgstr ""
33853389

3386-
#: shared-bindings/audiomixer/MixerVoice.c
3387-
msgid "level must be between 0 and 1"
3388-
msgstr ""
3389-
33903390
#: py/objarray.c
33913391
msgid "lhs and rhs should be compatible"
33923392
msgstr ""

ports/raspberrypi/bindings/rp2pio/StateMachine.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,14 @@ static mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n
334334
args[ARG_frequency].u_int,
335335
init_bufinfo.buf, init_bufinfo.len / 2,
336336
may_exec_bufinfo.buf, may_exec_bufinfo.len / 2,
337-
first_out_pin, out_pin_count, args[ARG_initial_out_pin_state].u_int, args[ARG_initial_out_pin_direction].u_int,
338-
first_in_pin, in_pin_count, args[ARG_pull_in_pin_up].u_int, args[ARG_pull_in_pin_down].u_int,
339-
first_set_pin, set_pin_count, args[ARG_initial_set_pin_state].u_int, args[ARG_initial_set_pin_direction].u_int,
337+
first_out_pin, out_pin_count, PIO_PINMASK32_FROM_VALUE(args[ARG_initial_out_pin_state].u_int), PIO_PINMASK32_FROM_VALUE(args[ARG_initial_out_pin_direction].u_int),
338+
first_in_pin, in_pin_count, PIO_PINMASK32_FROM_VALUE(args[ARG_pull_in_pin_up].u_int), PIO_PINMASK32_FROM_VALUE(args[ARG_pull_in_pin_down].u_int),
339+
first_set_pin, set_pin_count, PIO_PINMASK32_FROM_VALUE(args[ARG_initial_set_pin_state].u_int), PIO_PINMASK32_FROM_VALUE(args[ARG_initial_set_pin_direction].u_int),
340340
first_sideset_pin, sideset_pin_count, args[ARG_sideset_pindirs].u_bool,
341-
args[ARG_initial_sideset_pin_state].u_int, args[ARG_initial_sideset_pin_direction].u_int,
341+
PIO_PINMASK32_FROM_VALUE(args[ARG_initial_sideset_pin_state].u_int), PIO_PINMASK32_FROM_VALUE(args[ARG_initial_sideset_pin_direction].u_int),
342342
args[ARG_sideset_enable].u_bool,
343343
jmp_pin, jmp_pin_pull,
344-
0,
344+
PIO_PINMASK_FROM_VALUE(0), // wait_gpio_mask
345345
args[ARG_exclusive_pin_use].u_bool,
346346
args[ARG_auto_pull].u_bool, pull_threshold, args[ARG_out_shift_right].u_bool,
347347
args[ARG_wait_for_txstall].u_bool,

ports/raspberrypi/bindings/rp2pio/StateMachine.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
2121
size_t frequency,
2222
const uint16_t *init, size_t init_len,
2323
const uint16_t *may_exec, size_t may_exec_len,
24-
const mcu_pin_obj_t *first_out_pin, uint8_t out_pin_count, uint32_t initial_out_pin_state, uint32_t initial_out_pin_direction,
25-
const mcu_pin_obj_t *first_in_pin, uint8_t in_pin_count, uint32_t pull_pin_up, uint32_t pull_pin_down,
26-
const mcu_pin_obj_t *first_set_pin, uint8_t set_pin_count, uint32_t initial_set_pin_state, uint32_t initial_set_pin_direction,
24+
const mcu_pin_obj_t *first_out_pin, uint8_t out_pin_count, pio_pinmask32_t initial_out_pin_state, pio_pinmask32_t initial_out_pin_direction,
25+
const mcu_pin_obj_t *first_in_pin, uint8_t in_pin_count, pio_pinmask32_t in_pull_pin_up, pio_pinmask32_t in_pull_pin_down,
26+
const mcu_pin_obj_t *first_set_pin, uint8_t set_pin_count, pio_pinmask32_t initial_set_pin_state, pio_pinmask32_t initial_set_pin_direction,
2727
const mcu_pin_obj_t *first_sideset_pin, uint8_t sideset_pin_count, bool sideset_pindirs,
28-
uint32_t initial_sideset_pin_state, uint32_t initial_sideset_pin_direction,
28+
pio_pinmask32_t initial_sideset_pin_state, pio_pinmask32_t initial_sideset_pin_direction,
2929
bool sideset_enable,
3030
const mcu_pin_obj_t *jmp_pin, digitalio_pull_t jmp_pin_pull,
31-
uint32_t wait_gpio_mask,
31+
pio_pinmask_t wait_gpio_mask,
3232
bool exclusive_pin_use,
3333
bool auto_pull, uint8_t pull_threshold, bool out_shift_right,
3434
bool wait_for_txstall,

ports/raspberrypi/common-hal/audiobusio/I2SOut.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
184184
44100 * 32 * 6, // Clock at 44.1 khz to warm the DAC up.
185185
NULL, 0, // init
186186
NULL, 0, // may_exec
187-
data, 1, 0, 0xffffffff, // out pin
187+
data, 1, PIO_PINMASK32_NONE, PIO_PINMASK32_ALL, // out pin
188188
NULL, 0, // in pins
189-
0, 0, // in pulls
190-
NULL, 0, 0, 0x1f, // set pins
191-
sideset_pin, 2, false, 0, 0x1f, // sideset pins
189+
PIO_PINMASK32_NONE, PIO_PINMASK32_NONE, // in pulls
190+
NULL, 0, PIO_PINMASK32_NONE, PIO_PINMASK32_FROM_VALUE(0x1f), // set pins
191+
sideset_pin, 2, false, PIO_PINMASK32_NONE, PIO_PINMASK32_FROM_VALUE(0x1f), // sideset pins
192192
false, // No sideset enable
193193
NULL, PULL_NONE, // jump pin
194-
0, // wait gpio pins
194+
PIO_PINMASK_NONE, // wait gpio pins
195195
true, // exclusive pin use
196196
false, 32, false, // shift out left to start with MSB
197197
false, // Wait for txstall

ports/raspberrypi/common-hal/audiobusio/PDMIn.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self,
4646
sample_rate * 32 * 2, // Frequency based on sample rate
4747
NULL, 0,
4848
NULL, 0, // may_exec
49-
NULL, 1, 0, 0xffffffff, // out pin
49+
NULL, 1, PIO_PINMASK32_NONE, PIO_PINMASK32_ALL, // out pin
5050
data_pin, 1, // in pins
51-
0, 0, // in pulls
52-
NULL, 0, 0, 0x1f, // set pins
53-
clock_pin, 1, false, 0, 0x1f, // sideset pins
51+
PIO_PINMASK32_NONE, PIO_PINMASK32_NONE, // in pulls
52+
NULL, 0, PIO_PINMASK32_NONE, PIO_PINMASK32_FROM_VALUE(0x1f), // set pins
53+
clock_pin, 1, false, PIO_PINMASK32_NONE, PIO_PINMASK32_FROM_VALUE(0x1f), // sideset pins
5454
false, // No sideset enable
5555
NULL, PULL_NONE, // jump pin
56-
0, // wait gpio pins
56+
PIO_PINMASK_NONE, // wait gpio pins
5757
true, // exclusive pin use
5858
false, 32, false, // out settings
5959
false, // Wait for txstall

ports/raspberrypi/common-hal/floppyio/__init__.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ int common_hal_floppyio_flux_readinto(void *buf, size_t len, digitalio_digitalin
7777

7878
memset(buf, 0, len);
7979

80-
uint32_t pins_we_use = 1 << data->pin->number;
80+
81+
pio_pinmask_t pins_we_use = PIO_PINMASK_FROM_PIN(data->pin->number);
8182

8283
rp2pio_statemachine_obj_t state_machine;
8384
bool ok = rp2pio_statemachine_construct(&state_machine,
@@ -86,10 +87,10 @@ int common_hal_floppyio_flux_readinto(void *buf, size_t len, digitalio_digitalin
8687
NULL, 0, // init program
8788
NULL, 0, // out
8889
index->pin, 1, // in
89-
1, 0, // in pull up/down
90+
PIO_PINMASK_FROM_PIN(index->pin->number), PIO_PINMASK_FROM_VALUE(0), // pull up/down
9091
NULL, 0, // set
9192
NULL, 0, false, // sideset
92-
0, 0, // initial pin state
93+
PIO_PINMASK_FROM_VALUE(0), PIO_PINMASK_FROM_VALUE(0), // initial pin state
9394
data->pin, // jump pin
9495
pins_we_use, false, true,
9596
true, 32, false, // TX setting we don't use

ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,19 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle
8383
common_hal_mcu_processor_get_frequency(), // full speed (4 instructions per loop -> max pclk 30MHz @ 120MHz)
8484
0, 0, // init
8585
NULL, 0, // may_exec
86-
NULL, 0, 0, 0, // out pins
86+
NULL, 0, PIO_PINMASK32_NONE, PIO_PINMASK32_NONE, // out pins
8787
pin_from_number(data_pins[0]), data_count, // in pins
88-
0, 0, // in pulls
89-
NULL, 0, 0, 0, // set pins
88+
PIO_PINMASK32_NONE, PIO_PINMASK32_NONE, // in pulls
89+
NULL, 0, PIO_PINMASK32_NONE, PIO_PINMASK32_NONE, // set pins
9090
#if DEBUG_STATE_MACHINE
91-
&pin_GPIO26, 3, 7, 7, // sideset pins
91+
&pin_GPIO26, 3, PIO_PINMASK32_FROM_VALUE(7), PIO_PINMASK32_FROM_VALUE(7), // sideset pins
9292
#else
93-
NULL, 0, false, 0, 0, // sideset pins
93+
NULL, 0, false, PIO_PINMASK32_NONE, PIO_PINMASK32_NONE, // sideset pins
9494
#endif
9595
false, // No sideset enable
9696
NULL, PULL_NONE, // jump pin
97-
(1 << vertical_sync->number) | (1 << horizontal_reference->number) | (1 << data_clock->number), // wait gpio pins
97+
PIO_PINMASK_OR3(PIO_PINMASK_FROM_PIN(vertical_sync->number), PIO_PINMASK_FROM_PIN(horizontal_reference->number), PIO_PINMASK_FROM_PIN(data_clock->number)),
98+
// wait gpio pins
9899
true, // exclusive pin use
99100
false, 32, false, // out settings
100101
false, // wait for txstall

ports/raspberrypi/common-hal/neopixel_write/__init__.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout,
4040

4141
// TODO: Cache the state machine after we create it once. We'll need a way to
4242
// change the pins then though.
43-
uint32_t pins_we_use = 1 << digitalinout->pin->number;
43+
pio_pinmask_t pins_we_use = PIO_PINMASK_FROM_PIN(digitalinout->pin->number);
4444
bool ok = rp2pio_statemachine_construct(&state_machine,
4545
neopixel_program, MP_ARRAY_SIZE(neopixel_program),
4646
12800000, // 12.8MHz, to get appropriate sub-bit times in PIO program.
4747
NULL, 0, // init program
4848
NULL, 1, // out
4949
NULL, 1, // in
50-
0, 0, // in pulls
50+
PIO_PINMASK_NONE, PIO_PINMASK_NONE, // gpio pulls
5151
NULL, 1, // set
5252
digitalinout->pin, 1, false, // sideset
53-
0, pins_we_use, // initial pin state
53+
PIO_PINMASK_NONE, pins_we_use, // initial pin state
5454
NULL, // jump pin
5555
pins_we_use, true, false,
5656
true, 8, false, // TX, auto pull every 8 bits. shift left to output msb first

ports/raspberrypi/common-hal/paralleldisplaybus/ParallelBus.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ void common_hal_paralleldisplaybus_parallelbus_construct(paralleldisplaybus_para
7979
frequency * 2, // frequency multiplied by 2 as 2 PIO instructions
8080
NULL, 0, // init
8181
NULL, 0, // may_exec
82-
data0, 8, 0, 255, // first out pin, # out pins
83-
NULL, 0, 0, 0, // first in pin, # in pins
84-
NULL, 0, 0, 0, // first set pin
85-
write, 1, false, 0, 1, // first sideset pin
82+
data0, 8, PIO_PINMASK32_NONE, PIO_PINMASK32_FROM_VALUE(255), // first out pin, # out pins
83+
NULL, 0, PIO_PINMASK32_NONE, PIO_PINMASK32_NONE, // first in pin, # in pins
84+
NULL, 0, PIO_PINMASK32_NONE, PIO_PINMASK32_NONE, // first set pin
85+
write, 1, false, PIO_PINMASK32_NONE, PIO_PINMASK32_FROM_VALUE(1), // first sideset pin
8686
false, // No sideset enable
8787
NULL, PULL_NONE, // jump pin
88-
0, // wait gpio pins
88+
PIO_PINMASK_NONE, // wait gpio pins
8989
true, // exclusive pin usage
9090
true, 8, true, // TX, auto pull every 8 bits. shift left to output msb first
9191
false, // wait for TX stall

0 commit comments

Comments
 (0)