mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 17:17:36 +08:00
Safeguard against back-to-back transactions while setting up to handle a register read request.
This commit is contained in:
@@ -242,6 +242,7 @@ i2c_rx_complete(void)
|
||||
uint16_t *regs;
|
||||
unsigned reg_count;
|
||||
|
||||
/* work out which registers are being addressed */
|
||||
int ret = registers_get(selected_page, selected_offset, ®s, ®_count);
|
||||
if (ret == 0) {
|
||||
tx_buf = (uint8_t *)regs;
|
||||
@@ -250,6 +251,14 @@ i2c_rx_complete(void)
|
||||
tx_buf = junk_buf;
|
||||
tx_len = sizeof(junk_buf);
|
||||
}
|
||||
|
||||
/* disable interrupts while reconfiguring DMA for the selected registers */
|
||||
irqstate_t flags = irqsave();
|
||||
|
||||
stm32_dmastop(tx_dma);
|
||||
i2c_tx_setup();
|
||||
|
||||
irqrestore(flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,9 +80,9 @@ volatile uint16_t r_page_controls[PX4IO_CONTROL_CHANNELS];
|
||||
* Static configuration parameters.
|
||||
*/
|
||||
static const uint16_t r_page_config[] = {
|
||||
[PX4IO_P_CONFIG_PROTOCOL_VERSION] = 0,
|
||||
[PX4IO_P_CONFIG_SOFTWARE_VERSION] = 0,
|
||||
[PX4IO_P_CONFIG_BOOTLOADER_VERSION] = 0,
|
||||
[PX4IO_P_CONFIG_PROTOCOL_VERSION] = 1, /* XXX hardcoded magic number */
|
||||
[PX4IO_P_CONFIG_SOFTWARE_VERSION] = 1, /* XXX hardcoded magic number */
|
||||
[PX4IO_P_CONFIG_BOOTLOADER_VERSION] = 3, /* XXX hardcoded magic number */
|
||||
[PX4IO_P_CONFIG_MAX_TRANSFER] = 64, /* XXX hardcoded magic number */
|
||||
[PX4IO_P_CONFIG_CONTROL_COUNT] = PX4IO_CONTROL_CHANNELS,
|
||||
[PX4IO_P_CONFIG_ACTUATOR_COUNT] = IO_SERVO_COUNT,
|
||||
|
||||
Reference in New Issue
Block a user