mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
ina228: fix sign error on CURRENT reading (#19296)
This commit is contained in:
parent
b7e0f17c6a
commit
3e21efb721
@ -124,7 +124,12 @@ int INA228::read(uint8_t address, int32_t &data)
|
||||
const int ret = transfer(&address, 1, (uint8_t *)&received_bytes, sizeof(received_bytes) - 1);
|
||||
|
||||
if (ret == PX4_OK) {
|
||||
data = swap32(received_bytes) >> ((32 - 24) + 4);
|
||||
data = swap32(received_bytes) >> ((32 - 24) + 4); // Convert to 20bit value
|
||||
|
||||
// Handle negative 20bit twos complement
|
||||
if (data & 0x80000) {
|
||||
data = -((0x000FFFFF & ~data) + 1);
|
||||
}
|
||||
|
||||
} else {
|
||||
perf_count(_comms_errors);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user