Loading...
Searching...
No Matches
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
9#pragma once
10
62
63#include <stdint.h>
64#include <limits.h>
65
66#include "periph_cpu.h"
67#include "periph_conf.h"
68
69#ifdef __cplusplus
70extern "C" {
71#endif
72
76#ifndef PWM_DEV
77#define PWM_DEV(x) (x)
78#endif
79
83#ifndef PWM_UNDEF
84#define PWM_UNDEF (UINT_FAST8_MAX)
85#endif
86
90#ifndef HAVE_PWM_T
91typedef uint_fast8_t pwm_t;
92#endif
93
97#ifndef HAVE_PWM_MODE_T
103#endif
104
105#ifdef MODULE_ARDUINO
110typedef struct {
111 pwm_t dev;
112 uint8_t chan;
113 uint8_t pin;
114} arduino_pwm_t;
115#endif
116
138uint32_t pwm_init(pwm_t dev, pwm_mode_t mode, uint32_t freq, uint16_t res);
139
147uint8_t pwm_channels(pwm_t dev);
148
159void pwm_set(pwm_t dev, uint8_t channel, uint16_t value);
160
173
183
184#ifdef __cplusplus
185}
186#endif
187
pwm_mode_t
@ PWM_CENTER
center aligned
@ PWM_LEFT
left aligned
@ PWM_RIGHT
right aligned
void pwm_poweron(pwm_t dev)
Resume PWM generation on the given device.
uint32_t pwm_init(pwm_t dev, pwm_mode_t mode, uint32_t freq, uint16_t res)
Initialize a PWM device.
uint8_t pwm_channels(pwm_t dev)
Get the number of available channels.
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.
void pwm_poweroff(pwm_t dev)
Stop PWM generation on the given device.
uint_fast8_t pwm_t
Default PWM type definition.
Definition pwm.h:91