diff --git a/lib/pbio/drv/ioport/ioport_lpf2.c b/lib/pbio/drv/ioport/ioport_lpf2.c index 9a0340f60..1fb07c2f7 100644 --- a/lib/pbio/drv/ioport/ioport_lpf2.c +++ b/lib/pbio/drv/ioport/ioport_lpf2.c @@ -517,9 +517,9 @@ PROCESS_THREAD(pbdrv_ioport_lpf2_process, ev, data) { iodev->info = info; const lump_mode_flags_t *flags = &info->mode_info[0].flags; - iodev->motor_flags = PBIO_IODEV_MOTOR_FLAG_NONE; + iodev->capability_flags = PBIO_IODEV_CAPABILITY_FLAG_NONE; if (flags->flags0 & LUMP_MODE_FLAGS0_MOTOR_POWER) { - iodev->motor_flags |= PBIO_IODEV_MOTOR_FLAG_IS_MOTOR; + iodev->capability_flags |= PBIO_IODEV_CAPABILITY_FLAG_IS_MOTOR; } ioport->iodev = iodev; } diff --git a/lib/pbio/include/pbio/iodev.h b/lib/pbio/include/pbio/iodev.h index 06ae89a97..d93c9d68c 100644 --- a/lib/pbio/include/pbio/iodev.h +++ b/lib/pbio/include/pbio/iodev.h @@ -187,38 +187,38 @@ typedef enum { /** * Convience value for no flags set. */ - PBIO_IODEV_MOTOR_FLAG_NONE = 0, + PBIO_IODEV_CAPABILITY_FLAG_NONE = 0, /** - * Indicates that this device is motor. + * Indicates that this device is a motor. */ - PBIO_IODEV_MOTOR_FLAG_IS_MOTOR = 1 << 0, + PBIO_IODEV_CAPABILITY_FLAG_IS_MOTOR = 1 << 0, /** * Indicates that the motor provides speed feedback. */ - PBIO_IODEV_MOTOR_FLAG_HAS_SPEED = 1 << 1, + PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_SPEED = 1 << 1, /** * Indicates that the motor provides relative position feedback. */ - PBIO_IODEV_MOTOR_FLAG_HAS_REL_POS = 1 << 2, + PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_REL_POS = 1 << 2, /** * Indicates that the motor provides absolute position feedback. */ - PBIO_IODEV_MOTOR_FLAG_HAS_ABS_POS = 1 << 3, -} pbio_iodev_motor_flags_t; + PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_ABS_POS = 1 << 3, +} pbio_iodev_capability_flags_t; /** * Macro for testing if I/O device is a motor. * * @param [in] d Pointer to pbio_iodev_t. */ -#define PBIO_IODEV_IS_MOTOR(d) ((d)->motor_flags & PBIO_IODEV_MOTOR_FLAG_IS_MOTOR) +#define PBIO_IODEV_IS_MOTOR(d) ((d)->capability_flags & PBIO_IODEV_CAPABILITY_FLAG_IS_MOTOR) /** * Macro for testing if I/O device is a motor with speed/position feedback. * * @param [in] d Pointer to pbio_iodev_t. */ -#define PBIO_IODEV_IS_FEEDBACK_MOTOR(d) ((d)->motor_flags > PBIO_IODEV_MOTOR_FLAG_IS_MOTOR) +#define PBIO_IODEV_IS_FEEDBACK_MOTOR(d) ((d)->capability_flags > PBIO_IODEV_CAPABILITY_FLAG_IS_MOTOR) /** * Mapping flags that describe the input and output values of an I/O device. @@ -377,9 +377,9 @@ struct _pbio_iodev_t { */ uint8_t mode; /** - * Motor capability flags. + * Device capability flags. */ - pbio_iodev_motor_flags_t motor_flags; + pbio_iodev_capability_flags_t capability_flags; /** * Most recent binary data read from the device. How to interpret this data * is determined by the ::pbio_iodev_mode_t info associated with the current diff --git a/lib/pbio/src/uartdev.c b/lib/pbio/src/uartdev.c index cb9e5355b..c57c6f7c5 100644 --- a/lib/pbio/src/uartdev.c +++ b/lib/pbio/src/uartdev.c @@ -483,16 +483,16 @@ static void pbio_uartdev_parse_msg(uartdev_port_data_t *data) { } if (flags->flags0 & LUMP_MODE_FLAGS0_MOTOR_POWER) { - data->iodev.motor_flags |= PBIO_IODEV_MOTOR_FLAG_IS_MOTOR; + data->iodev.capability_flags |= PBIO_IODEV_CAPABILITY_FLAG_IS_MOTOR; } if (flags->flags0 & LUMP_MODE_FLAGS0_MOTOR_SPEED) { - data->iodev.motor_flags |= PBIO_IODEV_MOTOR_FLAG_HAS_SPEED; + data->iodev.capability_flags |= PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_SPEED; } if (flags->flags0 & LUMP_MODE_FLAGS0_MOTOR_REL_POS) { - data->iodev.motor_flags |= PBIO_IODEV_MOTOR_FLAG_HAS_REL_POS; + data->iodev.capability_flags |= PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_REL_POS; } if (flags->flags0 & LUMP_MODE_FLAGS0_MOTOR_ABS_POS) { - data->iodev.motor_flags |= PBIO_IODEV_MOTOR_FLAG_HAS_ABS_POS; + data->iodev.capability_flags |= PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_ABS_POS; } debug_pr("new_mode: %d\n", data->new_mode); @@ -680,7 +680,7 @@ static void pbio_uartdev_parse_msg(uartdev_port_data_t *data) { // The counter driver must return the corrected count data->tacho_count = tacho_count_msg - data->tacho_offset; - if (data->iodev.motor_flags & PBIO_IODEV_MOTOR_FLAG_HAS_ABS_POS) { + if (data->iodev.capability_flags & PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_ABS_POS) { data->abs_pos = data->rx_msg[7] << 8 | data->rx_msg[6]; } } else { @@ -827,7 +827,7 @@ static PT_THREAD(pbio_uartdev_update(uartdev_port_data_t * data)) { // reset state for new device data->info->type_id = PBIO_IODEV_TYPE_ID_NONE; - data->iodev.motor_flags = PBIO_IODEV_MOTOR_FLAG_NONE; + data->iodev.capability_flags = PBIO_IODEV_CAPABILITY_FLAG_NONE; data->ext_mode = 0; data->status = PBIO_UARTDEV_STATUS_SYNCING; // default max tacho rate for BOOST external motor since it is the only @@ -1244,7 +1244,7 @@ static pbio_error_t pbio_uartdev_get_abs_count(pbdrv_counter_dev_t *dev, int32_t return PBIO_ERROR_NO_DEV; } - if (!(port_data->iodev.motor_flags & PBIO_IODEV_MOTOR_FLAG_HAS_ABS_POS)) { + if (!(port_data->iodev.capability_flags & PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_ABS_POS)) { return PBIO_ERROR_NOT_SUPPORTED; } diff --git a/lib/pbio/test/src/uartdev.c b/lib/pbio/test/src/uartdev.c index 601d1be58..56d65e8b9 100644 --- a/lib/pbio/test/src/uartdev.c +++ b/lib/pbio/test/src/uartdev.c @@ -353,7 +353,7 @@ PT_THREAD(test_boost_color_distance_sensor(struct pt *pt)) { tt_want_uint_op(iodev->info->num_view_modes, ==, 8); // TODO: verify fw/hw versions tt_want_uint_op(iodev->info->mode_combos, ==, 1 << 6 | 1 << 3 | 1 << 2 | 1 << 1 | 1 << 0); - tt_want_uint_op(iodev->motor_flags, ==, PBIO_IODEV_MOTOR_FLAG_NONE); + tt_want_uint_op(iodev->capability_flags, ==, PBIO_IODEV_CAPABILITY_FLAG_NONE); tt_want_uint_op(iodev->mode, ==, 0); tt_want_str_op(iodev->info->mode_info[0].name, ==, "COLOR"); @@ -777,8 +777,8 @@ PT_THREAD(test_boost_interactive_motor(struct pt *pt)) { tt_want_uint_op(iodev->info->num_view_modes, ==, 3); // TODO: verify fw/hw versions tt_want_uint_op(iodev->info->mode_combos, ==, 1 << 2 | 1 << 1); - tt_want_uint_op(iodev->motor_flags, ==, PBIO_IODEV_MOTOR_FLAG_IS_MOTOR | - PBIO_IODEV_MOTOR_FLAG_HAS_SPEED | PBIO_IODEV_MOTOR_FLAG_HAS_REL_POS); + tt_want_uint_op(iodev->capability_flags, ==, PBIO_IODEV_CAPABILITY_FLAG_IS_MOTOR | + PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_SPEED | PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_REL_POS); tt_want_uint_op(iodev->mode, ==, 0); tt_want_str_op(iodev->info->mode_info[0].name, ==, "POWER"); @@ -1048,8 +1048,8 @@ PT_THREAD(test_technic_large_motor(struct pt *pt)) { tt_want_uint_op(iodev->info->num_view_modes, ==, 4); // TODO: verify fw/hw versions tt_want_uint_op(iodev->info->mode_combos, ==, 1 << 3 | 1 << 2 | 1 << 1); - tt_want_uint_op(iodev->motor_flags, ==, PBIO_IODEV_MOTOR_FLAG_IS_MOTOR | PBIO_IODEV_MOTOR_FLAG_HAS_SPEED - | PBIO_IODEV_MOTOR_FLAG_HAS_REL_POS | PBIO_IODEV_MOTOR_FLAG_HAS_ABS_POS); + tt_want_uint_op(iodev->capability_flags, ==, PBIO_IODEV_CAPABILITY_FLAG_IS_MOTOR | PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_SPEED + | PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_REL_POS | PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_ABS_POS); tt_want_uint_op(iodev->mode, ==, 0); tt_want_str_op(iodev->info->mode_info[0].name, ==, "POWER"); @@ -1371,8 +1371,8 @@ PT_THREAD(test_technic_xl_motor(struct pt *pt)) { tt_want_uint_op(iodev->info->num_view_modes, ==, 4); // TODO: verify fw/hw versions tt_want_uint_op(iodev->info->mode_combos, ==, 1 << 3 | 1 << 2 | 1 << 1); - tt_want_uint_op(iodev->motor_flags, ==, PBIO_IODEV_MOTOR_FLAG_IS_MOTOR | PBIO_IODEV_MOTOR_FLAG_HAS_SPEED - | PBIO_IODEV_MOTOR_FLAG_HAS_REL_POS | PBIO_IODEV_MOTOR_FLAG_HAS_ABS_POS); + tt_want_uint_op(iodev->capability_flags, ==, PBIO_IODEV_CAPABILITY_FLAG_IS_MOTOR | PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_SPEED + | PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_REL_POS | PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_ABS_POS); tt_want_uint_op(iodev->mode, ==, 0); tt_want_str_op(iodev->info->mode_info[0].name, ==, "POWER");