STM8S/A Standard Peripherals Drivers
|
stm8s_tim4.h
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file stm8s_tim4.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 TIM4 peripheral. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© 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_TIM4_H 00030 #define __STM8S_TIM4_H 00031 00032 /* Includes ------------------------------------------------------------------*/ 00033 #include "stm8s.h" 00034 00035 /** @addtogroup STM8S_StdPeriph_Driver 00036 * @{ 00037 */ 00038 00039 /* Exported types ------------------------------------------------------------*/ 00040 00041 /** @addtogroup TIM4_Exported_Types 00042 * @{ 00043 */ 00044 00045 00046 00047 /** TIM4 Prescaler */ 00048 typedef enum 00049 { 00050 TIM4_PRESCALER_1 = ((uint8_t)0x00), 00051 TIM4_PRESCALER_2 = ((uint8_t)0x01), 00052 TIM4_PRESCALER_4 = ((uint8_t)0x02), 00053 TIM4_PRESCALER_8 = ((uint8_t)0x03), 00054 TIM4_PRESCALER_16 = ((uint8_t)0x04), 00055 TIM4_PRESCALER_32 = ((uint8_t)0x05), 00056 TIM4_PRESCALER_64 = ((uint8_t)0x06), 00057 TIM4_PRESCALER_128 = ((uint8_t)0x07) 00058 } TIM4_Prescaler_TypeDef; 00059 00060 #define IS_TIM4_PRESCALER_OK(PRESCALER) (((PRESCALER) == TIM4_PRESCALER_1 ) || \ 00061 ((PRESCALER) == TIM4_PRESCALER_2 ) || \ 00062 ((PRESCALER) == TIM4_PRESCALER_4 ) || \ 00063 ((PRESCALER) == TIM4_PRESCALER_8 ) || \ 00064 ((PRESCALER) == TIM4_PRESCALER_16 ) || \ 00065 ((PRESCALER) == TIM4_PRESCALER_32 ) || \ 00066 ((PRESCALER) == TIM4_PRESCALER_64 ) || \ 00067 ((PRESCALER) == TIM4_PRESCALER_128 ) ) 00068 00069 /** TIM4 One Pulse Mode */ 00070 typedef enum 00071 { 00072 TIM4_OPMODE_SINGLE = ((uint8_t)0x01), 00073 TIM4_OPMODE_REPETITIVE = ((uint8_t)0x00) 00074 } TIM4_OPMode_TypeDef; 00075 00076 #define IS_TIM4_OPM_MODE_OK(MODE) (((MODE) == TIM4_OPMODE_SINGLE) || \ 00077 ((MODE) == TIM4_OPMODE_REPETITIVE)) 00078 00079 /** TIM4 Prescaler Reload Mode */ 00080 typedef enum 00081 { 00082 TIM4_PSCRELOADMODE_UPDATE = ((uint8_t)0x00), 00083 TIM4_PSCRELOADMODE_IMMEDIATE = ((uint8_t)0x01) 00084 } TIM4_PSCReloadMode_TypeDef; 00085 00086 #define IS_TIM4_PRESCALER_RELOAD_OK(RELOAD) (((RELOAD) == TIM4_PSCRELOADMODE_UPDATE) || \ 00087 ((RELOAD) == TIM4_PSCRELOADMODE_IMMEDIATE)) 00088 00089 /** TIM4 Update Source */ 00090 typedef enum 00091 { 00092 TIM4_UPDATESOURCE_GLOBAL = ((uint8_t)0x00), 00093 TIM4_UPDATESOURCE_REGULAR = ((uint8_t)0x01) 00094 } TIM4_UpdateSource_TypeDef; 00095 00096 #define IS_TIM4_UPDATE_SOURCE_OK(SOURCE) (((SOURCE) == TIM4_UPDATESOURCE_GLOBAL) || \ 00097 ((SOURCE) == TIM4_UPDATESOURCE_REGULAR)) 00098 00099 /** TIM4 Event Source */ 00100 typedef enum 00101 { 00102 TIM4_EVENTSOURCE_UPDATE = ((uint8_t)0x01) 00103 }TIM4_EventSource_TypeDef; 00104 00105 #define IS_TIM4_EVENT_SOURCE_OK(SOURCE) (((SOURCE) == 0x01)) 00106 00107 /** TIM4 Flags */ 00108 typedef enum 00109 { 00110 TIM4_FLAG_UPDATE = ((uint8_t)0x01) 00111 }TIM4_FLAG_TypeDef; 00112 00113 #define IS_TIM4_GET_FLAG_OK(FLAG) ((FLAG) == TIM4_FLAG_UPDATE) 00114 00115 00116 00117 /** TIM4 interrupt sources */ 00118 typedef enum 00119 { 00120 TIM4_IT_UPDATE = ((uint8_t)0x01) 00121 }TIM4_IT_TypeDef; 00122 00123 #define IS_TIM4_IT_OK(IT) ((IT) == TIM4_IT_UPDATE) 00124 00125 00126 00127 /** 00128 * @} 00129 */ 00130 00131 /* Exported macro ------------------------------------------------------------*/ 00132 00133 /* Exported functions --------------------------------------------------------*/ 00134 00135 /** @addtogroup TIM4_Exported_Functions 00136 * @{ 00137 */ 00138 void TIM4_DeInit(void); 00139 void TIM4_TimeBaseInit(TIM4_Prescaler_TypeDef TIM4_Prescaler, uint8_t TIM4_Period); 00140 void TIM4_Cmd(FunctionalState NewState); 00141 void TIM4_ITConfig(TIM4_IT_TypeDef TIM4_IT, FunctionalState NewState); 00142 void TIM4_UpdateDisableConfig(FunctionalState NewState); 00143 void TIM4_UpdateRequestConfig(TIM4_UpdateSource_TypeDef TIM4_UpdateSource); 00144 void TIM4_SelectOnePulseMode(TIM4_OPMode_TypeDef TIM4_OPMode); 00145 void TIM4_PrescalerConfig(TIM4_Prescaler_TypeDef Prescaler, TIM4_PSCReloadMode_TypeDef TIM4_PSCReloadMode); 00146 void TIM4_ARRPreloadConfig(FunctionalState NewState); 00147 void TIM4_GenerateEvent(TIM4_EventSource_TypeDef TIM4_EventSource); 00148 void TIM4_SetCounter(uint8_t Counter); 00149 void TIM4_SetAutoreload(uint8_t Autoreload); 00150 uint8_t TIM4_GetCounter(void); 00151 TIM4_Prescaler_TypeDef TIM4_GetPrescaler(void); 00152 FlagStatus TIM4_GetFlagStatus(TIM4_FLAG_TypeDef TIM4_FLAG); 00153 void TIM4_ClearFlag(TIM4_FLAG_TypeDef TIM4_FLAG); 00154 ITStatus TIM4_GetITStatus(TIM4_IT_TypeDef TIM4_IT); 00155 void TIM4_ClearITPendingBit(TIM4_IT_TypeDef TIM4_IT); 00156 00157 00158 /** 00159 * @} 00160 */ 00161 00162 #endif /* __STM8S_TIM4_H */ 00163 00164 /** 00165 * @} 00166 */ 00167 00168 00169 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/