stm8s_tim4.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /**
  2. ******************************************************************************
  3. * @file stm8s_tim4.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 TIM4 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_TIM4_H
  29. #define __STM8S_TIM4_H
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "stm8s.h"
  32. /** @addtogroup STM8S_StdPeriph_Driver
  33. * @{
  34. */
  35. /* Exported types ------------------------------------------------------------*/
  36. /** @addtogroup TIM4_Exported_Types
  37. * @{
  38. */
  39. /** TIM4 Prescaler */
  40. typedef enum
  41. {
  42. TIM4_PRESCALER_1 = ((uint8_t)0x00),
  43. TIM4_PRESCALER_2 = ((uint8_t)0x01),
  44. TIM4_PRESCALER_4 = ((uint8_t)0x02),
  45. TIM4_PRESCALER_8 = ((uint8_t)0x03),
  46. TIM4_PRESCALER_16 = ((uint8_t)0x04),
  47. TIM4_PRESCALER_32 = ((uint8_t)0x05),
  48. TIM4_PRESCALER_64 = ((uint8_t)0x06),
  49. TIM4_PRESCALER_128 = ((uint8_t)0x07)
  50. } TIM4_Prescaler_TypeDef;
  51. #define IS_TIM4_PRESCALER_OK(PRESCALER) (((PRESCALER) == TIM4_PRESCALER_1 ) || \
  52. ((PRESCALER) == TIM4_PRESCALER_2 ) || \
  53. ((PRESCALER) == TIM4_PRESCALER_4 ) || \
  54. ((PRESCALER) == TIM4_PRESCALER_8 ) || \
  55. ((PRESCALER) == TIM4_PRESCALER_16 ) || \
  56. ((PRESCALER) == TIM4_PRESCALER_32 ) || \
  57. ((PRESCALER) == TIM4_PRESCALER_64 ) || \
  58. ((PRESCALER) == TIM4_PRESCALER_128 ) )
  59. /** TIM4 One Pulse Mode */
  60. typedef enum
  61. {
  62. TIM4_OPMODE_SINGLE = ((uint8_t)0x01),
  63. TIM4_OPMODE_REPETITIVE = ((uint8_t)0x00)
  64. } TIM4_OPMode_TypeDef;
  65. #define IS_TIM4_OPM_MODE_OK(MODE) (((MODE) == TIM4_OPMODE_SINGLE) || \
  66. ((MODE) == TIM4_OPMODE_REPETITIVE))
  67. /** TIM4 Prescaler Reload Mode */
  68. typedef enum
  69. {
  70. TIM4_PSCRELOADMODE_UPDATE = ((uint8_t)0x00),
  71. TIM4_PSCRELOADMODE_IMMEDIATE = ((uint8_t)0x01)
  72. } TIM4_PSCReloadMode_TypeDef;
  73. #define IS_TIM4_PRESCALER_RELOAD_OK(RELOAD) (((RELOAD) == TIM4_PSCRELOADMODE_UPDATE) || \
  74. ((RELOAD) == TIM4_PSCRELOADMODE_IMMEDIATE))
  75. /** TIM4 Update Source */
  76. typedef enum
  77. {
  78. TIM4_UPDATESOURCE_GLOBAL = ((uint8_t)0x00),
  79. TIM4_UPDATESOURCE_REGULAR = ((uint8_t)0x01)
  80. } TIM4_UpdateSource_TypeDef;
  81. #define IS_TIM4_UPDATE_SOURCE_OK(SOURCE) (((SOURCE) == TIM4_UPDATESOURCE_GLOBAL) || \
  82. ((SOURCE) == TIM4_UPDATESOURCE_REGULAR))
  83. /** TIM4 Event Source */
  84. typedef enum
  85. {
  86. TIM4_EVENTSOURCE_UPDATE = ((uint8_t)0x01)
  87. }TIM4_EventSource_TypeDef;
  88. #define IS_TIM4_EVENT_SOURCE_OK(SOURCE) (((SOURCE) == 0x01))
  89. /** TIM4 Flags */
  90. typedef enum
  91. {
  92. TIM4_FLAG_UPDATE = ((uint8_t)0x01)
  93. }TIM4_FLAG_TypeDef;
  94. #define IS_TIM4_GET_FLAG_OK(FLAG) ((FLAG) == TIM4_FLAG_UPDATE)
  95. /** TIM4 interrupt sources */
  96. typedef enum
  97. {
  98. TIM4_IT_UPDATE = ((uint8_t)0x01)
  99. }TIM4_IT_TypeDef;
  100. #define IS_TIM4_IT_OK(IT) ((IT) == TIM4_IT_UPDATE)
  101. /**
  102. * @}
  103. */
  104. /* Exported macro ------------------------------------------------------------*/
  105. /* Exported functions --------------------------------------------------------*/
  106. /** @addtogroup TIM4_Exported_Functions
  107. * @{
  108. */
  109. void TIM4_DeInit(void);
  110. void TIM4_TimeBaseInit(TIM4_Prescaler_TypeDef TIM4_Prescaler, uint8_t TIM4_Period);
  111. void TIM4_Cmd(FunctionalState NewState);
  112. void TIM4_ITConfig(TIM4_IT_TypeDef TIM4_IT, FunctionalState NewState);
  113. void TIM4_UpdateDisableConfig(FunctionalState NewState);
  114. void TIM4_UpdateRequestConfig(TIM4_UpdateSource_TypeDef TIM4_UpdateSource);
  115. void TIM4_SelectOnePulseMode(TIM4_OPMode_TypeDef TIM4_OPMode);
  116. void TIM4_PrescalerConfig(TIM4_Prescaler_TypeDef Prescaler, TIM4_PSCReloadMode_TypeDef TIM4_PSCReloadMode);
  117. void TIM4_ARRPreloadConfig(FunctionalState NewState);
  118. void TIM4_GenerateEvent(TIM4_EventSource_TypeDef TIM4_EventSource);
  119. void TIM4_SetCounter(uint8_t Counter);
  120. void TIM4_SetAutoreload(uint8_t Autoreload);
  121. uint8_t TIM4_GetCounter(void);
  122. TIM4_Prescaler_TypeDef TIM4_GetPrescaler(void);
  123. FlagStatus TIM4_GetFlagStatus(TIM4_FLAG_TypeDef TIM4_FLAG);
  124. void TIM4_ClearFlag(TIM4_FLAG_TypeDef TIM4_FLAG);
  125. ITStatus TIM4_GetITStatus(TIM4_IT_TypeDef TIM4_IT);
  126. void TIM4_ClearITPendingBit(TIM4_IT_TypeDef TIM4_IT);
  127. /**
  128. * @}
  129. */
  130. #endif /* __STM8S_TIM4_H */
  131. /**
  132. * @}
  133. */
  134. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/