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