@@ -185,13 +185,13 @@ bool FspTimer::begin(timer_mode_t mode, uint8_t tp, uint8_t channel, float freq_
185185
186186 init_ok = true ;
187187 /* 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) {
189189 /* 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);
191191 }
192192 else {
193193 /* 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);
195195 }
196196
197197 if (duty_perc >= 0 && duty_perc <= 100 ) {
@@ -215,11 +215,11 @@ void FspTimer::set_irq_callback(GPTimerCbk_f cbk , void *ctx /*= nullptr*/ ) {
215215}
216216
217217/* -------------------------------------------------------------------------- */
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) {
219219/* -------------------------------------------------------------------------- */
220220
221221 uint32_t freq_hz = 0 ;
222- if (type == GPT_TIMER) {
222+ if (tp == GPT_TIMER) {
223223 freq_hz = R_FSP_SystemClockHzGet (FSP_PRIV_CLOCK_PCLKD);
224224 if (period * (float ) freq_hz / 1.0 < _max) {
225225 _period_counts = (uint32_t ) (period * (float ) freq_hz / 1.0 );
@@ -249,7 +249,7 @@ void FspTimer::set_period_counts(float period, uint32_t _max) {
249249 init_ok = false ;
250250 }
251251 }
252- else if (type == AGT_TIMER) {
252+ else if (tp == AGT_TIMER) {
253253 freq_hz = R_FSP_SystemClockHzGet (FSP_PRIV_CLOCK_PCLKB);
254254 if (period * (float ) freq_hz / 1.0 < _max) {
255255 _period_counts = (uint32_t ) (period * (float ) freq_hz / 1.0 );
@@ -418,11 +418,11 @@ bool FspTimer::set_period_ms(double ms) {
418418 close ();
419419 if (timer_cfg.channel < TIMER_16_BIT_OFFSET && type == GPT_TIMER) {
420420 /* timer a 32 BIT */
421- set_period_counts (period_sec, CH32BIT_MAX);
421+ set_period_counts (type, period_sec, CH32BIT_MAX);
422422 }
423423 else {
424424 /* timer a 16 BIT */
425- set_period_counts (period_sec, CH16BIT_MAX);
425+ set_period_counts (type, period_sec, CH16BIT_MAX);
426426 }
427427
428428 timer_cfg.period_counts = _period_counts;
0 commit comments