STM8S/A Standard Peripherals Drivers: stm8s_tim6.h Source File

STM8S/A

stm8s_tim6.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm8s_tim6.h
00004   * @author  MCD Application Team
00005   * @version V2.3.0
00006   * @date    16-June-2017
00007   * @brief   This file contains all functions prototype and macros for the TIM6 peripheral.
00008    ******************************************************************************
00009   * @attention
00010   *
00011   * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
00012   *
00013   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
00014   * You may not use this file except in compliance with the License.
00015   * You may obtain a copy of the License at:
00016   *
00017   *        http://www.st.com/software_license_agreement_liberty_v2
00018   *
00019   * Unless required by applicable law or agreed to in writing, software 
00020   * distributed under the License is distributed on an "AS IS" BASIS, 
00021   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00022   * See the License for the specific language governing permissions and
00023   * limitations under the License.
00024   *
00025   ******************************************************************************
00026   */
00027 
00028 /* Define to prevent recursive inclusion -------------------------------------*/
00029 #ifndef __STM8S_TIM6_H
00030 #define __STM8S_TIM6_H
00031 
00032 /* Includes ------------------------------------------------------------------*/
00033 #include "stm8s.h"
00034 
00035 /** @addtogroup STM8S_StdPeriph_Driver
00036   * @{
00037   */
00038 
00039 /* Exported variables ------------------------------------------------------- */
00040 /* Exported types ------------------------------------------------------------*/
00041 
00042 /** @addtogroup TIM6_Exported_Types
00043   * @{
00044   */
00045 
00046 
00047 /**
00048   * @brief  TIM6 Prescaler
00049   */
00050 typedef enum
00051 {
00052     TIM6_PRESCALER_1      = ((uint8_t)0x00),  /*!< Time base Prescaler = 1 (No effect)*/
00053     TIM6_PRESCALER_2      = ((uint8_t)0x01),  /*!< Time base Prescaler = 2 */
00054     TIM6_PRESCALER_4      = ((uint8_t)0x02),  /*!< Time base Prescaler = 4 */
00055     TIM6_PRESCALER_8      = ((uint8_t)0x03),  /*!< Time base Prescaler = 8 */
00056     TIM6_PRESCALER_16     = ((uint8_t)0x04),  /*!< Time base Prescaler = 16 */
00057     TIM6_PRESCALER_32     = ((uint8_t)0x05),  /*!< Time base Prescaler = 32 */
00058     TIM6_PRESCALER_64     = ((uint8_t)0x06),  /*!< Time base Prescaler = 64 */
00059     TIM6_PRESCALER_128    = ((uint8_t)0x07)  /*!< Time base Prescaler = 128 */
00060 }TIM6_Prescaler_TypeDef;
00061 
00062 /**
00063   * @brief  TIM6 One Pulse Mode
00064   */
00065 typedef enum
00066 {
00067     TIM6_OPMODE_SINGLE      = ((uint8_t)0x01),  /*!< Single one Pulse mode (OPM Active) */
00068     TIM6_OPMODE_REPETITIVE  = ((uint8_t)0x00)   /*!< Repetitive Pulse mode (OPM inactive) */
00069 }TIM6_OPMode_TypeDef;
00070 
00071 /**
00072   * @brief  TIM6 Prescaler Reload Mode
00073   */
00074 typedef enum
00075 {
00076     TIM6_PSCRELOADMODE_UPDATE      =((uint8_t)0x00),  /*!< Prescaler value is reloaded at every update*/
00077     TIM6_PSCRELOADMODE_IMMEDIATE   =((uint8_t)0x01)    /*!< Prescaler value is reloaded immediately*/
00078 }TIM6_PSCReloadMode_TypeDef;
00079 
00080 /**
00081   * @brief  TIM6 Update Source
00082   */
00083 typedef enum
00084 {
00085     TIM6_UPDATESOURCE_GLOBAL   =((uint8_t)0x00),  /*!< Global Update request source */
00086     TIM6_UPDATESOURCE_REGULAR  =((uint8_t)0x01)    /*!< Regular Update request source */
00087 }TIM6_UpdateSource_TypeDef;
00088 
00089 /**
00090   * @brief  TIM6 Event Source
00091   */
00092 typedef enum
00093 {
00094     TIM6_EVENTSOURCE_UPDATE    = ((uint8_t)0x01),    /*!< Update Event*/
00095     TIM6_EVENTSOURCE_TRIGGER   = ((uint8_t)0x40)    /*!< Trigger Event*/
00096 }TIM6_EventSource_TypeDef;
00097 
00098 /**
00099   * @brief  TIM6 Trigger Output Source
00100   */
00101 typedef enum
00102 {
00103     TIM6_TRGOSOURCE_RESET    = ((uint8_t)0x00),    /*!< Trigger Output source = Reset*/
00104     TIM6_TRGOSOURCE_ENABLE   = ((uint8_t)0x10),    /*!< Trigger Output source = TIM5 is enabled*/
00105     TIM6_TRGOSOURCE_UPDATE   = ((uint8_t)0x20)    /*!< Trigger Output source = Update event*/
00106 }TIM6_TRGOSource_TypeDef;
00107 
00108 /**
00109   * @brief  TIM6 Slave Mode
00110   */
00111 typedef enum
00112 {
00113     TIM6_SLAVEMODE_DISABLE    = ((uint8_t)0x00),   /*!< Disable slave mode to clock the prescaler directly with the internal clock */
00114     TIM6_SLAVEMODE_RESET      = ((uint8_t)0x04),   /*!< Slave Mode Selection  = Reset*/
00115     TIM6_SLAVEMODE_GATED      = ((uint8_t)0x05),   /*!< Slave Mode Selection  = Gated*/
00116     TIM6_SLAVEMODE_TRIGGER    = ((uint8_t)0x06),    /*!< Slave Mode Selection  = Trigger*/
00117     TIM6_SLAVEMODE_EXTERNAL1  = ((uint8_t)0x07)    /*!< Slave Mode Selection  = External 1*/
00118 }TIM6_SlaveMode_TypeDef;
00119 
00120 /**
00121   * @brief  TIM6 Flags
00122   */
00123 typedef enum
00124 {
00125     TIM6_FLAG_UPDATE   = ((uint8_t)0x01),    /*!< Update Flag */
00126     TIM6_FLAG_TRIGGER  = ((uint8_t)0x40)    /*!< Trigger Flag */
00127 }TIM6_FLAG_TypeDef;
00128 
00129 /**
00130   * @brief  TIM6 interrupt sources
00131   */
00132 typedef enum
00133 {
00134     TIM6_IT_UPDATE   = ((uint8_t)0x01),    /*!< Update Interrupt*/
00135     TIM6_IT_TRIGGER  = ((uint8_t)0x40)    /*!< Trigger  Interrupt*/
00136 }TIM6_IT_TypeDef;
00137 
00138 /**
00139   * @brief  TIM6 Internal Trigger Selection
00140   */
00141 typedef enum
00142 {
00143     TIM6_TS_TIM1  = ((uint8_t)0x20),/*!< TRIG Input source =  TIM1 TRIG Output  */
00144     TIM6_TS_TIM5  = ((uint8_t)0x30) /*!< TRIG Input source =  TIM5 TRIG Output  */
00145 }TIM6_TS_TypeDef;
00146 
00147 /**
00148   * @}
00149   */
00150 
00151 /* Exported constants --------------------------------------------------------*/
00152 /* Exported macros -----------------------------------------------------------*/
00153 /* Private macros ------------------------------------------------------------*/
00154 
00155 /** @addtogroup TIM6_Private_Macros
00156   * @{
00157   */
00158 
00159 /**
00160   * @brief  Macro used by the assert function to check the different functions parameters.
00161   */
00162 
00163 /**
00164   * @brief  Macro TIM6 Prescaler
00165   */
00166 #define IS_TIM6_PRESCALER_OK(PRESCALER)  \
00167    (((PRESCALER) == TIM6_PRESCALER_1)    || \
00168     ((PRESCALER) == TIM6_PRESCALER_2)    || \
00169     ((PRESCALER) == TIM6_PRESCALER_4)    || \
00170     ((PRESCALER) == TIM6_PRESCALER_8)    || \
00171     ((PRESCALER) == TIM6_PRESCALER_16)   || \
00172     ((PRESCALER) == TIM6_PRESCALER_32)   || \
00173     ((PRESCALER) == TIM6_PRESCALER_64)   || \
00174     ((PRESCALER) == TIM6_PRESCALER_128))
00175 /**
00176   * @brief  Macro TIM6 One Pulse Mode
00177   */
00178 #define IS_TIM6_OPM_MODE_OK(MODE)  \
00179    (((MODE) == TIM6_OPMODE_SINGLE) || \
00180     ((MODE) == TIM6_OPMODE_REPETITIVE))
00181 
00182 /**
00183   * @brief  Macro TIM6 Prescaler reload
00184   */
00185 #define IS_TIM6_PRESCALER_RELOAD_OK(RELOAD) \
00186    (((RELOAD) == TIM6_PSCRELOADMODE_UPDATE) || \
00187     ((RELOAD) == TIM6_PSCRELOADMODE_IMMEDIATE))
00188 /**
00189   * @brief  Macro TIM6 Update source
00190   */
00191 #define IS_TIM6_UPDATE_SOURCE_OK(SOURCE) \
00192    (((SOURCE) == TIM6_UPDATESOURCE_GLOBAL) || \
00193     ((SOURCE) == TIM6_UPDATESOURCE_REGULAR))
00194 /**
00195   * @brief  Macro TIM6 Event source
00196   */
00197 #define IS_TIM6_EVENT_SOURCE_OK(SOURCE) \
00198    ((((SOURCE) & (uint8_t)0xBE) == 0x00) && \
00199     ((SOURCE) != 0x00))
00200 
00201 /**
00202   * @brief  Macro TIM6 TRGO source
00203   */
00204 #define IS_TIM6_TRGO_SOURCE_OK(SOURCE) \
00205    (((SOURCE) == TIM6_TRGOSOURCE_RESET) || \
00206     ((SOURCE) == TIM6_TRGOSOURCE_ENABLE)|| \
00207     ((SOURCE) == TIM6_TRGOSOURCE_UPDATE))
00208 /**
00209   * @brief  Macro TIM6 Slave mode
00210   */
00211 #define IS_TIM6_SLAVE_MODE_OK(MODE) \
00212    (((MODE) == TIM6_SLAVEMODE_DISABLE) || \
00213     ((MODE) == TIM6_SLAVEMODE_RESET)   || \
00214     ((MODE) == TIM6_SLAVEMODE_GATED)   || \
00215     ((MODE) == TIM6_SLAVEMODE_TRIGGER) || \
00216     ((MODE) == TIM6_SLAVEMODE_EXTERNAL1))
00217 /**
00218   * @brief  Macro TIM6 Flags
00219   */
00220 #define IS_TIM6_GET_FLAG_OK(FLAG) \
00221    (((FLAG) == TIM6_FLAG_UPDATE) || \
00222     ((FLAG) == TIM6_FLAG_TRIGGER))
00223 
00224 #define IS_TIM6_CLEAR_FLAG_OK(FLAG) \
00225    ((((FLAG) & (uint8_t)0xBE) == 0x00) && ((FLAG) != 0x00))
00226 /**
00227   * @brief  Macro TIM6 interrupts
00228   */
00229 #define IS_TIM6_IT_OK(IT) \
00230    (((IT) != 0x00) && \
00231     (((IT) & (uint8_t)(~(uint8_t)(0x41)))== 0x00))
00232 
00233 #define IS_TIM6_GET_IT_OK(IT) \
00234    (((IT) == TIM6_IT_UPDATE) || \
00235     ((IT) == TIM6_IT_TRIGGER))
00236 /**
00237   * @brief  Macro TIM6 Trigger selection
00238   */
00239 #define IS_TIM6_TRIGGER_SELECTION_OK(SELECTION) \
00240    (((SELECTION) == TIM6_TS_TIM5) || \
00241     ((SELECTION) == TIM6_TS_TIM1))
00242 /**
00243  * @}
00244  */
00245 
00246 /* Exported functions --------------------------------------------------------*/
00247 
00248 /** @addtogroup TIM6_Exported_Functions
00249   * @{
00250   */
00251 
00252 void TIM6_DeInit(void);
00253 void TIM6_TimeBaseInit(TIM6_Prescaler_TypeDef TIM6_Prescaler, uint8_t TIM6_Period);
00254 void TIM6_Cmd(FunctionalState NewState);
00255 void TIM6_UpdateDisableConfig(FunctionalState NewState);
00256 void TIM6_UpdateRequestConfig(TIM6_UpdateSource_TypeDef TIM6_UpdateSource);
00257 void TIM6_SelectOnePulseMode(TIM6_OPMode_TypeDef TIM6_OPMode);
00258 void TIM6_PrescalerConfig(TIM6_Prescaler_TypeDef Prescaler, TIM6_PSCReloadMode_TypeDef TIM6_PSCReloadMode);
00259 void TIM6_ARRPreloadConfig(FunctionalState NewState);
00260 void TIM6_SetCounter(uint8_t Counter);
00261 void TIM6_SetAutoreload(uint8_t Autoreload);
00262 uint8_t TIM6_GetCounter(void);
00263 TIM6_Prescaler_TypeDef TIM6_GetPrescaler(void);
00264 void TIM6_ITConfig(TIM6_IT_TypeDef TIM6_IT, FunctionalState NewState);
00265 void TIM6_ClearFlag(TIM6_FLAG_TypeDef TIM6_FLAG);
00266 ITStatus TIM6_GetITStatus(TIM6_IT_TypeDef TIM6_IT);
00267 void TIM6_GenerateEvent(TIM6_EventSource_TypeDef TIM6_EventSource);
00268 FlagStatus TIM6_GetFlagStatus(TIM6_FLAG_TypeDef TIM6_FLAG);
00269 void TIM6_ClearITPendingBit(TIM6_IT_TypeDef TIM6_IT);
00270 void TIM6_SelectOutputTrigger(TIM6_TRGOSource_TypeDef TIM6_TRGOSource);
00271 void TIM6_SelectMasterSlaveMode(FunctionalState NewState);
00272 void TIM6_SelectInputTrigger(TIM6_TS_TypeDef TIM6_InputTriggerSource);
00273 void TIM6_InternalClockConfig(void);
00274 void TIM6_SelectSlaveMode(TIM6_SlaveMode_TypeDef TIM6_SlaveMode);
00275 
00276 /**
00277  * @}
00278  */
00279 
00280 #endif /* __STM8S_TIM6_H */
00281 
00282 /**
00283   * @}
00284   */
00285   
00286 
00287 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM8 Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM8 8-bit Microcontrollers platform visit www.st.com