From 49697115932424f5a43e9aa3c538967e8007357b Mon Sep 17 00:00:00 2001 From: kurte Date: Fri, 1 Sep 2023 08:00:25 -0700 Subject: [PATCH 1/7] UNOR4 - update timer period Instead of fixed 100us timer, it now changes the timer period on the fly to get better granularity. And like most other Servo implementations, It also only starts one servo at a time, to help minimize current surge to try to start all of the servos at the same time. I have done some testing with one and two servos with the sweep, where the 2nd servo is 180-pos... --- src/renesas/Servo.cpp | 118 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 97 insertions(+), 21 deletions(-) diff --git a/src/renesas/Servo.cpp b/src/renesas/Servo.cpp index eaeb073..016922d 100644 --- a/src/renesas/Servo.cpp +++ b/src/renesas/Servo.cpp @@ -28,6 +28,9 @@ #include "math.h" #include "FspTimer.h" +// uncomment to print servo Debug information +//#define SERVO_PRINT_DEBUG_INFO + #define SERVO_MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) #define SERVO_INVALID_INDEX (255) // Lower the timer ticks for finer resolution. @@ -35,6 +38,8 @@ #define SERVO_US_PER_CYCLE (20000) #define SERVO_IO_PORT_ADDR(pn) &((R_PORT0 + ((uint32_t) (R_PORT1 - R_PORT0) * (pn)))->PCNTR3) +#define MIN_CYCLE_OFF_US 50 + // Internal Servo sturct to keep track of RA configuration. typedef struct { // Servo period in microseconds. @@ -43,8 +48,8 @@ typedef struct { // Servo class are not wide enough for the pulse width. uint32_t period_min; uint32_t period_max; - // Period period_count in microseconds. - uint32_t period_count; + // Period period_count in timer ticks. + uint32_t period_ticks; // Internal FSP GPIO port/pin control bits. volatile uint32_t *io_port; uint32_t io_mask; @@ -58,25 +63,66 @@ static FspTimer servo_timer; static bool servo_timer_started = false; void servo_timer_callback(timer_callback_args_t *args); +// GPT pointer. +static R_GPT0_Type *s_pgpt0 = nullptr; +static uint32_t servo_ticks_per_cycle = 0; +static uint32_t min_servo_cycle_low = 0; +static uint32_t active_servos_mask = 0; +static uint32_t active_servos_mask_refresh = 0; + + +static uint32_t usToticks(uint32_t time_us) { + return (float(servo_ticks_per_cycle) / float(SERVO_US_PER_CYCLE)) * time_us; +} + + + + static int servo_timer_config(uint32_t period_us) { static bool configured = false; if (configured == false) { - // Configure and enable the servo timer. + // Configure and enable the servo timer, for full 20ms uint8_t type = 0; int8_t channel = FspTimer::get_available_timer(type); if (channel != -1) { + // lets initially configure the servo to 50ms servo_timer.begin(TIMER_MODE_PERIODIC, type, channel, 1000000.0f/period_us, 50.0f, servo_timer_callback, nullptr); + + // First pass assume GPT timer + s_pgpt0 = (R_GPT0_Type *)((uint32_t)R_GPT0 + ((uint32_t)R_GPT1 - (uint32_t)R_GPT0) * channel); + // turn off GTPR Buffer + s_pgpt0->GTBER_b.PR = 0; + s_pgpt0->GTBER_b.BD1 = 1; + servo_timer.setup_overflow_irq(); servo_timer.open(); servo_timer.stop(); + + // Now lets see what the period; + servo_ticks_per_cycle = servo_timer.get_period_raw(); + min_servo_cycle_low = usToticks(MIN_CYCLE_OFF_US); + #ifdef SERVO_PRINT_DEBUG_INFO + Serial.print("Period:"); + Serial.println(servo_ticks_per_cycle, DEC); + uint32_t ticks_544 = usToticks(544); + uint32_t ticks_2400 = usToticks(2400); + Serial.print("Min 544(ticks): "); + Serial.print(ticks_544); + Serial.print(" Max 2400: "); + Serial.print(ticks_2400); + Serial.print(" per degree: "); + Serial.println((float)(ticks_2400 - ticks_544) / 180.0f, 2); + #endif + configured = true; } } return configured ? 0 : -1; } + static int servo_timer_start() { // Start the timer if it's not started @@ -99,22 +145,43 @@ static int servo_timer_stop() return 0; } +inline static void updateClockPeriod(uint32_t period) { + if (s_pgpt0) s_pgpt0->GTPR = period; +} + + void servo_timer_callback(timer_callback_args_t *args) { - for (size_t i=0; iperiod_us) { - servo->period_count += SERVO_TIMER_TICK_US; - if (servo->period_count <= servo->period_us) { - *servo->io_port = (uint32_t) servo->io_mask; - } else { - *servo->io_port = (uint32_t) (servo->io_mask << 16); - } - if (servo->period_count == SERVO_US_PER_CYCLE) { - servo->period_count = 0; - } + (void)args; // remove warning + static uint8_t channel=SERVO_MAX_SERVOS; + static uint8_t channel_pin_set_high=0xff; + static uint32_t ticks_accum=0; + + // See if we need to set a servo back low + if (channel_pin_set_high != 0xff) { + *ra_servos[channel_pin_set_high].io_port = (uint32_t)(ra_servos[channel_pin_set_high].io_mask << 16); + } + + // Find the next servo to set high + while (active_servos_mask_refresh) { + channel = __builtin_ctz(active_servos_mask_refresh); + active_servos_mask_refresh &= ~(1 << channel); + if (ra_servos[channel].period_us) { + *ra_servos[channel].io_port = (uint32_t)ra_servos[channel].io_mask; + updateClockPeriod(ra_servos[channel].period_ticks); + channel_pin_set_high = channel; + ticks_accum += ra_servos[channel_pin_set_high].period_ticks; + return; } } + + // Got to hear we finished processing all servos, now delay to start of next pass. + ticks_accum += min_servo_cycle_low; + uint32_t time_to_next_cycle = (servo_ticks_per_cycle > ticks_accum)? servo_ticks_per_cycle - ticks_accum : min_servo_cycle_low; + ticks_accum = 0; + updateClockPeriod(time_to_next_cycle); + channel_pin_set_high = 0xff; + active_servos_mask_refresh = active_servos_mask; } Servo::Servo() @@ -139,6 +206,11 @@ uint8_t Servo::attach(int pin, int min, int max) return 0; } + // Configure and the timer + if (servo_timer_config(SERVO_US_PER_CYCLE) != 0) { + return 0; + } + // Try to find a free servo slot. ra_servo_t *servo = NULL; bsp_io_port_pin_t io_pin = g_pin_cfg[pin].pin; @@ -151,6 +223,7 @@ uint8_t Servo::attach(int pin, int min, int max) servo->period_max = max; servo->io_mask = (1U << (io_pin & 0xFF)); servo->io_port = SERVO_IO_PORT_ADDR(((io_pin >> 8U) & 0xFF)); + active_servos_mask |= (1 << i); // update mask of servos that are active. writeMicroseconds(DEFAULT_PULSE_WIDTH); break; } @@ -164,11 +237,11 @@ uint8_t Servo::attach(int pin, int min, int max) R_IOPORT_PinCfg(&g_ioport_ctrl, io_pin, IOPORT_CFG_PORT_DIRECTION_OUTPUT | IOPORT_CFG_PORT_OUTPUT_HIGH); - // Configure and start the timer if it's not started. - if (servo_timer_config(SERVO_TIMER_TICK_US) != 0 || - servo_timer_start() != 0) { + // start the timer if it's not started. + if (servo_timer_start() != 0) { return 0; } + return 1; } @@ -178,10 +251,12 @@ void Servo::detach() ra_servo_t *servo = &ra_servos[servoIndex]; servo_timer_stop(); servo->period_us = 0; + active_servos_mask &= ~(1 << servoIndex); // update mask of servos that are active. + servoIndex = SERVO_INVALID_INDEX; if (--n_servos) { servo_timer_start(); } - servoIndex = SERVO_INVALID_INDEX; + } } @@ -207,8 +282,9 @@ void Servo::writeMicroseconds(int us) { if (servoIndex != SERVO_INVALID_INDEX) { ra_servo_t *servo = &ra_servos[servoIndex]; - servo->period_count = 0; - servo->period_us = constrain(us, servo->period_min, servo->period_max); + //servo->period_count = 0; + servo->period_us = constrain(us, (int)servo->period_min, (int)servo->period_max); + servo->period_ticks = usToticks(servo->period_us); } } From 604d84f43f14960fdbc519546982a95f541d7f83 Mon Sep 17 00:00:00 2001 From: kurte Date: Sat, 2 Sep 2023 06:30:51 -0700 Subject: [PATCH 2/7] Initial support if FspTimer is AGT timer Note FSP->AGT timer code is completely busted Will produce PR to hopefully fix it. --- src/renesas/Servo.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/renesas/Servo.cpp b/src/renesas/Servo.cpp index 016922d..2b4c26b 100644 --- a/src/renesas/Servo.cpp +++ b/src/renesas/Servo.cpp @@ -85,18 +85,25 @@ static int servo_timer_config(uint32_t period_us) // Configure and enable the servo timer, for full 20ms uint8_t type = 0; int8_t channel = FspTimer::get_available_timer(type); + #ifdef SERVO_PRINT_DEBUG_INFO + Serial.print("\nservo_timer_config: type:"); + Serial.print(type, DEC); + Serial.print(" Channel: "); + Serial.println(channel, DEC); + #endif if (channel != -1) { // lets initially configure the servo to 50ms servo_timer.begin(TIMER_MODE_PERIODIC, type, channel, 1000000.0f/period_us, 50.0f, servo_timer_callback, nullptr); // First pass assume GPT timer - s_pgpt0 = (R_GPT0_Type *)((uint32_t)R_GPT0 + ((uint32_t)R_GPT1 - (uint32_t)R_GPT0) * channel); - // turn off GTPR Buffer - s_pgpt0->GTBER_b.PR = 0; - s_pgpt0->GTBER_b.BD1 = 1; - - servo_timer.setup_overflow_irq(); + if (type == GPT_TIMER) { + s_pgpt0 = (R_GPT0_Type *)((uint32_t)R_GPT0 + ((uint32_t)R_GPT1 - (uint32_t)R_GPT0) * channel); + // turn off GTPR Buffer + s_pgpt0->GTBER_b.PR = 0; + s_pgpt0->GTBER_b.BD1 = 1; + } + servo_timer.setup_overflow_irq(10); servo_timer.open(); servo_timer.stop(); @@ -146,7 +153,12 @@ static int servo_timer_stop() } inline static void updateClockPeriod(uint32_t period) { - if (s_pgpt0) s_pgpt0->GTPR = period; + if (s_pgpt0) { + s_pgpt0->GTPR = period; + } else { + // AGT... + servo_timer.set_period(period); + } } @@ -165,14 +177,15 @@ void servo_timer_callback(timer_callback_args_t *args) // Find the next servo to set high while (active_servos_mask_refresh) { channel = __builtin_ctz(active_servos_mask_refresh); - active_servos_mask_refresh &= ~(1 << channel); if (ra_servos[channel].period_us) { *ra_servos[channel].io_port = (uint32_t)ra_servos[channel].io_mask; updateClockPeriod(ra_servos[channel].period_ticks); channel_pin_set_high = channel; ticks_accum += ra_servos[channel_pin_set_high].period_ticks; + active_servos_mask_refresh &= ~(1 << channel); return; } + active_servos_mask_refresh &= ~(1 << channel); } // Got to hear we finished processing all servos, now delay to start of next pass. From 02c5ee9978f354492f27ab1ff318f7c459754e8e Mon Sep 17 00:00:00 2001 From: kurte Date: Sat, 9 Sep 2023 08:18:25 -0700 Subject: [PATCH 3/7] remove debug, extra lines spaces = Removed the #ifdef print code. Also removed a couple of extra blank lines that were added. Found a couple places where I cut and pasted in some variable definitions that did not have spaces around = --- src/renesas/Servo.cpp | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/src/renesas/Servo.cpp b/src/renesas/Servo.cpp index 2b4c26b..30bc1e6 100644 --- a/src/renesas/Servo.cpp +++ b/src/renesas/Servo.cpp @@ -28,16 +28,12 @@ #include "math.h" #include "FspTimer.h" -// uncomment to print servo Debug information -//#define SERVO_PRINT_DEBUG_INFO - #define SERVO_MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) #define SERVO_INVALID_INDEX (255) // Lower the timer ticks for finer resolution. #define SERVO_TIMER_TICK_US (100) #define SERVO_US_PER_CYCLE (20000) #define SERVO_IO_PORT_ADDR(pn) &((R_PORT0 + ((uint32_t) (R_PORT1 - R_PORT0) * (pn)))->PCNTR3) - #define MIN_CYCLE_OFF_US 50 // Internal Servo sturct to keep track of RA configuration. @@ -76,8 +72,6 @@ static uint32_t usToticks(uint32_t time_us) { } - - static int servo_timer_config(uint32_t period_us) { static bool configured = false; @@ -85,12 +79,6 @@ static int servo_timer_config(uint32_t period_us) // Configure and enable the servo timer, for full 20ms uint8_t type = 0; int8_t channel = FspTimer::get_available_timer(type); - #ifdef SERVO_PRINT_DEBUG_INFO - Serial.print("\nservo_timer_config: type:"); - Serial.print(type, DEC); - Serial.print(" Channel: "); - Serial.println(channel, DEC); - #endif if (channel != -1) { // lets initially configure the servo to 50ms servo_timer.begin(TIMER_MODE_PERIODIC, type, channel, @@ -110,18 +98,6 @@ static int servo_timer_config(uint32_t period_us) // Now lets see what the period; servo_ticks_per_cycle = servo_timer.get_period_raw(); min_servo_cycle_low = usToticks(MIN_CYCLE_OFF_US); - #ifdef SERVO_PRINT_DEBUG_INFO - Serial.print("Period:"); - Serial.println(servo_ticks_per_cycle, DEC); - uint32_t ticks_544 = usToticks(544); - uint32_t ticks_2400 = usToticks(2400); - Serial.print("Min 544(ticks): "); - Serial.print(ticks_544); - Serial.print(" Max 2400: "); - Serial.print(ticks_2400); - Serial.print(" per degree: "); - Serial.println((float)(ticks_2400 - ticks_544) / 180.0f, 2); - #endif configured = true; } @@ -129,7 +105,6 @@ static int servo_timer_config(uint32_t period_us) return configured ? 0 : -1; } - static int servo_timer_start() { // Start the timer if it's not started @@ -165,9 +140,9 @@ inline static void updateClockPeriod(uint32_t period) { void servo_timer_callback(timer_callback_args_t *args) { (void)args; // remove warning - static uint8_t channel=SERVO_MAX_SERVOS; - static uint8_t channel_pin_set_high=0xff; - static uint32_t ticks_accum=0; + static uint8_t channel = SERVO_MAX_SERVOS; + static uint8_t channel_pin_set_high = 0xff; + static uint32_t ticks_accum = 0; // See if we need to set a servo back low if (channel_pin_set_high != 0xff) { @@ -254,7 +229,6 @@ uint8_t Servo::attach(int pin, int min, int max) if (servo_timer_start() != 0) { return 0; } - return 1; } From 04b9322aff6d27d5cbb9f53cd7307206a968a0ca Mon Sep 17 00:00:00 2001 From: kurte Date: Sun, 10 Sep 2023 07:21:40 -0700 Subject: [PATCH 4/7] Move timer specific stuff into core. I moved the code that disables the period buffer into a new member function. I then checked for this in the set_period(p) call, which will either allow it to go to FSP code, or directly set the appropriate register with the new period. https://github.com/arduino/ArduinoCore-renesas/pull/131 --- src/renesas/Servo.cpp | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/renesas/Servo.cpp b/src/renesas/Servo.cpp index 30bc1e6..05134a1 100644 --- a/src/renesas/Servo.cpp +++ b/src/renesas/Servo.cpp @@ -59,8 +59,6 @@ static FspTimer servo_timer; static bool servo_timer_started = false; void servo_timer_callback(timer_callback_args_t *args); -// GPT pointer. -static R_GPT0_Type *s_pgpt0 = nullptr; static uint32_t servo_ticks_per_cycle = 0; static uint32_t min_servo_cycle_low = 0; static uint32_t active_servos_mask = 0; @@ -83,14 +81,7 @@ static int servo_timer_config(uint32_t period_us) // lets initially configure the servo to 50ms servo_timer.begin(TIMER_MODE_PERIODIC, type, channel, 1000000.0f/period_us, 50.0f, servo_timer_callback, nullptr); - - // First pass assume GPT timer - if (type == GPT_TIMER) { - s_pgpt0 = (R_GPT0_Type *)((uint32_t)R_GPT0 + ((uint32_t)R_GPT1 - (uint32_t)R_GPT0) * channel); - // turn off GTPR Buffer - s_pgpt0->GTBER_b.PR = 0; - s_pgpt0->GTBER_b.BD1 = 1; - } + servo_timer.use_period_buffer(false); // disable period buffering servo_timer.setup_overflow_irq(10); servo_timer.open(); servo_timer.stop(); @@ -128,12 +119,7 @@ static int servo_timer_stop() } inline static void updateClockPeriod(uint32_t period) { - if (s_pgpt0) { - s_pgpt0->GTPR = period; - } else { - // AGT... servo_timer.set_period(period); - } } From fc280bbc69246d66cb08b7e38c756ef804ce0ede Mon Sep 17 00:00:00 2001 From: kurte Date: Tue, 12 Sep 2023 05:09:37 -0700 Subject: [PATCH 5/7] Update to match method name change in name in core --- src/renesas/Servo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renesas/Servo.cpp b/src/renesas/Servo.cpp index 05134a1..524259f 100644 --- a/src/renesas/Servo.cpp +++ b/src/renesas/Servo.cpp @@ -81,7 +81,7 @@ static int servo_timer_config(uint32_t period_us) // lets initially configure the servo to 50ms servo_timer.begin(TIMER_MODE_PERIODIC, type, channel, 1000000.0f/period_us, 50.0f, servo_timer_callback, nullptr); - servo_timer.use_period_buffer(false); // disable period buffering + servo_timer.set_period_buffer(false); // disable period buffering servo_timer.setup_overflow_irq(10); servo_timer.open(); servo_timer.stop(); From 0091d6d785ce4f3e5abc80af0436fa2468d56eda Mon Sep 17 00:00:00 2001 From: KurtE Date: Thu, 4 Jan 2024 11:26:59 -0800 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Ibrahim Abdelkader --- src/renesas/Servo.cpp | 44 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/renesas/Servo.cpp b/src/renesas/Servo.cpp index 524259f..62a10c9 100644 --- a/src/renesas/Servo.cpp +++ b/src/renesas/Servo.cpp @@ -31,10 +31,9 @@ #define SERVO_MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) #define SERVO_INVALID_INDEX (255) // Lower the timer ticks for finer resolution. -#define SERVO_TIMER_TICK_US (100) #define SERVO_US_PER_CYCLE (20000) #define SERVO_IO_PORT_ADDR(pn) &((R_PORT0 + ((uint32_t) (R_PORT1 - R_PORT0) * (pn)))->PCNTR3) -#define MIN_CYCLE_OFF_US 50 +#define SERVO_MIN_CYCLE_OFF_US 50 // Internal Servo sturct to keep track of RA configuration. typedef struct { @@ -65,28 +64,25 @@ static uint32_t active_servos_mask = 0; static uint32_t active_servos_mask_refresh = 0; -static uint32_t usToticks(uint32_t time_us) { - return (float(servo_ticks_per_cycle) / float(SERVO_US_PER_CYCLE)) * time_us; +static uint32_t us_to_ticks(uint32_t time_us) { + return ((float) servo_ticks_per_cycle / (float) SERVO_US_PER_CYCLE) * time_us; } - static int servo_timer_config(uint32_t period_us) { static bool configured = false; if (configured == false) { - // Configure and enable the servo timer, for full 20ms + // Configure and enable the servo timer. uint8_t type = 0; int8_t channel = FspTimer::get_available_timer(type); if (channel != -1) { - // lets initially configure the servo to 50ms servo_timer.begin(TIMER_MODE_PERIODIC, type, channel, 1000000.0f/period_us, 50.0f, servo_timer_callback, nullptr); servo_timer.set_period_buffer(false); // disable period buffering servo_timer.setup_overflow_irq(10); servo_timer.open(); servo_timer.stop(); - - // Now lets see what the period; + // Read the timer's period count. servo_ticks_per_cycle = servo_timer.get_period_raw(); min_servo_cycle_low = usToticks(MIN_CYCLE_OFF_US); @@ -118,11 +114,10 @@ static int servo_timer_stop() return 0; } -inline static void updateClockPeriod(uint32_t period) { +inline static void servo_timer_set_period(uint32_t period) { servo_timer.set_period(period); } - void servo_timer_callback(timer_callback_args_t *args) { (void)args; // remove warning @@ -132,28 +127,32 @@ void servo_timer_callback(timer_callback_args_t *args) // See if we need to set a servo back low if (channel_pin_set_high != 0xff) { - *ra_servos[channel_pin_set_high].io_port = (uint32_t)(ra_servos[channel_pin_set_high].io_mask << 16); + *ra_servos[channel_pin_set_high].io_port = ra_servos[channel_pin_set_high].io_mask << 16; } // Find the next servo to set high while (active_servos_mask_refresh) { channel = __builtin_ctz(active_servos_mask_refresh); if (ra_servos[channel].period_us) { - *ra_servos[channel].io_port = (uint32_t)ra_servos[channel].io_mask; - updateClockPeriod(ra_servos[channel].period_ticks); + *ra_servos[channel].io_port = ra_servos[channel].io_mask; + servo_timer_set_period(ra_servos[channel].period_ticks); channel_pin_set_high = channel; - ticks_accum += ra_servos[channel_pin_set_high].period_ticks; + ticks_accum += ra_servos[channel].period_ticks; active_servos_mask_refresh &= ~(1 << channel); return; } active_servos_mask_refresh &= ~(1 << channel); } - - // Got to hear we finished processing all servos, now delay to start of next pass. + // Finished processing all servos, now delay to start of next pass. ticks_accum += min_servo_cycle_low; - uint32_t time_to_next_cycle = (servo_ticks_per_cycle > ticks_accum)? servo_ticks_per_cycle - ticks_accum : min_servo_cycle_low; + uint32_t time_to_next_cycle; + if (servo_ticks_per_cycle > ticks_accum) { + time_to_next_cycle = servo_ticks_per_cycle - ticks_accum; + } else { + time_to_next_cycle = min_servo_cycle_low; + } ticks_accum = 0; - updateClockPeriod(time_to_next_cycle); + servo_timer_set_period(time_to_next_cycle); channel_pin_set_high = 0xff; active_servos_mask_refresh = active_servos_mask; } @@ -180,7 +179,7 @@ uint8_t Servo::attach(int pin, int min, int max) return 0; } - // Configure and the timer + // Configure the servo timer. if (servo_timer_config(SERVO_US_PER_CYCLE) != 0) { return 0; } @@ -211,7 +210,7 @@ uint8_t Servo::attach(int pin, int min, int max) R_IOPORT_PinCfg(&g_ioport_ctrl, io_pin, IOPORT_CFG_PORT_DIRECTION_OUTPUT | IOPORT_CFG_PORT_OUTPUT_HIGH); - // start the timer if it's not started. + // Start the timer if it's not started. if (servo_timer_start() != 0) { return 0; } @@ -255,8 +254,7 @@ void Servo::writeMicroseconds(int us) { if (servoIndex != SERVO_INVALID_INDEX) { ra_servo_t *servo = &ra_servos[servoIndex]; - //servo->period_count = 0; - servo->period_us = constrain(us, (int)servo->period_min, (int)servo->period_max); + servo->period_us = constrain(us, servo->period_min, servo->period_max); servo->period_ticks = usToticks(servo->period_us); } } From 27dd79bcdf31f41c7d83c85b6d8d6620cf8607ef Mon Sep 17 00:00:00 2001 From: kurte Date: Thu, 4 Jan 2024 11:40:48 -0800 Subject: [PATCH 7/7] Fix errors due to changes done in Code Review Updates the usages of functions or constants that the names were changed --- src/renesas/Servo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renesas/Servo.cpp b/src/renesas/Servo.cpp index 62a10c9..e9e940f 100644 --- a/src/renesas/Servo.cpp +++ b/src/renesas/Servo.cpp @@ -84,7 +84,7 @@ static int servo_timer_config(uint32_t period_us) servo_timer.stop(); // Read the timer's period count. servo_ticks_per_cycle = servo_timer.get_period_raw(); - min_servo_cycle_low = usToticks(MIN_CYCLE_OFF_US); + min_servo_cycle_low = us_to_ticks(SERVO_MIN_CYCLE_OFF_US); configured = true; } @@ -255,7 +255,7 @@ void Servo::writeMicroseconds(int us) if (servoIndex != SERVO_INVALID_INDEX) { ra_servo_t *servo = &ra_servos[servoIndex]; servo->period_us = constrain(us, servo->period_min, servo->period_max); - servo->period_ticks = usToticks(servo->period_us); + servo->period_ticks = us_to_ticks(servo->period_us); } }