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