stm8s_tim6.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. /**
  2. ******************************************************************************
  3. * @file stm8s_tim6.h
  4. * @author MCD Application Team
  5. * @version V2.3.0
  6. * @date 16-June-2017
  7. * @brief This file contains all functions prototype and macros for the TIM6 peripheral.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  12. *
  13. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  14. * You may not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at:
  16. *
  17. * http://www.st.com/software_license_agreement_liberty_v2
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS,
  21. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. *
  25. ******************************************************************************
  26. */
  27. /* Define to prevent recursive inclusion -------------------------------------*/
  28. #ifndef __STM8S_TIM6_H
  29. #define __STM8S_TIM6_H
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "stm8s.h"
  32. /** @addtogroup STM8S_StdPeriph_Driver
  33. * @{
  34. */
  35. /* Exported variables ------------------------------------------------------- */
  36. /* Exported types ------------------------------------------------------------*/
  37. /** @addtogroup TIM6_Exported_Types
  38. * @{
  39. */
  40. /**
  41. * @brief TIM6 Prescaler
  42. */
  43. typedef enum
  44. {
  45. TIM6_PRESCALER_1 = ((uint8_t)0x00), /*!< Time base Prescaler = 1 (No effect)*/
  46. TIM6_PRESCALER_2 = ((uint8_t)0x01), /*!< Time base Prescaler = 2 */
  47. TIM6_PRESCALER_4 = ((uint8_t)0x02), /*!< Time base Prescaler = 4 */
  48. TIM6_PRESCALER_8 = ((uint8_t)0x03), /*!< Time base Prescaler = 8 */
  49. TIM6_PRESCALER_16 = ((uint8_t)0x04), /*!< Time base Prescaler = 16 */
  50. TIM6_PRESCALER_32 = ((uint8_t)0x05), /*!< Time base Prescaler = 32 */
  51. TIM6_PRESCALER_64 = ((uint8_t)0x06), /*!< Time base Prescaler = 64 */
  52. TIM6_PRESCALER_128 = ((uint8_t)0x07) /*!< Time base Prescaler = 128 */
  53. }TIM6_Prescaler_TypeDef;
  54. /**
  55. * @brief TIM6 One Pulse Mode
  56. */
  57. typedef enum
  58. {
  59. TIM6_OPMODE_SINGLE = ((uint8_t)0x01), /*!< Single one Pulse mode (OPM Active) */
  60. TIM6_OPMODE_REPETITIVE = ((uint8_t)0x00) /*!< Repetitive Pulse mode (OPM inactive) */
  61. }TIM6_OPMode_TypeDef;
  62. /**
  63. * @brief TIM6 Prescaler Reload Mode
  64. */
  65. typedef enum
  66. {
  67. TIM6_PSCRELOADMODE_UPDATE =((uint8_t)0x00), /*!< Prescaler value is reloaded at every update*/
  68. TIM6_PSCRELOADMODE_IMMEDIATE =((uint8_t)0x01) /*!< Prescaler value is reloaded immediately*/
  69. }TIM6_PSCReloadMode_TypeDef;
  70. /**
  71. * @brief TIM6 Update Source
  72. */
  73. typedef enum
  74. {
  75. TIM6_UPDATESOURCE_GLOBAL =((uint8_t)0x00), /*!< Global Update request source */
  76. TIM6_UPDATESOURCE_REGULAR =((uint8_t)0x01) /*!< Regular Update request source */
  77. }TIM6_UpdateSource_TypeDef;
  78. /**
  79. * @brief TIM6 Event Source
  80. */
  81. typedef enum
  82. {
  83. TIM6_EVENTSOURCE_UPDATE = ((uint8_t)0x01), /*!< Update Event*/
  84. TIM6_EVENTSOURCE_TRIGGER = ((uint8_t)0x40) /*!< Trigger Event*/
  85. }TIM6_EventSource_TypeDef;
  86. /**
  87. * @brief TIM6 Trigger Output Source
  88. */
  89. typedef enum
  90. {
  91. TIM6_TRGOSOURCE_RESET = ((uint8_t)0x00), /*!< Trigger Output source = Reset*/
  92. TIM6_TRGOSOURCE_ENABLE = ((uint8_t)0x10), /*!< Trigger Output source = TIM5 is enabled*/
  93. TIM6_TRGOSOURCE_UPDATE = ((uint8_t)0x20) /*!< Trigger Output source = Update event*/
  94. }TIM6_TRGOSource_TypeDef;
  95. /**
  96. * @brief TIM6 Slave Mode
  97. */
  98. typedef enum
  99. {
  100. TIM6_SLAVEMODE_DISABLE = ((uint8_t)0x00), /*!< Disable slave mode to clock the prescaler directly with the internal clock */
  101. TIM6_SLAVEMODE_RESET = ((uint8_t)0x04), /*!< Slave Mode Selection = Reset*/
  102. TIM6_SLAVEMODE_GATED = ((uint8_t)0x05), /*!< Slave Mode Selection = Gated*/
  103. TIM6_SLAVEMODE_TRIGGER = ((uint8_t)0x06), /*!< Slave Mode Selection = Trigger*/
  104. TIM6_SLAVEMODE_EXTERNAL1 = ((uint8_t)0x07) /*!< Slave Mode Selection = External 1*/
  105. }TIM6_SlaveMode_TypeDef;
  106. /**
  107. * @brief TIM6 Flags
  108. */
  109. typedef enum
  110. {
  111. TIM6_FLAG_UPDATE = ((uint8_t)0x01), /*!< Update Flag */
  112. TIM6_FLAG_TRIGGER = ((uint8_t)0x40) /*!< Trigger Flag */
  113. }TIM6_FLAG_TypeDef;
  114. /**
  115. * @brief TIM6 interrupt sources
  116. */
  117. typedef enum
  118. {
  119. TIM6_IT_UPDATE = ((uint8_t)0x01), /*!< Update Interrupt*/
  120. TIM6_IT_TRIGGER = ((uint8_t)0x40) /*!< Trigger Interrupt*/
  121. }TIM6_IT_TypeDef;
  122. /**
  123. * @brief TIM6 Internal Trigger Selection
  124. */
  125. typedef enum
  126. {
  127. TIM6_TS_TIM1 = ((uint8_t)0x20),/*!< TRIG Input source = TIM1 TRIG Output */
  128. TIM6_TS_TIM5 = ((uint8_t)0x30) /*!< TRIG Input source = TIM5 TRIG Output */
  129. }TIM6_TS_TypeDef;
  130. /**
  131. * @}
  132. */
  133. /* Exported constants --------------------------------------------------------*/
  134. /* Exported macros -----------------------------------------------------------*/
  135. /* Private macros ------------------------------------------------------------*/
  136. /** @addtogroup TIM6_Private_Macros
  137. * @{
  138. */
  139. /**
  140. * @brief Macro used by the assert function to check the different functions parameters.
  141. */
  142. /**
  143. * @brief Macro TIM6 Prescaler
  144. */
  145. #define IS_TIM6_PRESCALER_OK(PRESCALER) \
  146. (((PRESCALER) == TIM6_PRESCALER_1) || \
  147. ((PRESCALER) == TIM6_PRESCALER_2) || \
  148. ((PRESCALER) == TIM6_PRESCALER_4) || \
  149. ((PRESCALER) == TIM6_PRESCALER_8) || \
  150. ((PRESCALER) == TIM6_PRESCALER_16) || \
  151. ((PRESCALER) == TIM6_PRESCALER_32) || \
  152. ((PRESCALER) == TIM6_PRESCALER_64) || \
  153. ((PRESCALER) == TIM6_PRESCALER_128))
  154. /**
  155. * @brief Macro TIM6 One Pulse Mode
  156. */
  157. #define IS_TIM6_OPM_MODE_OK(MODE) \
  158. (((MODE) == TIM6_OPMODE_SINGLE) || \
  159. ((MODE) == TIM6_OPMODE_REPETITIVE))
  160. /**
  161. * @brief Macro TIM6 Prescaler reload
  162. */
  163. #define IS_TIM6_PRESCALER_RELOAD_OK(RELOAD) \
  164. (((RELOAD) == TIM6_PSCRELOADMODE_UPDATE) || \
  165. ((RELOAD) == TIM6_PSCRELOADMODE_IMMEDIATE))
  166. /**
  167. * @brief Macro TIM6 Update source
  168. */
  169. #define IS_TIM6_UPDATE_SOURCE_OK(SOURCE) \
  170. (((SOURCE) == TIM6_UPDATESOURCE_GLOBAL) || \
  171. ((SOURCE) == TIM6_UPDATESOURCE_REGULAR))
  172. /**
  173. * @brief Macro TIM6 Event source
  174. */
  175. #define IS_TIM6_EVENT_SOURCE_OK(SOURCE) \
  176. ((((SOURCE) & (uint8_t)0xBE) == 0x00) && \
  177. ((SOURCE) != 0x00))
  178. /**
  179. * @brief Macro TIM6 TRGO source
  180. */
  181. #define IS_TIM6_TRGO_SOURCE_OK(SOURCE) \
  182. (((SOURCE) == TIM6_TRGOSOURCE_RESET) || \
  183. ((SOURCE) == TIM6_TRGOSOURCE_ENABLE)|| \
  184. ((SOURCE) == TIM6_TRGOSOURCE_UPDATE))
  185. /**
  186. * @brief Macro TIM6 Slave mode
  187. */
  188. #define IS_TIM6_SLAVE_MODE_OK(MODE) \
  189. (((MODE) == TIM6_SLAVEMODE_DISABLE) || \
  190. ((MODE) == TIM6_SLAVEMODE_RESET) || \
  191. ((MODE) == TIM6_SLAVEMODE_GATED) || \
  192. ((MODE) == TIM6_SLAVEMODE_TRIGGER) || \
  193. ((MODE) == TIM6_SLAVEMODE_EXTERNAL1))
  194. /**
  195. * @brief Macro TIM6 Flags
  196. */
  197. #define IS_TIM6_GET_FLAG_OK(FLAG) \
  198. (((FLAG) == TIM6_FLAG_UPDATE) || \
  199. ((FLAG) == TIM6_FLAG_TRIGGER))
  200. #define IS_TIM6_CLEAR_FLAG_OK(FLAG) \
  201. ((((FLAG) & (uint8_t)0xBE) == 0x00) && ((FLAG) != 0x00))
  202. /**
  203. * @brief Macro TIM6 interrupts
  204. */
  205. #define IS_TIM6_IT_OK(IT) \
  206. (((IT) != 0x00) && \
  207. (((IT) & (uint8_t)(~(uint8_t)(0x41)))== 0x00))
  208. #define IS_TIM6_GET_IT_OK(IT) \
  209. (((IT) == TIM6_IT_UPDATE) || \
  210. ((IT) == TIM6_IT_TRIGGER))
  211. /**
  212. * @brief Macro TIM6 Trigger selection
  213. */
  214. #define IS_TIM6_TRIGGER_SELECTION_OK(SELECTION) \
  215. (((SELECTION) == TIM6_TS_TIM5) || \
  216. ((SELECTION) == TIM6_TS_TIM1))
  217. /**
  218. * @}
  219. */
  220. /* Exported functions --------------------------------------------------------*/
  221. /** @addtogroup TIM6_Exported_Functions
  222. * @{
  223. */
  224. void TIM6_DeInit(void);
  225. void TIM6_TimeBaseInit(TIM6_Prescaler_TypeDef TIM6_Prescaler, uint8_t TIM6_Period);
  226. void TIM6_Cmd(FunctionalState NewState);
  227. void TIM6_UpdateDisableConfig(FunctionalState NewState);
  228. void TIM6_UpdateRequestConfig(TIM6_UpdateSource_TypeDef TIM6_UpdateSource);
  229. void TIM6_SelectOnePulseMode(TIM6_OPMode_TypeDef TIM6_OPMode);
  230. void TIM6_PrescalerConfig(TIM6_Prescaler_TypeDef Prescaler, TIM6_PSCReloadMode_TypeDef TIM6_PSCReloadMode);
  231. void TIM6_ARRPreloadConfig(FunctionalState NewState);
  232. void TIM6_SetCounter(uint8_t Counter);
  233. void TIM6_SetAutoreload(uint8_t Autoreload);
  234. uint8_t TIM6_GetCounter(void);
  235. TIM6_Prescaler_TypeDef TIM6_GetPrescaler(void);
  236. void TIM6_ITConfig(TIM6_IT_TypeDef TIM6_IT, FunctionalState NewState);
  237. void TIM6_ClearFlag(TIM6_FLAG_TypeDef TIM6_FLAG);
  238. ITStatus TIM6_GetITStatus(TIM6_IT_TypeDef TIM6_IT);
  239. void TIM6_GenerateEvent(TIM6_EventSource_TypeDef TIM6_EventSource);
  240. FlagStatus TIM6_GetFlagStatus(TIM6_FLAG_TypeDef TIM6_FLAG);
  241. void TIM6_ClearITPendingBit(TIM6_IT_TypeDef TIM6_IT);
  242. void TIM6_SelectOutputTrigger(TIM6_TRGOSource_TypeDef TIM6_TRGOSource);
  243. void TIM6_SelectMasterSlaveMode(FunctionalState NewState);
  244. void TIM6_SelectInputTrigger(TIM6_TS_TypeDef TIM6_InputTriggerSource);
  245. void TIM6_InternalClockConfig(void);
  246. void TIM6_SelectSlaveMode(TIM6_SlaveMode_TypeDef TIM6_SlaveMode);
  247. /**
  248. * @}
  249. */
  250. #endif /* __STM8S_TIM6_H */
  251. /**
  252. * @}
  253. */
  254. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/