From c3f79479e9a9adf01f9b9a0903bbbd84962317b3 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Tue, 29 Jun 2021 13:50:04 -0500 Subject: [PATCH] tree-wide: rename pbio_port_t to pbio_port_id_t This is consistent with using "id" for other similar lookup IDs and will free up pbio_port_t to be used as a struct type. --- lib/ev3dev/include/ev3dev_stretch/lego_port.h | 2 +- .../include/ev3dev_stretch/lego_sensor.h | 2 +- lib/ev3dev/include/ev3dev_stretch/nxtcolor.h | 2 +- lib/ev3dev/include/ev3dev_stretch/sysfs.h | 2 +- lib/ev3dev/src/ev3dev_stretch/lego_port.c | 6 +-- lib/ev3dev/src/ev3dev_stretch/lego_sensor.c | 8 +-- lib/ev3dev/src/ev3dev_stretch/nxtcolor.c | 20 ++++---- lib/ev3dev/src/ev3dev_stretch/sysfs.c | 4 +- lib/pbio/drv/city_hub/motor.c | 32 ++++++------ lib/pbio/drv/counter/counter_nxt.c | 2 +- lib/pbio/drv/ev3dev_stretch/motor.c | 12 ++--- lib/pbio/drv/ioport/ioport_lpf2.c | 2 +- lib/pbio/drv/move_hub/motor.c | 50 +++++++++---------- lib/pbio/drv/nxt/motor.c | 8 +-- lib/pbio/drv/prime_hub/motor.c | 8 +-- lib/pbio/drv/technic_hub/motor.c | 8 +-- lib/pbio/include/pbdrv/config.h | 4 +- lib/pbio/include/pbdrv/ioport.h | 4 +- lib/pbio/include/pbdrv/motor.h | 16 +++--- lib/pbio/include/pbio/dcmotor.h | 6 +-- lib/pbio/include/pbio/iodev.h | 2 +- lib/pbio/include/pbio/motor_process.h | 2 +- lib/pbio/include/pbio/port.h | 24 ++++----- lib/pbio/include/pbio/servo.h | 2 +- lib/pbio/include/pbio/tacho.h | 4 +- lib/pbio/platform/city_hub/pbdrvconfig.h | 8 +-- lib/pbio/platform/debug/platform.c | 4 +- .../platform/ev3dev_stretch/pbdrvconfig.h | 8 +-- lib/pbio/platform/move_hub/pbdrvconfig.h | 8 +-- lib/pbio/platform/nxt/pbdrvconfig.h | 4 +- lib/pbio/platform/prime_hub/pbdrvconfig.h | 8 +-- lib/pbio/platform/technic_hub/pbdrvconfig.h | 8 +-- lib/pbio/src/dcmotor.c | 2 +- lib/pbio/src/motor_process.c | 2 +- lib/pbio/src/tacho.c | 2 +- lib/pbio/test/pbdrvconfig.h | 4 +- lib/pbio/test/src/servo.c | 10 ++-- pybricks/common/pb_type_dcmotor.c | 2 +- pybricks/common/pb_type_motor.c | 2 +- .../pb_type_ev3devices_colorsensor.c | 2 +- .../pb_type_ev3devices_gyrosensor.c | 2 +- .../pb_type_ev3devices_infraredsensor.c | 2 +- .../pb_type_ev3devices_touchsensor.c | 2 +- .../pb_type_ev3devices_ultrasonicsensor.c | 2 +- .../pb_type_iodevices_analogsensor.c | 2 +- .../pb_type_iodevices_ev3devsensor.c | 2 +- .../iodevices/pb_type_iodevices_i2cdevice.c | 4 +- .../iodevices/pb_type_iodevices_lumpdevice.c | 2 +- .../iodevices/pb_type_iodevices_pupdevice.c | 2 +- .../iodevices/pb_type_iodevices_uartdevice.c | 2 +- .../pb_type_nxtdevices_colorsensor.c | 2 +- .../pb_type_nxtdevices_energymeter.c | 2 +- .../pb_type_nxtdevices_lightsensor.c | 2 +- .../pb_type_nxtdevices_soundsensor.c | 2 +- .../pb_type_nxtdevices_temperaturesensor.c | 2 +- .../pb_type_nxtdevices_touchsensor.c | 2 +- .../pb_type_nxtdevices_ultrasonicsensor.c | 2 +- pybricks/parameters/pb_type_port.c | 20 ++++---- .../pb_type_pupdevices_colordistancesensor.c | 2 +- .../pb_type_pupdevices_colorsensor.c | 2 +- .../pb_type_pupdevices_forcesensor.c | 2 +- .../pb_type_pupdevices_infraredsensor.c | 2 +- .../pupdevices/pb_type_pupdevices_light.c | 2 +- .../pb_type_pupdevices_tiltsensor.c | 2 +- .../pb_type_pupdevices_ultrasonicsensor.c | 2 +- pybricks/util_pb/pb_device.h | 2 +- pybricks/util_pb/pb_device_ev3dev.c | 10 ++-- pybricks/util_pb/pb_device_stm32.c | 2 +- pybricks/util_pb/pb_serial.h | 2 +- pybricks/util_pb/pb_serial_ev3dev.c | 8 +-- 70 files changed, 200 insertions(+), 200 deletions(-) diff --git a/lib/ev3dev/include/ev3dev_stretch/lego_port.h b/lib/ev3dev/include/ev3dev_stretch/lego_port.h index 819a79524..569a6cd8b 100644 --- a/lib/ev3dev/include/ev3dev_stretch/lego_port.h +++ b/lib/ev3dev/include/ev3dev_stretch/lego_port.h @@ -9,6 +9,6 @@ #include #include -pbio_error_t ev3dev_lego_port_configure(pbio_port_t port, pbio_iodev_type_id_t id); +pbio_error_t ev3dev_lego_port_configure(pbio_port_id_t port, pbio_iodev_type_id_t id); #endif // _PBIO_LEGO_PORT_H_ diff --git a/lib/ev3dev/include/ev3dev_stretch/lego_sensor.h b/lib/ev3dev/include/ev3dev_stretch/lego_sensor.h index 3d43e72e1..55b4d8fd7 100644 --- a/lib/ev3dev/include/ev3dev_stretch/lego_sensor.h +++ b/lib/ev3dev/include/ev3dev_stretch/lego_sensor.h @@ -49,7 +49,7 @@ typedef enum { typedef struct _lego_sensor_t lego_sensor_t; -pbio_error_t lego_sensor_get(lego_sensor_t **sensor, pbio_port_t port, pbio_iodev_type_id_t valid_id); +pbio_error_t lego_sensor_get(lego_sensor_t **sensor, pbio_port_id_t port, pbio_iodev_type_id_t valid_id); pbio_error_t lego_sensor_get_info(lego_sensor_t *sensor, uint8_t *data_len, lego_sensor_data_type_t *data_type); diff --git a/lib/ev3dev/include/ev3dev_stretch/nxtcolor.h b/lib/ev3dev/include/ev3dev_stretch/nxtcolor.h index 0f1f9eecb..e29d5236c 100644 --- a/lib/ev3dev/include/ev3dev_stretch/nxtcolor.h +++ b/lib/ev3dev/include/ev3dev_stretch/nxtcolor.h @@ -9,6 +9,6 @@ #include #include -pbio_error_t nxtcolor_get_values_at_mode(pbio_port_t port, uint8_t mode, void *values); +pbio_error_t nxtcolor_get_values_at_mode(pbio_port_id_t port, uint8_t mode, void *values); #endif // _PBIO_NXTCOLOR_H_ diff --git a/lib/ev3dev/include/ev3dev_stretch/sysfs.h b/lib/ev3dev/include/ev3dev_stretch/sysfs.h index 7f005144c..e9b2c372a 100644 --- a/lib/ev3dev/include/ev3dev_stretch/sysfs.h +++ b/lib/ev3dev/include/ev3dev_stretch/sysfs.h @@ -9,7 +9,7 @@ #include #include -pbio_error_t sysfs_get_number(pbio_port_t port, const char *rdir, int *sysfs_number); +pbio_error_t sysfs_get_number(pbio_port_id_t port, const char *rdir, int *sysfs_number); pbio_error_t sysfs_open(FILE **file, const char *pathpat, int n, const char *attribute, const char *rw); diff --git a/lib/ev3dev/src/ev3dev_stretch/lego_port.c b/lib/ev3dev/src/ev3dev_stretch/lego_port.c index 32544dd11..b69e24e50 100644 --- a/lib/ev3dev/src/ev3dev_stretch/lego_port.c +++ b/lib/ev3dev/src/ev3dev_stretch/lego_port.c @@ -52,7 +52,7 @@ static const char* const port_modes[] = { }; // Get the port mode -static pbio_error_t ev3dev_lego_port_get_mode(pbio_port_t port, const char *attribute, ev3dev_lego_port_t *port_mode) { +static pbio_error_t ev3dev_lego_port_get_mode(pbio_port_id_t port, const char *attribute, ev3dev_lego_port_t *port_mode) { // Read lego-port number int n_lport; pbio_error_t err; @@ -91,7 +91,7 @@ static pbio_error_t ev3dev_lego_port_get_mode(pbio_port_t port, const char *attr } // Write the port mode without questions -static pbio_error_t ev3dev_lego_port_set_mode(pbio_port_t port, ev3dev_lego_port_t mode) { +static pbio_error_t ev3dev_lego_port_set_mode(pbio_port_id_t port, ev3dev_lego_port_t mode) { // Read lego-port number int n_lport; @@ -121,7 +121,7 @@ static pbio_error_t ev3dev_lego_port_set_mode(pbio_port_t port, ev3dev_lego_port } // Set compatible port configuration for given device -pbio_error_t ev3dev_lego_port_configure(pbio_port_t port, pbio_iodev_type_id_t id) { +pbio_error_t ev3dev_lego_port_configure(pbio_port_id_t port, pbio_iodev_type_id_t id) { pbio_error_t err; // Get the current port mode and status diff --git a/lib/ev3dev/src/ev3dev_stretch/lego_sensor.c b/lib/ev3dev/src/ev3dev_stretch/lego_sensor.c index 16ad59552..7b14f9209 100644 --- a/lib/ev3dev/src/ev3dev_stretch/lego_sensor.c +++ b/lib/ev3dev/src/ev3dev_stretch/lego_sensor.c @@ -30,7 +30,7 @@ struct _lego_sensor_t { uint8_t bin_data[PBIO_IODEV_MAX_DATA_SIZE] __attribute__((aligned(32))); }; // Initialize an ev3dev sensor by opening the relevant sysfs attributes -static pbio_error_t ev3_sensor_init(lego_sensor_t *sensor, pbio_port_t port) { +static pbio_error_t ev3_sensor_init(lego_sensor_t *sensor, pbio_port_id_t port) { pbio_error_t err; err = sysfs_get_number(port, "/sys/class/lego-sensor", &sensor->n_sensor); @@ -161,12 +161,12 @@ static pbio_error_t ev3_sensor_assert_id(lego_sensor_t *sensor, pbio_iodev_type_ struct _lego_sensor_t sensors[4]; // Get an ev3dev sensor -pbio_error_t lego_sensor_get(lego_sensor_t **sensor, pbio_port_t port, pbio_iodev_type_id_t valid_id) { - if (port < PBIO_PORT_1 || port > PBIO_PORT_4) { +pbio_error_t lego_sensor_get(lego_sensor_t **sensor, pbio_port_id_t port, pbio_iodev_type_id_t valid_id) { + if (port < PBIO_PORT_ID_1 || port > PBIO_PORT_ID_4) { return PBIO_ERROR_INVALID_PORT; } - *sensor = &sensors[port - PBIO_PORT_1]; + *sensor = &sensors[port - PBIO_PORT_ID_1]; pbio_error_t err; diff --git a/lib/ev3dev/src/ev3dev_stretch/nxtcolor.c b/lib/ev3dev/src/ev3dev_stretch/nxtcolor.c index 07054523b..b2af2d519 100644 --- a/lib/ev3dev/src/ev3dev_stretch/nxtcolor.c +++ b/lib/ev3dev/src/ev3dev_stretch/nxtcolor.c @@ -29,25 +29,25 @@ typedef struct { } nxtcolor_pininfo_t; static const nxtcolor_pininfo_t pininfo[4] = { - [PBIO_PORT_1 - PBIO_PORT_1] = { + [PBIO_PORT_ID_1 - PBIO_PORT_ID_1] = { .digi0 = 2, .digi1 = 15, .adc_val = 5, .adc_con = 6, }, - [PBIO_PORT_2 - PBIO_PORT_1] = { + [PBIO_PORT_ID_2 - PBIO_PORT_ID_1] = { .digi0 = 14, .digi1 = 13, .adc_val = 7, .adc_con = 8, }, - [PBIO_PORT_3 - PBIO_PORT_1] = { + [PBIO_PORT_ID_3 - PBIO_PORT_ID_1] = { .digi0 = 12, .digi1 = 30, .adc_val = 9, .adc_con = 10, }, - [PBIO_PORT_4 - PBIO_PORT_1] = { + [PBIO_PORT_ID_4 - PBIO_PORT_ID_1] = { .digi0 = 1, .digi1 = 31, .adc_val = 11, @@ -275,12 +275,12 @@ static pbio_error_t nxtcolor_send_byte(nxtcolor_t *nxtcolor, uint8_t msg) return PBIO_SUCCESS; } -static pbio_error_t nxtcolor_init_fs(nxtcolor_t *nxtcolor, pbio_port_t port) { +static pbio_error_t nxtcolor_init_fs(nxtcolor_t *nxtcolor, pbio_port_id_t port) { pbio_error_t err; // Get the pin info for this port - nxtcolor->pins = &pininfo[port-PBIO_PORT_1]; + nxtcolor->pins = &pininfo[port-PBIO_PORT_ID_1]; // Open the sysfs files for this sensor err = sysfs_open(&nxtcolor->f_digi0_val, "/sys/class/gpio/gpio%d/%s", nxtcolor->pins->digi0, "value", "w"); @@ -333,7 +333,7 @@ static pbio_error_t nxtcolor_init_fs(nxtcolor_t *nxtcolor, pbio_port_t port) { return PBIO_SUCCESS; } -static pbio_error_t nxtcolor_init(nxtcolor_t *nxtcolor, pbio_port_t port) { +static pbio_error_t nxtcolor_init(nxtcolor_t *nxtcolor, pbio_port_id_t port) { pbio_error_t err; // Init the file system @@ -441,15 +441,15 @@ pbio_error_t nxtcolor_set_light(nxtcolor_t *nxtcolor, nxtcolor_color_state color return PBIO_SUCCESS; } -pbio_error_t nxtcolor_get_values_at_mode(pbio_port_t port, uint8_t mode, int32_t *values) { +pbio_error_t nxtcolor_get_values_at_mode(pbio_port_id_t port, uint8_t mode, int32_t *values) { pbio_error_t err; - if (port < PBIO_PORT_1 || port > PBIO_PORT_4) { + if (port < PBIO_PORT_ID_1 || port > PBIO_PORT_ID_4) { return PBIO_ERROR_INVALID_PORT; } - nxtcolor_t *nxtcolor = &nxtcolorsensors[port-PBIO_PORT_1]; + nxtcolor_t *nxtcolor = &nxtcolorsensors[port-PBIO_PORT_ID_1]; // We don't have a formal "get" function since the higher level code // does not know about the color sensor being a special case. So instead diff --git a/lib/ev3dev/src/ev3dev_stretch/sysfs.c b/lib/ev3dev/src/ev3dev_stretch/sysfs.c index 53c81f6f7..ff22576a7 100644 --- a/lib/ev3dev/src/ev3dev_stretch/sysfs.c +++ b/lib/ev3dev/src/ev3dev_stretch/sysfs.c @@ -15,7 +15,7 @@ #define MAX_READ_LENGTH "60" // Get the ev3dev sensor number for a given port -pbio_error_t sysfs_get_number(pbio_port_t port, const char *rdir, int *sysfs_number) { +pbio_error_t sysfs_get_number(pbio_port_id_t port, const char *rdir, int *sysfs_number) { // Open lego-sensor directory in sysfs DIR *d_sensor; struct dirent *entry; @@ -44,7 +44,7 @@ pbio_error_t sysfs_get_number(pbio_port_t port, const char *rdir, int *sysfs_num if (fscanf(f_address, "ev3-ports:%*[a-z]%c", &port_char) < 1) { return PBIO_ERROR_IO; } - pbio_port_t port_found = port_char; + pbio_port_id_t port_found = port_char; if (fclose(f_address) != 0) { return PBIO_ERROR_IO; diff --git a/lib/pbio/drv/city_hub/motor.c b/lib/pbio/drv/city_hub/motor.c index 268eb71c5..da972cae6 100644 --- a/lib/pbio/drv/city_hub/motor.c +++ b/lib/pbio/drv/city_hub/motor.c @@ -17,17 +17,17 @@ #include #include -pbio_error_t pbdrv_motor_coast(pbio_port_t port) { +pbio_error_t pbdrv_motor_coast(pbio_port_id_t port) { // set both port pins 1 and 2 to output low switch (port) { - case PBIO_PORT_B: + case PBIO_PORT_ID_B: GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER6_Msk) | (1 << GPIO_MODER_MODER6_Pos); GPIOC->BRR = GPIO_BRR_BR_6; GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER8_Msk) | (1 << GPIO_MODER_MODER8_Pos); GPIOC->BRR = GPIO_BRR_BR_8; break; - case PBIO_PORT_A: + case PBIO_PORT_ID_A: GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER7_Msk) | (1 << GPIO_MODER_MODER7_Pos); GPIOC->BRR = GPIO_BRR_BR_7; GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER9_Msk) | (1 << GPIO_MODER_MODER9_Pos); @@ -40,16 +40,16 @@ pbio_error_t pbdrv_motor_coast(pbio_port_t port) { return PBIO_SUCCESS; } -static void pbdrv_motor_brake(pbio_port_t port) { +static void pbdrv_motor_brake(pbio_port_id_t port) { // set both port pins 1 and 2 to output high switch (port) { - case PBIO_PORT_B: + case PBIO_PORT_ID_B: GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER6_Msk) | (1 << GPIO_MODER_MODER6_Pos); GPIOC->BSRR = GPIO_BSRR_BS_6; GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER8_Msk) | (1 << GPIO_MODER_MODER8_Pos); GPIOC->BSRR = GPIO_BSRR_BS_8; break; - case PBIO_PORT_A: + case PBIO_PORT_ID_A: GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER7_Msk) | (1 << GPIO_MODER_MODER7_Pos); GPIOC->BSRR = GPIO_BSRR_BS_7; GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER9_Msk) | (1 << GPIO_MODER_MODER9_Pos); @@ -60,12 +60,12 @@ static void pbdrv_motor_brake(pbio_port_t port) { } } -static void pbdrv_motor_run_fwd(pbio_port_t port, int16_t duty_cycle) { // duty is pos +static void pbdrv_motor_run_fwd(pbio_port_id_t port, int16_t duty_cycle) { // duty is pos pbdrv_pwm_dev_t *dev; // one pin as out, high and the other as PWM switch (port) { - case PBIO_PORT_B: + case PBIO_PORT_ID_B: GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER6_Msk) | (1 << GPIO_MODER_MODER6_Pos); GPIOC->BSRR = GPIO_BSRR_BS_6; if (pbdrv_pwm_get_dev(0, &dev) == PBIO_SUCCESS) { @@ -73,7 +73,7 @@ static void pbdrv_motor_run_fwd(pbio_port_t port, int16_t duty_cycle) { // duty } GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER8_Msk) | (2 << GPIO_MODER_MODER8_Pos); break; - case PBIO_PORT_A: + case PBIO_PORT_ID_A: GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER7_Msk) | (1 << GPIO_MODER_MODER7_Pos); GPIOC->BSRR = GPIO_BSRR_BS_7; if (pbdrv_pwm_get_dev(0, &dev) == PBIO_SUCCESS) { @@ -86,12 +86,12 @@ static void pbdrv_motor_run_fwd(pbio_port_t port, int16_t duty_cycle) { // duty } } -static void pbdrv_motor_run_rev(pbio_port_t port, int16_t duty_cycle) { // duty is neg +static void pbdrv_motor_run_rev(pbio_port_id_t port, int16_t duty_cycle) { // duty is neg pbdrv_pwm_dev_t *dev; // one pin as out, high and the other as PWM switch (port) { - case PBIO_PORT_B: + case PBIO_PORT_ID_B: GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER8_Msk) | (1 << GPIO_MODER_MODER8_Pos); GPIOC->BSRR = GPIO_BSRR_BS_8; if (pbdrv_pwm_get_dev(0, &dev) == PBIO_SUCCESS) { @@ -99,7 +99,7 @@ static void pbdrv_motor_run_rev(pbio_port_t port, int16_t duty_cycle) { // duty } GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER6_Msk) | (2 << GPIO_MODER_MODER6_Pos); break; - case PBIO_PORT_A: + case PBIO_PORT_ID_A: GPIOC->MODER = (GPIOC->MODER & ~GPIO_MODER_MODER9_Msk) | (1 << GPIO_MODER_MODER9_Pos); GPIOC->BSRR = GPIO_BSRR_BS_9; if (pbdrv_pwm_get_dev(0, &dev) == PBIO_SUCCESS) { @@ -112,8 +112,8 @@ static void pbdrv_motor_run_rev(pbio_port_t port, int16_t duty_cycle) { // duty } } -pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { - if (port < PBIO_PORT_A || port > PBIO_PORT_B) { +pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_id_t port, int16_t duty_cycle) { + if (port < PBIO_PORT_ID_A || port > PBIO_PORT_ID_B) { return PBIO_ERROR_INVALID_PORT; } @@ -132,7 +132,7 @@ pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { return PBIO_SUCCESS; } -pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { +pbio_error_t pbdrv_motor_get_id(pbio_port_id_t port, pbio_iodev_type_id_t *id) { pbio_iodev_t *iodev; pbio_error_t err; @@ -151,7 +151,7 @@ pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { return PBIO_SUCCESS; } -pbio_error_t pbdrv_motor_setup(pbio_port_t port, bool is_servo) { +pbio_error_t pbdrv_motor_setup(pbio_port_id_t port, bool is_servo) { return PBIO_SUCCESS; } diff --git a/lib/pbio/drv/counter/counter_nxt.c b/lib/pbio/drv/counter/counter_nxt.c index 29546f319..f4a674ff8 100644 --- a/lib/pbio/drv/counter/counter_nxt.c +++ b/lib/pbio/drv/counter/counter_nxt.c @@ -17,7 +17,7 @@ typedef struct { pbdrv_counter_dev_t *dev; - pbio_port_t port; + pbio_port_id_t port; } private_data_t; static private_data_t private_data[PBDRV_CONFIG_COUNTER_NXT_NUM_DEV]; diff --git a/lib/pbio/drv/ev3dev_stretch/motor.c b/lib/pbio/drv/ev3dev_stretch/motor.c index 8a7a90587..7598ce9a8 100644 --- a/lib/pbio/drv/ev3dev_stretch/motor.c +++ b/lib/pbio/drv/ev3dev_stretch/motor.c @@ -32,7 +32,7 @@ typedef struct _motor_t { static motor_t motors[4]; -static pbio_error_t ev3dev_motor_init(motor_t *mtr, pbio_port_t port) { +static pbio_error_t ev3dev_motor_init(motor_t *mtr, pbio_port_id_t port) { pbio_error_t err; @@ -107,7 +107,7 @@ static pbio_error_t ev3dev_motor_init(motor_t *mtr, pbio_port_t port) { return sysfs_write_str(mtr->f_command, "stop"); } -static pbio_error_t ev3dev_motor_get(motor_t **motor, pbio_port_t port) { +static pbio_error_t ev3dev_motor_get(motor_t **motor, pbio_port_id_t port) { // Verify port if (port < PBDRV_CONFIG_FIRST_MOTOR_PORT || port > PBDRV_CONFIG_LAST_MOTOR_PORT) { @@ -132,7 +132,7 @@ static pbio_error_t ev3dev_motor_connect_status(motor_t *mtr, pbio_error_t err) return err; } -pbio_error_t pbdrv_motor_coast(pbio_port_t port) { +pbio_error_t pbdrv_motor_coast(pbio_port_id_t port) { // Get the motor and initialize if needed pbio_error_t err; motor_t *mtr; @@ -150,7 +150,7 @@ pbio_error_t pbdrv_motor_coast(pbio_port_t port) { return ev3dev_motor_connect_status(mtr, err); } -pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { +pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_id_t port, int16_t duty_cycle) { // Get the motor and initialize if needed pbio_error_t err; motor_t *mtr; @@ -171,7 +171,7 @@ pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { return ev3dev_motor_connect_status(mtr, err); } -pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { +pbio_error_t pbdrv_motor_get_id(pbio_port_id_t port, pbio_iodev_type_id_t *id) { pbio_error_t err; motor_t *mtr; err = ev3dev_motor_get(&mtr, port); @@ -182,7 +182,7 @@ pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { return ev3dev_motor_connect_status(mtr, PBIO_SUCCESS); } -pbio_error_t pbdrv_motor_setup(pbio_port_t port, bool is_servo) { +pbio_error_t pbdrv_motor_setup(pbio_port_id_t port, bool is_servo) { // Verify port if (port < PBDRV_CONFIG_FIRST_MOTOR_PORT || port > PBDRV_CONFIG_LAST_MOTOR_PORT) { diff --git a/lib/pbio/drv/ioport/ioport_lpf2.c b/lib/pbio/drv/ioport/ioport_lpf2.c index 8c7e02ad8..16a5dba02 100644 --- a/lib/pbio/drv/ioport/ioport_lpf2.c +++ b/lib/pbio/drv/ioport/ioport_lpf2.c @@ -174,7 +174,7 @@ static void init_one(uint8_t ioport) { } // TODO: This should be moved to a common ioport_core.c file or removed entirely -pbio_error_t pbdrv_ioport_get_iodev(pbio_port_t port, pbio_iodev_t **iodev) { +pbio_error_t pbdrv_ioport_get_iodev(pbio_port_id_t port, pbio_iodev_t **iodev) { if (port < PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT || port > PBDRV_CONFIG_IOPORT_LPF2_LAST_PORT) { return PBIO_ERROR_INVALID_PORT; } diff --git a/lib/pbio/drv/move_hub/motor.c b/lib/pbio/drv/move_hub/motor.c index a9812e7ea..76407f769 100644 --- a/lib/pbio/drv/move_hub/motor.c +++ b/lib/pbio/drv/move_hub/motor.c @@ -27,23 +27,23 @@ static const pbdrv_gpio_t port_c_pin_2 = { .bank = GPIOC, .pin = 6 }; static const pbdrv_gpio_t port_d_pin_1 = { .bank = GPIOC, .pin = 7 }; static const pbdrv_gpio_t port_d_pin_2 = { .bank = GPIOC, .pin = 9 }; -pbio_error_t pbdrv_motor_coast(pbio_port_t port) { +pbio_error_t pbdrv_motor_coast(pbio_port_id_t port) { // motor terminals will be floating when both pins are low switch (port) { - case PBIO_PORT_A: + case PBIO_PORT_ID_A: pbdrv_gpio_out_low(&port_a_pin_1); pbdrv_gpio_out_low(&port_a_pin_2); break; - case PBIO_PORT_B: + case PBIO_PORT_ID_B: pbdrv_gpio_out_low(&port_b_pin_1); pbdrv_gpio_out_low(&port_b_pin_2); break; - case PBIO_PORT_C: + case PBIO_PORT_ID_C: pbdrv_gpio_out_low(&port_c_pin_1); pbdrv_gpio_out_low(&port_c_pin_2); break; - case PBIO_PORT_D: + case PBIO_PORT_ID_D: pbdrv_gpio_out_low(&port_d_pin_1); pbdrv_gpio_out_low(&port_d_pin_2); break; @@ -54,22 +54,22 @@ pbio_error_t pbdrv_motor_coast(pbio_port_t port) { return PBIO_SUCCESS; } -static void pbdrv_motor_brake(pbio_port_t port) { +static void pbdrv_motor_brake(pbio_port_id_t port) { // motor terminals will short-circuit when both pins are high switch (port) { - case PBIO_PORT_A: + case PBIO_PORT_ID_A: pbdrv_gpio_out_high(&port_a_pin_1); pbdrv_gpio_out_high(&port_a_pin_2); break; - case PBIO_PORT_B: + case PBIO_PORT_ID_B: pbdrv_gpio_out_high(&port_b_pin_1); pbdrv_gpio_out_high(&port_b_pin_2); break; pbdrv_gpio_out_high(&port_c_pin_1); pbdrv_gpio_out_high(&port_c_pin_2); break; - case PBIO_PORT_D: + case PBIO_PORT_ID_D: pbdrv_gpio_out_high(&port_d_pin_1); pbdrv_gpio_out_high(&port_d_pin_2); break; @@ -78,33 +78,33 @@ static void pbdrv_motor_brake(pbio_port_t port) { } } -static void pbdrv_motor_run_fwd(pbio_port_t port, int16_t duty_cycle) { +static void pbdrv_motor_run_fwd(pbio_port_id_t port, int16_t duty_cycle) { pbdrv_pwm_dev_t *dev; // one pin as out, high and the other as PWM switch (port) { - case PBIO_PORT_A: + case PBIO_PORT_ID_A: pbdrv_gpio_out_high(&port_a_pin_2); if (pbdrv_pwm_get_dev(0, &dev) == PBIO_SUCCESS) { pbdrv_pwm_set_duty(dev, 1, 1000 - duty_cycle / 10); } pbdrv_gpio_alt(&port_a_pin_1, 2); break; - case PBIO_PORT_B: + case PBIO_PORT_ID_B: pbdrv_gpio_out_high(&port_b_pin_2); if (pbdrv_pwm_get_dev(0, &dev) == PBIO_SUCCESS) { pbdrv_pwm_set_duty(dev, 2, 1000 - duty_cycle / 10); } pbdrv_gpio_alt(&port_b_pin_1, 2); break; - case PBIO_PORT_C: + case PBIO_PORT_ID_C: pbdrv_gpio_out_high(&port_c_pin_2); if (pbdrv_pwm_get_dev(1, &dev) == PBIO_SUCCESS) { pbdrv_pwm_set_duty(dev, 3, 1000 - duty_cycle / 10); } pbdrv_gpio_alt(&port_c_pin_1, 0); break; - case PBIO_PORT_D: + case PBIO_PORT_ID_D: pbdrv_gpio_out_high(&port_d_pin_2); if (pbdrv_pwm_get_dev(1, &dev) == PBIO_SUCCESS) { pbdrv_pwm_set_duty(dev, 2, 1000 - duty_cycle / 10); @@ -116,33 +116,33 @@ static void pbdrv_motor_run_fwd(pbio_port_t port, int16_t duty_cycle) { } } -static void pbdrv_motor_run_rev(pbio_port_t port, int16_t duty_cycle) { +static void pbdrv_motor_run_rev(pbio_port_id_t port, int16_t duty_cycle) { pbdrv_pwm_dev_t *dev; // one pin as out, high and the other as PWM switch (port) { - case PBIO_PORT_A: + case PBIO_PORT_ID_A: pbdrv_gpio_out_high(&port_a_pin_1); if (pbdrv_pwm_get_dev(0, &dev) == PBIO_SUCCESS) { pbdrv_pwm_set_duty(dev, 3, 1000 + duty_cycle / 10); } pbdrv_gpio_alt(&port_a_pin_2, 2); break; - case PBIO_PORT_B: + case PBIO_PORT_ID_B: pbdrv_gpio_out_high(&port_b_pin_1); if (pbdrv_pwm_get_dev(0, &dev) == PBIO_SUCCESS) { pbdrv_pwm_set_duty(dev, 4, 1000 + duty_cycle / 10); } pbdrv_gpio_alt(&port_b_pin_2, 2); break; - case PBIO_PORT_C: + case PBIO_PORT_ID_C: pbdrv_gpio_out_high(&port_c_pin_1); if (pbdrv_pwm_get_dev(1, &dev) == PBIO_SUCCESS) { pbdrv_pwm_set_duty(dev, 1, 1000 + duty_cycle / 10); } pbdrv_gpio_alt(&port_c_pin_2, 0); break; - case PBIO_PORT_D: + case PBIO_PORT_ID_D: pbdrv_gpio_out_high(&port_d_pin_1); if (pbdrv_pwm_get_dev(1, &dev) == PBIO_SUCCESS) { pbdrv_pwm_set_duty(dev, 4, 1000 + duty_cycle / 10); @@ -154,8 +154,8 @@ static void pbdrv_motor_run_rev(pbio_port_t port, int16_t duty_cycle) { } } -pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { - if (port < PBIO_PORT_A || port > PBIO_PORT_D) { +pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_id_t port, int16_t duty_cycle) { + if (port < PBIO_PORT_ID_A || port > PBIO_PORT_ID_D) { return PBIO_ERROR_INVALID_PORT; } @@ -174,11 +174,11 @@ pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { return PBIO_SUCCESS; } -pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { - if (port == PBIO_PORT_A || port == PBIO_PORT_B) { +pbio_error_t pbdrv_motor_get_id(pbio_port_id_t port, pbio_iodev_type_id_t *id) { + if (port == PBIO_PORT_ID_A || port == PBIO_PORT_ID_B) { *id = PBIO_IODEV_TYPE_ID_MOVE_HUB_MOTOR; return PBIO_SUCCESS; - } else if (port == PBIO_PORT_C || port == PBIO_PORT_D) { + } else if (port == PBIO_PORT_ID_C || port == PBIO_PORT_ID_D) { pbio_iodev_t *iodev; pbio_error_t err; @@ -199,7 +199,7 @@ pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { return PBIO_ERROR_INVALID_PORT; } -pbio_error_t pbdrv_motor_setup(pbio_port_t port, bool is_servo) { +pbio_error_t pbdrv_motor_setup(pbio_port_id_t port, bool is_servo) { return PBIO_SUCCESS; } diff --git a/lib/pbio/drv/nxt/motor.c b/lib/pbio/drv/nxt/motor.c index bac4304ae..ffe1fa5a4 100644 --- a/lib/pbio/drv/nxt/motor.c +++ b/lib/pbio/drv/nxt/motor.c @@ -12,7 +12,7 @@ #include -pbio_error_t pbdrv_motor_coast(pbio_port_t port) { +pbio_error_t pbdrv_motor_coast(pbio_port_id_t port) { if (port < PBDRV_CONFIG_FIRST_MOTOR_PORT || port > PBDRV_CONFIG_LAST_MOTOR_PORT) { return PBIO_ERROR_INVALID_PORT; } @@ -20,7 +20,7 @@ pbio_error_t pbdrv_motor_coast(pbio_port_t port) { return PBIO_SUCCESS; } -pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { +pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_id_t port, int16_t duty_cycle) { if (port < PBDRV_CONFIG_FIRST_MOTOR_PORT || port > PBDRV_CONFIG_LAST_MOTOR_PORT) { return PBIO_ERROR_INVALID_PORT; } @@ -28,7 +28,7 @@ pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { return PBIO_SUCCESS; } -pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { +pbio_error_t pbdrv_motor_get_id(pbio_port_id_t port, pbio_iodev_type_id_t *id) { if (port < PBDRV_CONFIG_FIRST_MOTOR_PORT || port > PBDRV_CONFIG_LAST_MOTOR_PORT) { return PBIO_ERROR_INVALID_PORT; } @@ -36,7 +36,7 @@ pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { return PBIO_SUCCESS; } -pbio_error_t pbdrv_motor_setup(pbio_port_t port, bool is_servo) { +pbio_error_t pbdrv_motor_setup(pbio_port_id_t port, bool is_servo) { return PBIO_SUCCESS; } diff --git a/lib/pbio/drv/prime_hub/motor.c b/lib/pbio/drv/prime_hub/motor.c index 356c97125..4a9d43692 100644 --- a/lib/pbio/drv/prime_hub/motor.c +++ b/lib/pbio/drv/prime_hub/motor.c @@ -109,7 +109,7 @@ static const pbdrv_motor_data_t }, }; -pbio_error_t pbdrv_motor_coast(pbio_port_t port) { +pbio_error_t pbdrv_motor_coast(pbio_port_id_t port) { const pbdrv_motor_data_t *data; if (port < PBDRV_CONFIG_FIRST_MOTOR_PORT || port > PBDRV_CONFIG_LAST_MOTOR_PORT) { @@ -147,7 +147,7 @@ static void pbdrv_motor_run_rev(const pbdrv_motor_data_t *data, int16_t duty_cyc pbdrv_gpio_alt(&data->pin2_gpio, data->pin2_alt); } -pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { +pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_id_t port, int16_t duty_cycle) { const pbdrv_motor_data_t *data; if (port < PBDRV_CONFIG_FIRST_MOTOR_PORT || port > PBDRV_CONFIG_LAST_MOTOR_PORT) { @@ -171,7 +171,7 @@ pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { return PBIO_SUCCESS; } -pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { +pbio_error_t pbdrv_motor_get_id(pbio_port_id_t port, pbio_iodev_type_id_t *id) { pbio_iodev_t *iodev; pbio_error_t err; @@ -190,7 +190,7 @@ pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { return PBIO_SUCCESS; } -pbio_error_t pbdrv_motor_setup(pbio_port_t port, bool is_servo) { +pbio_error_t pbdrv_motor_setup(pbio_port_id_t port, bool is_servo) { return PBIO_SUCCESS; } diff --git a/lib/pbio/drv/technic_hub/motor.c b/lib/pbio/drv/technic_hub/motor.c index a075623f8..b2f74dc62 100644 --- a/lib/pbio/drv/technic_hub/motor.c +++ b/lib/pbio/drv/technic_hub/motor.c @@ -68,7 +68,7 @@ static const pbdrv_motor_data_t }, }; -pbio_error_t pbdrv_motor_coast(pbio_port_t port) { +pbio_error_t pbdrv_motor_coast(pbio_port_id_t port) { const pbdrv_motor_data_t *data; if (port < PBDRV_CONFIG_FIRST_MOTOR_PORT || port > PBDRV_CONFIG_LAST_MOTOR_PORT) { @@ -106,7 +106,7 @@ static void pbdrv_motor_run_rev(const pbdrv_motor_data_t *data, int16_t duty_cyc pbdrv_gpio_alt(&data->pin2_gpio, data->alt); } -pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { +pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_id_t port, int16_t duty_cycle) { const pbdrv_motor_data_t *data; if (port < PBDRV_CONFIG_FIRST_MOTOR_PORT || port > PBDRV_CONFIG_LAST_MOTOR_PORT) { @@ -130,7 +130,7 @@ pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { return PBIO_SUCCESS; } -pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { +pbio_error_t pbdrv_motor_get_id(pbio_port_id_t port, pbio_iodev_type_id_t *id) { pbio_iodev_t *iodev; pbio_error_t err; @@ -149,7 +149,7 @@ pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { return PBIO_SUCCESS; } -pbio_error_t pbdrv_motor_setup(pbio_port_t port, bool is_servo) { +pbio_error_t pbdrv_motor_setup(pbio_port_id_t port, bool is_servo) { return PBIO_SUCCESS; } diff --git a/lib/pbio/include/pbdrv/config.h b/lib/pbio/include/pbdrv/config.h index dbf61c184..40e21c072 100644 --- a/lib/pbio/include/pbdrv/config.h +++ b/lib/pbio/include/pbdrv/config.h @@ -67,12 +67,12 @@ #define PBDRV_CONFIG_COUNTER_COUNTS_PER_DEGREE (1) #endif -// the pbio_port_t enum value of the first motor port +// the pbio_port_id_t enum value of the first motor port #ifndef PBDRV_CONFIG_FIRST_MOTOR_PORT #error PBDRV_CONFIG_NUM_MOTOR_CONTROLLER requires that PBDRV_CONFIG_FIRST_MOTOR_PORT is defined #endif -// the pbio_port_t enum value of the last motor port +// the pbio_port_id_t enum value of the last motor port #ifndef PBDRV_CONFIG_LAST_MOTOR_PORT #error PBDRV_CONFIG_NUM_MOTOR_CONTROLLER requires that PBDRV_CONFIG_LAST_MOTOR_PORT is defined #endif diff --git a/lib/pbio/include/pbdrv/ioport.h b/lib/pbio/include/pbdrv/ioport.h index 97e70e5f0..e351b55cf 100644 --- a/lib/pbio/include/pbdrv/ioport.h +++ b/lib/pbio/include/pbdrv/ioport.h @@ -18,13 +18,13 @@ #if PBDRV_CONFIG_IOPORT -pbio_error_t pbdrv_ioport_get_iodev(pbio_port_t port, pbio_iodev_t **iodev); +pbio_error_t pbdrv_ioport_get_iodev(pbio_port_id_t port, pbio_iodev_t **iodev); void pbio_ioport_reset_passive_devices(void); #else // PBDRV_CONFIG_IOPORT -static inline pbio_error_t pbdrv_ioport_get_iodev(pbio_port_t port, pbio_iodev_t **iodev) { +static inline pbio_error_t pbdrv_ioport_get_iodev(pbio_port_id_t port, pbio_iodev_t **iodev) { *iodev = NULL; return PBIO_ERROR_NOT_SUPPORTED; } diff --git a/lib/pbio/include/pbdrv/motor.h b/lib/pbio/include/pbdrv/motor.h index 3027622a1..5f36d32bd 100644 --- a/lib/pbio/include/pbdrv/motor.h +++ b/lib/pbio/include/pbdrv/motor.h @@ -32,7 +32,7 @@ * ::PBIO_ERROR_NO_DEV if port is valid but motor is not connected * ::PBIO_ERROR_IO if there was an I/O error */ -pbio_error_t pbdrv_motor_coast(pbio_port_t port); +pbio_error_t pbdrv_motor_coast(pbio_port_id_t port); /** * Sets the PWM duty cycle for the motor. Setting a duty cycle of 0 will "brake" the motor. @@ -44,7 +44,7 @@ pbio_error_t pbdrv_motor_coast(pbio_port_t port); * ::PBIO_ERROR_NO_DEV if port is valid but motor is not connected * ::PBIO_ERROR_IO if there was an I/O error */ -pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle); +pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_id_t port, int16_t duty_cycle); /** * Gets the device id of the motor @@ -55,7 +55,7 @@ pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle); * ::PBIO_ERROR_NO_DEV if port is valid but motor is not connected * ::PBIO_ERROR_IO if there was an I/O error */ -pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id); +pbio_error_t pbdrv_motor_get_id(pbio_port_id_t port, pbio_iodev_type_id_t *id); /** * Sets up the motor port @@ -67,21 +67,21 @@ pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id); * ::PBIO_ERROR_EAGAIN if this should be called again later * ::PBIO_ERROR_IO if there was an I/O error */ -pbio_error_t pbdrv_motor_setup(pbio_port_t port, bool is_servo); +pbio_error_t pbdrv_motor_setup(pbio_port_id_t port, bool is_servo); #else -static inline pbio_error_t pbdrv_motor_coast(pbio_port_t port) { +static inline pbio_error_t pbdrv_motor_coast(pbio_port_id_t port) { return PBIO_ERROR_NOT_SUPPORTED; } -static inline pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { +static inline pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_id_t port, int16_t duty_cycle) { return PBIO_ERROR_NOT_SUPPORTED; } -static inline pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { +static inline pbio_error_t pbdrv_motor_get_id(pbio_port_id_t port, pbio_iodev_type_id_t *id) { *id = 0; return PBIO_ERROR_NOT_SUPPORTED; } -static inline pbio_error_t pbdrv_motor_setup(pbio_port_t port, bool is_servo) { +static inline pbio_error_t pbdrv_motor_setup(pbio_port_id_t port, bool is_servo) { return PBIO_ERROR_NOT_SUPPORTED; } diff --git a/lib/pbio/include/pbio/dcmotor.h b/lib/pbio/include/pbio/dcmotor.h index f4af1ed30..a5514d29f 100644 --- a/lib/pbio/include/pbio/dcmotor.h +++ b/lib/pbio/include/pbio/dcmotor.h @@ -24,7 +24,7 @@ typedef enum { } pbio_passivity_t; typedef struct _pbio_dcmotor_t { - pbio_port_t port; + pbio_port_id_t port; pbio_iodev_type_id_t id; pbio_direction_t direction; pbio_passivity_t state; @@ -33,7 +33,7 @@ typedef struct _pbio_dcmotor_t { #if PBIO_CONFIG_DCMOTOR -pbio_error_t pbio_dcmotor_get(pbio_port_t port, pbio_dcmotor_t **dcmotor, pbio_direction_t direction, bool is_servo); +pbio_error_t pbio_dcmotor_get(pbio_port_id_t port, pbio_dcmotor_t **dcmotor, pbio_direction_t direction, bool is_servo); pbio_error_t pbio_dcmotor_get_state(pbio_dcmotor_t *dcmotor, pbio_passivity_t *state, int32_t *duty_now); @@ -44,7 +44,7 @@ pbio_error_t pbio_dcmotor_set_duty_cycle_usr(pbio_dcmotor_t *dcmotor, int32_t du #else -static inline pbio_error_t pbio_dcmotor_get(pbio_port_t port, pbio_dcmotor_t **dcmotor, pbio_direction_t direction, bool is_servo) { +static inline pbio_error_t pbio_dcmotor_get(pbio_port_id_t port, pbio_dcmotor_t **dcmotor, pbio_direction_t direction, bool is_servo) { return PBIO_ERROR_NOT_SUPPORTED; } diff --git a/lib/pbio/include/pbio/iodev.h b/lib/pbio/include/pbio/iodev.h index 140f580c5..d69f60326 100644 --- a/lib/pbio/include/pbio/iodev.h +++ b/lib/pbio/include/pbio/iodev.h @@ -331,7 +331,7 @@ struct _pbio_iodev_t { /** * The port the device is attached to. */ - pbio_port_t port; + pbio_port_id_t port; /** * The current active mode. */ diff --git a/lib/pbio/include/pbio/motor_process.h b/lib/pbio/include/pbio/motor_process.h index 1ec0429f0..1a7bb314e 100644 --- a/lib/pbio/include/pbio/motor_process.h +++ b/lib/pbio/include/pbio/motor_process.h @@ -11,7 +11,7 @@ #if PBDRV_CONFIG_NUM_MOTOR_CONTROLLER != 0 pbio_error_t pbio_motor_process_get_drivebase(pbio_drivebase_t **db); -pbio_error_t pbio_motor_process_get_servo(pbio_port_t port, pbio_servo_t **srv); +pbio_error_t pbio_motor_process_get_servo(pbio_port_id_t port, pbio_servo_t **srv); void pbio_motor_process_reset(void); diff --git a/lib/pbio/include/pbio/port.h b/lib/pbio/include/pbio/port.h index 3d69d0a13..6d955495d 100644 --- a/lib/pbio/include/pbio/port.h +++ b/lib/pbio/include/pbio/port.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2018-2020 The Pybricks Authors +// Copyright (c) 2018-2021 The Pybricks Authors #ifndef _PBIO_PORT_H_ #define _PBIO_PORT_H_ @@ -20,36 +20,36 @@ */ typedef enum { #if PBDRV_CONFIG_HAS_PORT_A - PBIO_PORT_A = 'A', /**< I/O port labeled as "A" */ + PBIO_PORT_ID_A = 'A', /**< I/O port labeled as "A" */ #endif #if PBDRV_CONFIG_HAS_PORT_B - PBIO_PORT_B = 'B', /**< I/O port labeled as "B" */ + PBIO_PORT_ID_B = 'B', /**< I/O port labeled as "B" */ #endif #if PBDRV_CONFIG_HAS_PORT_C - PBIO_PORT_C = 'C', /**< I/O port labeled as "C" */ + PBIO_PORT_ID_C = 'C', /**< I/O port labeled as "C" */ #endif #if PBDRV_CONFIG_HAS_PORT_D - PBIO_PORT_D = 'D', /**< I/O port labeled as "D" */ + PBIO_PORT_ID_D = 'D', /**< I/O port labeled as "D" */ #endif #if PBDRV_CONFIG_HAS_PORT_E - PBIO_PORT_E = 'E', /**< I/O port labeled as "C" */ + PBIO_PORT_ID_E = 'E', /**< I/O port labeled as "C" */ #endif #if PBDRV_CONFIG_HAS_PORT_F - PBIO_PORT_F = 'F', /**< I/O port labeled as "F" */ + PBIO_PORT_ID_F = 'F', /**< I/O port labeled as "F" */ #endif #if PBDRV_CONFIG_HAS_PORT_1 - PBIO_PORT_1 = '1', /**< I/O port labeled as "1" */ + PBIO_PORT_ID_1 = '1', /**< I/O port labeled as "1" */ #endif #if PBDRV_CONFIG_HAS_PORT_2 - PBIO_PORT_2 = '2', /**< I/O port labeled as "2" */ + PBIO_PORT_ID_2 = '2', /**< I/O port labeled as "2" */ #endif #if PBDRV_CONFIG_HAS_PORT_3 - PBIO_PORT_3 = '3', /**< I/O port labeled as "3" */ + PBIO_PORT_ID_3 = '3', /**< I/O port labeled as "3" */ #endif #if PBDRV_CONFIG_HAS_PORT_4 - PBIO_PORT_4 = '4', /**< I/O port labeled as "4" */ + PBIO_PORT_ID_4 = '4', /**< I/O port labeled as "4" */ #endif -} pbio_port_t; +} pbio_port_id_t; /** @} */ diff --git a/lib/pbio/include/pbio/servo.h b/lib/pbio/include/pbio/servo.h index fbd5dbd70..97a3d7132 100644 --- a/lib/pbio/include/pbio/servo.h +++ b/lib/pbio/include/pbio/servo.h @@ -28,7 +28,7 @@ #define PBIO_SERVO_LOG_COLS (9) typedef struct _pbio_servo_t { - pbio_port_t port; + pbio_port_id_t port; bool connected; bool claimed; pbio_dcmotor_t *dcmotor; diff --git a/lib/pbio/include/pbio/tacho.h b/lib/pbio/include/pbio/tacho.h index 9bf78d229..c200982e7 100644 --- a/lib/pbio/include/pbio/tacho.h +++ b/lib/pbio/include/pbio/tacho.h @@ -16,7 +16,7 @@ typedef struct _pbio_tacho_t pbio_tacho_t; #if PBIO_CONFIG_TACHO -pbio_error_t pbio_tacho_get(pbio_port_t port, pbio_tacho_t **tacho, pbio_direction_t direction, fix16_t gear_ratio); +pbio_error_t pbio_tacho_get(pbio_port_id_t port, pbio_tacho_t **tacho, pbio_direction_t direction, fix16_t gear_ratio); pbio_error_t pbio_tacho_get_count(pbio_tacho_t *tacho, int32_t *count); pbio_error_t pbio_tacho_get_angle(pbio_tacho_t *tacho, int32_t *angle); @@ -26,7 +26,7 @@ pbio_error_t pbio_tacho_get_angular_rate(pbio_tacho_t *tacho, int32_t *angular_r #else -static inline pbio_error_t pbio_tacho_get(pbio_port_t port, pbio_tacho_t **tacho, pbio_direction_t direction, fix16_t gear_ratio) { +static inline pbio_error_t pbio_tacho_get(pbio_port_id_t port, pbio_tacho_t **tacho, pbio_direction_t direction, fix16_t gear_ratio) { return PBIO_ERROR_NOT_SUPPORTED; } diff --git a/lib/pbio/platform/city_hub/pbdrvconfig.h b/lib/pbio/platform/city_hub/pbdrvconfig.h index 65e16f0f0..df6619255 100644 --- a/lib/pbio/platform/city_hub/pbdrvconfig.h +++ b/lib/pbio/platform/city_hub/pbdrvconfig.h @@ -41,8 +41,8 @@ #define PBDRV_CONFIG_IOPORT (1) #define PBDRV_CONFIG_IOPORT_LPF2 (1) #define PBDRV_CONFIG_IOPORT_LPF2_NUM_PORTS (2) -#define PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT PBIO_PORT_A -#define PBDRV_CONFIG_IOPORT_LPF2_LAST_PORT PBIO_PORT_B +#define PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT PBIO_PORT_ID_A +#define PBDRV_CONFIG_IOPORT_LPF2_LAST_PORT PBIO_PORT_ID_B #define PBDRV_CONFIG_LED (1) #define PBDRV_CONFIG_LED_NUM_DEV (1) @@ -71,8 +71,8 @@ #define PBDRV_CONFIG_HAS_PORT_A (1) #define PBDRV_CONFIG_HAS_PORT_B (1) -#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_A -#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_B +#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_ID_A +#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_ID_B #define PBDRV_CONFIG_NUM_MOTOR_CONTROLLER (2) #define PBDRV_CONFIG_SYS_CLOCK_RATE 48000000 diff --git a/lib/pbio/platform/debug/platform.c b/lib/pbio/platform/debug/platform.c index ca40e285f..6abe01169 100644 --- a/lib/pbio/platform/debug/platform.c +++ b/lib/pbio/platform/debug/platform.c @@ -244,8 +244,8 @@ void USART2_IRQHandler(void) { // HACK: we don't have a generic ioport interface yet so defining this function // in platform.c -pbio_error_t pbdrv_ioport_get_iodev(pbio_port_t port, pbio_iodev_t **iodev) { - if (port != PBIO_PORT_1) { +pbio_error_t pbdrv_ioport_get_iodev(pbio_port_id_t port, pbio_iodev_t **iodev) { + if (port != PBIO_PORT_ID_1) { return PBIO_ERROR_INVALID_PORT; } diff --git a/lib/pbio/platform/ev3dev_stretch/pbdrvconfig.h b/lib/pbio/platform/ev3dev_stretch/pbdrvconfig.h index eac6cf5db..dd0799cef 100644 --- a/lib/pbio/platform/ev3dev_stretch/pbdrvconfig.h +++ b/lib/pbio/platform/ev3dev_stretch/pbdrvconfig.h @@ -31,13 +31,13 @@ #define PBDRV_CONFIG_HAS_PORT_3 (1) #define PBDRV_CONFIG_HAS_PORT_4 (1) -#define PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT PBIO_PORT_1 -#define PBDRV_CONFIG_IOPORT_LPF2_LAST_PORT PBIO_PORT_4 +#define PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT PBIO_PORT_ID_1 +#define PBDRV_CONFIG_IOPORT_LPF2_LAST_PORT PBIO_PORT_ID_4 #define PBDRV_CONFIG_MOTOR (1) -#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_A -#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_D +#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_ID_A +#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_ID_D #define PBDRV_CONFIG_NUM_MOTOR_CONTROLLER (4) #endif // _PBDRVCONFIG_H_ diff --git a/lib/pbio/platform/move_hub/pbdrvconfig.h b/lib/pbio/platform/move_hub/pbdrvconfig.h index 8096397d2..bc8054429 100644 --- a/lib/pbio/platform/move_hub/pbdrvconfig.h +++ b/lib/pbio/platform/move_hub/pbdrvconfig.h @@ -42,8 +42,8 @@ #define PBDRV_CONFIG_IOPORT (1) #define PBDRV_CONFIG_IOPORT_LPF2 (1) #define PBDRV_CONFIG_IOPORT_LPF2_NUM_PORTS (2) -#define PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT PBIO_PORT_C -#define PBDRV_CONFIG_IOPORT_LPF2_LAST_PORT PBIO_PORT_D +#define PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT PBIO_PORT_ID_C +#define PBDRV_CONFIG_IOPORT_LPF2_LAST_PORT PBIO_PORT_ID_D #define PBDRV_CONFIG_LED (1) #define PBDRV_CONFIG_LED_NUM_DEV (1) @@ -74,8 +74,8 @@ #define PBDRV_CONFIG_HAS_PORT_C (1) #define PBDRV_CONFIG_HAS_PORT_D (1) -#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_A -#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_D +#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_ID_A +#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_ID_D #define PBDRV_CONFIG_NUM_MOTOR_CONTROLLER (4) #define PBDRV_CONFIG_SYS_CLOCK_RATE 48000000 diff --git a/lib/pbio/platform/nxt/pbdrvconfig.h b/lib/pbio/platform/nxt/pbdrvconfig.h index 905b6e080..9037bd6bb 100644 --- a/lib/pbio/platform/nxt/pbdrvconfig.h +++ b/lib/pbio/platform/nxt/pbdrvconfig.h @@ -30,8 +30,8 @@ #define PBDRV_CONFIG_MOTOR (1) -#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_A -#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_C +#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_ID_A +#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_ID_C #define PBDRV_CONFIG_NUM_MOTOR_CONTROLLER (3) #define PBDRV_CONFIG_RESET (1) diff --git a/lib/pbio/platform/prime_hub/pbdrvconfig.h b/lib/pbio/platform/prime_hub/pbdrvconfig.h index 81ff2f2d2..33a4ff073 100644 --- a/lib/pbio/platform/prime_hub/pbdrvconfig.h +++ b/lib/pbio/platform/prime_hub/pbdrvconfig.h @@ -48,8 +48,8 @@ #define PBDRV_CONFIG_IOPORT (1) #define PBDRV_CONFIG_IOPORT_LPF2 (1) #define PBDRV_CONFIG_IOPORT_LPF2_NUM_PORTS (6) -#define PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT PBIO_PORT_A -#define PBDRV_CONFIG_IOPORT_LPF2_LAST_PORT PBIO_PORT_F +#define PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT PBIO_PORT_ID_A +#define PBDRV_CONFIG_IOPORT_LPF2_LAST_PORT PBIO_PORT_ID_F #define PBDRV_CONFIG_LED (1) #define PBDRV_CONFIG_LED_NUM_DEV (5) @@ -97,8 +97,8 @@ #define PBDRV_CONFIG_HAS_PORT_E (1) #define PBDRV_CONFIG_HAS_PORT_F (1) -#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_A -#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_F +#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_ID_A +#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_ID_F #define PBDRV_CONFIG_NUM_MOTOR_CONTROLLER (6) #define PBDRV_CONFIG_SYS_CLOCK_RATE 96000000 diff --git a/lib/pbio/platform/technic_hub/pbdrvconfig.h b/lib/pbio/platform/technic_hub/pbdrvconfig.h index 1496d24ac..ba0d3acb2 100644 --- a/lib/pbio/platform/technic_hub/pbdrvconfig.h +++ b/lib/pbio/platform/technic_hub/pbdrvconfig.h @@ -46,8 +46,8 @@ #define PBDRV_CONFIG_IOPORT (1) #define PBDRV_CONFIG_IOPORT_LPF2 (1) #define PBDRV_CONFIG_IOPORT_LPF2_NUM_PORTS (4) -#define PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT PBIO_PORT_A -#define PBDRV_CONFIG_IOPORT_LPF2_LAST_PORT PBIO_PORT_D +#define PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT PBIO_PORT_ID_A +#define PBDRV_CONFIG_IOPORT_LPF2_LAST_PORT PBIO_PORT_ID_D #define PBDRV_CONFIG_LED (1) #define PBDRV_CONFIG_LED_NUM_DEV (1) @@ -78,8 +78,8 @@ #define PBDRV_CONFIG_HAS_PORT_C (1) #define PBDRV_CONFIG_HAS_PORT_D (1) -#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_A -#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_D +#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_ID_A +#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_ID_D #define PBDRV_CONFIG_NUM_MOTOR_CONTROLLER (4) #define PBDRV_CONFIG_SYS_CLOCK_RATE 80000000 diff --git a/lib/pbio/src/dcmotor.c b/lib/pbio/src/dcmotor.c index bc6e949d5..dc871de27 100644 --- a/lib/pbio/src/dcmotor.c +++ b/lib/pbio/src/dcmotor.c @@ -44,7 +44,7 @@ static pbio_error_t pbio_dcmotor_setup(pbio_dcmotor_t *dcmotor, pbio_direction_t return PBIO_SUCCESS; } -pbio_error_t pbio_dcmotor_get(pbio_port_t port, pbio_dcmotor_t **dcmotor, pbio_direction_t direction, bool is_servo) { +pbio_error_t pbio_dcmotor_get(pbio_port_id_t port, pbio_dcmotor_t **dcmotor, pbio_direction_t direction, bool is_servo) { // Validate port if (port < PBDRV_CONFIG_FIRST_MOTOR_PORT || port > PBDRV_CONFIG_LAST_MOTOR_PORT) { return PBIO_ERROR_INVALID_PORT; diff --git a/lib/pbio/src/motor_process.c b/lib/pbio/src/motor_process.c index 75ef8dfd4..7e28403f1 100644 --- a/lib/pbio/src/motor_process.c +++ b/lib/pbio/src/motor_process.c @@ -20,7 +20,7 @@ pbio_error_t pbio_motor_process_get_drivebase(pbio_drivebase_t **db) { return PBIO_SUCCESS; } -pbio_error_t pbio_motor_process_get_servo(pbio_port_t port, pbio_servo_t **srv) { +pbio_error_t pbio_motor_process_get_servo(pbio_port_id_t port, pbio_servo_t **srv) { if (port < PBDRV_CONFIG_FIRST_MOTOR_PORT || port > PBDRV_CONFIG_LAST_MOTOR_PORT) { return PBIO_ERROR_INVALID_PORT; diff --git a/lib/pbio/src/tacho.c b/lib/pbio/src/tacho.c index ede410946..c9e3b2561 100644 --- a/lib/pbio/src/tacho.c +++ b/lib/pbio/src/tacho.c @@ -83,7 +83,7 @@ static pbio_error_t pbio_tacho_setup(pbio_tacho_t *tacho, uint8_t counter_id, pb return err; } -pbio_error_t pbio_tacho_get(pbio_port_t port, pbio_tacho_t **tacho, pbio_direction_t direction, fix16_t gear_ratio) { +pbio_error_t pbio_tacho_get(pbio_port_id_t port, pbio_tacho_t **tacho, pbio_direction_t direction, fix16_t gear_ratio) { // Validate port if (port < PBDRV_CONFIG_FIRST_MOTOR_PORT || port > PBDRV_CONFIG_LAST_MOTOR_PORT) { return PBIO_ERROR_INVALID_PORT; diff --git a/lib/pbio/test/pbdrvconfig.h b/lib/pbio/test/pbdrvconfig.h index d151c84ca..3f9205c92 100644 --- a/lib/pbio/test/pbdrvconfig.h +++ b/lib/pbio/test/pbdrvconfig.h @@ -24,6 +24,6 @@ #define PBDRV_CONFIG_MOTOR (1) #define PBDRV_CONFIG_HAS_PORT_A (1) -#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_A -#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_A +#define PBDRV_CONFIG_FIRST_MOTOR_PORT PBIO_PORT_ID_A +#define PBDRV_CONFIG_LAST_MOTOR_PORT PBIO_PORT_ID_A #define PBDRV_CONFIG_NUM_MOTOR_CONTROLLER (1) diff --git a/lib/pbio/test/src/servo.c b/lib/pbio/test/src/servo.c index f51164f72..9fd74381f 100644 --- a/lib/pbio/test/src/servo.c +++ b/lib/pbio/test/src/servo.c @@ -41,13 +41,13 @@ static struct { h_bridge_output_t output; } test_motor_driver; -pbio_error_t pbdrv_motor_coast(pbio_port_t port) { +pbio_error_t pbdrv_motor_coast(pbio_port_id_t port) { test_motor_driver.output = H_BRIDGE_OUTPUT_LL; test_motor_driver.duty_cycle = 0; return PBIO_SUCCESS; } -pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { +pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_id_t port, int16_t duty_cycle) { if (duty_cycle > 0) { test_motor_driver.output = H_BRIDGE_OUTPUT_LH; } else if (duty_cycle < 0) { @@ -59,13 +59,13 @@ pbio_error_t pbdrv_motor_set_duty_cycle(pbio_port_t port, int16_t duty_cycle) { return PBIO_SUCCESS; } -pbio_error_t pbdrv_motor_get_id(pbio_port_t port, pbio_iodev_type_id_t *id) { +pbio_error_t pbdrv_motor_get_id(pbio_port_id_t port, pbio_iodev_type_id_t *id) { const char *motor_id = getenv("PBIO_TEST_MOTOR_TYPE"); *id = motor_id == NULL ? PBIO_IODEV_TYPE_ID_INTERACTIVE_MOTOR : atoi(motor_id); return PBIO_SUCCESS; } -pbio_error_t pbdrv_motor_setup(pbio_port_t port, bool is_servo) { +pbio_error_t pbdrv_motor_setup(pbio_port_id_t port, bool is_servo) { return PBIO_SUCCESS; } @@ -88,7 +88,7 @@ static PT_THREAD(test_servo_run_func(struct pt *pt, const char *name, pbio_error process_start(&pbio_motor_process, NULL); tt_want(process_is_running(&pbio_motor_process)); - tt_uint_op(pbio_motor_process_get_servo(PBIO_PORT_A, &servo), ==, PBIO_SUCCESS); + tt_uint_op(pbio_motor_process_get_servo(PBIO_PORT_ID_A, &servo), ==, PBIO_SUCCESS); tt_uint_op(pbio_servo_setup(servo, PBIO_DIRECTION_CLOCKWISE, F16C(1, 0)), ==, PBIO_SUCCESS); pbio_servo_set_connected(servo, true); diff --git a/pybricks/common/pb_type_dcmotor.c b/pybricks/common/pb_type_dcmotor.c index 73fd8be08..cea56a801 100644 --- a/pybricks/common/pb_type_dcmotor.c +++ b/pybricks/common/pb_type_dcmotor.c @@ -21,7 +21,7 @@ STATIC mp_obj_t common_DCMotor_make_new(const mp_obj_type_t *type, size_t n_args PB_ARG_DEFAULT_OBJ(positive_direction, pb_Direction_CLOCKWISE_obj)); // Configure the motor with the selected arguments at pbio level - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); pbio_direction_t direction = pb_type_enum_get_value(positive_direction_in, &pb_enum_type_Direction); // Get and initialize DC Motor diff --git a/pybricks/common/pb_type_motor.c b/pybricks/common/pb_type_motor.c index 666d99580..d05ee57af 100644 --- a/pybricks/common/pb_type_motor.c +++ b/pybricks/common/pb_type_motor.c @@ -37,7 +37,7 @@ STATIC mp_obj_t common_Motor_make_new(const mp_obj_type_t *type, size_t n_args, PB_ARG_DEFAULT_NONE(gears)); // Configure the motor with the selected arguments at pbio level - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); pbio_direction_t positive_direction = pb_type_enum_get_value(positive_direction_in, &pb_enum_type_Direction); pbio_error_t err; pbio_servo_t *srv; diff --git a/pybricks/ev3devices/pb_type_ev3devices_colorsensor.c b/pybricks/ev3devices/pb_type_ev3devices_colorsensor.c index 7ce7e860f..91cb4109c 100644 --- a/pybricks/ev3devices/pb_type_ev3devices_colorsensor.c +++ b/pybricks/ev3devices/pb_type_ev3devices_colorsensor.c @@ -26,7 +26,7 @@ STATIC mp_obj_t ev3devices_ColorSensor_make_new(const mp_obj_type_t *type, size_ ev3devices_ColorSensor_obj_t *self = m_new_obj(ev3devices_ColorSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_EV3_COLOR_SENSOR); diff --git a/pybricks/ev3devices/pb_type_ev3devices_gyrosensor.c b/pybricks/ev3devices/pb_type_ev3devices_gyrosensor.c index 9c2ca521a..241cce26e 100644 --- a/pybricks/ev3devices/pb_type_ev3devices_gyrosensor.c +++ b/pybricks/ev3devices/pb_type_ev3devices_gyrosensor.c @@ -16,7 +16,7 @@ // pybricks.ev3devices.GyroSensor class object typedef struct _ev3devices_GyroSensor_obj_t { mp_obj_base_t base; - pbio_port_t port; // FIXME: Shouldn't be here + pbio_port_id_t port; // FIXME: Shouldn't be here pb_device_t *pbdev; pbio_direction_t direction; mp_int_t offset; diff --git a/pybricks/ev3devices/pb_type_ev3devices_infraredsensor.c b/pybricks/ev3devices/pb_type_ev3devices_infraredsensor.c index 20cd05d76..5ecfba7da 100644 --- a/pybricks/ev3devices/pb_type_ev3devices_infraredsensor.c +++ b/pybricks/ev3devices/pb_type_ev3devices_infraredsensor.c @@ -28,7 +28,7 @@ STATIC mp_obj_t ev3devices_InfraredSensor_make_new(const mp_obj_type_t *type, si ev3devices_InfraredSensor_obj_t *self = m_new_obj(ev3devices_InfraredSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_EV3_IR_SENSOR); diff --git a/pybricks/ev3devices/pb_type_ev3devices_touchsensor.c b/pybricks/ev3devices/pb_type_ev3devices_touchsensor.c index bf1bd478c..6b5debd68 100644 --- a/pybricks/ev3devices/pb_type_ev3devices_touchsensor.c +++ b/pybricks/ev3devices/pb_type_ev3devices_touchsensor.c @@ -27,7 +27,7 @@ STATIC mp_obj_t ev3devices_TouchSensor_make_new(const mp_obj_type_t *type, size_ ev3devices_TouchSensor_obj_t *self = m_new_obj(ev3devices_TouchSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_EV3_TOUCH_SENSOR); diff --git a/pybricks/ev3devices/pb_type_ev3devices_ultrasonicsensor.c b/pybricks/ev3devices/pb_type_ev3devices_ultrasonicsensor.c index 442d0b133..73da42f2d 100644 --- a/pybricks/ev3devices/pb_type_ev3devices_ultrasonicsensor.c +++ b/pybricks/ev3devices/pb_type_ev3devices_ultrasonicsensor.c @@ -28,7 +28,7 @@ STATIC mp_obj_t ev3devices_UltrasonicSensor_make_new(const mp_obj_type_t *type, ev3devices_UltrasonicSensor_obj_t *self = m_new_obj(ev3devices_UltrasonicSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_EV3_ULTRASONIC_SENSOR); diff --git a/pybricks/iodevices/pb_type_iodevices_analogsensor.c b/pybricks/iodevices/pb_type_iodevices_analogsensor.c index 2d028f97f..9e836b442 100644 --- a/pybricks/iodevices/pb_type_iodevices_analogsensor.c +++ b/pybricks/iodevices/pb_type_iodevices_analogsensor.c @@ -29,7 +29,7 @@ STATIC mp_obj_t iodevices_AnalogSensor_make_new(const mp_obj_type_t *otype, size iodevices_AnalogSensor_obj_t *self = m_new_obj(iodevices_AnalogSensor_obj_t); self->base.type = (mp_obj_type_t *)otype; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_NXT_ANALOG); diff --git a/pybricks/iodevices/pb_type_iodevices_ev3devsensor.c b/pybricks/iodevices/pb_type_iodevices_ev3devsensor.c index 119a41b97..22ae717a7 100644 --- a/pybricks/iodevices/pb_type_iodevices_ev3devsensor.c +++ b/pybricks/iodevices/pb_type_iodevices_ev3devsensor.c @@ -33,7 +33,7 @@ STATIC mp_obj_t iodevices_Ev3devSensor_make_new(const mp_obj_type_t *type, size_ iodevices_Ev3devSensor_obj_t *self = m_new_obj(iodevices_Ev3devSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_EV3DEV_LEGO_SENSOR); diff --git a/pybricks/iodevices/pb_type_iodevices_i2cdevice.c b/pybricks/iodevices/pb_type_iodevices_i2cdevice.c index aebd5ace7..49e4d5899 100644 --- a/pybricks/iodevices/pb_type_iodevices_i2cdevice.c +++ b/pybricks/iodevices/pb_type_iodevices_i2cdevice.c @@ -36,7 +36,7 @@ STATIC mp_obj_t iodevices_I2CDevice_make_new(const mp_obj_type_t *otype, size_t self->base.type = (mp_obj_type_t *)otype; // Get port number - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); // Get selected I2C Address mp_int_t address = mp_obj_get_int(address_in); @@ -49,7 +49,7 @@ STATIC mp_obj_t iodevices_I2CDevice_make_new(const mp_obj_type_t *otype, size_t self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_CUSTOM_I2C); // Get the smbus, which on ev3dev is zero based sensor port number + 3. - pb_assert(pb_smbus_get(&self->bus, port - PBIO_PORT_1 + 3)); + pb_assert(pb_smbus_get(&self->bus, port - PBIO_PORT_ID_1 + 3)); return MP_OBJ_FROM_PTR(self); } diff --git a/pybricks/iodevices/pb_type_iodevices_lumpdevice.c b/pybricks/iodevices/pb_type_iodevices_lumpdevice.c index 1f85fad38..51969b9e8 100644 --- a/pybricks/iodevices/pb_type_iodevices_lumpdevice.c +++ b/pybricks/iodevices/pb_type_iodevices_lumpdevice.c @@ -32,7 +32,7 @@ STATIC mp_obj_t iodevices_LUMPDevice_make_new(const mp_obj_type_t *type, size_t iodevices_LUMPDevice_obj_t *self = m_new_obj(iodevices_LUMPDevice_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_LUMP_UART); diff --git a/pybricks/iodevices/pb_type_iodevices_pupdevice.c b/pybricks/iodevices/pb_type_iodevices_pupdevice.c index a54bea935..47d632efc 100644 --- a/pybricks/iodevices/pb_type_iodevices_pupdevice.c +++ b/pybricks/iodevices/pb_type_iodevices_pupdevice.c @@ -31,7 +31,7 @@ STATIC mp_obj_t iodevices_PUPDevice_make_new(const mp_obj_type_t *type, size_t n iodevices_PUPDevice_obj_t *self = m_new_obj(iodevices_PUPDevice_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_LUMP_UART); diff --git a/pybricks/iodevices/pb_type_iodevices_uartdevice.c b/pybricks/iodevices/pb_type_iodevices_uartdevice.c index dd7c35caa..81a19cf2d 100644 --- a/pybricks/iodevices/pb_type_iodevices_uartdevice.c +++ b/pybricks/iodevices/pb_type_iodevices_uartdevice.c @@ -39,7 +39,7 @@ STATIC mp_obj_t iodevices_UARTDevice_make_new(const mp_obj_type_t *otype, size_t self->base.type = (mp_obj_type_t *)otype; // Get port number - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); // Init UART port pb_device_get_device(port, PBIO_IODEV_TYPE_ID_CUSTOM_UART); diff --git a/pybricks/nxtdevices/pb_type_nxtdevices_colorsensor.c b/pybricks/nxtdevices/pb_type_nxtdevices_colorsensor.c index d8b80d7e2..122b7e72d 100644 --- a/pybricks/nxtdevices/pb_type_nxtdevices_colorsensor.c +++ b/pybricks/nxtdevices/pb_type_nxtdevices_colorsensor.c @@ -30,7 +30,7 @@ STATIC mp_obj_t nxtdevices_ColorSensor_make_new(const mp_obj_type_t *type, size_ nxtdevices_ColorSensor_obj_t *self = m_new_obj(nxtdevices_ColorSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_NXT_COLOR_SENSOR); diff --git a/pybricks/nxtdevices/pb_type_nxtdevices_energymeter.c b/pybricks/nxtdevices/pb_type_nxtdevices_energymeter.c index 3f3d45a3a..80f301495 100644 --- a/pybricks/nxtdevices/pb_type_nxtdevices_energymeter.c +++ b/pybricks/nxtdevices/pb_type_nxtdevices_energymeter.c @@ -26,7 +26,7 @@ STATIC mp_obj_t nxtdevices_EnergyMeter_make_new(const mp_obj_type_t *type, size_ nxtdevices_EnergyMeter_obj_t *self = m_new_obj(nxtdevices_EnergyMeter_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_NXT_ENERGY_METER); diff --git a/pybricks/nxtdevices/pb_type_nxtdevices_lightsensor.c b/pybricks/nxtdevices/pb_type_nxtdevices_lightsensor.c index 94b9af5aa..d1f4fcf55 100644 --- a/pybricks/nxtdevices/pb_type_nxtdevices_lightsensor.c +++ b/pybricks/nxtdevices/pb_type_nxtdevices_lightsensor.c @@ -58,7 +58,7 @@ STATIC mp_obj_t nxtdevices_LightSensor_make_new(const mp_obj_type_t *type, size_ nxtdevices_LightSensor_obj_t *self = m_new_obj(nxtdevices_LightSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_NXT_LIGHT_SENSOR); diff --git a/pybricks/nxtdevices/pb_type_nxtdevices_soundsensor.c b/pybricks/nxtdevices/pb_type_nxtdevices_soundsensor.c index c6d9ce634..a9075802d 100644 --- a/pybricks/nxtdevices/pb_type_nxtdevices_soundsensor.c +++ b/pybricks/nxtdevices/pb_type_nxtdevices_soundsensor.c @@ -42,7 +42,7 @@ STATIC mp_obj_t nxtdevices_SoundSensor_make_new(const mp_obj_type_t *type, size_ nxtdevices_SoundSensor_obj_t *self = m_new_obj(nxtdevices_SoundSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_NXT_SOUND_SENSOR); diff --git a/pybricks/nxtdevices/pb_type_nxtdevices_temperaturesensor.c b/pybricks/nxtdevices/pb_type_nxtdevices_temperaturesensor.c index 374bc3f1c..bb6807346 100644 --- a/pybricks/nxtdevices/pb_type_nxtdevices_temperaturesensor.c +++ b/pybricks/nxtdevices/pb_type_nxtdevices_temperaturesensor.c @@ -27,7 +27,7 @@ STATIC mp_obj_t nxtdevices_TemperatureSensor_make_new(const mp_obj_type_t *type, nxtdevices_TemperatureSensor_obj_t *self = m_new_obj(nxtdevices_TemperatureSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_NXT_TEMPERATURE_SENSOR); diff --git a/pybricks/nxtdevices/pb_type_nxtdevices_touchsensor.c b/pybricks/nxtdevices/pb_type_nxtdevices_touchsensor.c index 459034343..d668221cb 100644 --- a/pybricks/nxtdevices/pb_type_nxtdevices_touchsensor.c +++ b/pybricks/nxtdevices/pb_type_nxtdevices_touchsensor.c @@ -27,7 +27,7 @@ STATIC mp_obj_t nxtdevices_TouchSensor_make_new(const mp_obj_type_t *type, size_ nxtdevices_TouchSensor_obj_t *self = m_new_obj(nxtdevices_TouchSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_NXT_TOUCH_SENSOR); diff --git a/pybricks/nxtdevices/pb_type_nxtdevices_ultrasonicsensor.c b/pybricks/nxtdevices/pb_type_nxtdevices_ultrasonicsensor.c index ac92848ce..88b9ef8b2 100644 --- a/pybricks/nxtdevices/pb_type_nxtdevices_ultrasonicsensor.c +++ b/pybricks/nxtdevices/pb_type_nxtdevices_ultrasonicsensor.c @@ -27,7 +27,7 @@ STATIC mp_obj_t nxtdevices_UltrasonicSensor_make_new(const mp_obj_type_t *type, nxtdevices_UltrasonicSensor_obj_t *self = m_new_obj(nxtdevices_UltrasonicSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_NXT_ULTRASONIC_SENSOR); diff --git a/pybricks/parameters/pb_type_port.c b/pybricks/parameters/pb_type_port.c index 3368fad39..673615cc8 100644 --- a/pybricks/parameters/pb_type_port.c +++ b/pybricks/parameters/pb_type_port.c @@ -17,7 +17,7 @@ const pb_obj_enum_member_t pb_Port_A_obj = { {&pb_enum_type_Port}, .name = MP_QSTR_A, - .value = PBIO_PORT_A + .value = PBIO_PORT_ID_A }; #endif @@ -25,7 +25,7 @@ const pb_obj_enum_member_t pb_Port_A_obj = { const pb_obj_enum_member_t pb_Port_B_obj = { {&pb_enum_type_Port}, .name = MP_QSTR_B, - .value = PBIO_PORT_B + .value = PBIO_PORT_ID_B }; #endif @@ -33,7 +33,7 @@ const pb_obj_enum_member_t pb_Port_B_obj = { const pb_obj_enum_member_t pb_Port_C_obj = { {&pb_enum_type_Port}, .name = MP_QSTR_C, - .value = PBIO_PORT_C + .value = PBIO_PORT_ID_C }; #endif @@ -41,7 +41,7 @@ const pb_obj_enum_member_t pb_Port_C_obj = { const pb_obj_enum_member_t pb_Port_D_obj = { {&pb_enum_type_Port}, .name = MP_QSTR_D, - .value = PBIO_PORT_D + .value = PBIO_PORT_ID_D }; #endif @@ -49,7 +49,7 @@ const pb_obj_enum_member_t pb_Port_D_obj = { const pb_obj_enum_member_t pb_Port_E_obj = { {&pb_enum_type_Port}, .name = MP_QSTR_E, - .value = PBIO_PORT_E + .value = PBIO_PORT_ID_E }; #endif @@ -57,7 +57,7 @@ const pb_obj_enum_member_t pb_Port_E_obj = { const pb_obj_enum_member_t pb_Port_F_obj = { {&pb_enum_type_Port}, .name = MP_QSTR_F, - .value = PBIO_PORT_F + .value = PBIO_PORT_ID_F }; #endif @@ -65,7 +65,7 @@ const pb_obj_enum_member_t pb_Port_F_obj = { const pb_obj_enum_member_t pb_Port_1_obj = { {&pb_enum_type_Port}, .name = MP_QSTR_S1, - .value = PBIO_PORT_1 + .value = PBIO_PORT_ID_1 }; #endif @@ -73,7 +73,7 @@ const pb_obj_enum_member_t pb_Port_1_obj = { const pb_obj_enum_member_t pb_Port_2_obj = { {&pb_enum_type_Port}, .name = MP_QSTR_S2, - .value = PBIO_PORT_2 + .value = PBIO_PORT_ID_2 }; #endif @@ -81,7 +81,7 @@ const pb_obj_enum_member_t pb_Port_2_obj = { const pb_obj_enum_member_t pb_Port_3_obj = { {&pb_enum_type_Port}, .name = MP_QSTR_S3, - .value = PBIO_PORT_3 + .value = PBIO_PORT_ID_3 }; #endif @@ -89,7 +89,7 @@ const pb_obj_enum_member_t pb_Port_3_obj = { const pb_obj_enum_member_t pb_Port_4_obj = { {&pb_enum_type_Port}, .name = MP_QSTR_S4, - .value = PBIO_PORT_4 + .value = PBIO_PORT_ID_4 }; #endif diff --git a/pybricks/pupdevices/pb_type_pupdevices_colordistancesensor.c b/pybricks/pupdevices/pb_type_pupdevices_colordistancesensor.c index 27e06fde2..7a792bd85 100644 --- a/pybricks/pupdevices/pb_type_pupdevices_colordistancesensor.c +++ b/pybricks/pupdevices/pb_type_pupdevices_colordistancesensor.c @@ -61,7 +61,7 @@ STATIC mp_obj_t pupdevices_ColorDistanceSensor_make_new(const mp_obj_type_t *typ pupdevices_ColorDistanceSensor_obj_t *self = m_new_obj(pupdevices_ColorDistanceSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_COLOR_DIST_SENSOR); diff --git a/pybricks/pupdevices/pb_type_pupdevices_colorsensor.c b/pybricks/pupdevices/pb_type_pupdevices_colorsensor.c index cbf264c05..9049ccfdf 100644 --- a/pybricks/pupdevices/pb_type_pupdevices_colorsensor.c +++ b/pybricks/pupdevices/pb_type_pupdevices_colorsensor.c @@ -68,7 +68,7 @@ STATIC mp_obj_t pupdevices_ColorSensor_make_new(const mp_obj_type_t *type, size_ pupdevices_ColorSensor_obj_t *self = m_new_obj(pupdevices_ColorSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); // Get iodevices self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_SPIKE_COLOR_SENSOR); diff --git a/pybricks/pupdevices/pb_type_pupdevices_forcesensor.c b/pybricks/pupdevices/pb_type_pupdevices_forcesensor.c index 261fa4453..009453c1b 100644 --- a/pybricks/pupdevices/pb_type_pupdevices_forcesensor.c +++ b/pybricks/pupdevices/pb_type_pupdevices_forcesensor.c @@ -61,7 +61,7 @@ STATIC mp_obj_t pupdevices_ForceSensor_make_new(const mp_obj_type_t *type, size_ pupdevices_ForceSensor_obj_t *self = m_new_obj(pupdevices_ForceSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); // Get iodevices self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_SPIKE_FORCE_SENSOR); diff --git a/pybricks/pupdevices/pb_type_pupdevices_infraredsensor.c b/pybricks/pupdevices/pb_type_pupdevices_infraredsensor.c index 8e5d643a3..483e272e5 100644 --- a/pybricks/pupdevices/pb_type_pupdevices_infraredsensor.c +++ b/pybricks/pupdevices/pb_type_pupdevices_infraredsensor.c @@ -35,7 +35,7 @@ STATIC mp_obj_t pupdevices_InfraredSensor_make_new(const mp_obj_type_t *type, si pupdevices_InfraredSensor_obj_t *self = m_new_obj(pupdevices_InfraredSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); // Get iodevice self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_WEDO2_MOTION_SENSOR); diff --git a/pybricks/pupdevices/pb_type_pupdevices_light.c b/pybricks/pupdevices/pb_type_pupdevices_light.c index 3b3d1f6cc..8ecf496e0 100644 --- a/pybricks/pupdevices/pb_type_pupdevices_light.c +++ b/pybricks/pupdevices/pb_type_pupdevices_light.c @@ -27,7 +27,7 @@ STATIC mp_obj_t pupdevices_Light_make_new(const mp_obj_type_t *type, size_t n_ar pupdevices_Light_obj_t *self = m_new_obj(pupdevices_Light_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); // Get iodevices self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_LPF2_LIGHT); diff --git a/pybricks/pupdevices/pb_type_pupdevices_tiltsensor.c b/pybricks/pupdevices/pb_type_pupdevices_tiltsensor.c index 98030b7d6..84811a360 100644 --- a/pybricks/pupdevices/pb_type_pupdevices_tiltsensor.c +++ b/pybricks/pupdevices/pb_type_pupdevices_tiltsensor.c @@ -27,7 +27,7 @@ STATIC mp_obj_t pupdevices_TiltSensor_make_new(const mp_obj_type_t *type, size_t pupdevices_TiltSensor_obj_t *self = m_new_obj(pupdevices_TiltSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); // Get iodevice self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_WEDO2_TILT_SENSOR); diff --git a/pybricks/pupdevices/pb_type_pupdevices_ultrasonicsensor.c b/pybricks/pupdevices/pb_type_pupdevices_ultrasonicsensor.c index b0105526f..bdba88acb 100644 --- a/pybricks/pupdevices/pb_type_pupdevices_ultrasonicsensor.c +++ b/pybricks/pupdevices/pb_type_pupdevices_ultrasonicsensor.c @@ -28,7 +28,7 @@ STATIC mp_obj_t pupdevices_UltrasonicSensor_make_new(const mp_obj_type_t *type, pupdevices_UltrasonicSensor_obj_t *self = m_new_obj(pupdevices_UltrasonicSensor_obj_t); self->base.type = (mp_obj_type_t *)type; - pbio_port_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); + pbio_port_id_t port = pb_type_enum_get_value(port_in, &pb_enum_type_Port); // Get iodevices self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_SPIKE_ULTRASONIC_SENSOR); diff --git a/pybricks/util_pb/pb_device.h b/pybricks/util_pb/pb_device.h index 442a55fec..4b5df3ebd 100644 --- a/pybricks/util_pb/pb_device.h +++ b/pybricks/util_pb/pb_device.h @@ -12,7 +12,7 @@ typedef struct _pb_device_t pb_device_t; -pb_device_t *pb_device_get_device(pbio_port_t port, pbio_iodev_type_id_t valid_id); +pb_device_t *pb_device_get_device(pbio_port_id_t port, pbio_iodev_type_id_t valid_id); void pb_device_get_values(pb_device_t *pbdev, uint8_t mode, int32_t *values); diff --git a/pybricks/util_pb/pb_device_ev3dev.c b/pybricks/util_pb/pb_device_ev3dev.c index dd6f27267..d70230ce1 100644 --- a/pybricks/util_pb/pb_device_ev3dev.c +++ b/pybricks/util_pb/pb_device_ev3dev.c @@ -27,7 +27,7 @@ struct _pb_device_t { /** * The port the device is attached to. */ - pbio_port_t port; + pbio_port_id_t port; /** * The current active mode. */ @@ -49,12 +49,12 @@ struct _pb_device_t { pb_device_t iodevices[4]; // Get an ev3dev sensor -static pbio_error_t get_device(pb_device_t **pbdev, pbio_iodev_type_id_t valid_id, pbio_port_t port) { - if (port < PBIO_PORT_1 || port > PBIO_PORT_4) { +static pbio_error_t get_device(pb_device_t **pbdev, pbio_iodev_type_id_t valid_id, pbio_port_id_t port) { + if (port < PBIO_PORT_ID_1 || port > PBIO_PORT_ID_4) { return PBIO_ERROR_INVALID_PORT; } - pb_device_t *_pbdev = &iodevices[port - PBIO_PORT_1]; + pb_device_t *_pbdev = &iodevices[port - PBIO_PORT_ID_1]; _pbdev->port = port; @@ -184,7 +184,7 @@ static pbio_error_t get_values(pb_device_t *pbdev, uint8_t mode, int32_t *values return PBIO_SUCCESS; } -pb_device_t *pb_device_get_device(pbio_port_t port, pbio_iodev_type_id_t valid_id) { +pb_device_t *pb_device_get_device(pbio_port_id_t port, pbio_iodev_type_id_t valid_id) { pb_device_t *pbdev = NULL; pbio_error_t err; diff --git a/pybricks/util_pb/pb_device_stm32.c b/pybricks/util_pb/pb_device_stm32.c index 72676f7d6..45627076a 100644 --- a/pybricks/util_pb/pb_device_stm32.c +++ b/pybricks/util_pb/pb_device_stm32.c @@ -75,7 +75,7 @@ static void set_mode(pbio_iodev_t *iodev, uint8_t new_mode) { } } -pb_device_t *pb_device_get_device(pbio_port_t port, pbio_iodev_type_id_t valid_id) { +pb_device_t *pb_device_get_device(pbio_port_id_t port, pbio_iodev_type_id_t valid_id) { // Get the iodevice pbio_iodev_t *iodev; diff --git a/pybricks/util_pb/pb_serial.h b/pybricks/util_pb/pb_serial.h index 2bbb91369..50d127f78 100644 --- a/pybricks/util_pb/pb_serial.h +++ b/pybricks/util_pb/pb_serial.h @@ -9,7 +9,7 @@ typedef struct _pb_serial_t pb_serial_t; -pbio_error_t pb_serial_get(pb_serial_t **_ser, pbio_port_t port, int baudrate); +pbio_error_t pb_serial_get(pb_serial_t **_ser, pbio_port_id_t port, int baudrate); pbio_error_t pb_serial_write(pb_serial_t *ser, const void *buf, size_t count); diff --git a/pybricks/util_pb/pb_serial_ev3dev.c b/pybricks/util_pb/pb_serial_ev3dev.c index 530ed4e34..4f26e821f 100644 --- a/pybricks/util_pb/pb_serial_ev3dev.c +++ b/pybricks/util_pb/pb_serial_ev3dev.c @@ -138,18 +138,18 @@ static pbio_error_t pb_serial_config(pb_serial_t *ser, int baudrate) { } -pbio_error_t pb_serial_get(pb_serial_t **_ser, pbio_port_t port, int baudrate) { +pbio_error_t pb_serial_get(pb_serial_t **_ser, pbio_port_id_t port, int baudrate) { - if (port < PBIO_PORT_1 || port > PBIO_PORT_4) { + if (port < PBIO_PORT_ID_1 || port > PBIO_PORT_ID_4) { return PBIO_ERROR_INVALID_PORT; } // Get device pointer pbio_error_t err; - pb_serial_t *ser = &pb_serials[port - PBIO_PORT_1]; + pb_serial_t *ser = &pb_serials[port - PBIO_PORT_ID_1]; // Open pb_serial port - err = pb_serial_open(ser, TTY_PATH[port - PBIO_PORT_1]); + err = pb_serial_open(ser, TTY_PATH[port - PBIO_PORT_ID_1]); if (err != PBIO_SUCCESS) { return err; }