stm32_clk.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef _STM32_CLK_H_
  2. #define _STM32_CLK_H_
  3. /*
  4. * Copyright (C) 2010 by Ulrich Prinz (uprinz2@netscape.net)
  5. *
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the copyright holders nor the names of
  18. * contributors may be used to endorse or promote products derived
  19. * from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  31. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * For additional information see http://www.ethernut.de/
  35. */
  36. /*
  37. * \verbatim
  38. * $Id: stm32_gpio.c 3182 2010-10-17 21:46:04Z Astralix $
  39. * \endverbatim
  40. */
  41. #include <stdint.h>
  42. /* STM32F Clock source selectors */
  43. #define SYSCLK_HSI 0
  44. #define SYSCLK_PLL 1
  45. #define SYSCLK_HSE 2
  46. #define PLLCLK_HSI 3
  47. #define PLLCLK_HSE 4
  48. /* RTC clock sources */
  49. #define RTCCLK_NONE 0
  50. #define RTCCLK_LSE 1
  51. #define RTCCLK_LSI 2
  52. #define RTCCLK_HSE 3
  53. #define RTCCLK_LSEBYP 4
  54. /* Retrieve CPU/AHB/APBx clock*/
  55. extern uint32_t STM_ClockGet(int idx);
  56. /* Control functions for the separate clocks */
  57. extern int CtlHseClock( uint8_t ena);
  58. extern int CtlHsiClock( uint8_t ena);
  59. extern int CtlPllClock( uint8_t ena);
  60. /* Selection functions for the clock sources */
  61. extern int SetPllClock( int src);
  62. extern int SetPllClockSource( int src);
  63. extern int SetSysClock(void);
  64. extern uint32_t SysCtlClockGet(void);
  65. #if defined(MCU_STM32L1)
  66. extern int SetRTCClock(int source);
  67. #endif
  68. #endif /* _STM32_CLK_H_ */