Small doc/example changes
* Use PIO IRQ accessors in PIO I2C example * Update pio/ir_nec/README.adoc file links (#183) The "List of Files" now links (only) to files, not to directories (which prevented this example being included in the C SDK databook)
This commit is contained in:
parent
188d849b1f
commit
afd1d2008f
@ -117,7 +117,8 @@ void bmp280_read_raw(int32_t* temp, int32_t* pressure) {
|
|||||||
// note: normal mode does not require further ctrl_meas and config register writes
|
// note: normal mode does not require further ctrl_meas and config register writes
|
||||||
|
|
||||||
uint8_t buf[6];
|
uint8_t buf[6];
|
||||||
i2c_write_blocking(i2c_default, ADDR, (uint8_t*)REG_PRESSURE_MSB, 1, true); // true to keep master control of bus
|
uint8_t reg = REG_PRESSURE_MSB;
|
||||||
|
i2c_write_blocking(i2c_default, ADDR, ®, 1, true); // true to keep master control of bus
|
||||||
i2c_read_blocking(i2c_default, ADDR, buf, 6, false); // false - finished with bus
|
i2c_read_blocking(i2c_default, ADDR, buf, 6, false); // false - finished with bus
|
||||||
|
|
||||||
// store the 20 bit read in a 32 bit signed integer for conversion
|
// store the 20 bit read in a 32 bit signed integer for conversion
|
||||||
@ -184,7 +185,8 @@ void bmp280_get_calib_params(struct bmp280_calib_param* params) {
|
|||||||
// and MSB register, so we read from 24 registers
|
// and MSB register, so we read from 24 registers
|
||||||
|
|
||||||
uint8_t buf[NUM_CALIB_PARAMS] = { 0 };
|
uint8_t buf[NUM_CALIB_PARAMS] = { 0 };
|
||||||
i2c_write_blocking(i2c_default, ADDR, (uint8_t*)REG_DIG_T1_LSB, 1, true); // true to keep master control of bus
|
uint8_t reg = REG_DIG_T1_LSB;
|
||||||
|
i2c_write_blocking(i2c_default, ADDR, ®, 1, true); // true to keep master control of bus
|
||||||
// read in one go as register addresses auto-increment
|
// read in one go as register addresses auto-increment
|
||||||
i2c_read_blocking(i2c_default, ADDR, buf, NUM_CALIB_PARAMS, false); // false, we're done reading
|
i2c_read_blocking(i2c_default, ADDR, buf, NUM_CALIB_PARAMS, false); // false, we're done reading
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
gpio_set_oeover(pin_scl, GPIO_OVERRIDE_INVERT);
|
||||||
pio_sm_set_pins_with_mask(pio, sm, 0, both_pins);
|
pio_sm_set_pins_with_mask(pio, sm, 0, both_pins);
|
||||||
|
|
||||||
// Clear IRQ flag before starting
|
// Clear IRQ flag before starting, and make sure flag doesn't actually
|
||||||
hw_clear_bits(&pio->inte0, 1u << sm);
|
// assert a system-level interrupt (we're using it as a status flag)
|
||||||
hw_clear_bits(&pio->inte1, 1u << sm);
|
pio_set_irq0_source_enabled(pio, pis_interrupt0 + sm, false);
|
||||||
pio->irq = 1u << sm;
|
pio_set_irq1_source_enabled(pio, pis_interrupt0 + sm, false);
|
||||||
|
pio_interrupt_clear(pio, sm);
|
||||||
|
|
||||||
// Configure and start SM
|
// Configure and start SM
|
||||||
pio_sm_init(pio, sm, offset + i2c_offset_entry_point, &c);
|
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) {
|
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) {
|
void pio_i2c_resume_after_error(PIO pio, uint sm) {
|
||||||
pio_sm_drain_tx_fifo(pio, 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_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) {
|
void pio_i2c_rx_enable(PIO pio, uint sm, bool en) {
|
||||||
|
|||||||
@ -26,20 +26,17 @@ After a successful build the executable program can be found in the **build/ir_l
|
|||||||
== List of Files
|
== List of Files
|
||||||
|
|
||||||
CMakeLists.txt:: CMake file to incorporate the example in to the examples build tree.
|
CMakeLists.txt:: CMake file to incorporate the example in to the examples build tree.
|
||||||
ir_loopback:: A directory containing the code for the loopback example.
|
ir_loopback/CMakeLists.txt:: CMake file to incorporate the loopback example in to the examples build tree.
|
||||||
CMakeLists.txt::: CMake file to incorporate the example in to the examples build tree.
|
ir_loopback/ir_loopback.c:: The code for the loopback example.
|
||||||
ir_loopback.c::: The code for the loopback example.
|
nec_receive_library/CMakeLists.txt:: CMake file to incorporate the IR receive library in to the examples build tree.
|
||||||
nec_receive_library:: A directory containing the code for the IR receive functions.
|
nec_receive_library/nec_receive.c:: The source code for the IR receive functions.
|
||||||
CMakeLists.txt::: CMake file to incorporate the IR receive library in to the examples build tree.
|
nec_receive_library/nec_receive.h:: The headers for the IR receive functions.
|
||||||
nec_receive.c::: The source code for the IR receive functions.
|
nec_receive_library/nec_receive.pio:: The PIO assembler code to receive a frame.
|
||||||
nec_receive.h::: The headers for the IR receive functions.
|
nec_transmit_library/CMakeLists.txt:: CMake file to incorporate the IR transmit library in to the examples build tree.
|
||||||
nec_receive.pio::: The PIO assembler code to receive a frame.
|
nec_transmit_library/nec_transmit.c:: The source code for the IR transmit functions.
|
||||||
nec_transmit_library:: A directory containing the code for the IR transmit functions.
|
nec_transmit_library/nec_transmit.h:: The headers for the IR transmit functions.
|
||||||
CMakeLists.txt::: CMake file to incorporate the IR transmit library in to the examples build tree.
|
nec_transmit_library/nec_carrier_burst.pio:: The PIO assembler code to generate a carrier burst.
|
||||||
nec_transmit.c::: The source code for the IR transmit functions.
|
nec_transmit_library/nec_carrier_control.pio:: The PIO assembler code to transmit a complete frame.
|
||||||
nec_transmit.h::: The headers for the IR transmit functions.
|
|
||||||
nec_carrier_burst.pio::: The PIO assembler code to generate a carrier burst.
|
|
||||||
nec_carrier_control.pio::: The PIO assembler code to transmit a complete frame.
|
|
||||||
|
|
||||||
== Bill of Materials
|
== Bill of Materials
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user