A bundled STM32F10x Std Periph and CMSIS library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

118 lines
3.1 KiB

  1. /*
  2. system_stm32f10x.h - This provides system clock functions and an exported
  3. variable for System init and clock configuration.
  4. includes:
  5. SystemInit, SystemInit_ExtMemCtl, Sys_Sysclk_Update, Sys_GetSysclk_src,
  6. Sys_SetSysclk_src, Sys_HSI_Cmd, Sys_HSE_Cmd, Sys_ExtClock_Cmd,
  7. Sys_PLL_Cmd, Sys_SetPLLClock
  8. Copyright (C) 2011 Houtouridis Christos (http://houtouridis.blogspot.com/)
  9. This program is free software: you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation, either version 3 of the License, or
  12. (at your option) any later version.
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU General Public License for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. Author: Houtouridis Christos <houtouridis.ch@gmail.com>
  20. Date: 11/2011
  21. Version: 0.1
  22. */
  23. #ifndef __stm32f10x_clock_h__
  24. #define __stm32f10x_clock_h__
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #include <stm32f10x.h>
  29. #include "stm32f10x_assert.h"
  30. /* ================ User Defines ======================*/
  31. #define SYSTEM_STARTUP_TIMEOUT (0x500)
  32. /* ================ General Defines ======================*/
  33. #define SYSCLK_HSI_FREQ (8000000)
  34. #ifndef CLOCK
  35. #warning "CLOCK is not defined. Used 8000000 as default value"
  36. #define CLOCK (SYSCLK_HSI_FREQ)
  37. #endif
  38. #if defined (STM32F10X_LD_VL) || (defined STM32F10X_MD_VL) || (defined STM32F10X_HD_VL)
  39. #define SYSTEM_MAX_CLK (24000000)
  40. #define SYSTEM_MIN_CLK (8000000)
  41. #elif defined (STM32F10X_MD)
  42. #define SYSTEM_MAX_CLK (32000000)
  43. #define SYSTEM_MIN_CLK (8000000)
  44. #elif defined (STM32F10X_HD)
  45. #define SYSTEM_MAX_CLK (36000000)
  46. //#define SYSTEM_MAX_CLK (48000000)
  47. //#define SYSTEM_MAX_CLK (72000000)
  48. #define SYSTEM_MIN_CLK (8000000)
  49. #endif
  50. typedef uint32_t CLK_t;
  51. typedef enum
  52. {
  53. // DO NOT change the numbers,
  54. //see STM Reference manual page 83
  55. HSI=0, HSE, PLLCLK
  56. }Sys_CLK_src_t;
  57. typedef enum
  58. {
  59. DIS=0, EN
  60. }Sys_FunctionalState_t;
  61. typedef enum
  62. {
  63. HSI_2=0, PREDIV
  64. }Sys_PLL_src_t;
  65. typedef enum
  66. {
  67. System_OK=0, System_ERROR
  68. }Sys_Exit_t;
  69. /* ================ Exported Functions ======================*/
  70. CLK_t Sys_Sysclk_Update (void);
  71. Sys_CLK_src_t Sys_GetSysclk_src (void);
  72. Sys_Exit_t Sys_SetSysclk_src (Sys_CLK_src_t cs);
  73. Sys_Exit_t Sys_HSI_Cmd (Sys_FunctionalState_t state);
  74. Sys_Exit_t Sys_HSE_Cmd (Sys_FunctionalState_t state);
  75. Sys_Exit_t Sys_ExtClock_Cmd (Sys_FunctionalState_t state);
  76. Sys_Exit_t Sys_PLL_Cmd (Sys_FunctionalState_t state);
  77. Sys_Exit_t Sys_SetPLLClock (CLK_t clk, Sys_PLL_src_t ps);
  78. #ifdef __cplusplus
  79. }
  80. #endif
  81. #endif // #ifndef __stm32f10x_clock_h__