Use PIO IRQ accessors in PIO I2C example (#164)
* Use PIO IRQ accessors in PIO I2C example
This commit is contained in:
		
							parent
							
								
									fb96fad5a5
								
							
						
					
					
						commit
						498caedd1f
					
				| @ -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); | ||||
|  | ||||
| @ -13,13 +13,13 @@ const int PIO_I2C_NAK_LSB    = 0; | ||||
| 
 | ||||
| 
 | ||||
| bool pio_i2c_check_error(PIO pio, uint sm) { | ||||
|     return !!(pio->irq & (1u << sm)); | ||||
|     return pio_interrupt_get(pio, sm); | ||||
| } | ||||
| 
 | ||||
| void pio_i2c_resume_after_error(PIO pio, uint sm) { | ||||
|     pio_sm_drain_tx_fifo(pio, sm); | ||||
|     pio_sm_exec(pio, sm, (pio->sm[sm].execctrl & PIO_SM0_EXECCTRL_WRAP_BOTTOM_BITS) >> PIO_SM0_EXECCTRL_WRAP_BOTTOM_LSB); | ||||
|     pio->irq = 1u << sm; | ||||
|     pio_interrupt_clear(pio, sm); | ||||
| } | ||||
| 
 | ||||
| void pio_i2c_rx_enable(PIO pio, uint sm, bool en) { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user