rp2pio: Add pull up/down support for the "jmp pin"
This is needed so that the floppy flux reader can enable the pull up on the index pin while using it as a pio jmp pin. Also fixes a doc bug where the `jmp_pin` was omitted in one spot in the docs.
This commit is contained in:
parent
8e895e1986
commit
bf57f3606a
@ -79,6 +79,8 @@
|
||||
//| initial_sideset_pin_state: int = 0,
|
||||
//| initial_sideset_pin_direction: int = 0x1f,
|
||||
//| sideset_enable: bool = False,
|
||||
//| jmp_pin: Optional[microcontroller.Pin] = None,
|
||||
//| jmp_pin_pull: Optional[digitalio.Pull] = None,
|
||||
//| exclusive_pin_use: bool = True,
|
||||
//| auto_pull: bool = False,
|
||||
//| pull_threshold: int = 32,
|
||||
@ -113,6 +115,7 @@
|
||||
//| :param int initial_sideset_pin_direction: the initial output direction for sideset pins starting at first_sideset_pin
|
||||
//| :param bool sideset_enable: True when the top sideset bit is to enable. This should be used with the ".side_set # opt" directive
|
||||
//| :param ~microcontroller.Pin jmp_pin: the pin which determines the branch taken by JMP PIN instructions
|
||||
//| :param ~digitalio.Pull jmp_pin_pull: The pull value for the jmp pin, default is no pull.
|
||||
//| :param bool exclusive_pin_use: When True, do not share any pins with other state machines. Pins are never shared with other peripherals
|
||||
//| :param bool auto_pull: When True, automatically load data from the tx FIFO into the
|
||||
//| output shift register (OSR) when an OUT instruction shifts more than pull_threshold bits
|
||||
@ -150,7 +153,7 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n
|
||||
ARG_first_set_pin, ARG_set_pin_count, ARG_initial_set_pin_state, ARG_initial_set_pin_direction,
|
||||
ARG_first_sideset_pin, ARG_sideset_pin_count, ARG_initial_sideset_pin_state, ARG_initial_sideset_pin_direction,
|
||||
ARG_sideset_enable,
|
||||
ARG_jmp_pin,
|
||||
ARG_jmp_pin, ARG_jmp_pin_pull,
|
||||
ARG_exclusive_pin_use,
|
||||
ARG_auto_pull, ARG_pull_threshold, ARG_out_shift_right,
|
||||
ARG_wait_for_txstall,
|
||||
@ -184,6 +187,7 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n
|
||||
{ MP_QSTR_sideset_enable, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
|
||||
|
||||
{ MP_QSTR_jmp_pin, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_jmp_pin_pull, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
|
||||
{ MP_QSTR_exclusive_pin_use, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
|
||||
{ MP_QSTR_auto_pull, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
|
||||
@ -230,6 +234,7 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n
|
||||
}
|
||||
|
||||
const mcu_pin_obj_t *jmp_pin = validate_obj_is_pin_or_none(args[ARG_jmp_pin].u_obj);
|
||||
digitalio_pull_t jmp_pin_pull = validate_pull(args[ARG_jmp_pin_pull].u_rom_obj, MP_QSTR_jmp_pull);
|
||||
|
||||
mp_int_t pull_threshold = args[ARG_pull_threshold].u_int;
|
||||
mp_int_t push_threshold = args[ARG_push_threshold].u_int;
|
||||
@ -263,7 +268,7 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n
|
||||
first_set_pin, args[ARG_set_pin_count].u_int, args[ARG_initial_set_pin_state].u_int, args[ARG_initial_set_pin_direction].u_int,
|
||||
first_sideset_pin, args[ARG_sideset_pin_count].u_int, args[ARG_initial_sideset_pin_state].u_int, args[ARG_initial_sideset_pin_direction].u_int,
|
||||
args[ARG_sideset_enable].u_bool,
|
||||
jmp_pin,
|
||||
jmp_pin, jmp_pin_pull,
|
||||
0,
|
||||
args[ARG_exclusive_pin_use].u_bool,
|
||||
args[ARG_auto_pull].u_bool, pull_threshold, args[ARG_out_shift_right].u_bool,
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
#include "shared-bindings/digitalio/Pull.h"
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "common-hal/rp2pio/StateMachine.h"
|
||||
|
||||
@ -45,7 +46,7 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
|
||||
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,
|
||||
const mcu_pin_obj_t *first_sideset_pin, uint8_t sideset_pin_count, uint32_t initial_sideset_pin_state, uint32_t initial_sideset_pin_direction,
|
||||
bool sideset_enable,
|
||||
const mcu_pin_obj_t *jmp_pin,
|
||||
const mcu_pin_obj_t *jmp_pin, digitalio_pull_t jmp_pin_pull,
|
||||
uint32_t wait_gpio_mask,
|
||||
bool exclusive_pin_use,
|
||||
bool auto_pull, uint8_t pull_threshold, bool out_shift_right,
|
||||
|
@ -127,7 +127,7 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
|
||||
0, 0, // in pulls
|
||||
NULL, 0, 0, 0x1f, // set pins
|
||||
bit_clock, 2, 0, 0x1f, // sideset pins
|
||||
NULL, // jump pin
|
||||
NULL, PULL_NONE, // jump pin
|
||||
0, // wait gpio pins
|
||||
true, // exclusive pin use
|
||||
false, 32, false, // shift out left to start with MSB
|
||||
|
@ -71,7 +71,7 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self,
|
||||
0, 0, // in pulls
|
||||
NULL, 0, 0, 0x1f, // set pins
|
||||
clock_pin, 1, 0, 0x1f, // sideset pins
|
||||
NULL, // jump pin
|
||||
NULL, PULL_NONE, // jump pin
|
||||
0, // wait gpio pins
|
||||
true, // exclusive pin use
|
||||
false, 32, false, // out settings
|
||||
|
@ -112,7 +112,7 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle
|
||||
NULL, 0, 0, 0, // sideset pins
|
||||
#endif
|
||||
false, // No sideset enable
|
||||
NULL, // jump pin
|
||||
NULL, PULL_NONE, // jump pin
|
||||
(1 << vertical_sync->number) | (1 << horizontal_reference->number) | (1 << data_clock->number), // wait gpio pins
|
||||
true, // exclusive pin use
|
||||
false, 32, false, // out settings
|
||||
|
@ -100,7 +100,7 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu
|
||||
NULL, 0, 0, 0, // first set pin
|
||||
write, 1, 0, 1, // first sideset pin
|
||||
false, // No sideset enable
|
||||
NULL, // jump pin
|
||||
NULL, PULL_NONE, // jump pin
|
||||
0, // wait gpio pins
|
||||
true, // exclusive pin usage
|
||||
true, 8, true, // TX, auto pull every 8 bits. shift left to output msb first
|
||||
|
@ -86,7 +86,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode
|
||||
NULL, 0, 0, 0x1f, // set pins
|
||||
NULL, 0, 0, 0x1f, // sideset pins
|
||||
false, // No sideset enable
|
||||
NULL, // jump pin
|
||||
NULL, PULL_NONE, // jump pin
|
||||
0, // wait gpio pins
|
||||
true, // exclusive pin use
|
||||
false, 32, false, // out settings
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "bindings/rp2pio/StateMachine.h"
|
||||
|
||||
#include "common-hal/microcontroller/__init__.h"
|
||||
#include "shared-bindings/digitalio/Pull.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
@ -342,7 +343,7 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
|
||||
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,
|
||||
const mcu_pin_obj_t *first_sideset_pin, uint8_t sideset_pin_count, uint32_t initial_sideset_pin_state, uint32_t initial_sideset_pin_direction,
|
||||
bool sideset_enable,
|
||||
const mcu_pin_obj_t *jmp_pin,
|
||||
const mcu_pin_obj_t *jmp_pin, digitalio_pull_t jmp_pull,
|
||||
uint32_t wait_gpio_mask,
|
||||
bool exclusive_pin_use,
|
||||
bool auto_pull, uint8_t pull_threshold, bool out_shift_right,
|
||||
@ -489,6 +490,16 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
|
||||
// Deal with pull up/downs
|
||||
uint32_t pull_up = mask_and_rotate(first_in_pin, in_pin_count, pull_pin_up);
|
||||
uint32_t pull_down = mask_and_rotate(first_in_pin, in_pin_count, pull_pin_down);
|
||||
|
||||
if (jmp_pin) {
|
||||
uint32_t jmp_mask = mask_and_rotate(jmp_pin, 1, 0x1f);
|
||||
if (jmp_pull == PULL_UP) {
|
||||
pull_up |= jmp_mask;
|
||||
}
|
||||
if (jmp_pull == PULL_DOWN) {
|
||||
pull_up |= jmp_mask;
|
||||
}
|
||||
}
|
||||
if (initial_pin_direction & (pull_up | pull_down)) {
|
||||
mp_raise_ValueError(translate("pull masks conflict with direction masks"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user