mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 16:28:53 +08:00
pwm_out:use inttypes, match signature
This commit is contained in:
committed by
Julian Oes
parent
bd511e1074
commit
9443dd6345
@@ -381,7 +381,7 @@ int PWMOut::set_mode(Mode mode)
|
||||
* For Oneshot there is no rate, 0 is therefore used
|
||||
* to select Oneshot mode
|
||||
*/
|
||||
int PWMOut::set_pwm_rate(uint32_t rate_map, unsigned default_rate, unsigned alt_rate)
|
||||
int PWMOut::set_pwm_rate(unsigned rate_map, unsigned default_rate, unsigned alt_rate)
|
||||
{
|
||||
PX4_DEBUG("pwm_out%u set_pwm_rate %x %u %u", _instance, rate_map, default_rate, alt_rate);
|
||||
|
||||
@@ -416,7 +416,7 @@ int PWMOut::set_pwm_rate(uint32_t rate_map, unsigned default_rate, unsigned alt_
|
||||
if (pass == 0) {
|
||||
// preflight
|
||||
if ((alt != 0) && (alt != mask)) {
|
||||
PX4_WARN("rate group %u mask %x bad overlap %x", group, mask, alt);
|
||||
PX4_WARN("rate group %u mask %" PRIx32 " bad overlap %" PRIx32, group, mask, alt);
|
||||
// not a legal map, bail
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -540,7 +540,9 @@ void PWMOut::capture_trampoline(void *context, uint32_t chan_index,
|
||||
void PWMOut::capture_callback(uint32_t chan_index,
|
||||
hrt_abstime edge_time, uint32_t edge_state, uint32_t overflow)
|
||||
{
|
||||
fprintf(stdout, "FMU: Capture chan:%d time:%lld state:%d overflow:%d\n", chan_index, edge_time, edge_state, overflow);
|
||||
fprintf(stdout, "FMU: Capture chan:%" PRId32 " time:%" PRId64 " state:%" PRId32 " overflow:%" PRId32 "\n", chan_index,
|
||||
edge_time, edge_state,
|
||||
overflow);
|
||||
}
|
||||
|
||||
bool PWMOut::update_pwm_out_state(bool on)
|
||||
@@ -707,7 +709,7 @@ void PWMOut::update_params()
|
||||
|
||||
if (param_get(param_find(str), &pwm_min) == PX4_OK) {
|
||||
if (pwm_min >= 0) {
|
||||
_mixing_output.minValue(i) = math::constrain(pwm_min, PWM_LOWEST_MIN, PWM_HIGHEST_MIN);
|
||||
_mixing_output.minValue(i) = math::constrain(pwm_min, (int32_t) PWM_LOWEST_MIN, (int32_t) PWM_HIGHEST_MIN);
|
||||
|
||||
if (pwm_min != _mixing_output.minValue(i)) {
|
||||
int32_t pwm_min_new = _mixing_output.minValue(i);
|
||||
@@ -727,7 +729,7 @@ void PWMOut::update_params()
|
||||
|
||||
if (param_get(param_find(str), &pwm_max) == PX4_OK) {
|
||||
if (pwm_max >= 0) {
|
||||
_mixing_output.maxValue(i) = math::constrain(pwm_max, PWM_LOWEST_MAX, PWM_HIGHEST_MAX);
|
||||
_mixing_output.maxValue(i) = math::constrain(pwm_max, (int32_t) PWM_LOWEST_MAX, (int32_t) PWM_HIGHEST_MAX);
|
||||
|
||||
if (pwm_max != _mixing_output.maxValue(i)) {
|
||||
int32_t pwm_max_new = _mixing_output.maxValue(i);
|
||||
@@ -747,7 +749,7 @@ void PWMOut::update_params()
|
||||
|
||||
if (param_get(param_find(str), &pwm_failsafe) == PX4_OK) {
|
||||
if (pwm_failsafe >= 0) {
|
||||
_mixing_output.failsafeValue(i) = math::constrain(pwm_failsafe, 0, PWM_HIGHEST_MAX);
|
||||
_mixing_output.failsafeValue(i) = math::constrain(pwm_failsafe, (int32_t) 0, (int32_t) PWM_HIGHEST_MAX);
|
||||
|
||||
if (pwm_failsafe != _mixing_output.failsafeValue(i)) {
|
||||
int32_t pwm_fail_new = _mixing_output.failsafeValue(i);
|
||||
@@ -764,7 +766,7 @@ void PWMOut::update_params()
|
||||
|
||||
if (param_get(param_find(str), &pwm_dis) == PX4_OK) {
|
||||
if (pwm_dis >= 0) {
|
||||
_mixing_output.disarmedValue(i) = math::constrain(pwm_dis, 0, PWM_HIGHEST_MAX);
|
||||
_mixing_output.disarmedValue(i) = math::constrain(pwm_dis, (int32_t) 0, (int32_t) PWM_HIGHEST_MAX);
|
||||
|
||||
if (pwm_dis != _mixing_output.disarmedValue(i)) {
|
||||
int32_t pwm_dis_new = _mixing_output.disarmedValue(i);
|
||||
@@ -1863,7 +1865,7 @@ int PWMOut::test(const char *dev)
|
||||
PX4_INFO("Not in a capture mode");
|
||||
}
|
||||
|
||||
PX4_INFO("Testing %u servos and %u input captures", (unsigned)servo_count, capture_count);
|
||||
PX4_INFO("Testing %u servos and %u input captures", servo_count, capture_count);
|
||||
memset(capture_conf, 0, sizeof(capture_conf));
|
||||
|
||||
if (capture_count != 0) {
|
||||
@@ -1873,7 +1875,7 @@ int PWMOut::test(const char *dev)
|
||||
|
||||
/* Save handler */
|
||||
if (::ioctl(fd, INPUT_CAP_GET_CALLBACK, (unsigned long)&capture_conf[i].chan.channel) != 0) {
|
||||
PX4_ERR("Unable to get capture callback for chan %u\n", capture_conf[i].chan.channel);
|
||||
PX4_ERR("Unable to get capture callback for chan %" PRIu8 "\n", capture_conf[i].chan.channel);
|
||||
goto err_out;
|
||||
|
||||
} else {
|
||||
@@ -1885,7 +1887,7 @@ int PWMOut::test(const char *dev)
|
||||
capture_conf[i].valid = true;
|
||||
|
||||
} else {
|
||||
PX4_ERR("Unable to set capture callback for chan %u\n", capture_conf[i].chan.channel);
|
||||
PX4_ERR("Unable to set capture callback for chan %" PRIu8 "\n", capture_conf[i].chan.channel);
|
||||
goto err_out;
|
||||
}
|
||||
}
|
||||
@@ -1938,12 +1940,12 @@ int PWMOut::test(const char *dev)
|
||||
servo_position_t value;
|
||||
|
||||
if (::ioctl(fd, PWM_SERVO_GET(i), (unsigned long)&value)) {
|
||||
PX4_ERR("error reading PWM servo %d", i);
|
||||
PX4_ERR("error reading PWM servo %u", i);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
if (value != servos[i]) {
|
||||
PX4_ERR("servo %d readback error, got %u expected %u", i, value, servos[i]);
|
||||
PX4_ERR("servo %u readback error, got %" PRIu16 " expected %" PRIu16, i, value, servos[i]);
|
||||
goto err_out;
|
||||
}
|
||||
}
|
||||
@@ -1955,11 +1957,12 @@ int PWMOut::test(const char *dev)
|
||||
stats.chan_in_edges_out = capture_conf[i].chan.channel;
|
||||
|
||||
if (::ioctl(fd, INPUT_CAP_GET_STATS, (unsigned long)&stats) != 0) {
|
||||
PX4_ERR("Unable to get stats for chan %u\n", capture_conf[i].chan.channel);
|
||||
PX4_ERR("Unable to get stats for chan %" PRIu8 "\n", capture_conf[i].chan.channel);
|
||||
goto err_out;
|
||||
|
||||
} else {
|
||||
fprintf(stdout, "FMU: Status chan:%u edges: %d last time:%lld last state:%d overflows:%d lantency:%u\n",
|
||||
fprintf(stdout, "FMU: Status chan:%" PRIu8 " edges: %" PRIu32 " last time:%" PRIu64 " last state:%" PRIu32
|
||||
" overflows:%" PRIu32 " lantency:%" PRIu16 "\n",
|
||||
capture_conf[i].chan.channel,
|
||||
stats.chan_in_edges_out,
|
||||
stats.last_time,
|
||||
@@ -1993,7 +1996,7 @@ int PWMOut::test(const char *dev)
|
||||
if (capture_conf[i].valid) {
|
||||
/* Save handler */
|
||||
if (::ioctl(fd, INPUT_CAP_SET_CALLBACK, (unsigned long)&capture_conf[i].chan) != 0) {
|
||||
PX4_ERR("Unable to set capture callback for chan %u\n", capture_conf[i].chan.channel);
|
||||
PX4_ERR("Unable to set capture callback for chan %" PRIu8 "\n", capture_conf[i].chan.channel);
|
||||
goto err_out;
|
||||
}
|
||||
}
|
||||
@@ -2194,13 +2197,13 @@ int PWMOut::custom_command(int argc, char *argv[])
|
||||
int PWMOut::print_status()
|
||||
{
|
||||
if (_class_instance == CLASS_DEVICE_PRIMARY) {
|
||||
PX4_INFO("%d - PWM_MAIN 0x%04X", _instance, _pwm_mask);
|
||||
PX4_INFO("%d - PWM_MAIN 0x%04" PRIx32, _instance, _pwm_mask);
|
||||
|
||||
} else if (_class_instance == CLASS_DEVICE_SECONDARY) {
|
||||
PX4_INFO("%d - PWM_AUX 0x%04X", _instance, _pwm_mask);
|
||||
PX4_INFO("%d - PWM_AUX 0x%04" PRIx32, _instance, _pwm_mask);
|
||||
|
||||
} else if (_class_instance == CLASS_DEVICE_TERTIARY) {
|
||||
PX4_INFO("%d - PWM_EXTRA 0x%04X", _instance, _pwm_mask);
|
||||
PX4_INFO("%d - PWM_EXTRA 0x%04" PRIx32, _instance, _pwm_mask);
|
||||
}
|
||||
|
||||
PX4_INFO("%d - Max update rate: %i Hz", _instance, _current_update_rate);
|
||||
|
||||
Reference in New Issue
Block a user