Skip to content

Commit 35b69cd

Browse files
[nrf fromlist] drivers: pwm: nrfx: adjust PWM driver to fast PWM120
Fast PWM120 instance works with 320MHz clock, thus pwm_nrfx_get_cycles_per_sec needs to be adjusted. Also, it uses cachable RAM, thus sys_cache function needs to be added to flush the cached sequence. Upstream PR #: 80672 Signed-off-by: Michał Stasiak <[email protected]>
1 parent d59b845 commit 35b69cd

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

drivers/pwm/pwm_nrfx.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ static int pwm_nrfx_set_cycles(const struct device *dev, uint32_t channel,
129129
uint32_t period_cycles, uint32_t pulse_cycles,
130130
pwm_flags_t flags)
131131
{
132-
/* We assume here that period_cycles will always be 16MHz
133-
* peripheral clock. Since pwm_nrfx_get_cycles_per_sec() function might
134-
* be removed, see ISSUE #6958.
135-
* TODO: Remove this comment when issue has been resolved.
136-
*/
137132
const struct pwm_nrfx_config *config = dev->config;
138133
struct pwm_nrfx_data *data = dev->data;
139134
uint16_t compare_value;
@@ -176,6 +171,10 @@ static int pwm_nrfx_set_cycles(const struct device *dev, uint32_t channel,
176171

177172
seq_values_ptr_get(dev)[channel] = PWM_NRFX_CH_VALUE(compare_value, inverted);
178173

174+
#ifdef CONFIG_NRFX_PWM120
175+
sys_cache_data_flush_range((void *)config->seq.values.p_raw, config->seq.length);
176+
#endif
177+
179178
LOG_DBG("channel %u, pulse %u, period %u, prescaler: %u.",
180179
channel, pulse_cycles, period_cycles, data->prescaler);
181180

@@ -243,12 +242,11 @@ static int pwm_nrfx_set_cycles(const struct device *dev, uint32_t channel,
243242
static int pwm_nrfx_get_cycles_per_sec(const struct device *dev, uint32_t channel,
244243
uint64_t *cycles)
245244
{
246-
/* TODO: Since this function might be removed, we will always return
247-
* 16MHz from this function and handle the conversion with prescaler,
248-
* etc, in the pin set function. See issue #6958.
249-
*/
245+
#ifdef CONFIG_NRFX_PWM120
246+
*cycles = 320ul * 1000ul * 1000ul;
247+
#else
250248
*cycles = 16ul * 1000ul * 1000ul;
251-
249+
#endif
252250
return 0;
253251
}
254252

0 commit comments

Comments
 (0)