Skip to content

Commit ccbd07c

Browse files
authored
add extra assertions to pio.h (earlephilhower#2211)
* add extra assertions to pio.h * add another assert * minor clarifications
1 parent 0c2de5d commit ccbd07c

File tree

1 file changed

+12
-1
lines changed
  • src/rp2_common/hardware_pio/include/hardware

1 file changed

+12
-1
lines changed

src/rp2_common/hardware_pio/include/hardware/pio.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ typedef pio_hw_t *PIO;
172172
*/
173173
#ifndef PIO_NUM
174174
static_assert(PIO1_BASE - PIO0_BASE == (1u << 20), "hardware layout mismatch");
175+
#if NUM_PIOS > 2
176+
static_assert(PIO2_BASE - PIO0_BASE == (2u << 20), "hardware layout mismatch");
177+
#endif
175178
#define PIO_NUM(pio) (((uintptr_t)(pio) - PIO0_BASE) >> 20)
176179
#endif
177180

@@ -185,6 +188,9 @@ static_assert(PIO1_BASE - PIO0_BASE == (1u << 20), "hardware layout mismatch");
185188
*/
186189
#ifndef PIO_INSTANCE
187190
static_assert(PIO1_BASE - PIO0_BASE == (1u << 20), "hardware layout mismatch");
191+
#if NUM_PIOS > 2
192+
static_assert(PIO2_BASE - PIO0_BASE == (2u << 20), "hardware layout mismatch");
193+
#endif
188194
#define PIO_INSTANCE(instance) ((pio_hw_t *)(PIO0_BASE + (instance) * (1u << 20)))
189195
#endif
190196

@@ -214,8 +220,13 @@ static_assert(DREQ_PIO0_TX1 == DREQ_PIO0_TX0 + 1, "");
214220
static_assert(DREQ_PIO0_TX2 == DREQ_PIO0_TX0 + 2, "");
215221
static_assert(DREQ_PIO0_TX3 == DREQ_PIO0_TX0 + 3, "");
216222
static_assert(DREQ_PIO0_RX0 == DREQ_PIO0_TX0 + NUM_PIO_STATE_MACHINES, "");
223+
static_assert(DREQ_PIO1_TX0 == DREQ_PIO0_RX0 + NUM_PIO_STATE_MACHINES, "");
217224
static_assert(DREQ_PIO1_RX0 == DREQ_PIO1_TX0 + NUM_PIO_STATE_MACHINES, "");
218-
#define PIO_DREQ_NUM(pio, sm, is_tx) ((sm) + (((is_tx) ? 0 : NUM_PIO_STATE_MACHINES) + PIO_NUM(pio) * (DREQ_PIO1_TX0 - DREQ_PIO0_TX0)))
225+
#if NUM_PIOS > 2
226+
static_assert(DREQ_PIO2_TX0 == DREQ_PIO1_RX0 + NUM_PIO_STATE_MACHINES, "");
227+
static_assert(DREQ_PIO2_RX0 == DREQ_PIO2_TX0 + NUM_PIO_STATE_MACHINES, "");
228+
#endif
229+
#define PIO_DREQ_NUM(pio, sm, is_tx) (DREQ_PIO0_TX0 + (sm) + (((is_tx) ? 0 : NUM_PIO_STATE_MACHINES) + PIO_NUM(pio) * (DREQ_PIO1_TX0 - DREQ_PIO0_TX0)))
219230
#endif
220231

221232
/**

0 commit comments

Comments
 (0)