pwm.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014-2015 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
61 #ifndef PERIPH_PWM_H
62 #define PERIPH_PWM_H
63 
64 #include <stdint.h>
65 #include <limits.h>
66 
67 #include "periph_cpu.h"
68 #include "periph_conf.h"
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
78 #ifndef PWM_DEV
79 #define PWM_DEV(x) (x)
80 #endif
81 
87 #ifndef PWM_UNDEF
88 #define PWM_UNDEF (UINT_MAX)
89 #endif
90 
96 #ifndef HAVE_PWM_T
97 typedef unsigned int pwm_t;
98 #endif
99 
105 #ifndef HAVE_PWM_MODE_T
106 typedef enum {
107  PWM_LEFT, /*< use left aligned PWM */
108  PWM_RIGHT, /*< use right aligned PWM */
109  PWM_CENTER /*< use center aligned PWM */
110 } pwm_mode_t;
111 #endif
112 
135 uint32_t pwm_init(pwm_t dev, pwm_mode_t mode, uint32_t freq, uint16_t res);
136 
144 uint8_t pwm_channels(pwm_t dev);
145 
156 void pwm_set(pwm_t dev, uint8_t channel, uint16_t value);
157 
169 void pwm_poweron(pwm_t dev);
170 
179 void pwm_poweroff(pwm_t dev);
180 
181 #ifdef __cplusplus
182 }
183 #endif
184 
185 #endif /* PERIPH_PWM_H */
186 
void pwm_poweroff(pwm_t dev)
Stop PWM generation on the given device.
pwm_mode_t
Default PWM mode definition.
Definition: pwm.h:106
uint8_t pwm_channels(pwm_t dev)
Get the number of available channels.
void pwm_poweron(pwm_t dev)
Resume PWM generation on the given device.
void pwm_set(pwm_t dev, uint8_t channel, uint16_t value)
Set the duty-cycle for a given channel of the given PWM device.
uint32_t pwm_init(pwm_t dev, pwm_mode_t mode, uint32_t freq, uint16_t res)
Initialize a PWM device.
unsigned int pwm_t
Default PWM type definition.
Definition: pwm.h:97