rp2pio: Add sideset_pindirs parameter to StateMachine constructor
This allows use of PIO programs that need to control pin *direction* from the side set portion of the instruction.
This commit is contained in:
parent
68cdc535b2
commit
92eb0edc9d
12 changed files with 23 additions and 16 deletions
|
|
@ -64,6 +64,7 @@
|
|||
//| initial_set_pin_direction: int = 0x1F,
|
||||
//| first_sideset_pin: Optional[microcontroller.Pin] = None,
|
||||
//| sideset_pin_count: int = 1,
|
||||
//| sideset_pindirs: bool = False,
|
||||
//| initial_sideset_pin_state: int = 0,
|
||||
//| initial_sideset_pin_direction: int = 0x1F,
|
||||
//| sideset_enable: bool = False,
|
||||
|
|
@ -133,6 +134,7 @@
|
|||
//| :param int in_pin_count: the count of consecutive pins to use with IN starting at first_in_pin
|
||||
//| :param int set_pin_count: the count of consecutive pins to use with SET starting at first_set_pin
|
||||
//| :param int sideset_pin_count: the count of consecutive pins to use with a side set starting at first_sideset_pin. Does not include sideset enable
|
||||
//| :param bool sideset_pindirs: `True` to indicate that the side set values should be applied to the PINDIRs and not the PINs
|
||||
//| :param int pio_version: The version of the PIO peripheral required by the program. The constructor will raise an error if the actual hardware is not compatible with this program version.
|
||||
//| :param bool auto_push: When True, automatically save data from input shift register
|
||||
//| (ISR) into the rx FIFO when an IN instruction shifts more than push_threshold bits
|
||||
|
|
@ -173,7 +175,8 @@ static mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n
|
|||
ARG_first_in_pin, ARG_in_pin_count,
|
||||
ARG_pull_in_pin_up, ARG_pull_in_pin_down,
|
||||
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_first_sideset_pin, ARG_sideset_pin_count, ARG_sideset_pindirs,
|
||||
ARG_initial_sideset_pin_state, ARG_initial_sideset_pin_direction,
|
||||
ARG_sideset_enable,
|
||||
ARG_jmp_pin, ARG_jmp_pin_pull,
|
||||
ARG_exclusive_pin_use,
|
||||
|
|
@ -211,6 +214,7 @@ static mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n
|
|||
|
||||
{ MP_QSTR_first_sideset_pin, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_sideset_pin_count, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} },
|
||||
{ MP_QSTR_sideset_pindirs, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
|
||||
{ MP_QSTR_initial_sideset_pin_state, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
|
||||
{ MP_QSTR_initial_sideset_pin_direction, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0x1f} },
|
||||
|
||||
|
|
@ -329,7 +333,8 @@ static mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n
|
|||
first_out_pin, out_pin_count, args[ARG_initial_out_pin_state].u_int, args[ARG_initial_out_pin_direction].u_int,
|
||||
first_in_pin, in_pin_count, args[ARG_pull_in_pin_up].u_int, args[ARG_pull_in_pin_down].u_int,
|
||||
first_set_pin, set_pin_count, args[ARG_initial_set_pin_state].u_int, args[ARG_initial_set_pin_direction].u_int,
|
||||
first_sideset_pin, sideset_pin_count, args[ARG_initial_sideset_pin_state].u_int, args[ARG_initial_sideset_pin_direction].u_int,
|
||||
first_sideset_pin, sideset_pin_count, args[ARG_sideset_pindirs].u_bool,
|
||||
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_pull,
|
||||
0,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
|
|||
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,
|
||||
const mcu_pin_obj_t *first_in_pin, uint8_t in_pin_count, uint32_t pull_pin_up, uint32_t pull_pin_down,
|
||||
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,
|
||||
const mcu_pin_obj_t *first_sideset_pin, uint8_t sideset_pin_count, bool sideset_pindirs,
|
||||
uint32_t initial_sideset_pin_state, uint32_t initial_sideset_pin_direction,
|
||||
bool sideset_enable,
|
||||
const mcu_pin_obj_t *jmp_pin, digitalio_pull_t jmp_pin_pull,
|
||||
uint32_t wait_gpio_mask,
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
|
|||
NULL, 0, // in pins
|
||||
0, 0, // in pulls
|
||||
NULL, 0, 0, 0x1f, // set pins
|
||||
sideset_pin, 2, 0, 0x1f, // sideset pins
|
||||
sideset_pin, 2, false, 0, 0x1f, // sideset pins
|
||||
false, // No sideset enable
|
||||
NULL, PULL_NONE, // jump pin
|
||||
0, // wait gpio pins
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self,
|
|||
data_pin, 1, // in pins
|
||||
0, 0, // in pulls
|
||||
NULL, 0, 0, 0x1f, // set pins
|
||||
clock_pin, 1, 0, 0x1f, // sideset pins
|
||||
clock_pin, 1, false, 0, 0x1f, // sideset pins
|
||||
false, // No sideset enable
|
||||
NULL, PULL_NONE, // jump pin
|
||||
0, // wait gpio pins
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ int common_hal_floppyio_flux_readinto(void *buf, size_t len, digitalio_digitalin
|
|||
index->pin, 1, // in
|
||||
1, 0, // in pull up/down
|
||||
NULL, 0, // set
|
||||
NULL, 0, // sideset
|
||||
NULL, 0, false, // sideset
|
||||
0, 0, // initial pin state
|
||||
data->pin, // jump pin
|
||||
pins_we_use, false, true,
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle
|
|||
#if DEBUG_STATE_MACHINE
|
||||
&pin_GPIO26, 3, 7, 7, // sideset pins
|
||||
#else
|
||||
NULL, 0, 0, 0, // sideset pins
|
||||
NULL, 0, false, 0, 0, // sideset pins
|
||||
#endif
|
||||
false, // No sideset enable
|
||||
NULL, PULL_NONE, // jump pin
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout,
|
|||
NULL, 1, // in
|
||||
0, 0, // in pulls
|
||||
NULL, 1, // set
|
||||
digitalinout->pin, 1, // sideset
|
||||
digitalinout->pin, 1, false, // sideset
|
||||
0, pins_we_use, // initial pin state
|
||||
NULL, // jump pin
|
||||
pins_we_use, true, false,
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ void common_hal_paralleldisplaybus_parallelbus_construct(paralleldisplaybus_para
|
|||
data0, 8, 0, 255, // first out pin, # out pins
|
||||
NULL, 0, 0, 0, // first in pin, # in pins
|
||||
NULL, 0, 0, 0, // first set pin
|
||||
write, 1, 0, 1, // first sideset pin
|
||||
write, 1, false, 0, 1, // first sideset pin
|
||||
false, // No sideset enable
|
||||
NULL, PULL_NONE, // jump pin
|
||||
0, // wait gpio pins
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
|
|||
NULL, 0, 0, 0, // first out pin, # out pins, initial_out_pin_state
|
||||
pin, 1, 0, 0, // first in pin, # in pins
|
||||
NULL, 0, 0, 0, // first set pin
|
||||
NULL, 0, 0, 0, // first sideset pin
|
||||
NULL, 0, false, 0, 0, // first sideset pin
|
||||
false, // No sideset enable
|
||||
NULL, PULL_NONE, // jump pin, jmp_pull
|
||||
0, // wait gpio pins
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode
|
|||
pins[0], 2, // in pins
|
||||
3, 0, // in pulls
|
||||
NULL, 0, 0, 0x1f, // set pins
|
||||
NULL, 0, 0, 0x1f, // sideset pins
|
||||
NULL, 0, false, 0, 0x1f, // sideset pins
|
||||
false, // No sideset enable
|
||||
NULL, PULL_NONE, // jump pin
|
||||
0, // wait gpio pins
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ bool rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
|
|||
const mcu_pin_obj_t *first_in_pin, uint8_t in_pin_count,
|
||||
uint32_t pull_pin_up, uint32_t pull_pin_down,
|
||||
const mcu_pin_obj_t *first_set_pin, uint8_t set_pin_count,
|
||||
const mcu_pin_obj_t *first_sideset_pin, uint8_t sideset_pin_count,
|
||||
const mcu_pin_obj_t *first_sideset_pin, uint8_t sideset_pin_count, bool sideset_pindirs,
|
||||
uint32_t initial_pin_state, uint32_t initial_pin_direction,
|
||||
const mcu_pin_obj_t *jmp_pin,
|
||||
uint32_t pins_we_use, bool tx_fifo, bool rx_fifo,
|
||||
|
|
@ -390,7 +390,7 @@ bool rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
|
|||
if (sideset_enable) {
|
||||
total_sideset_bits += 1;
|
||||
}
|
||||
sm_config_set_sideset(&c, total_sideset_bits, sideset_enable, false /* pin direction */);
|
||||
sm_config_set_sideset(&c, total_sideset_bits, sideset_enable, sideset_pindirs);
|
||||
sm_config_set_sideset_pins(&c, first_sideset_pin->number);
|
||||
}
|
||||
if (jmp_pin != NULL) {
|
||||
|
|
@ -593,7 +593,8 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
|
|||
const mcu_pin_obj_t *first_in_pin, uint8_t in_pin_count,
|
||||
uint32_t pull_pin_up, uint32_t pull_pin_down,
|
||||
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,
|
||||
const mcu_pin_obj_t *first_sideset_pin, uint8_t sideset_pin_count, bool sideset_pindirs,
|
||||
uint32_t initial_sideset_pin_state, uint32_t initial_sideset_pin_direction,
|
||||
bool sideset_enable,
|
||||
const mcu_pin_obj_t *jmp_pin, digitalio_pull_t jmp_pull,
|
||||
uint32_t wait_gpio_mask,
|
||||
|
|
@ -687,7 +688,7 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
|
|||
first_in_pin, in_pin_count,
|
||||
pull_up, pull_down,
|
||||
first_set_pin, set_pin_count,
|
||||
first_sideset_pin, sideset_pin_count,
|
||||
first_sideset_pin, sideset_pin_count, sideset_pindirs,
|
||||
initial_pin_state, initial_pin_direction,
|
||||
jmp_pin,
|
||||
pins_we_use, state.outputs.tx_fifo, state.outputs.rx_fifo,
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ bool rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
|
|||
const mcu_pin_obj_t *first_in_pin, uint8_t in_pin_count,
|
||||
uint32_t pull_pin_up, uint32_t pull_pin_down,
|
||||
const mcu_pin_obj_t *first_set_pin, uint8_t set_pin_count,
|
||||
const mcu_pin_obj_t *first_sideset_pin, uint8_t sideset_pin_count,
|
||||
const mcu_pin_obj_t *first_sideset_pin, uint8_t sideset_pin_count, bool sideset_pindirs,
|
||||
uint32_t initial_pin_state, uint32_t initial_pin_direction,
|
||||
const mcu_pin_obj_t *jmp_pin,
|
||||
uint32_t pins_we_use, bool tx_fifo, bool rx_fifo,
|
||||
|
|
|
|||
Loading…
Reference in a new issue