Mistake on this page?
Report an issue in GitHub or email us
pwmout_api.h
1 
2 /** \addtogroup hal */
3 /** @{*/
4 /* mbed Microcontroller Library
5  * Copyright (c) 2006-2013 ARM Limited
6  * SPDX-License-Identifier: Apache-2.0
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 #ifndef MBED_PWMOUT_API_H
21 #define MBED_PWMOUT_API_H
22 
23 #include "device.h"
24 #include "pinmap.h"
25 
26 #if DEVICE_PWMOUT
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /** Pwmout hal structure. pwmout_s is declared in the target's hal
33  */
34 typedef struct pwmout_s pwmout_t;
35 
36 /**
37  * \defgroup hal_pwmout Pwmout hal functions
38  * @{
39  */
40 
41 /** Initialize the pwm out peripheral and configure the pin
42  *
43  * @param obj The pwmout object to initialize
44  * @param pin The pwmout pin to initialize
45  */
46 void pwmout_init(pwmout_t *obj, PinName pin);
47 
48 /** Deinitialize the pwmout object
49  *
50  * @param obj The pwmout object
51  */
52 void pwmout_free(pwmout_t *obj);
53 
54 /** Set the output duty-cycle in range <0.0f, 1.0f>
55  *
56  * Value 0.0f represents 0 percentage, 1.0f represents 100 percent.
57  * @param obj The pwmout object
58  * @param percent The floating-point percentage number
59  */
60 void pwmout_write(pwmout_t *obj, float percent);
61 
62 /** Read the current float-point output duty-cycle
63  *
64  * @param obj The pwmout object
65  * @return A floating-point output duty-cycle
66  */
67 float pwmout_read(pwmout_t *obj);
68 
69 /** Set the PWM period specified in seconds, keeping the duty cycle the same
70  *
71  * Periods smaller than microseconds (the lowest resolution) are set to zero.
72  * @param obj The pwmout object
73  * @param seconds The floating-point seconds period
74  */
75 void pwmout_period(pwmout_t *obj, float seconds);
76 
77 /** Set the PWM period specified in miliseconds, keeping the duty cycle the same
78  *
79  * @param obj The pwmout object
80  * @param ms The milisecond period
81  */
82 void pwmout_period_ms(pwmout_t *obj, int ms);
83 
84 /** Set the PWM period specified in microseconds, keeping the duty cycle the same
85  *
86  * @param obj The pwmout object
87  * @param us The microsecond period
88  */
89 void pwmout_period_us(pwmout_t *obj, int us);
90 
91 /** Set the PWM pulsewidth specified in seconds, keeping the period the same.
92  *
93  * @param obj The pwmout object
94  * @param seconds The floating-point pulsewidth in seconds
95  */
96 void pwmout_pulsewidth(pwmout_t *obj, float seconds);
97 
98 /** Set the PWM pulsewidth specified in miliseconds, keeping the period the same.
99  *
100  * @param obj The pwmout object
101  * @param ms The floating-point pulsewidth in miliseconds
102  */
103 void pwmout_pulsewidth_ms(pwmout_t *obj, int ms);
104 
105 /** Set the PWM pulsewidth specified in microseconds, keeping the period the same.
106  *
107  * @param obj The pwmout object
108  * @param us The floating-point pulsewidth in microseconds
109  */
110 void pwmout_pulsewidth_us(pwmout_t *obj, int us);
111 
112 /** Get the pins that support PWM
113  *
114  * Return a PinMap array of pins that support PWM.
115  * The array is terminated with {NC, NC, 0}.
116  *
117  * @return PinMap array
118  */
119 const PinMap *pwmout_pinmap(void);
120 
121 /**@}*/
122 
123 #ifdef __cplusplus
124 }
125 #endif
126 
127 #endif
128 
129 #endif
130 
131 /** @}*/
void pwmout_period_us(pwmout_t *obj, int us)
Set the PWM period specified in microseconds, keeping the duty cycle the same.
void pwmout_pulsewidth_ms(pwmout_t *obj, int ms)
Set the PWM pulsewidth specified in miliseconds, keeping the period the same.
void pwmout_write(pwmout_t *obj, float percent)
Set the output duty-cycle in range <0.0f, 1.0f>
void pwmout_pulsewidth_us(pwmout_t *obj, int us)
Set the PWM pulsewidth specified in microseconds, keeping the period the same.
void pwmout_period(pwmout_t *obj, float seconds)
Set the PWM period specified in seconds, keeping the duty cycle the same.
const PinMap * pwmout_pinmap(void)
Get the pins that support PWM.
void pwmout_init(pwmout_t *obj, PinName pin)
Initialize the pwm out peripheral and configure the pin.
void pwmout_period_ms(pwmout_t *obj, int ms)
Set the PWM period specified in miliseconds, keeping the duty cycle the same.
Definition: pinmap.h:30
float pwmout_read(pwmout_t *obj)
Read the current float-point output duty-cycle.
struct pwmout_s pwmout_t
Pwmout hal structure.
Definition: pwmout_api.h:34
void pwmout_pulsewidth(pwmout_t *obj, float seconds)
Set the PWM pulsewidth specified in seconds, keeping the period the same.
void pwmout_free(pwmout_t *obj)
Deinitialize the pwmout object.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.