Lines Matching +full:divider +full:- +full:int +full:- +full:1
4 * SPDX-License-Identifier: Apache-2.0
30 uint8_t divider; member
33 static int sam_pwm_get_cycles_per_sec(const struct device *dev, in sam_pwm_get_cycles_per_sec()
36 const struct sam_pwm_config *config = dev->config; in sam_pwm_get_cycles_per_sec()
37 uint8_t prescaler = config->prescaler; in sam_pwm_get_cycles_per_sec()
38 uint8_t divider = config->divider; in sam_pwm_get_cycles_per_sec() local
41 ((1 << prescaler) * divider); in sam_pwm_get_cycles_per_sec()
46 static int sam_pwm_set_cycles(const struct device *dev, uint32_t channel, in sam_pwm_set_cycles()
50 const struct sam_pwm_config *config = dev->config; in sam_pwm_set_cycles()
52 Pwm * const pwm = config->regs; in sam_pwm_set_cycles()
56 return -EINVAL; in sam_pwm_set_cycles()
60 return -ENOTSUP; in sam_pwm_set_cycles()
64 return -ENOTSUP; in sam_pwm_set_cycles()
75 if (pwm->PWM_CH_NUM[channel].PWM_CMR != cmr) { in sam_pwm_set_cycles()
76 pwm->PWM_DIS = 1 << channel; in sam_pwm_set_cycles()
78 pwm->PWM_CH_NUM[channel].PWM_CMR = cmr; in sam_pwm_set_cycles()
79 pwm->PWM_CH_NUM[channel].PWM_CPRD = period_cycles; in sam_pwm_set_cycles()
80 pwm->PWM_CH_NUM[channel].PWM_CDTY = pulse_cycles; in sam_pwm_set_cycles()
85 pwm->PWM_CH_NUM[channel].PWM_CPRDUPD = period_cycles; in sam_pwm_set_cycles()
86 pwm->PWM_CH_NUM[channel].PWM_CDTYUPD = pulse_cycles; in sam_pwm_set_cycles()
90 pwm->PWM_ENA = 1 << channel; in sam_pwm_set_cycles()
95 static int sam_pwm_init(const struct device *dev) in sam_pwm_init()
97 const struct sam_pwm_config *config = dev->config; in sam_pwm_init()
99 Pwm * const pwm = config->regs; in sam_pwm_init()
100 uint8_t prescaler = config->prescaler; in sam_pwm_init()
101 uint8_t divider = config->divider; in sam_pwm_init() local
102 int retval; in sam_pwm_init()
104 /* FIXME: way to validate prescaler & divider */ in sam_pwm_init()
108 (clock_control_subsys_t)&config->clock_cfg); in sam_pwm_init()
110 retval = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT); in sam_pwm_init()
116 pwm->PWM_CLK = PWM_CLK_PREA(prescaler) | PWM_CLK_DIVA(divider); in sam_pwm_init()
133 .divider = DT_INST_PROP(inst, divider), \