From 060839ee4cd7679994607665f770f390a80d812d Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Thu, 2 May 2013 10:36:22 -0700 Subject: [PATCH] sam3x: Add some pwm convenience funcitons. --- include/libopencm3/sam3x/pwm.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/libopencm3/sam3x/pwm.h b/include/libopencm3/sam3x/pwm.h index a911cbf3..181b8091 100644 --- a/include/libopencm3/sam3x/pwm.h +++ b/include/libopencm3/sam3x/pwm.h @@ -78,4 +78,24 @@ #define PWM_DT(x) MMIO32(PWM_BASE + 0x0218 + 0x20*(x)) #define PWM_DTUPD(x) MMIO32(PWM_BASE + 0x021C + 0x20*(x)) +static inline pwm_set_period(int ch, u32 period) +{ + PWM_CPRD(ch) = period; +} + +static inline pwm_set_duty(int ch, u32 duty) +{ + PWM_CDTY(ch) = duty; +} + +static inline pwm_enable(int ch) +{ + PWM_ENA = 1 << ch; +} + +static inline pwm_disable(int ch) +{ + PWM_DIS = 1 << ch; +} + #endif