Dependents:   sensomed

Committer:
switches
Date:
Tue Nov 08 18:27:11 2016 +0000
Revision:
0:0e018d759a2a
Initial commit

Who changed what in which revision?

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