Skip to content

Commit 04b9322

Browse files
committed
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. arduino/ArduinoCore-renesas#131
1 parent 02c5ee9 commit 04b9322

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

Diff for: src/renesas/Servo.cpp

+1-15
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ static FspTimer servo_timer;
5959
static bool servo_timer_started = false;
6060
void servo_timer_callback(timer_callback_args_t *args);
6161

62-
// GPT pointer.
63-
static R_GPT0_Type *s_pgpt0 = nullptr;
6462
static uint32_t servo_ticks_per_cycle = 0;
6563
static uint32_t min_servo_cycle_low = 0;
6664
static uint32_t active_servos_mask = 0;
@@ -83,14 +81,7 @@ static int servo_timer_config(uint32_t period_us)
8381
// lets initially configure the servo to 50ms
8482
servo_timer.begin(TIMER_MODE_PERIODIC, type, channel,
8583
1000000.0f/period_us, 50.0f, servo_timer_callback, nullptr);
86-
87-
// First pass assume GPT timer
88-
if (type == GPT_TIMER) {
89-
s_pgpt0 = (R_GPT0_Type *)((uint32_t)R_GPT0 + ((uint32_t)R_GPT1 - (uint32_t)R_GPT0) * channel);
90-
// turn off GTPR Buffer
91-
s_pgpt0->GTBER_b.PR = 0;
92-
s_pgpt0->GTBER_b.BD1 = 1;
93-
}
84+
servo_timer.use_period_buffer(false); // disable period buffering
9485
servo_timer.setup_overflow_irq(10);
9586
servo_timer.open();
9687
servo_timer.stop();
@@ -128,12 +119,7 @@ static int servo_timer_stop()
128119
}
129120

130121
inline static void updateClockPeriod(uint32_t period) {
131-
if (s_pgpt0) {
132-
s_pgpt0->GTPR = period;
133-
} else {
134-
// AGT...
135122
servo_timer.set_period(period);
136-
}
137123
}
138124

139125

0 commit comments

Comments
 (0)