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