Skip to content

Commit

Permalink
fix bug in sm_config_set_in_pin_count (#1880)
Browse files Browse the repository at this point in the history
* fix bug in sm_config_set_in_pin_count

* comment updates
  • Loading branch information
kilograham authored Aug 29, 2024
1 parent 2d60604 commit 91864a0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/rp2_common/hardware_pio/include/hardware/pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,19 @@ static inline void sm_config_set_in_pins(pio_sm_config *c, uint in_base) {
sm_config_set_in_pin_base(c, in_base);
}

/*! \brief Set the count of 'in' pins in a state machine configuration
* \ingroup sm_config
*
* When reading pins using the IN pin mapping, this many (low) bits will be read, with the rest taking
* the value zero.
*
* \if rp2040_specific
* RP2040 does not have the ability to mask unused input pins, so the in_count must be 32
* \endif
*
* \param c Pointer to the configuration structure to modify
* \param in_count 1-32 The number of pins to include when reading via the IN pin mapping
*/
static inline void sm_config_set_in_pin_count(pio_sm_config *c, uint in_count) {
#if PICO_PIO_VERSION == 0
// can't be changed from 32 on PIO v0
Expand All @@ -390,7 +403,7 @@ static inline void sm_config_set_in_pin_count(pio_sm_config *c, uint in_count) {
#else
valid_params_if(HARDWARE_PIO, in_count && in_count <= 32);
c->shiftctrl = (c->shiftctrl & ~PIO_SM0_SHIFTCTRL_IN_COUNT_BITS) |
((in_count - 1) << PIO_SM0_SHIFTCTRL_IN_COUNT_LSB);
((in_count & 0x1fu) << PIO_SM0_SHIFTCTRL_IN_COUNT_LSB);
#endif
}

Expand Down Expand Up @@ -634,7 +647,7 @@ static inline void sm_config_set_mov_status(pio_sm_config *c, enum pio_mov_statu
* --------|--------
* Out Pins | 32 starting at 0
* Set Pins | 0 starting at 0
* In Pins (base) | 0
* In Pins | 32 starting at 0
* Side Set Pins (base) | 0
* Side Set | disabled
* Wrap | wrap=31, wrap_to=0
Expand Down

0 comments on commit 91864a0

Please sign in to comment.