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 templates/pwm_lld.h 00029 * @brief PWM Driver subsystem low level driver header template. 00030 * 00031 * @addtogroup PWM_LLD 00032 * @{ 00033 */ 00034 00035 #ifndef _PWM_LLD_H_ 00036 #define _PWM_LLD_H_ 00037 00038 /*===========================================================================*/ 00039 /* Driver constants. */ 00040 /*===========================================================================*/ 00041 00042 /*===========================================================================*/ 00043 /* Driver pre-compile time settings. */ 00044 /*===========================================================================*/ 00045 00046 /** 00047 * @brief Number of PWM channels per PWM driver. 00048 */ 00049 #if !defined(PWM_CHANNELS) || defined(__DOXYGEN__) 00050 #define PWM_CHANNELS 1 00051 #endif 00052 00053 /*===========================================================================*/ 00054 /* Derived constants and error checks. */ 00055 /*===========================================================================*/ 00056 00057 /*===========================================================================*/ 00058 /* Driver data structures and types. */ 00059 /*===========================================================================*/ 00060 00061 /** 00062 * @brief PWM channel type. 00063 */ 00064 typedef uint8_t pwmchannel_t; 00065 00066 /** 00067 * @brief PWM counter type. 00068 */ 00069 typedef uint16_t pwmcnt_t; 00070 00071 /** 00072 * @brief Driver configuration structure. 00073 * @note It could be empty on some architectures. 00074 */ 00075 typedef struct { 00076 00077 } PWMConfig; 00078 00079 /** 00080 * @brief Structure representing an PWM driver. 00081 */ 00082 typedef struct { 00083 /** 00084 * @brief Driver state. 00085 */ 00086 pwmstate_t pd_state; 00087 /** 00088 * @brief Current configuration data. 00089 */ 00090 const PWMConfig *pd_config; 00091 /* End of the mandatory fields.*/ 00092 } PWMDriver; 00093 00094 /*===========================================================================*/ 00095 /* Driver macros. */ 00096 /*===========================================================================*/ 00097 00098 /*===========================================================================*/ 00099 /* External declarations. */ 00100 /*===========================================================================*/ 00101 00102 #ifdef __cplusplus 00103 extern "C" { 00104 #endif 00105 void pwm_lld_init(void); 00106 void pwm_lld_start(PWMDriver *pwmp); 00107 void pwm_lld_stop(PWMDriver *pwmp); 00108 bool_t pwm_lld_is_enabled(PWMDriver *pwmp, pwmchannel_t channel); 00109 void pwm_lld_set_callback(PWMDriver *pwmp, pwmchannel_t channel, 00110 pwmedge_t edge, pwmcallback_t callback); 00111 void pwm_lld_enable_channel(PWMDriver *pwmp, 00112 pwmchannel_t channel, 00113 pwmcnt_t width); 00114 void pwm_lld_disable_channel(PWMDriver *pwmp, pwmchannel_t channel); 00115 #ifdef __cplusplus 00116 } 00117 #endif 00118 00119 #endif /* _PWM_LLD_H_ */ 00120 00121 /** @} */