TUKS MCU Introductory course / TUKS-COURSE-TIMER
Committer:
elmot
Date:
Sat Feb 25 00:23:53 2017 +0000
Revision:
2:5acdd8565d02
Parent:
1:d0dfbce63a89
Ready to show

Who changed what in which revision?

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