001

Committer:
ganlikun
Date:
Sun Jun 12 14:02:44 2022 +0000
Revision:
0:13413ea9a877
00

Who changed what in which revision?

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