mbed library sources. Supersedes mbed-src.

Dependents:   LPCXpresso1769_blinky

Fork of mbed-dev by mbed official

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pwmout_api.h Source File

pwmout_api.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef MBED_PWMOUT_API_H
00017 #define MBED_PWMOUT_API_H
00018 
00019 #include "device.h"
00020 
00021 #if DEVICE_PWMOUT
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 /** Pwmout hal structure. pwmout_s is declared in the target's hal
00028  */
00029 typedef struct pwmout_s pwmout_t;
00030 
00031 /**
00032  * \defgroup hal_pwmout Pwmout hal functions
00033  * @{
00034  */
00035 
00036 /** Initialize the pwm out peripheral and configure the pin
00037  *
00038  * @param obj The pwmout object to initialize
00039  * @param pin The pwmout pin to initialize
00040  */
00041 void pwmout_init(pwmout_t *obj, PinName pin);
00042 
00043 /** Deinitialize the pwmout object
00044  *
00045  * @param obj The pwmout object
00046  */
00047 void pwmout_free(pwmout_t *obj);
00048 
00049 /** Set the output duty-cycle in range <0.0f, 1.0f>
00050  *
00051  * Value 0.0f represents 0 percentage, 1.0f represents 100 percent.
00052  * @param obj     The pwmout object
00053  * @param percent The floating-point percentage number
00054  */
00055 void pwmout_write(pwmout_t *obj, float percent);
00056 
00057 /** Read the current float-point output duty-cycle
00058  *
00059  * @param obj The pwmout object
00060  * @return A floating-point output duty-cycle
00061  */
00062 float pwmout_read(pwmout_t *obj);
00063 
00064 /** Set the PWM period specified in seconds, keeping the duty cycle the same
00065  *
00066  * Periods smaller than microseconds (the lowest resolution) are set to zero.
00067  * @param obj     The pwmout object
00068  * @param seconds The floating-point seconds period
00069  */
00070 void pwmout_period(pwmout_t *obj, float seconds);
00071 
00072 /** Set the PWM period specified in miliseconds, keeping the duty cycle the same
00073  *
00074  * @param obj The pwmout object
00075  * @param ms  The milisecond period
00076  */
00077 void pwmout_period_ms(pwmout_t *obj, int ms);
00078 
00079 /** Set the PWM period specified in microseconds, keeping the duty cycle the same
00080  *
00081  * @param obj The pwmout object
00082  * @param us  The microsecond period
00083  */
00084 void pwmout_period_us(pwmout_t *obj, int us);
00085 
00086 /** Set the PWM pulsewidth specified in seconds, keeping the period the same.
00087  *
00088  * @param obj     The pwmout object
00089  * @param seconds The floating-point pulsewidth in seconds
00090  */
00091 void pwmout_pulsewidth(pwmout_t *obj, float seconds);
00092 
00093 /** Set the PWM pulsewidth specified in miliseconds, keeping the period the same.
00094  *
00095  * @param obj The pwmout object
00096  * @param ms  The floating-point pulsewidth in miliseconds
00097  */
00098 void pwmout_pulsewidth_ms(pwmout_t *obj, int ms);
00099 
00100 /** Set the PWM pulsewidth specified in microseconds, keeping the period the same.
00101  *
00102  * @param obj The pwmout object
00103  * @param us  The floating-point pulsewidth in microseconds
00104  */
00105 void pwmout_pulsewidth_us(pwmout_t *obj, int us);
00106 
00107 /**@}*/
00108 
00109 #ifdef __cplusplus
00110 }
00111 #endif
00112 
00113 #endif
00114 
00115 #endif