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