ChibiOS/RT Architecture - Reference Manual - Guides |
00001 /* 00002 ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. 00003 00004 This file is part of ChibiOS/RT. 00005 00006 ChibiOS/RT is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 ChibiOS/RT is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 00019 --- 00020 00021 A special exception to the GPL can be applied should you wish to distribute 00022 a combined work that includes ChibiOS/RT, without being obliged to provide 00023 the source code for any proprietary components. See the file exception.txt 00024 for full details of how and when the exception can be applied. 00025 */ 00026 00027 /** 00028 * @file pwm.h 00029 * @brief PWM Driver macros and structures. 00030 * 00031 * @addtogroup PWM 00032 * @{ 00033 */ 00034 00035 #ifndef _PWM_H_ 00036 #define _PWM_H_ 00037 00038 #if CH_HAL_USE_PWM || defined(__DOXYGEN__) 00039 00040 /*===========================================================================*/ 00041 /* Driver constants. */ 00042 /*===========================================================================*/ 00043 00044 /*===========================================================================*/ 00045 /* Driver pre-compile time settings. */ 00046 /*===========================================================================*/ 00047 00048 /*===========================================================================*/ 00049 /* Derived constants and error checks. */ 00050 /*===========================================================================*/ 00051 00052 /*===========================================================================*/ 00053 /* Driver data structures and types. */ 00054 /*===========================================================================*/ 00055 00056 /** 00057 * @brief Driver state machine possible states. 00058 */ 00059 typedef enum { 00060 PWM_UNINIT = 0, /**< Not initialized. */ 00061 PWM_STOP = 1, /**< Stopped. */ 00062 PWM_READY = 2, /**< Ready. */ 00063 } pwmstate_t; 00064 00065 /** 00066 * @brief PWM logic mode. 00067 */ 00068 typedef enum { 00069 PWM_OUTPUT_DISABLED = 0, /**< Output not driven, callback only. */ 00070 PWM_OUTPUT_ACTIVE_HIGH = 1, /**< Idle is logic level 0. */ 00071 PWM_OUTPUT_ACTIVE_LOW = 2 /**< Idle is logic level 1. */ 00072 } pwmmode_t; 00073 00074 #include "pwm_lld.h" 00075 00076 /*===========================================================================*/ 00077 /* Driver macros. */ 00078 /*===========================================================================*/ 00079 00080 /** 00081 * @brief Enables a PWM channel. 00082 * @details Programs (or reprograms) a PWM channel. 00083 * @note This function has to be invoked from a lock zone. 00084 * 00085 * @param[in] pwmp pointer to a @p PWMDriver object 00086 * @param[in] channel PWM channel identifier 00087 * @param[in] width PWM pulse width as clock pulses number 00088 */ 00089 #define pwmEnableChannelI(pwmp, channel, width) \ 00090 pwm_lld_enable_channel(pwmp, channel, width) 00091 00092 /** 00093 * @brief Disables a PWM channel. 00094 * @details The channel is disabled and its output line returned to the 00095 * idle state. 00096 * @note This function has to be invoked from a lock zone. 00097 * 00098 * @param[in] pwmp pointer to a @p PWMDriver object 00099 * @param[in] channel PWM channel identifier 00100 */ 00101 #define pwmDisableChannelI(pwmp, channel) \ 00102 pwm_lld_disable_channel(pwmp, channel) 00103 00104 /*===========================================================================*/ 00105 /* External declarations. */ 00106 /*===========================================================================*/ 00107 00108 #ifdef __cplusplus 00109 extern "C" { 00110 #endif 00111 void pwmInit(void); 00112 void pwmObjectInit(PWMDriver *pwmp); 00113 void pwmStart(PWMDriver *pwmp, const PWMConfig *config); 00114 void pwmStop(PWMDriver *pwmp); 00115 void pwmEnableChannel(PWMDriver *pwmp, 00116 pwmchannel_t channel, 00117 pwmcnt_t width); 00118 void pwmDisableChannel(PWMDriver *pwmp, pwmchannel_t channel); 00119 #ifdef __cplusplus 00120 } 00121 #endif 00122 00123 #endif /* CH_HAL_USE_PWM */ 00124 00125 #endif /* _PWM_H_ */ 00126 00127 /** @} */