/stm32/inc/tm_stm32f4_mco_output.h

https://github.com/drowe67/codec2 · C Header · 188 lines · 36 code · 19 blank · 133 comment · 0 complexity · 3490224b04961ef733e7047969f3acaa MD5 · raw file

  1. /**
  2. * @author Tilen Majerle
  3. * @email tilen@majerle.eu
  4. * @website http://stm32f4-discovery.com
  5. * @link http://stm32f4-discovery.com/2014/10/library-40-output-clocks-stm32f4/
  6. * @version v1.1
  7. * @ide Keil uVision
  8. * @license GNU GPL v3
  9. * @brief MCO Output for STM32F4xx
  10. *
  11. @verbatim
  12. ----------------------------------------------------------------------
  13. Copyright (C) Tilen Majerle, 2015
  14. This program is free software: you can redistribute it and/or modify
  15. it under the terms of the GNU General Public License as published by
  16. the Free Software Foundation, either version 3 of the License, or
  17. any later version.
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. GNU General Public License for more details.
  22. You should have received a copy of the GNU General Public License
  23. along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. ----------------------------------------------------------------------
  25. @endverbatim
  26. */
  27. #ifndef TM_MCOOUTPUT_H
  28. #define TM_MCOOUTPUT_H 110
  29. /**
  30. * @addtogroup TM_STM32F4xx_Libraries
  31. * @{
  32. */
  33. /**
  34. * @defgroup TM_MCO
  35. * @brief MCO Output clock for STM32F4xx - http://stm32f4-discovery.com/2014/10/library-40-output-clocks-stm32f4/
  36. * @{
  37. *
  38. * This library allows you to output different frequencies. They are split into 2 different output sections.
  39. *
  40. * \par MCO1 output = PA8
  41. *
  42. * MCO1 output
  43. * - Pin PA8
  44. * - HSI: High Speed Internal clock, 16MHz RC oscillator
  45. * - HSE: High Speed External clock, external crystal or user clock
  46. * - LSE: External 32738Hz low-speed oscillator or ceramic resonator
  47. * - PLLCLK: Output from PLL
  48. *
  49. * \par MCO2 output = PC9
  50. *
  51. * MCO2 output
  52. * - Pin PC9
  53. * - SYSCLK: Output system core clock
  54. * - PLLI2SCLK: Accurate clock for high-quality audio performance in I2S and SAI interfaces
  55. * - HSE: High Speed External clock, external crystal or user clock
  56. * - PLLCLK: Output from PLL
  57. *
  58. * \par Changelog
  59. *
  60. @verbatim
  61. Version 1.1
  62. - March 11, 2015
  63. - Support for my new GPIO library
  64. Version 1.0
  65. - First release
  66. @endverbatim
  67. *
  68. * \par Dependencies
  69. *
  70. @verbatim
  71. - STM32F4xx
  72. - STM32F4xx RCC
  73. - defines.h
  74. - TM GPIO
  75. @endverbatim
  76. */
  77. #include "stm32f4xx.h"
  78. #include "stm32f4xx_rcc.h"
  79. #include "defines.h"
  80. #include "tm_stm32f4_gpio.h"
  81. /* C++ detection */
  82. #ifdef __cplusplus
  83. extern "C" {
  84. #endif
  85. /**
  86. * @defgroup TM_MCO_Typedefs
  87. * @brief Library Typedefs
  88. * @{
  89. */
  90. /**
  91. * @brief Prescaler values for output clock
  92. */
  93. typedef enum {
  94. TM_MCOOUTPUT_Prescaler_1, /*!< Output original value of clock on MCO pin */
  95. TM_MCOOUTPUT_Prescaler_2, /*!< Output clock is original / 2 */
  96. TM_MCOOUTPUT_Prescaler_3, /*!< Output clock is original / 3 */
  97. TM_MCOOUTPUT_Prescaler_4, /*!< Output clock is original / 4 */
  98. TM_MCOOUTPUT_Prescaler_5 /*!< Output clock is original / 5 */
  99. } TM_MCOOUTPUT_Prescaler_t;
  100. /**
  101. * @brief Possible output clocks on MCO1 pin
  102. */
  103. typedef enum {
  104. TM_MCOOUTPUT1_Source_HSI, /*!< High Speed Internal clock, 16MHz RC oscillator */
  105. TM_MCOOUTPUT1_Source_HSE, /*!< High Speed External clock, external crystal or user clock */
  106. TM_MCOOUTPUT1_Source_LSE, /*!< External 32738Hz low-speed oscillator or ceramic resonator */
  107. TM_MCOOUTPUT1_Source_PLLCLK /*!< Output from PLL */
  108. } TM_MCOOUTPUT1_Source_t;
  109. /**
  110. * @brief Possible output clocks on MCO2 pin
  111. */
  112. typedef enum {
  113. TM_MCOOUTPUT2_Source_SYSCLK, /*!< System core clock */
  114. TM_MCOOUTPUT2_Source_PLLI2SCLK, /*!< Accurate clock for high-quality audio performance in I2S and SAI interfaces */
  115. TM_MCOOUTPUT2_Source_HSE, /*!< High Speed External clock, external crystal or user clock */
  116. TM_MCOOUTPUT2_Source_PLLCLK /*!< Output from PLL */
  117. } TM_MCOOUTPUT2_Source_t;
  118. /**
  119. * @}
  120. */
  121. /**
  122. * @defgroup TM_MCO_Functions
  123. * @brief Library Functions
  124. * @{
  125. */
  126. /**
  127. * @brief Initializes and prepares MCO1 pin to output clock
  128. * @param None
  129. * @retval None
  130. */
  131. void TM_MCOOUTPUT_InitMCO1(void);
  132. /**
  133. * @brief Sets output for MCO1 pin
  134. * @param Source: Clock source to output. This parameter can be a value of @ref TM_MCOOUTPUT1_Source_t enumeration.
  135. * @param Prescaler: Prescaler used for clock. This parameter can be a value of @ref TM_MCOOUTPUT_Prescaler_t enumeration.
  136. * @retval None
  137. */
  138. void TM_MCOOUTPUT_SetOutput1(TM_MCOOUTPUT1_Source_t Source, TM_MCOOUTPUT_Prescaler_t Prescaler);
  139. /**
  140. * @brief Initializes and prepares MCO2 pin to output clock
  141. * @param None
  142. * @retval None
  143. */
  144. void TM_MCOOUTPUT_InitMCO2(void);
  145. /**
  146. * @brief Sets output for MCO2 pin
  147. * @param Source: Clock source to output. This parameter can be a value of @ref TM_MCOOUTPUT2_Source_t enumeration.
  148. * @param Prescaler: Prescaler used for clock. This parameter can be a value of @ref TM_MCOOUTPUT_Prescaler_t enumeration.
  149. * @retval None
  150. */
  151. void TM_MCOOUTPUT_SetOutput2(TM_MCOOUTPUT2_Source_t Source, TM_MCOOUTPUT_Prescaler_t Prescaler);
  152. /**
  153. * @}
  154. */
  155. /**
  156. * @}
  157. */
  158. /**
  159. * @}
  160. */
  161. /* C++ detection */
  162. #ifdef __cplusplus
  163. }
  164. #endif
  165. #endif