mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-28 02:00:36 +08:00
trone: fixed code style
This commit is contained in:
+24
-23
@@ -212,7 +212,8 @@ static const uint8_t crc_table[] = {
|
||||
0xfa, 0xfd, 0xf4, 0xf3
|
||||
};
|
||||
|
||||
static uint8_t crc8(uint8_t *p, uint8_t len) {
|
||||
static uint8_t crc8(uint8_t *p, uint8_t len)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t crc = 0x0;
|
||||
|
||||
@@ -301,7 +302,7 @@ TRONE::init()
|
||||
_reports->get(&ds_report);
|
||||
|
||||
_distance_sensor_topic = orb_advertise_multi(ORB_ID(distance_sensor), &ds_report,
|
||||
&_orb_class_instance, ORB_PRIO_LOW);
|
||||
&_orb_class_instance, ORB_PRIO_LOW);
|
||||
|
||||
if (_distance_sensor_topic == nullptr) {
|
||||
DEVICE_LOG("failed to create distance_sensor object. Did you start uOrb?");
|
||||
@@ -318,23 +319,23 @@ out:
|
||||
int
|
||||
TRONE::probe()
|
||||
{
|
||||
uint8_t who_am_i=0;
|
||||
uint8_t who_am_i = 0;
|
||||
|
||||
const uint8_t cmd = TRONE_WHO_AM_I_REG;
|
||||
|
||||
// set the I2C bus address
|
||||
set_address(TRONE_BASEADDR);
|
||||
|
||||
// can't use a single transfer as TROne need a bit of time for internal processing
|
||||
|
||||
// set the I2C bus address
|
||||
set_address(TRONE_BASEADDR);
|
||||
|
||||
// can't use a single transfer as TROne need a bit of time for internal processing
|
||||
if (transfer(&cmd, 1, nullptr, 0) == OK) {
|
||||
if ( transfer(nullptr, 0, &who_am_i, 1) == OK && who_am_i == TRONE_WHO_AM_I_REG_VAL){
|
||||
return measure();
|
||||
}
|
||||
}
|
||||
if (transfer(nullptr, 0, &who_am_i, 1) == OK && who_am_i == TRONE_WHO_AM_I_REG_VAL) {
|
||||
return measure();
|
||||
}
|
||||
}
|
||||
|
||||
DEVICE_DEBUG("WHO_AM_I byte mismatch 0x%02x should be 0x%02x\n",
|
||||
(unsigned)who_am_i,
|
||||
TRONE_WHO_AM_I_REG_VAL);
|
||||
(unsigned)who_am_i,
|
||||
TRONE_WHO_AM_I_REG_VAL);
|
||||
|
||||
// not found on any address
|
||||
return -EIO;
|
||||
@@ -596,7 +597,7 @@ TRONE::collect()
|
||||
|
||||
// This validation check can be used later
|
||||
_valid = crc8(val, 2) == val[2] && (float)report.current_distance > report.min_distance
|
||||
&& (float)report.current_distance < report.max_distance ? 1 : 0;
|
||||
&& (float)report.current_distance < report.max_distance ? 1 : 0;
|
||||
|
||||
/* publish it, if we are the primary */
|
||||
if (_distance_sensor_topic != nullptr) {
|
||||
@@ -680,10 +681,10 @@ TRONE::cycle()
|
||||
if (_measure_ticks > USEC2TICK(TRONE_CONVERSION_INTERVAL)) {
|
||||
/* schedule a fresh cycle call when we are ready to measure again */
|
||||
work_queue(HPWORK,
|
||||
&_work,
|
||||
(worker_t)&TRONE::cycle_trampoline,
|
||||
this,
|
||||
_measure_ticks - USEC2TICK(TRONE_CONVERSION_INTERVAL));
|
||||
&_work,
|
||||
(worker_t)&TRONE::cycle_trampoline,
|
||||
this,
|
||||
_measure_ticks - USEC2TICK(TRONE_CONVERSION_INTERVAL));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -699,10 +700,10 @@ TRONE::cycle()
|
||||
|
||||
/* schedule a fresh cycle call when the measurement is done */
|
||||
work_queue(HPWORK,
|
||||
&_work,
|
||||
(worker_t)&TRONE::cycle_trampoline,
|
||||
this,
|
||||
USEC2TICK(TRONE_CONVERSION_INTERVAL));
|
||||
&_work,
|
||||
(worker_t)&TRONE::cycle_trampoline,
|
||||
this,
|
||||
USEC2TICK(TRONE_CONVERSION_INTERVAL));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user