STM8L15x Standard Peripherals Drivers: stm8l15x_tim4.h Source File

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

stm8l15x_tim4.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm8l15x_tim4.h
00004   * @author  MCD Application Team
00005   * @version V1.5.0
00006   * @date    13-May-2011
00007   * @brief   This file contains all the functions prototypes for the TIM4 firmware
00008   *          library.
00009   ******************************************************************************
00010   * @attention
00011   *
00012   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00013   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00014   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00015   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00016   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00017   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00018   *
00019   * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
00020   ******************************************************************************  
00021   */
00022 
00023 /* Define to prevent recursive inclusion -------------------------------------*/
00024 #ifndef __STM8L15x_TIM4_H
00025 #define __STM8L15x_TIM4_H
00026 
00027 /* Includes ------------------------------------------------------------------*/
00028 #include "stm8l15x.h"
00029 
00030 /** @addtogroup STM8L15x_StdPeriph_Driver
00031   * @{
00032   */
00033 
00034 /** @addtogroup TIM4
00035   * @{
00036   */ 
00037   
00038 /* Exported types ------------------------------------------------------------*/
00039 
00040 /** @defgroup TIM4_Exported_Types
00041   * @{
00042   */
00043 
00044 
00045 /** @defgroup TIM4_Prescaler
00046   * @{
00047   */
00048 typedef enum
00049 {
00050   TIM4_Prescaler_1      = ((uint8_t)0x00),   /*!< Time base Prescaler = 1 (No effect)*/
00051   TIM4_Prescaler_2      = ((uint8_t)0x01),  /*!< Time base Prescaler = 2 */
00052   TIM4_Prescaler_4      = ((uint8_t)0x02),  /*!< Time base Prescaler = 4 */
00053   TIM4_Prescaler_8      = ((uint8_t)0x03),  /*!< Time base Prescaler = 8 */
00054   TIM4_Prescaler_16     = ((uint8_t)0x04),  /*!< Time base Prescaler = 16 */
00055   TIM4_Prescaler_32     = ((uint8_t)0x05),  /*!< Time base Prescaler = 32 */
00056   TIM4_Prescaler_64     = ((uint8_t)0x06),  /*!< Time base Prescaler = 64 */
00057   TIM4_Prescaler_128    = ((uint8_t)0x07),  /*!< Time base Prescaler = 128 */
00058   TIM4_Prescaler_256    = ((uint8_t)0x08),  /*!< Time base Prescaler = 256 */
00059   TIM4_Prescaler_512    = ((uint8_t)0x09),  /*!< Time base Prescaler = 512 */
00060   TIM4_Prescaler_1024   = ((uint8_t)0x0A),  /*!< Time base Prescaler = 1024 */
00061   TIM4_Prescaler_2048   = ((uint8_t)0x0B),  /*!< Time base Prescaler = 2048 */
00062   TIM4_Prescaler_4096   = ((uint8_t)0x0C),  /*!< Time base Prescaler = 4096 */
00063   TIM4_Prescaler_8192   = ((uint8_t)0x0D),  /*!< Time base Prescaler = 8196 */
00064   TIM4_Prescaler_16384  = ((uint8_t)0x0E),  /*!< Time base Prescaler = 16384 */
00065   TIM4_Prescaler_32768  = ((uint8_t)0x0F)   /*!< Time base Prescaler = 32768 */
00066 }TIM4_Prescaler_TypeDef;
00067 
00068 /**
00069   * @}
00070   */
00071   
00072 /** @defgroup TIM4_One_Pulse_Mode
00073   * @{
00074   */
00075 typedef enum
00076 {
00077   TIM4_OPMode_Single      = ((uint8_t) 0x01),  /*!< Single one Pulse mode (OPM Active) */
00078   TIM4_OPMode_Repetitive  = ((uint8_t) 0x00)   /*!< Repetitive Pulse mode (OPM inactive) */
00079 }TIM4_OPMode_TypeDef;
00080 
00081 /**
00082   * @}
00083   */
00084   
00085 /** @defgroup TIM4_Reload_Mode_Prescaler
00086   * @{
00087   */
00088 typedef enum
00089 {
00090   TIM4_PSCReloadMode_Update      = ((uint8_t)0x00), /*!< Prescaler value is reloaded at every update */
00091   TIM4_PSCReloadMode_Immediate  = ((uint8_t)0x01)  /*!< Prescaler value is reloaded immediatly */
00092 }TIM4_PSCReloadMode_TypeDef;
00093 
00094 /**
00095   * @}
00096   */
00097   
00098 /** @defgroup TIM4_Update_Source
00099   * @{
00100   */
00101 typedef enum
00102 {
00103   TIM4_UpdateSource_Global  = ((uint8_t)0x00),  /*!< Global Update request source */
00104   TIM4_UpdateSource_Regular  = ((uint8_t)0x01)   /*!< Regular Update request source */
00105 }TIM4_UpdateSource_TypeDef;
00106 
00107 /**
00108   * @}
00109   */
00110   
00111 /** @defgroup TIM4_Event_Source
00112   * @{
00113   */
00114 typedef enum
00115 {
00116   TIM4_EventSource_Update    = ((uint8_t)0x01),  /*!< Update Event */
00117   TIM4_EventSource_Trigger  = ((uint8_t)0x40)   /*!< Trigger Event */
00118 }TIM4_EventSource_TypeDef;
00119 
00120 /**
00121   * @}
00122   */
00123   
00124 /** @defgroup TIM4_Trigger_Output_Source
00125   * @{
00126   */
00127 typedef enum
00128 {
00129   TIM4_TRGOSource_Reset   = ((uint8_t)0x00),  /*!< Trigger Output source = Reset */
00130   TIM4_TRGOSource_Enable  = ((uint8_t)0x10),  /*!< Trigger Output source = TIM4 is enabled */
00131   TIM4_TRGOSource_Update  = ((uint8_t)0x20)   /*!< Trigger Output source = Update event */
00132 }TIM4_TRGOSource_TypeDef;
00133 
00134 /**
00135   * @}
00136   */
00137   
00138 /** @defgroup TIM4_Salve_Mode
00139   * @{
00140   */
00141 typedef enum
00142 {
00143   TIM4_SlaveMode_Disable    = ((uint8_t)0x00),   /*!< Disable slave mode to clock the prescaler
00144                                                       directly with the internal clock */
00145   TIM4_SlaveMode_Reset      = ((uint8_t)0x04),   /*!< Slave Mode Selection  = Reset*/
00146   TIM4_SlaveMode_Gated      = ((uint8_t)0x05),   /*!< Slave Mode Selection  = Gated*/
00147   TIM4_SlaveMode_Trigger    = ((uint8_t)0x06),  /*!< Slave Mode Selection  = Trigger*/
00148   TIM4_SlaveMode_External1  = ((uint8_t)0x07)    /*!< Slave Mode Selection  = External 1*/
00149 }TIM4_SlaveMode_TypeDef;
00150 
00151 /**
00152   * @}
00153   */
00154   
00155 /** @defgroup TIM4_Flags
00156   * @{
00157   */
00158 typedef enum
00159 {
00160   TIM4_FLAG_Update  = ((uint8_t)0x01),  /*!< Update Flag */
00161   TIM4_FLAG_Trigger  = ((uint8_t)0x40)    /*!< Trigger Flag */
00162 }TIM4_FLAG_TypeDef;
00163 
00164 /**
00165   * @}
00166   */
00167   
00168 /** @defgroup TIM4_Interrupts
00169   * @{
00170   */
00171 typedef enum
00172 {
00173   TIM4_IT_Update  = ((uint8_t)0x01),  /*!< Update Interrupt*/
00174   TIM4_IT_Trigger  = ((uint8_t)0x40)   /*!< Trigger  Interrupt*/
00175 }TIM4_IT_TypeDef;
00176 
00177 /**
00178   * @}
00179   */
00180   
00181 /** @defgroup TIM4_Internal_Trigger_Selection
00182   * @{
00183   */
00184 typedef enum
00185 {
00186   TIM4_TRGSelection_TIM5  = ((uint8_t)0x00), /*!< TRIG Input source =  TIM5 TRIG Output */
00187   TIM4_TRGSelection_TIM1  = ((uint8_t)0x10), /*!< TRIG Input source =  TIM1 TRIG Output */
00188   TIM4_TRGSelection_TIM3  = ((uint8_t)0x20), /*!< TRIG Input source =  TIM3 TRIG Output */
00189   TIM4_TRGSelection_TIM2  = ((uint8_t)0x30)  /*!< TRIG Input source =  TIM2 TRIG Output */
00190 }TIM4_TRGSelection_TypeDef;
00191 
00192 /**
00193   * @}
00194   */
00195   
00196 /** @defgroup TIM4_DMA_source_requests
00197   * @{
00198   */
00199 typedef enum
00200 {
00201   TIM4_DMASource_Update    = ((uint8_t)0x01)  /*!< TIM4 DMA Update Request*/
00202 }TIM4_DMASource_TypeDef;
00203 /**
00204   * @}
00205   */
00206 
00207 /**
00208   * @}
00209   */
00210   
00211 /* Exported constants --------------------------------------------------------*/
00212 /* Exported macros -----------------------------------------------------------*/
00213 
00214 /** @defgroup TIM4_Exported_Macros
00215   * @{
00216   */
00217 
00218 /**
00219   * @brief Macro used by the assert function to check the different functions parameters.
00220   */
00221 
00222 /**
00223   * @brief Macro TIM4 Prescaler
00224   */
00225 #define IS_TIM4_Prescaler(PRESCALER)  \
00226   (((PRESCALER) == TIM4_Prescaler_1)    || \
00227    ((PRESCALER) == TIM4_Prescaler_2)    || \
00228    ((PRESCALER) == TIM4_Prescaler_4)    || \
00229    ((PRESCALER) == TIM4_Prescaler_8)    || \
00230    ((PRESCALER) == TIM4_Prescaler_16)   || \
00231    ((PRESCALER) == TIM4_Prescaler_32)   || \
00232    ((PRESCALER) == TIM4_Prescaler_64)   || \
00233    ((PRESCALER) == TIM4_Prescaler_128)  || \
00234    ((PRESCALER) == TIM4_Prescaler_256)  || \
00235    ((PRESCALER) == TIM4_Prescaler_512)  || \
00236    ((PRESCALER) == TIM4_Prescaler_1024) || \
00237    ((PRESCALER) == TIM4_Prescaler_2048) || \
00238    ((PRESCALER) == TIM4_Prescaler_4096) || \
00239    ((PRESCALER) == TIM4_Prescaler_8192) || \
00240    ((PRESCALER) == TIM4_Prescaler_16384)|| \
00241    ((PRESCALER) == TIM4_Prescaler_32768))
00242 /**
00243   * @brief Macro TIM4 One Pulse Mode
00244   */
00245 #define IS_TIM4_OPM_MODE(MODE)  \
00246   (((MODE) == TIM4_OPMode_Single) || \
00247    ((MODE) == TIM4_OPMode_Repetitive))
00248 
00249 /**
00250   * @brief Macro TIM4 Prescaler reload
00251   */
00252 #define IS_TIM4_Prescaler_RELOAD(RELOAD) \
00253   (((RELOAD) == TIM4_PSCReloadMode_Update) || \
00254    ((RELOAD) == TIM4_PSCReloadMode_Immediate))
00255 /**
00256   * @brief Macro TIM4 Update source
00257   */
00258 #define IS_TIM4_UPDATE_SOURCE(SOURCE) \
00259   (((SOURCE) == TIM4_UpdateSource_Global) || \
00260    ((SOURCE) == TIM4_UpdateSource_Regular))
00261 /**
00262   * @brief Macro TIM4 Event source
00263   */
00264 #define IS_TIM4_EVENT_SOURCE(SOURCE) \
00265   ((((SOURCE) & (uint8_t)0xBE) == 0x00) && \
00266    ((SOURCE) != 0x00))
00267 
00268 /**
00269   * @brief Macro TIM4 TRGO source
00270   */
00271 #define IS_TIM4_TRGO_SOURCE(SOURCE) \
00272   (((SOURCE) == TIM4_TRGOSource_Reset) || \
00273    ((SOURCE) == TIM4_TRGOSource_Enable)|| \
00274    ((SOURCE) == TIM4_TRGOSource_Update))
00275 /**
00276   * @brief Macro TIM4 Slave mode
00277   */
00278 #define IS_TIM4_SLAVE_MODE(MODE) \
00279   (((MODE) == TIM4_SlaveMode_Disable) || \
00280    ((MODE) == TIM4_SlaveMode_Reset)   || \
00281    ((MODE) == TIM4_SlaveMode_Gated)   || \
00282    ((MODE) == TIM4_SlaveMode_Trigger) || \
00283    ((MODE) == TIM4_SlaveMode_External1))
00284 /**
00285   * @brief Macro TIM4 Flags
00286   */
00287 #define IS_TIM4_GET_FLAG(FLAG) \
00288   (((FLAG) == TIM4_FLAG_Update) || \
00289    ((FLAG) == TIM4_FLAG_Trigger))
00290 
00291 #define IS_TIM4_CLEAR_FLAG(FLAG) \
00292   ((((FLAG) & (uint8_t)0xBE) == 0x00) && ((FLAG) != 0x00))
00293 /**
00294   * @brief Macro TIM4 interrupts
00295   */
00296 #define IS_TIM4_IT(IT) \
00297   (((IT) != 0x00) && \
00298    (((uint8_t)(IT) & (uint8_t)(~(uint8_t)(0x41)))== 0x00))
00299 
00300 #define IS_TIM4_GET_IT(IT) \
00301   (((IT) == TIM4_IT_Update) || \
00302    ((IT) == TIM4_IT_Trigger))
00303 /**
00304   * @brief Macro TIM4 Trigger selection
00305   */
00306 #define IS_TIM4_TRIGGER_SELECTION(SELECTION) \
00307   (((SELECTION) == TIM4_TRGSelection_TIM5) || \
00308    ((SELECTION) == TIM4_TRGSelection_TIM1) || \
00309    ((SELECTION) == TIM4_TRGSelection_TIM3) || \
00310    ((SELECTION) == TIM4_TRGSelection_TIM2))
00311 
00312 /**
00313   * @brief Macro TIM4 DMA sources
00314   */
00315 
00316 #define IS_TIM4_DMA_SOURCE(SOURCE) (((SOURCE) == TIM4_DMASource_Update))
00317 /**
00318  * @}
00319  */
00320 
00321 /* Exported functions --------------------------------------------------------*/
00322 
00323 /* TimeBase management ********************************************************/
00324 void TIM4_DeInit(void);
00325 void TIM4_TimeBaseInit(TIM4_Prescaler_TypeDef TIM4_Prescaler,
00326                        uint8_t TIM4_Period);
00327 void TIM4_PrescalerConfig(TIM4_Prescaler_TypeDef Prescaler,
00328                           TIM4_PSCReloadMode_TypeDef TIM4_PSCReloadMode);
00329 void TIM4_SetCounter(uint8_t Counter);
00330 void TIM4_SetAutoreload(uint8_t Autoreload);
00331 uint8_t TIM4_GetCounter(void);
00332 TIM4_Prescaler_TypeDef TIM4_GetPrescaler(void);
00333 void TIM4_UpdateDisableConfig(FunctionalState NewState);
00334 void TIM4_UpdateRequestConfig(TIM4_UpdateSource_TypeDef TIM4_UpdateSource);
00335 void TIM4_ARRPreloadConfig(FunctionalState NewState);
00336 void TIM4_SelectOnePulseMode(TIM4_OPMode_TypeDef TIM4_OPMode);
00337 void TIM4_Cmd(FunctionalState NewState);
00338 
00339 /* Interrupts, DMA and flags management ***************************************/
00340 void TIM4_ITConfig(TIM4_IT_TypeDef TIM4_IT, FunctionalState NewState);
00341 void TIM4_GenerateEvent(TIM4_EventSource_TypeDef TIM4_EventSource);
00342 FlagStatus TIM4_GetFlagStatus(TIM4_FLAG_TypeDef TIM4_FLAG);
00343 void TIM4_ClearFlag(TIM4_FLAG_TypeDef TIM4_FLAG);
00344 ITStatus TIM4_GetITStatus(TIM4_IT_TypeDef TIM4_IT);
00345 void TIM4_ClearITPendingBit(TIM4_IT_TypeDef TIM4_IT);
00346 void TIM4_DMACmd(TIM4_DMASource_TypeDef TIM4_DMASource, FunctionalState NewState);
00347 
00348 /* Clocks management **********************************************************/
00349 void TIM4_InternalClockConfig(void);
00350 
00351 /* Synchronization management *************************************************/
00352 void TIM4_SelectInputTrigger(TIM4_TRGSelection_TypeDef TIM4_InputTriggerSource);
00353 void TIM4_SelectOutputTrigger(TIM4_TRGOSource_TypeDef TIM4_TRGOSource);
00354 void TIM4_SelectSlaveMode(TIM4_SlaveMode_TypeDef TIM4_SlaveMode);
00355 void TIM4_SelectMasterSlaveMode(FunctionalState NewState);
00356 
00357 #endif /* __STM8L15x_TIM4_H */
00358 
00359 /**
00360  * @}
00361  */
00362 
00363 
00364 /**
00365   * @}
00366   */
00367 
00368 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com