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