stm8s_awu.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. ******************************************************************************
  3. * @file stm8s_awu.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 AWU 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_AWU_H
  29. #define __STM8S_AWU_H
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "stm8s.h"
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @addtogroup AWU_Exported_Types
  34. * @{
  35. */
  36. /**
  37. * @brief AWU TimeBase selection
  38. */
  39. typedef enum
  40. {
  41. AWU_TIMEBASE_NO_IT = (uint8_t)0, /*!< No AWU interrupt selected */
  42. AWU_TIMEBASE_250US = (uint8_t)1, /*!< AWU Timebase equals 0.25 ms */
  43. AWU_TIMEBASE_500US = (uint8_t)2, /*!< AWU Timebase equals 0.5 ms */
  44. AWU_TIMEBASE_1MS = (uint8_t)3, /*!< AWU Timebase equals 1 ms */
  45. AWU_TIMEBASE_2MS = (uint8_t)4, /*!< AWU Timebase equals 2 ms */
  46. AWU_TIMEBASE_4MS = (uint8_t)5, /*!< AWU Timebase equals 4 ms */
  47. AWU_TIMEBASE_8MS = (uint8_t)6, /*!< AWU Timebase equals 8 ms */
  48. AWU_TIMEBASE_16MS = (uint8_t)7, /*!< AWU Timebase equals 16 ms */
  49. AWU_TIMEBASE_32MS = (uint8_t)8, /*!< AWU Timebase equals 32 ms */
  50. AWU_TIMEBASE_64MS = (uint8_t)9, /*!< AWU Timebase equals 64 ms */
  51. AWU_TIMEBASE_128MS = (uint8_t)10, /*!< AWU Timebase equals 128 ms */
  52. AWU_TIMEBASE_256MS = (uint8_t)11, /*!< AWU Timebase equals 256 ms */
  53. AWU_TIMEBASE_512MS = (uint8_t)12, /*!< AWU Timebase equals 512 ms */
  54. AWU_TIMEBASE_1S = (uint8_t)13, /*!< AWU Timebase equals 1 s */
  55. AWU_TIMEBASE_2S = (uint8_t)14, /*!< AWU Timebase equals 2 s */
  56. AWU_TIMEBASE_12S = (uint8_t)15, /*!< AWU Timebase equals 12 s */
  57. AWU_TIMEBASE_30S = (uint8_t)16 /*!< AWU Timebase equals 30 s */
  58. } AWU_Timebase_TypeDef;
  59. /**
  60. * @}
  61. */
  62. /* Exported constants --------------------------------------------------------*/
  63. /** @addtogroup AWU_Exported_Constants
  64. * @{
  65. */
  66. #define LSI_FREQUENCY_MIN ((uint32_t)110000) /*!< LSI minimum value in Hertz */
  67. #define LSI_FREQUENCY_MAX ((uint32_t)150000) /*!< LSI maximum value in Hertz */
  68. /**
  69. * @}
  70. */
  71. /* Exported macros ------------------------------------------------------------*/
  72. /* Private macros ------------------------------------------------------------*/
  73. /** @addtogroup AWU_Private_Macros
  74. * @{
  75. */
  76. /**
  77. * @brief Macro used by the assert function to check the different functions parameters.
  78. */
  79. /**
  80. * @brief Macro used by the assert function to check the AWU timebases
  81. */
  82. #define IS_AWU_TIMEBASE_OK(TB) \
  83. (((TB) == AWU_TIMEBASE_NO_IT) || \
  84. ((TB) == AWU_TIMEBASE_250US) || \
  85. ((TB) == AWU_TIMEBASE_500US) || \
  86. ((TB) == AWU_TIMEBASE_1MS) || \
  87. ((TB) == AWU_TIMEBASE_2MS) || \
  88. ((TB) == AWU_TIMEBASE_4MS) || \
  89. ((TB) == AWU_TIMEBASE_8MS) || \
  90. ((TB) == AWU_TIMEBASE_16MS) || \
  91. ((TB) == AWU_TIMEBASE_32MS) || \
  92. ((TB) == AWU_TIMEBASE_64MS) || \
  93. ((TB) == AWU_TIMEBASE_128MS) || \
  94. ((TB) == AWU_TIMEBASE_256MS) || \
  95. ((TB) == AWU_TIMEBASE_512MS) || \
  96. ((TB) == AWU_TIMEBASE_1S) || \
  97. ((TB) == AWU_TIMEBASE_2S) || \
  98. ((TB) == AWU_TIMEBASE_12S) || \
  99. ((TB) == AWU_TIMEBASE_30S))
  100. /**
  101. * @brief Macro used by the assert function to check the LSI frequency (in Hz)
  102. */
  103. #define IS_LSI_FREQUENCY_OK(FREQ) \
  104. (((FREQ) >= LSI_FREQUENCY_MIN) && \
  105. ((FREQ) <= LSI_FREQUENCY_MAX))
  106. /**
  107. * @}
  108. */
  109. /* Exported functions ------------------------------------------------------- */
  110. /** @addtogroup AWU_Exported_Functions
  111. * @{
  112. */
  113. void AWU_DeInit(void);
  114. void AWU_Init(AWU_Timebase_TypeDef AWU_TimeBase);
  115. void AWU_Cmd(FunctionalState NewState);
  116. void AWU_LSICalibrationConfig(uint32_t LSIFreqHz);
  117. void AWU_IdleModeEnable(void);
  118. FlagStatus AWU_GetFlagStatus(void);
  119. /**
  120. * @}
  121. */
  122. #endif /* __STM8S_AWU_H */
  123. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/