inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

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