mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
AP_HAL_Linux: AnalogIn_Raspilot: rename misleading variables
We are not doing any dma here, it's just an SPI transaction. Name them only rx/tx (although io_packet_tx/io_packet_rx could be another option). This also zero-initialize the struct to keep valgrind happy about not calling ioctl() with uninitialized variables.
This commit is contained in:
parent
0cff40ed7b
commit
a3cac102cd
@ -100,26 +100,26 @@ void RaspilotAnalogIn::_update()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IOPacket _dma_packet_tx, _dma_packet_rx;
|
struct IOPacket tx = { }, rx = { };
|
||||||
uint16_t count = RASPILOT_ADC_MAX_CHANNELS;
|
uint16_t count = RASPILOT_ADC_MAX_CHANNELS;
|
||||||
_dma_packet_tx.count_code = count | PKT_CODE_READ;
|
tx.count_code = count | PKT_CODE_READ;
|
||||||
_dma_packet_tx.page = PX4IO_PAGE_RAW_ADC_INPUT;
|
tx.page = PX4IO_PAGE_RAW_ADC_INPUT;
|
||||||
_dma_packet_tx.offset = 0;
|
tx.offset = 0;
|
||||||
_dma_packet_tx.crc = 0;
|
tx.crc = 0;
|
||||||
_dma_packet_tx.crc = crc_packet(&_dma_packet_tx);
|
tx.crc = crc_packet(&tx);
|
||||||
/* set raspilotio to read reg4 */
|
/* set raspilotio to read reg4 */
|
||||||
_spi->transaction((uint8_t *)&_dma_packet_tx, (uint8_t *)&_dma_packet_rx, sizeof(_dma_packet_tx));
|
_spi->transaction((uint8_t *)&tx, (uint8_t *)&rx, sizeof(tx));
|
||||||
|
|
||||||
hal.scheduler->delay_microseconds(200);
|
hal.scheduler->delay_microseconds(200);
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
_dma_packet_tx.count_code = count | PKT_CODE_READ;
|
tx.count_code = count | PKT_CODE_READ;
|
||||||
_dma_packet_tx.page = 0;
|
tx.page = 0;
|
||||||
_dma_packet_tx.offset = 0;
|
tx.offset = 0;
|
||||||
_dma_packet_tx.crc = 0;
|
tx.crc = 0;
|
||||||
_dma_packet_tx.crc = crc_packet(&_dma_packet_tx);
|
tx.crc = crc_packet(&tx);
|
||||||
/* get reg4 data from raspilotio */
|
/* get reg4 data from raspilotio */
|
||||||
_spi->transaction((uint8_t *)&_dma_packet_tx, (uint8_t *)&_dma_packet_rx, sizeof(_dma_packet_tx));
|
_spi->transaction((uint8_t *)&tx, (uint8_t *)&rx, sizeof(tx));
|
||||||
|
|
||||||
_spi_sem->give();
|
_spi_sem->give();
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ void RaspilotAnalogIn::_update()
|
|||||||
AnalogSource_Raspilot *source = _channels[j];
|
AnalogSource_Raspilot *source = _channels[j];
|
||||||
|
|
||||||
if (source != NULL && i == source->_pin) {
|
if (source != NULL && i == source->_pin) {
|
||||||
source->_value = _dma_packet_rx.regs[i] * 3.3 / 4096.0;
|
source->_value = rx.regs[i] * 3.3 / 4096.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user