@@ -185,13 +185,13 @@ bool FspTimer::begin(timer_mode_t mode, uint8_t tp, uint8_t channel, float freq_
185
185
186
186
init_ok = true ;
187
187
/* AGT timer is always 16 bit */
188
- if (channel < TIMER_16_BIT_OFFSET && type == GPT_TIMER) {
188
+ if (channel < TIMER_16_BIT_OFFSET && tp == GPT_TIMER) {
189
189
/* timer a 32 BIT */
190
- set_period_counts (1.0 / freq_hz, CH32BIT_MAX);
190
+ set_period_counts (tp, 1.0 / freq_hz, CH32BIT_MAX);
191
191
}
192
192
else {
193
193
/* timer a 16 BIT */
194
- set_period_counts (1.0 / freq_hz, CH16BIT_MAX);
194
+ set_period_counts (tp, 1.0 / freq_hz, CH16BIT_MAX);
195
195
}
196
196
197
197
if (duty_perc >= 0 && duty_perc <= 100 ) {
@@ -215,11 +215,11 @@ void FspTimer::set_irq_callback(GPTimerCbk_f cbk , void *ctx /*= nullptr*/ ) {
215
215
}
216
216
217
217
/* -------------------------------------------------------------------------- */
218
- void FspTimer::set_period_counts (float period, uint32_t _max) {
218
+ void FspTimer::set_period_counts (uint8_t tp, float period, uint32_t _max) {
219
219
/* -------------------------------------------------------------------------- */
220
220
221
221
uint32_t freq_hz = 0 ;
222
- if (type == GPT_TIMER) {
222
+ if (tp == GPT_TIMER) {
223
223
freq_hz = R_FSP_SystemClockHzGet (FSP_PRIV_CLOCK_PCLKD);
224
224
if (period * (float ) freq_hz / 1.0 < _max) {
225
225
_period_counts = (uint32_t ) (period * (float ) freq_hz / 1.0 );
@@ -249,7 +249,7 @@ void FspTimer::set_period_counts(float period, uint32_t _max) {
249
249
init_ok = false ;
250
250
}
251
251
}
252
- else if (type == AGT_TIMER) {
252
+ else if (tp == AGT_TIMER) {
253
253
freq_hz = R_FSP_SystemClockHzGet (FSP_PRIV_CLOCK_PCLKB);
254
254
if (period * (float ) freq_hz / 1.0 < _max) {
255
255
_period_counts = (uint32_t ) (period * (float ) freq_hz / 1.0 );
@@ -418,11 +418,11 @@ bool FspTimer::set_period_ms(double ms) {
418
418
close ();
419
419
if (timer_cfg.channel < TIMER_16_BIT_OFFSET && type == GPT_TIMER) {
420
420
/* timer a 32 BIT */
421
- set_period_counts (period_sec, CH32BIT_MAX);
421
+ set_period_counts (type, period_sec, CH32BIT_MAX);
422
422
}
423
423
else {
424
424
/* timer a 16 BIT */
425
- set_period_counts (period_sec, CH16BIT_MAX);
425
+ set_period_counts (type, period_sec, CH16BIT_MAX);
426
426
}
427
427
428
428
timer_cfg.period_counts = _period_counts;
0 commit comments