Use PIO IRQ accessors in PIO I2C example (#164)

* Use PIO IRQ accessors in PIO I2C example
This commit is contained in:
Luke Wren
2021-11-19 20:22:52 +00:00
committed by GitHub
parent fb96fad5a5
commit 498caedd1f
2 changed files with 7 additions and 6 deletions

View File

@@ -108,10 +108,11 @@ static inline void i2c_program_init(PIO pio, uint sm, uint offset, uint pin_sda,
gpio_set_oeover(pin_scl, GPIO_OVERRIDE_INVERT);
pio_sm_set_pins_with_mask(pio, sm, 0, both_pins);
// Clear IRQ flag before starting
hw_clear_bits(&pio->inte0, 1u << sm);
hw_clear_bits(&pio->inte1, 1u << sm);
pio->irq = 1u << sm;
// Clear IRQ flag before starting, and make sure flag doesn't actually
// assert a system-level interrupt (we're using it as a status flag)
pio_set_irq0_source_enabled(pio, pis_interrupt0 + sm, false);
pio_set_irq1_source_enabled(pio, pis_interrupt0 + sm, false);
pio_interrupt_clear(pio, sm);
// Configure and start SM
pio_sm_init(pio, sm, offset + i2c_offset_entry_point, &c);