The prosthetic control(MIT)

Committer:
ganlikun
Date:
Thu Jun 23 05:23:34 2022 +0000
Revision:
0:20e0c61e0684
01

Who changed what in which revision?

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