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