From: Nathael Pajani Date: Sat, 1 Dec 2018 13:19:17 +0000 (+0100) Subject: Use appropriate defined value X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=44ca88c86f9a811d9efdd831b3fcc85ea588dff7;p=soft%2Flpc122x%2Fcore Use appropriate defined value --- diff --git a/drivers/countertimers.c b/drivers/countertimers.c index ee49888..a3ac6ff 100644 --- a/drivers/countertimers.c +++ b/drivers/countertimers.c @@ -150,7 +150,7 @@ int countertimer_get_counter_val(uint8_t timer_num, uint32_t* val) int countertimer_get_capture_val(uint8_t timer_num, uint8_t channel, uint32_t* val) { - if (channel >= MAX_CHANNELS) { + if (channel >= NUM_COUNTERTIMERS_CHANS) { return -EINVAL; } *val = countertimers[timer_num].regs->capture_reg[channel]; @@ -161,7 +161,7 @@ int countertimer_get_capture_val(uint8_t timer_num, uint8_t channel, uint32_t* v /* Change the match value of a single timer channel */ int countertimer_set_match(uint8_t timer_num, uint8_t channel, uint32_t val) { - if (channel > NUM_COUNTERTIMERS_CHANS) + if (channel >= NUM_COUNTERTIMERS_CHANS) return -EINVAL; countertimers[timer_num].regs->match_reg[channel] = val; @@ -219,7 +219,7 @@ int countertimer_pwm_setup(uint8_t timer_num, const struct lpc_timer_pwm_config* break; } - if (conf->period_chan >= MAX_CHANNELS) { + if (conf->period_chan >= NUM_COUNTERTIMERS_CHANS) { return -EINVAL; } /* Setup selected PWM channels */ @@ -287,13 +287,13 @@ int countertimer_tc_setup(uint8_t timer_num, const struct lpc_tc_config* conf) } if (conf->mode & LPC_TIMER_MODE_CAPTURE) { - for (i = 0; i < MAX_CHANNELS; i++) { + for (i = 0; i < NUM_COUNTERTIMERS_CHANS; i++) { timer->regs->capture_ctrl |= ((conf->cap_control[i] & 0x07) << LPC_TIMER_CAPTURE_SHIFT(i)); } } if (conf->mode & LPC_TIMER_MODE_MATCH) { - for (i = 0; i < MAX_CHANNELS; i++) { + for (i = 0; i < NUM_COUNTERTIMERS_CHANS; i++) { timer->regs->match_ctrl |= ((conf->match_control[i] & 0x07) << LPC_TIMER_MATCH_SHIFT(i)); timer->regs->match_reg[i] = conf->match[i]; timer->regs->external_match |= ((conf->ext_match_config[i] & 0x03) << LPC_TIMER_EXT_MATCH_SHIFT(i));