stm8s_beep.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /**
  2. ******************************************************************************
  3. * @file stm8s_beep.h
  4. * @author MCD Application Team
  5. * @version V2.2.0
  6. * @date 30-September-2014
  7. * @brief This file contains all functions prototype and macros for the BEEP 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_BEEP_H
  29. #define __STM8S_BEEP_H
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "stm8s.h"
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @addtogroup BEEP_Exported_Types
  34. * @{
  35. */
  36. /**
  37. * @brief BEEP Frequency selection
  38. */
  39. typedef enum {
  40. BEEP_FREQUENCY_1KHZ = (uint8_t)0x00, /*!< Beep signal output frequency equals to 1 KHz */
  41. BEEP_FREQUENCY_2KHZ = (uint8_t)0x40, /*!< Beep signal output frequency equals to 2 KHz */
  42. BEEP_FREQUENCY_4KHZ = (uint8_t)0x80 /*!< Beep signal output frequency equals to 4 KHz */
  43. } BEEP_Frequency_TypeDef;
  44. /**
  45. * @}
  46. */
  47. /* Exported constants --------------------------------------------------------*/
  48. /** @addtogroup BEEP_Exported_Constants
  49. * @{
  50. */
  51. #define BEEP_CALIBRATION_DEFAULT ((uint8_t)0x0B) /*!< Default value when calibration is not done */
  52. #define LSI_FREQUENCY_MIN ((uint32_t)110000) /*!< LSI minimum value in Hertz */
  53. #define LSI_FREQUENCY_MAX ((uint32_t)150000) /*!< LSI maximum value in Hertz */
  54. /**
  55. * @}
  56. */
  57. /* Exported macros -----------------------------------------------------------*/
  58. /* Private macros ------------------------------------------------------------*/
  59. /** @addtogroup BEEP_Private_Macros
  60. * @{
  61. */
  62. /**
  63. * @brief Macro used by the assert function to check the different functions parameters.
  64. */
  65. /**
  66. * @brief Macro used by the assert function to check the BEEP frequencies.
  67. */
  68. #define IS_BEEP_FREQUENCY_OK(FREQ) \
  69. (((FREQ) == BEEP_FREQUENCY_1KHZ) || \
  70. ((FREQ) == BEEP_FREQUENCY_2KHZ) || \
  71. ((FREQ) == BEEP_FREQUENCY_4KHZ))
  72. /**
  73. * @brief Macro used by the assert function to check the LSI frequency (in Hz).
  74. */
  75. #define IS_LSI_FREQUENCY_OK(FREQ) \
  76. (((FREQ) >= LSI_FREQUENCY_MIN) && \
  77. ((FREQ) <= LSI_FREQUENCY_MAX))
  78. /**
  79. * @}
  80. */
  81. /* Exported functions ------------------------------------------------------- */
  82. /** @addtogroup BEEP_Exported_Functions
  83. * @{
  84. */
  85. void BEEP_DeInit(void);
  86. void BEEP_Init(BEEP_Frequency_TypeDef BEEP_Frequency);
  87. void BEEP_Cmd(FunctionalState NewState);
  88. void BEEP_LSICalibrationConfig(uint32_t LSIFreqHz);
  89. /**
  90. * @}
  91. */
  92. #endif /* __STM8S_BEEP_H */
  93. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/