libpynq (release 5EWC0-2023 version 0.2.2 of 2023-09-24 22:22)
Loading...
Searching...
No Matches
pwm.h
Go to the documentation of this file.
1/*
2Copyright (c) 2023 Eindhoven University of Technology
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all
12copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20SOFTWARE.
21*/
22#ifndef PWM_H
23#define PWM_H
24#include <libpynq.h>
25
47typedef enum { PWM0, PWM1, PWM2, PWM3, PWM4, PWM5, NUM_PWMS } pwm_index_t;
48
55extern bool pwm_initialized(const int pwm);
56
63extern void pwm_init(const int pwm, const uint32_t period);
64
70extern void pwm_destroy(const int pwm);
71
79extern void pwm_set_duty_cycle(const int pwm, const uint32_t duty);
80
88extern void pwm_set_period(const int pwm, const uint32_t period);
89
97uint32_t pwm_get_period(const int pwm);
98
106extern uint32_t pwm_get_duty_cycle(const int pwm);
107
116extern void pwm_set_steps(const int pwm, const uint32_t steps);
117
126extern uint32_t pwm_get_steps(const int pwm);
127
131#endif
void pwm_init(const int pwm, const uint32_t period)
Initializes the PWM channel with the specified period.
Definition pwm.c:61
uint32_t pwm_get_steps(const int pwm)
Get the number of steps a certain channel has taken so far.
Definition pwm.c:98
void pwm_set_steps(const int pwm, const uint32_t steps)
Generates steps steps on the PWM channel.
Definition pwm.c:103
void pwm_destroy(const int pwm)
Removes the instantiated shared memory system of the PWM channel.
Definition pwm.c:72
uint32_t pwm_get_duty_cycle(const int pwm)
Gets the duty cycle of the specified PWM channel.
Definition pwm.c:78
pwm_index_t
Enum of PWM channels.
Definition pwm.h:47
void pwm_set_duty_cycle(const int pwm, const uint32_t duty)
Sets the duty cycle for the specified PWM channel.
Definition pwm.c:93
bool pwm_initialized(const int pwm)
Checks if the channel index is initialized.
Definition pwm.c:38
void pwm_set_period(const int pwm, const uint32_t period)
Sets the period for the specified PWM channel.
Definition pwm.c:88
uint32_t pwm_get_period(const int pwm)
Returns the period of a certain PWM channel.
Definition pwm.c:83
@ NUM_PWMS
Definition pwm.h:47
@ PWM0
Definition pwm.h:47
@ PWM4
Definition pwm.h:47
@ PWM1
Definition pwm.h:47
@ PWM3
Definition pwm.h:47
@ PWM5
Definition pwm.h:47
@ PWM2
Definition pwm.h:47