/* Change the match value of a single timer channel */
int sctimer_set_match(uint8_t timer_num, uint8_t channel, uint32_t val)
{
- /* FIXME : To be done */
- return 0;
+ struct lpc_sct_timer* sct = LPC_SCTIMER;
+
+ if ((timer_num != LPC_SCT) || (channel >= MAX_CHANNELS)) {
+ return -EINVAL;
+ }
+ sct->match_reload[ channel + 1 ] = val;
+ return sct->match[ channel + 1 ];
}
struct common_operations sct_ops = {
/* Use a single state */
sct->state_var = 0;
- /* No need to reload, match registers will keep their values */
- sct->config |= LPC_SCT_NORELOAD;
/* All match/capture regs act as match registers */
sct->mode = 0;
uint32_t evt_ctrl = 0;
sct->match[ i + 1 ] = pwm->match_values[i];
+ sct->match_reload[ i + 1 ] = pwm->match_values[i];
/* Enable one event for state 0 for this match */
sct->event[ i + 1 ].state = LPC_SCT_EVT_EN_STATE(0);
/* Setup the event to happen on given match channel and control the requested output */
/* Select the channel 0 as the timer limit value to generate the PWM period.
* Use autolimit, but configure an event anyway as we want to toggle the outputs as well */
sct->match[0] = pwm->period;
+ sct->match_reload[0] = pwm->period;
sct->config |= LPC_SCT_AUTOLIMIT;
sct->event[0].state = LPC_SCT_EVT_EN_STATE(0);
sct->event[0].control = (LPC_SCT_MATCHSEL(0) | LPC_SCT_COMB_MODE_MATCH);