Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbed-os/hal/pwmout_api.h@3:6fe17b8a6d62, 2021-03-09 (annotated)
- Committer:
- boro
- Date:
- Tue Mar 09 13:10:40 2021 +0000
- Revision:
- 3:6fe17b8a6d62
- Parent:
- 0:4beb2ea291ec
SDBlockDevice added
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| boro | 0:4beb2ea291ec | 1 | |
| boro | 0:4beb2ea291ec | 2 | /** \addtogroup hal */ |
| boro | 0:4beb2ea291ec | 3 | /** @{*/ |
| boro | 0:4beb2ea291ec | 4 | /* mbed Microcontroller Library |
| boro | 0:4beb2ea291ec | 5 | * Copyright (c) 2006-2013 ARM Limited |
| boro | 0:4beb2ea291ec | 6 | * |
| boro | 0:4beb2ea291ec | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| boro | 0:4beb2ea291ec | 8 | * you may not use this file except in compliance with the License. |
| boro | 0:4beb2ea291ec | 9 | * You may obtain a copy of the License at |
| boro | 0:4beb2ea291ec | 10 | * |
| boro | 0:4beb2ea291ec | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| boro | 0:4beb2ea291ec | 12 | * |
| boro | 0:4beb2ea291ec | 13 | * Unless required by applicable law or agreed to in writing, software |
| boro | 0:4beb2ea291ec | 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| boro | 0:4beb2ea291ec | 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| boro | 0:4beb2ea291ec | 16 | * See the License for the specific language governing permissions and |
| boro | 0:4beb2ea291ec | 17 | * limitations under the License. |
| boro | 0:4beb2ea291ec | 18 | */ |
| boro | 0:4beb2ea291ec | 19 | #ifndef MBED_PWMOUT_API_H |
| boro | 0:4beb2ea291ec | 20 | #define MBED_PWMOUT_API_H |
| boro | 0:4beb2ea291ec | 21 | |
| boro | 0:4beb2ea291ec | 22 | #include "device.h" |
| boro | 0:4beb2ea291ec | 23 | |
| boro | 0:4beb2ea291ec | 24 | #if DEVICE_PWMOUT |
| boro | 0:4beb2ea291ec | 25 | |
| boro | 0:4beb2ea291ec | 26 | #ifdef __cplusplus |
| boro | 0:4beb2ea291ec | 27 | extern "C" { |
| boro | 0:4beb2ea291ec | 28 | #endif |
| boro | 0:4beb2ea291ec | 29 | |
| boro | 0:4beb2ea291ec | 30 | /** Pwmout hal structure. pwmout_s is declared in the target's hal |
| boro | 0:4beb2ea291ec | 31 | */ |
| boro | 0:4beb2ea291ec | 32 | typedef struct pwmout_s pwmout_t; |
| boro | 0:4beb2ea291ec | 33 | |
| boro | 0:4beb2ea291ec | 34 | /** |
| boro | 0:4beb2ea291ec | 35 | * \defgroup hal_pwmout Pwmout hal functions |
| boro | 0:4beb2ea291ec | 36 | * @{ |
| boro | 0:4beb2ea291ec | 37 | */ |
| boro | 0:4beb2ea291ec | 38 | |
| boro | 0:4beb2ea291ec | 39 | /** Initialize the pwm out peripheral and configure the pin |
| boro | 0:4beb2ea291ec | 40 | * |
| boro | 0:4beb2ea291ec | 41 | * @param obj The pwmout object to initialize |
| boro | 0:4beb2ea291ec | 42 | * @param pin The pwmout pin to initialize |
| boro | 0:4beb2ea291ec | 43 | */ |
| boro | 0:4beb2ea291ec | 44 | void pwmout_init(pwmout_t *obj, PinName pin); |
| boro | 0:4beb2ea291ec | 45 | |
| boro | 0:4beb2ea291ec | 46 | /** Deinitialize the pwmout object |
| boro | 0:4beb2ea291ec | 47 | * |
| boro | 0:4beb2ea291ec | 48 | * @param obj The pwmout object |
| boro | 0:4beb2ea291ec | 49 | */ |
| boro | 0:4beb2ea291ec | 50 | void pwmout_free(pwmout_t *obj); |
| boro | 0:4beb2ea291ec | 51 | |
| boro | 0:4beb2ea291ec | 52 | /** Set the output duty-cycle in range <0.0f, 1.0f> |
| boro | 0:4beb2ea291ec | 53 | * |
| boro | 0:4beb2ea291ec | 54 | * Value 0.0f represents 0 percentage, 1.0f represents 100 percent. |
| boro | 0:4beb2ea291ec | 55 | * @param obj The pwmout object |
| boro | 0:4beb2ea291ec | 56 | * @param percent The floating-point percentage number |
| boro | 0:4beb2ea291ec | 57 | */ |
| boro | 0:4beb2ea291ec | 58 | void pwmout_write(pwmout_t *obj, float percent); |
| boro | 0:4beb2ea291ec | 59 | |
| boro | 0:4beb2ea291ec | 60 | /** Read the current float-point output duty-cycle |
| boro | 0:4beb2ea291ec | 61 | * |
| boro | 0:4beb2ea291ec | 62 | * @param obj The pwmout object |
| boro | 0:4beb2ea291ec | 63 | * @return A floating-point output duty-cycle |
| boro | 0:4beb2ea291ec | 64 | */ |
| boro | 0:4beb2ea291ec | 65 | float pwmout_read(pwmout_t *obj); |
| boro | 0:4beb2ea291ec | 66 | |
| boro | 0:4beb2ea291ec | 67 | /** Set the PWM period specified in seconds, keeping the duty cycle the same |
| boro | 0:4beb2ea291ec | 68 | * |
| boro | 0:4beb2ea291ec | 69 | * Periods smaller than microseconds (the lowest resolution) are set to zero. |
| boro | 0:4beb2ea291ec | 70 | * @param obj The pwmout object |
| boro | 0:4beb2ea291ec | 71 | * @param seconds The floating-point seconds period |
| boro | 0:4beb2ea291ec | 72 | */ |
| boro | 0:4beb2ea291ec | 73 | void pwmout_period(pwmout_t *obj, float seconds); |
| boro | 0:4beb2ea291ec | 74 | |
| boro | 0:4beb2ea291ec | 75 | /** Set the PWM period specified in miliseconds, keeping the duty cycle the same |
| boro | 0:4beb2ea291ec | 76 | * |
| boro | 0:4beb2ea291ec | 77 | * @param obj The pwmout object |
| boro | 0:4beb2ea291ec | 78 | * @param ms The milisecond period |
| boro | 0:4beb2ea291ec | 79 | */ |
| boro | 0:4beb2ea291ec | 80 | void pwmout_period_ms(pwmout_t *obj, int ms); |
| boro | 0:4beb2ea291ec | 81 | |
| boro | 0:4beb2ea291ec | 82 | /** Set the PWM period specified in microseconds, keeping the duty cycle the same |
| boro | 0:4beb2ea291ec | 83 | * |
| boro | 0:4beb2ea291ec | 84 | * @param obj The pwmout object |
| boro | 0:4beb2ea291ec | 85 | * @param us The microsecond period |
| boro | 0:4beb2ea291ec | 86 | */ |
| boro | 0:4beb2ea291ec | 87 | void pwmout_period_us(pwmout_t *obj, int us); |
| boro | 0:4beb2ea291ec | 88 | |
| boro | 0:4beb2ea291ec | 89 | /** Set the PWM pulsewidth specified in seconds, keeping the period the same. |
| boro | 0:4beb2ea291ec | 90 | * |
| boro | 0:4beb2ea291ec | 91 | * @param obj The pwmout object |
| boro | 0:4beb2ea291ec | 92 | * @param seconds The floating-point pulsewidth in seconds |
| boro | 0:4beb2ea291ec | 93 | */ |
| boro | 0:4beb2ea291ec | 94 | void pwmout_pulsewidth(pwmout_t *obj, float seconds); |
| boro | 0:4beb2ea291ec | 95 | |
| boro | 0:4beb2ea291ec | 96 | /** Set the PWM pulsewidth specified in miliseconds, keeping the period the same. |
| boro | 0:4beb2ea291ec | 97 | * |
| boro | 0:4beb2ea291ec | 98 | * @param obj The pwmout object |
| boro | 0:4beb2ea291ec | 99 | * @param ms The floating-point pulsewidth in miliseconds |
| boro | 0:4beb2ea291ec | 100 | */ |
| boro | 0:4beb2ea291ec | 101 | void pwmout_pulsewidth_ms(pwmout_t *obj, int ms); |
| boro | 0:4beb2ea291ec | 102 | |
| boro | 0:4beb2ea291ec | 103 | /** Set the PWM pulsewidth specified in microseconds, keeping the period the same. |
| boro | 0:4beb2ea291ec | 104 | * |
| boro | 0:4beb2ea291ec | 105 | * @param obj The pwmout object |
| boro | 0:4beb2ea291ec | 106 | * @param us The floating-point pulsewidth in microseconds |
| boro | 0:4beb2ea291ec | 107 | */ |
| boro | 0:4beb2ea291ec | 108 | void pwmout_pulsewidth_us(pwmout_t *obj, int us); |
| boro | 0:4beb2ea291ec | 109 | |
| boro | 0:4beb2ea291ec | 110 | /**@}*/ |
| boro | 0:4beb2ea291ec | 111 | |
| boro | 0:4beb2ea291ec | 112 | #ifdef __cplusplus |
| boro | 0:4beb2ea291ec | 113 | } |
| boro | 0:4beb2ea291ec | 114 | #endif |
| boro | 0:4beb2ea291ec | 115 | |
| boro | 0:4beb2ea291ec | 116 | #endif |
| boro | 0:4beb2ea291ec | 117 | |
| boro | 0:4beb2ea291ec | 118 | #endif |
| boro | 0:4beb2ea291ec | 119 | |
| boro | 0:4beb2ea291ec | 120 | /** @}*/ |