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