Loading...
Searching...
No Matches
pwm.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014-2015 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
59
60#include <stdint.h>
61#include <limits.h>
62
63#include "periph_cpu.h"
64#include "periph_conf.h"
65
66#ifdef __cplusplus
67extern "C" {
68#endif
69
73#ifndef PWM_DEV
74#define PWM_DEV(x) (x)
75#endif
76
80#ifndef PWM_UNDEF
81#define PWM_UNDEF (UINT_FAST8_MAX)
82#endif
83
87#ifndef HAVE_PWM_T
88typedef uint_fast8_t pwm_t;
89#endif
90
94#ifndef HAVE_PWM_MODE_T
100#endif
101
102#ifdef MODULE_ARDUINO
107typedef struct {
108 pwm_t dev;
109 uint8_t chan;
110 uint8_t pin;
111} arduino_pwm_t;
112#endif
113
135uint32_t pwm_init(pwm_t dev, pwm_mode_t mode, uint32_t freq, uint16_t res);
136
144uint8_t pwm_channels(pwm_t dev);
145
156void pwm_set(pwm_t dev, uint8_t channel, uint16_t value);
157
170
180
181#ifdef __cplusplus
182}
183#endif
184
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:88