找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2708|回复: 1
打印 上一主题 下一主题
收起左侧

stm32f10x.h文件代码分析

[复制链接]
跳转到指定楼层
楼主
ID:91350 发表于 2015-9-30 13:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1.   * @author  MCD Application Team
  2.   * @version V3.5.0
  3.   * @date    11-March-2011
  4.   * @brief   CMSIS Cortex-M3 Device Peripheral Access Layer Header File.
  5.                外设分为内核外设和芯片级外设。这个头文件是芯片级外设方位层的头文件     
  6.   *          This file contains all the peripheral register's definitions, bits
  7.   *          definitions and memory mapping for STM32F10x Connectivity line,
  8.   *          High density, High density value line, Medium density,
  9.   *          Medium density Value line, Low density, Low density Value line
  10.   *          and XL-density devices.
  11.              这个文件为STM32F10x所有系列的芯片级外设寄存器做定义、寄存器位做定义。
  12.   *          The file is the unique include file that the application programmer
  13.   *          is using in the C source code, usually in main.c. This file contains:
  14.              应用编程者在使用c语言编写代码的时候,这个文件是唯一需要包含的文件,它包括:
  15.   *           - Configuration section that allows to select:
  16.   *              - The device used in the target application
  17.   *              - To use or not the peripheral抯 drivers in application code(i.e.
  18.   *                code will be based on direct access to peripheral抯 registers
  19.   *                rather than drivers API), this option is controlled by
  20.   *                "#define USE_STDPERIPH_DRIVER"
  21.   *              - To change few application-specific parameters such as the HSE
  22.   *                crystal frequency
  23.   *           - Data structures and the address mapping for all peripherals
  24.   *           - Peripheral's registers declarations and bits definition
  25.   *           - Macros to access peripheral抯 registers hardware
  26.   *        一些配置段,这些配置段允许我们选择一下内容:
  27.             选择目标应用中使用的芯片
  28.             选择是使用库函数还是直接寄存器访问,这个是由"#define USE_STDPERIPH_DRIVER"控制的
  29.             外设寄存器的结构体数据类型的定义以及地址映射
  30.             外设寄存器的声明和位定义
  31.             访问外设寄存器的宏定义
  32.             
  33.   ******************************************************************************
  34.   * @attention
  35.   *
  36.   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  37.   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  38.   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  39.   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  40.   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  41.   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  42.   *
  43.   *
  44. © COPYRIGHT 2011 STMicroelectronics
  45.   ******************************************************************************
  46.   */


  47.    
  48. #ifndef __STM32F10x_H
  49. #define __STM32F10x_H

  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53.   
  54.   

  55. #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL)
  56.      
  57.      
  58.      
  59.      
  60.      
  61.      
  62.      
  63.      
  64. #endif

  65. #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL)
  66. #error "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"
  67. #endif

  68. #if !defined  USE_STDPERIPH_DRIVER

  69. #endif

  70.          
  71. #if !defined  HSE_VALUE
  72. #ifdef STM32F10X_CL   
  73.   #define HSE_VALUE    ((uint32_t)25000000)
  74. #else
  75.   #define HSE_VALUE    ((uint32_t)8000000)
  76. #endif
  77. #endif


  78. #define HSE_STARTUP_TIMEOUT   ((uint16_t)0x0500)

  79. #define HSI_VALUE    ((uint32_t)8000000)

  80. #define __STM32F10X_STDPERIPH_VERSION_MAIN   (0x03)                                 
  81. #define __STM32F10X_STDPERIPH_VERSION_SUB1   (0x05)
  82. #define __STM32F10X_STDPERIPH_VERSION_SUB2   (0x00)
  83. #define __STM32F10X_STDPERIPH_VERSION_RC     (0x00)  
  84. #define __STM32F10X_STDPERIPH_VERSION       ( (__STM32F10X_STDPERIPH_VERSION_MAIN << 24)\
  85.                                              |(__STM32F10X_STDPERIPH_VERSION_SUB1 << 16)\
  86.                                              |(__STM32F10X_STDPERIPH_VERSION_SUB2 << 8)\
  87.                                              |(__STM32F10X_STDPERIPH_VERSION_RC))



  88. #ifdef STM32F10X_XL
  89. #define __MPU_PRESENT             1
  90. #else
  91. #define __MPU_PRESENT             0
  92. #endif
  93. #define __NVIC_PRIO_BITS          4
  94. #define __Vendor_SysTickConfig    0

  95. typedef enum IRQn
  96. {
  97.   NonMaskableInt_IRQn         = -14,   
  98.   MemoryManagement_IRQn       = -12,   
  99.   BusFault_IRQn               = -11,   
  100.   UsageFault_IRQn             = -10,   
  101.   SVCall_IRQn                 = -5,   
  102.   DebugMonitor_IRQn           = -4,   
  103.   PendSV_IRQn                 = -2,   
  104.   SysTick_IRQn                = -1,   

  105.   WWDG_IRQn                   = 0,      
  106.   PVD_IRQn                    = 1,      
  107.   TAMPER_IRQn                 = 2,      
  108.   RTC_IRQn                    = 3,      
  109.   FLASH_IRQn                  = 4,      
  110.   RCC_IRQn                    = 5,      
  111.   EXTI0_IRQn                  = 6,      
  112.   EXTI1_IRQn                  = 7,      
  113.   EXTI2_IRQn                  = 8,      
  114.   EXTI3_IRQn                  = 9,      
  115.   EXTI4_IRQn                  = 10,   
  116.   DMA1_Channel1_IRQn          = 11,   
  117.   DMA1_Channel2_IRQn          = 12,   
  118.   DMA1_Channel3_IRQn          = 13,   
  119.   DMA1_Channel4_IRQn          = 14,   
  120.   DMA1_Channel5_IRQn          = 15,   
  121.   DMA1_Channel6_IRQn          = 16,   
  122.   DMA1_Channel7_IRQn          = 17,   

  123. #ifdef STM32F10X_LD
  124.   ADC1_2_IRQn                 = 18,   
  125.   USB_HP_CAN1_TX_IRQn         = 19,   
  126.   USB_LP_CAN1_RX0_IRQn        = 20,   
  127.   CAN1_RX1_IRQn               = 21,   
  128.   CAN1_SCE_IRQn               = 22,   
  129.   EXTI9_5_IRQn                = 23,   
  130.   TIM1_BRK_IRQn               = 24,   
  131.   TIM1_UP_IRQn                = 25,   
  132.   TIM1_TRG_COM_IRQn           = 26,   
  133.   TIM1_CC_IRQn                = 27,   
  134.   TIM2_IRQn                   = 28,   
  135.   TIM3_IRQn                   = 29,   
  136.   I2C1_EV_IRQn                = 31,   
  137.   I2C1_ER_IRQn                = 32,   
  138.   SPI1_IRQn                   = 35,   
  139.   USART1_IRQn                 = 37,   
  140.   USART2_IRQn                 = 38,   
  141.   EXTI15_10_IRQn              = 40,   
  142.   RTCAlarm_IRQn               = 41,   
  143.   USBWakeUp_IRQn              = 42         
  144. #endif  

  145. #ifdef STM32F10X_LD_VL
  146.   ADC1_IRQn                   = 18,   
  147.   EXTI9_5_IRQn                = 23,   
  148.   TIM1_BRK_TIM15_IRQn         = 24,   
  149.   TIM1_UP_TIM16_IRQn          = 25,   
  150.   TIM1_TRG_COM_TIM17_IRQn     = 26,   
  151.   TIM1_CC_IRQn                = 27,   
  152.   TIM2_IRQn                   = 28,   
  153.   TIM3_IRQn                   = 29,   
  154.   I2C1_EV_IRQn                = 31,   
  155.   I2C1_ER_IRQn                = 32,   
  156.   SPI1_IRQn                   = 35,   
  157.   USART1_IRQn                 = 37,   
  158.   USART2_IRQn                 = 38,   
  159.   EXTI15_10_IRQn              = 40,   
  160.   RTCAlarm_IRQn               = 41,   
  161.   CEC_IRQn                    = 42,   
  162.   TIM6_DAC_IRQn               = 54,   
  163.   TIM7_IRQn                   = 55            
  164. #endif

  165. #ifdef STM32F10X_MD
  166.   ADC1_2_IRQn                 = 18,   
  167.   USB_HP_CAN1_TX_IRQn         = 19,   
  168.   USB_LP_CAN1_RX0_IRQn        = 20,   
  169.   CAN1_RX1_IRQn               = 21,   
  170.   CAN1_SCE_IRQn               = 22,   
  171.   EXTI9_5_IRQn                = 23,   
  172.   TIM1_BRK_IRQn               = 24,   
  173.   TIM1_UP_IRQn                = 25,   
  174.   TIM1_TRG_COM_IRQn           = 26,   
  175.   TIM1_CC_IRQn                = 27,   
  176.   TIM2_IRQn                   = 28,   
  177.   TIM3_IRQn                   = 29,   
  178.   TIM4_IRQn                   = 30,   
  179.   I2C1_EV_IRQn                = 31,   
  180.   I2C1_ER_IRQn                = 32,   
  181.   I2C2_EV_IRQn                = 33,   
  182.   I2C2_ER_IRQn                = 34,   
  183.   SPI1_IRQn                   = 35,   
  184.   SPI2_IRQn                   = 36,   
  185.   USART1_IRQn                 = 37,   
  186.   USART2_IRQn                 = 38,   
  187.   USART3_IRQn                 = 39,   
  188.   EXTI15_10_IRQn              = 40,   
  189.   RTCAlarm_IRQn               = 41,   
  190.   USBWakeUp_IRQn              = 42        
  191. #endif  

  192. #ifdef STM32F10X_MD_VL
  193.   ADC1_IRQn                   = 18,   
  194.   EXTI9_5_IRQn                = 23,   
  195.   TIM1_BRK_TIM15_IRQn         = 24,   
  196.   TIM1_UP_TIM16_IRQn          = 25,   
  197.   TIM1_TRG_COM_TIM17_IRQn     = 26,   
  198.   TIM1_CC_IRQn                = 27,   
  199.   TIM2_IRQn                   = 28,   
  200.   TIM3_IRQn                   = 29,   
  201.   TIM4_IRQn                   = 30,   
  202.   I2C1_EV_IRQn                = 31,   
  203.   I2C1_ER_IRQn                = 32,   
  204.   I2C2_EV_IRQn                = 33,   
  205.   I2C2_ER_IRQn                = 34,   
  206.   SPI1_IRQn                   = 35,   
  207.   SPI2_IRQn                   = 36,   
  208.   USART1_IRQn                 = 37,   
  209.   USART2_IRQn                 = 38,   
  210.   USART3_IRQn                 = 39,   
  211.   EXTI15_10_IRQn              = 40,   
  212.   RTCAlarm_IRQn               = 41,   
  213.   CEC_IRQn                    = 42,   
  214.   TIM6_DAC_IRQn               = 54,   
  215.   TIM7_IRQn                   = 55            
  216. #endif

  217. #ifdef STM32F10X_HD
  218.   ADC1_2_IRQn                 = 18,   
  219.   USB_HP_CAN1_TX_IRQn         = 19,   
  220.   USB_LP_CAN1_RX0_IRQn        = 20,   
  221.   CAN1_RX1_IRQn               = 21,   
  222.   CAN1_SCE_IRQn               = 22,   
  223.   EXTI9_5_IRQn                = 23,   
  224.   TIM1_BRK_IRQn               = 24,   
  225.   TIM1_UP_IRQn                = 25,   
  226.   TIM1_TRG_COM_IRQn           = 26,   
  227.   TIM1_CC_IRQn                = 27,   
  228.   TIM2_IRQn                   = 28,   
  229.   TIM3_IRQn                   = 29,   
  230.   TIM4_IRQn                   = 30,   
  231.   I2C1_EV_IRQn                = 31,   
  232.   I2C1_ER_IRQn                = 32,   
  233.   I2C2_EV_IRQn                = 33,   
  234.   I2C2_ER_IRQn                = 34,   
  235.   SPI1_IRQn                   = 35,   
  236.   SPI2_IRQn                   = 36,   
  237.   USART1_IRQn                 = 37,   
  238.   USART2_IRQn                 = 38,   
  239.   USART3_IRQn                 = 39,   
  240.   EXTI15_10_IRQn              = 40,   
  241.   RTCAlarm_IRQn               = 41,   
  242.   USBWakeUp_IRQn              = 42,   
  243.   TIM8_BRK_IRQn               = 43,   
  244.   TIM8_UP_IRQn                = 44,   
  245.   TIM8_TRG_COM_IRQn           = 45,   
  246.   TIM8_CC_IRQn                = 46,   
  247.   ADC3_IRQn                   = 47,   
  248.   FSMC_IRQn                   = 48,   
  249.   SDIO_IRQn                   = 49,   
  250.   TIM5_IRQn                   = 50,   
  251.   SPI3_IRQn                   = 51,   
  252.   UART4_IRQn                  = 52,   
  253.   UART5_IRQn                  = 53,   
  254.   TIM6_IRQn                   = 54,   
  255.   TIM7_IRQn                   = 55,   
  256.   DMA2_Channel1_IRQn          = 56,   
  257.   DMA2_Channel2_IRQn          = 57,   
  258.   DMA2_Channel3_IRQn          = 58,   
  259.   DMA2_Channel4_5_IRQn        = 59      
  260. #endif  

  261. #ifdef STM32F10X_HD_VL
  262.   ADC1_IRQn                   = 18,   
  263.   EXTI9_5_IRQn                = 23,   
  264.   TIM1_BRK_TIM15_IRQn         = 24,   
  265.   TIM1_UP_TIM16_IRQn          = 25,   
  266.   TIM1_TRG_COM_TIM17_IRQn     = 26,   
  267.   TIM1_CC_IRQn                = 27,   
  268.   TIM2_IRQn                   = 28,   
  269.   TIM3_IRQn                   = 29,   
  270.   TIM4_IRQn                   = 30,   
  271.   I2C1_EV_IRQn                = 31,   
  272.   I2C1_ER_IRQn                = 32,   
  273.   I2C2_EV_IRQn                = 33,   
  274.   I2C2_ER_IRQn                = 34,   
  275.   SPI1_IRQn                   = 35,   
  276.   SPI2_IRQn                   = 36,   
  277.   USART1_IRQn                 = 37,   
  278.   USART2_IRQn                 = 38,   
  279.   USART3_IRQn                 = 39,   
  280.   EXTI15_10_IRQn              = 40,   
  281.   RTCAlarm_IRQn               = 41,   
  282.   CEC_IRQn                    = 42,   
  283.   TIM12_IRQn                  = 43,   
  284.   TIM13_IRQn                  = 44,   
  285.   TIM14_IRQn                  = 45,   
  286.   TIM5_IRQn                   = 50,   
  287.   SPI3_IRQn                   = 51,   
  288.   UART4_IRQn                  = 52,   
  289.   UART5_IRQn                  = 53,      
  290.   TIM6_DAC_IRQn               = 54,   
  291.   TIM7_IRQn                   = 55,      
  292.   DMA2_Channel1_IRQn          = 56,   
  293.   DMA2_Channel2_IRQn          = 57,   
  294.   DMA2_Channel3_IRQn          = 58,   
  295.   DMA2_Channel4_5_IRQn        = 59,   
  296.   DMA2_Channel5_IRQn          = 60            
  297. #endif

  298. #ifdef STM32F10X_XL
  299.   ADC1_2_IRQn                 = 18,   
  300.   USB_HP_CAN1_TX_IRQn         = 19,   
  301.   USB_LP_CAN1_RX0_IRQn        = 20,   
  302.   CAN1_RX1_IRQn               = 21,   
  303.   CAN1_SCE_IRQn               = 22,   
  304.   EXTI9_5_IRQn                = 23,   
  305.   TIM1_BRK_TIM9_IRQn          = 24,   
  306.   TIM1_UP_TIM10_IRQn          = 25,   
  307.   TIM1_TRG_COM_TIM11_IRQn     = 26,   
  308.   TIM1_CC_IRQn                = 27,   
  309.   TIM2_IRQn                   = 28,   
  310.   TIM3_IRQn                   = 29,   
  311.   TIM4_IRQn                   = 30,   
  312.   I2C1_EV_IRQn                = 31,   
  313.   I2C1_ER_IRQn                = 32,   
  314.   I2C2_EV_IRQn                = 33,   
  315.   I2C2_ER_IRQn                = 34,   
  316.   SPI1_IRQn                   = 35,   
  317.   SPI2_IRQn                   = 36,   
  318.   USART1_IRQn                 = 37,   
  319.   USART2_IRQn                 = 38,   
  320.   USART3_IRQn                 = 39,   
  321.   EXTI15_10_IRQn              = 40,   
  322.   RTCAlarm_IRQn               = 41,   
  323.   USBWakeUp_IRQn              = 42,   
  324.   TIM8_BRK_TIM12_IRQn         = 43,   
  325.   TIM8_UP_TIM13_IRQn          = 44,   
  326.   TIM8_TRG_COM_TIM14_IRQn     = 45,   
  327.   TIM8_CC_IRQn                = 46,   
  328.   ADC3_IRQn                   = 47,   
  329.   FSMC_IRQn                   = 48,   
  330.   SDIO_IRQn                   = 49,   
  331.   TIM5_IRQn                   = 50,   
  332.   SPI3_IRQn                   = 51,   
  333.   UART4_IRQn                  = 52,   
  334.   UART5_IRQn                  = 53,   
  335.   TIM6_IRQn                   = 54,   
  336.   TIM7_IRQn                   = 55,   
  337.   DMA2_Channel1_IRQn          = 56,   
  338.   DMA2_Channel2_IRQn          = 57,   
  339.   DMA2_Channel3_IRQn          = 58,   
  340.   DMA2_Channel4_5_IRQn        = 59      
  341. #endif  

  342. #ifdef STM32F10X_CL
  343.   ADC1_2_IRQn                 = 18,   
  344.   CAN1_TX_IRQn                = 19,   
  345.   CAN1_RX0_IRQn               = 20,   
  346.   CAN1_RX1_IRQn               = 21,   
  347.   CAN1_SCE_IRQn               = 22,   
  348.   EXTI9_5_IRQn                = 23,   
  349.   TIM1_BRK_IRQn               = 24,   
  350.   TIM1_UP_IRQn                = 25,   
  351.   TIM1_TRG_COM_IRQn           = 26,   
  352.   TIM1_CC_IRQn                = 27,   
  353.   TIM2_IRQn                   = 28,   
  354.   TIM3_IRQn                   = 29,   
  355.   TIM4_IRQn                   = 30,   
  356.   I2C1_EV_IRQn                = 31,   
  357.   I2C1_ER_IRQn                = 32,   
  358.   I2C2_EV_IRQn                = 33,   
  359.   I2C2_ER_IRQn                = 34,   
  360.   SPI1_IRQn                   = 35,   
  361.   SPI2_IRQn                   = 36,   
  362.   USART1_IRQn                 = 37,   
  363.   USART2_IRQn                 = 38,   
  364.   USART3_IRQn                 = 39,   
  365.   EXTI15_10_IRQn              = 40,   
  366.   RTCAlarm_IRQn               = 41,   
  367.   OTG_FS_WKUP_IRQn            = 42,   
  368.   TIM5_IRQn                   = 50,   
  369.   SPI3_IRQn                   = 51,   
  370.   UART4_IRQn                  = 52,   
  371.   UART5_IRQn                  = 53,   
  372.   TIM6_IRQn                   = 54,   
  373.   TIM7_IRQn                   = 55,   
  374.   DMA2_Channel1_IRQn          = 56,   
  375.   DMA2_Channel2_IRQn          = 57,   
  376.   DMA2_Channel3_IRQn          = 58,   
  377.   DMA2_Channel4_IRQn          = 59,   
  378.   DMA2_Channel5_IRQn          = 60,   
  379.   ETH_IRQn                    = 61,   
  380.   ETH_WKUP_IRQn               = 62,   
  381.   CAN2_TX_IRQn                = 63,   
  382.   CAN2_RX0_IRQn               = 64,   
  383.   CAN2_RX1_IRQn               = 65,   
  384.   CAN2_SCE_IRQn               = 66,   
  385.   OTG_FS_IRQn                 = 67      
  386. #endif     
  387. } IRQn_Type;


  388. #include "core_cm3.h"
  389. #include "system_stm32f10x.h"
  390. #include



  391. typedef int32_t  s32;
  392. typedef int16_t s16;
  393. typedef int8_t  s8;

  394. typedef const int32_t sc32;  
  395. typedef const int16_t sc16;  
  396. typedef const int8_t sc8;  

  397. typedef __IO int32_t  vs32;
  398. typedef __IO int16_t  vs16;
  399. typedef __IO int8_t   vs8;

  400. typedef __I int32_t vsc32;  
  401. typedef __I int16_t vsc16;  
  402. typedef __I int8_t vsc8;  

  403. typedef uint32_t  u32;
  404. typedef uint16_t u16;
  405. typedef uint8_t  u8;

  406. typedef const uint32_t uc32;  
  407. typedef const uint16_t uc16;  
  408. typedef const uint8_t uc8;  

  409. typedef __IO uint32_t  vu32;
  410. typedef __IO uint16_t vu16;
  411. typedef __IO uint8_t  vu8;

  412. typedef __I uint32_t vuc32;  
  413. typedef __I uint16_t vuc16;  
  414. typedef __I uint8_t vuc8;  

  415. typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;

  416. typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
  417. #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))

  418. typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;

  419. #define HSEStartUp_TimeOut   HSE_STARTUP_TIMEOUT
  420. #define HSE_Value            HSE_VALUE
  421. #define HSI_Value            HSI_VALUE

  422.   


  423. typedef struct
  424. {
  425.   __IO uint32_t SR;
  426.   __IO uint32_t CR1;
  427.   __IO uint32_t CR2;
  428.   __IO uint32_t SMPR1;
  429.   __IO uint32_t SMPR2;
  430.   __IO uint32_t JOFR1;
  431.   __IO uint32_t JOFR2;
  432.   __IO uint32_t JOFR3;
  433.   __IO uint32_t JOFR4;
  434.   __IO uint32_t HTR;
  435.   __IO uint32_t LTR;
  436.   __IO uint32_t SQR1;
  437.   __IO uint32_t SQR2;
  438.   __IO uint32_t SQR3;
  439.   __IO uint32_t JSQR;
  440.   __IO uint32_t JDR1;
  441.   __IO uint32_t JDR2;
  442.   __IO uint32_t JDR3;
  443.   __IO uint32_t JDR4;
  444.   __IO uint32_t DR;
  445. } ADC_TypeDef;


  446. typedef struct
  447. {
  448.   uint32_t  RESERVED0;
  449.   __IO uint16_t DR1;
  450.   uint16_t  RESERVED1;
  451.   __IO uint16_t DR2;
  452.   uint16_t  RESERVED2;
  453.   __IO uint16_t DR3;
  454.   uint16_t  RESERVED3;
  455.   __IO uint16_t DR4;
  456.   uint16_t  RESERVED4;
  457.   __IO uint16_t DR5;
  458.   uint16_t  RESERVED5;
  459.   __IO uint16_t DR6;
  460.   uint16_t  RESERVED6;
  461.   __IO uint16_t DR7;
  462.   uint16_t  RESERVED7;
  463.   __IO uint16_t DR8;
  464.   uint16_t  RESERVED8;
  465.   __IO uint16_t DR9;
  466.   uint16_t  RESERVED9;
  467.   __IO uint16_t DR10;
  468.   uint16_t  RESERVED10;
  469.   __IO uint16_t RTCCR;
  470.   uint16_t  RESERVED11;
  471.   __IO uint16_t CR;
  472.   uint16_t  RESERVED12;
  473.   __IO uint16_t CSR;
  474.   uint16_t  RESERVED13[5];
  475.   __IO uint16_t DR11;
  476.   uint16_t  RESERVED14;
  477.   __IO uint16_t DR12;
  478.   uint16_t  RESERVED15;
  479.   __IO uint16_t DR13;
  480.   uint16_t  RESERVED16;
  481.   __IO uint16_t DR14;
  482.   uint16_t  RESERVED17;
  483.   __IO uint16_t DR15;
  484.   uint16_t  RESERVED18;
  485.   __IO uint16_t DR16;
  486.   uint16_t  RESERVED19;
  487.   __IO uint16_t DR17;
  488.   uint16_t  RESERVED20;
  489.   __IO uint16_t DR18;
  490.   uint16_t  RESERVED21;
  491.   __IO uint16_t DR19;
  492.   uint16_t  RESERVED22;
  493.   __IO uint16_t DR20;
  494.   uint16_t  RESERVED23;
  495.   __IO uint16_t DR21;
  496.   uint16_t  RESERVED24;
  497.   __IO uint16_t DR22;
  498.   uint16_t  RESERVED25;
  499.   __IO uint16_t DR23;
  500.   uint16_t  RESERVED26;
  501.   __IO uint16_t DR24;
  502.   uint16_t  RESERVED27;
  503.   __IO uint16_t DR25;
  504.   uint16_t  RESERVED28;
  505.   __IO uint16_t DR26;
  506.   uint16_t  RESERVED29;
  507.   __IO uint16_t DR27;
  508.   uint16_t  RESERVED30;
  509.   __IO uint16_t DR28;
  510.   uint16_t  RESERVED31;
  511.   __IO uint16_t DR29;
  512.   uint16_t  RESERVED32;
  513.   __IO uint16_t DR30;
  514.   uint16_t  RESERVED33;
  515.   __IO uint16_t DR31;
  516.   uint16_t  RESERVED34;
  517.   __IO uint16_t DR32;
  518.   uint16_t  RESERVED35;
  519.   __IO uint16_t DR33;
  520.   uint16_t  RESERVED36;
  521.   __IO uint16_t DR34;
  522.   uint16_t  RESERVED37;
  523.   __IO uint16_t DR35;
  524.   uint16_t  RESERVED38;
  525.   __IO uint16_t DR36;
  526.   uint16_t  RESERVED39;
  527.   __IO uint16_t DR37;
  528.   uint16_t  RESERVED40;
  529.   __IO uint16_t DR38;
  530.   uint16_t  RESERVED41;
  531.   __IO uint16_t DR39;
  532.   uint16_t  RESERVED42;
  533.   __IO uint16_t DR40;
  534.   uint16_t  RESERVED43;
  535.   __IO uint16_t DR41;
  536.   uint16_t  RESERVED44;
  537.   __IO uint16_t DR42;
  538.   uint16_t  RESERVED45;   
  539. } BKP_TypeDef;
  540.   

  541. typedef struct
  542. {
  543.   __IO uint32_t TIR;
  544.   __IO uint32_t TDTR;
  545.   __IO uint32_t TDLR;
  546.   __IO uint32_t TDHR;
  547. } CAN_TxMailBox_TypeDef;

  548.   
  549. typedef struct
  550. {
  551.   __IO uint32_t RIR;
  552.   __IO uint32_t RDTR;
  553.   __IO uint32_t RDLR;
  554.   __IO uint32_t RDHR;
  555. } CAN_FIFOMailBox_TypeDef;

  556.   
  557. typedef struct
  558. {
  559.   __IO uint32_t FR1;
  560.   __IO uint32_t FR2;
  561. } CAN_FilterRegister_TypeDef;

  562.   
  563. typedef struct
  564. {
  565.   __IO uint32_t MCR;
  566.   __IO uint32_t MSR;
  567.   __IO uint32_t TSR;
  568.   __IO uint32_t RF0R;
  569.   __IO uint32_t RF1R;
  570.   __IO uint32_t IER;
  571.   __IO uint32_t ESR;
  572.   __IO uint32_t BTR;
  573.   uint32_t  RESERVED0[88];
  574.   CAN_TxMailBox_TypeDef sTxMailBox[3];
  575.   CAN_FIFOMailBox_TypeDef sFIFOMailBox[2];
  576.   uint32_t  RESERVED1[12];
  577.   __IO uint32_t FMR;
  578.   __IO uint32_t FM1R;
  579.   uint32_t  RESERVED2;
  580.   __IO uint32_t FS1R;
  581.   uint32_t  RESERVED3;
  582.   __IO uint32_t FFA1R;
  583.   uint32_t  RESERVED4;
  584.   __IO uint32_t FA1R;
  585.   uint32_t  RESERVED5[8];
  586. #ifndef STM32F10X_CL
  587.   CAN_FilterRegister_TypeDef sFilterRegister[14];
  588. #else
  589.   CAN_FilterRegister_TypeDef sFilterRegister[28];
  590. #endif  
  591. } CAN_TypeDef;

  592. typedef struct
  593. {
  594.   __IO uint32_t CFGR;
  595.   __IO uint32_t OAR;
  596.   __IO uint32_t PRES;
  597.   __IO uint32_t ESR;
  598.   __IO uint32_t CSR;
  599.   __IO uint32_t TXD;
  600.   __IO uint32_t RXD;  
  601. } CEC_TypeDef;


  602. typedef struct
  603. {
  604.   __IO uint32_t DR;
  605.   __IO uint8_t  IDR;
  606.   uint8_t   RESERVED0;
  607.   uint16_t  RESERVED1;
  608.   __IO uint32_t CR;
  609. } CRC_TypeDef;


  610. typedef struct
  611. {
  612.   __IO uint32_t CR;
  613.   __IO uint32_t SWTRIGR;
  614.   __IO uint32_t DHR12R1;
  615.   __IO uint32_t DHR12L1;
  616.   __IO uint32_t DHR8R1;
  617.   __IO uint32_t DHR12R2;
  618.   __IO uint32_t DHR12L2;
  619.   __IO uint32_t DHR8R2;
  620.   __IO uint32_t DHR12RD;
  621.   __IO uint32_t DHR12LD;
  622.   __IO uint32_t DHR8RD;
  623.   __IO uint32_t DOR1;
  624.   __IO uint32_t DOR2;
  625. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  626.   __IO uint32_t SR;
  627. #endif
  628. } DAC_TypeDef;


  629. typedef struct
  630. {
  631.   __IO uint32_t IDCODE;
  632.   __IO uint32_t CR;
  633. }DBGMCU_TypeDef;


  634. typedef struct
  635. {
  636.   __IO uint32_t CCR;
  637.   __IO uint32_t CNDTR;
  638.   __IO uint32_t CPAR;
  639.   __IO uint32_t CMAR;
  640. } DMA_Channel_TypeDef;

  641. typedef struct
  642. {
  643.   __IO uint32_t ISR;
  644.   __IO uint32_t IFCR;
  645. } DMA_TypeDef;


  646. typedef struct
  647. {
  648.   __IO uint32_t MACCR;
  649.   __IO uint32_t MACFFR;
  650.   __IO uint32_t MACHTHR;
  651.   __IO uint32_t MACHTLR;
  652.   __IO uint32_t MACMIIAR;
  653.   __IO uint32_t MACMIIDR;
  654.   __IO uint32_t MACFCR;
  655.   __IO uint32_t MACVLANTR;            
  656.        uint32_t RESERVED0[2];
  657.   __IO uint32_t MACRWUFFR;            
  658.   __IO uint32_t MACPMTCSR;
  659.        uint32_t RESERVED1[2];
  660.   __IO uint32_t MACSR;               
  661.   __IO uint32_t MACIMR;
  662.   __IO uint32_t MACA0HR;
  663.   __IO uint32_t MACA0LR;
  664.   __IO uint32_t MACA1HR;
  665.   __IO uint32_t MACA1LR;
  666.   __IO uint32_t MACA2HR;
  667.   __IO uint32_t MACA2LR;
  668.   __IO uint32_t MACA3HR;
  669.   __IO uint32_t MACA3LR;              
  670.        uint32_t RESERVED2[40];
  671.   __IO uint32_t MMCCR;               
  672.   __IO uint32_t MMCRIR;
  673.   __IO uint32_t MMCTIR;
  674.   __IO uint32_t MMCRIMR;
  675.   __IO uint32_t MMCTIMR;              
  676.        uint32_t RESERVED3[14];
  677.   __IO uint32_t MMCTGFSCCR;            
  678.   __IO uint32_t MMCTGFMSCCR;
  679.        uint32_t RESERVED4[5];
  680.   __IO uint32_t MMCTGFCR;
  681.        uint32_t RESERVED5[10];
  682.   __IO uint32_t MMCRFCECR;
  683.   __IO uint32_t MMCRFAECR;
  684.        uint32_t RESERVED6[10];
  685.   __IO uint32_t MMCRGUFCR;
  686.        uint32_t RESERVED7[334];
  687.   __IO uint32_t PTPTSCR;
  688.   __IO uint32_t PTPSSIR;
  689.   __IO uint32_t PTPTSHR;
  690.   __IO uint32_t PTPTSLR;
  691.   __IO uint32_t PTPTSHUR;
  692.   __IO uint32_t PTPTSLUR;
  693.   __IO uint32_t PTPTSAR;
  694.   __IO uint32_t PTPTTHR;
  695.   __IO uint32_t PTPTTLR;
  696.        uint32_t RESERVED8[567];
  697.   __IO uint32_t DMABMR;
  698.   __IO uint32_t DMATPDR;
  699.   __IO uint32_t DMARPDR;
  700.   __IO uint32_t DMARDLAR;
  701.   __IO uint32_t DMATDLAR;
  702.   __IO uint32_t DMASR;
  703.   __IO uint32_t DMAOMR;
  704.   __IO uint32_t DMAIER;
  705.   __IO uint32_t DMAMFBOCR;
  706.        uint32_t RESERVED9[9];
  707.   __IO uint32_t DMACHTDR;
  708.   __IO uint32_t DMACHRDR;
  709.   __IO uint32_t DMACHTBAR;
  710.   __IO uint32_t DMACHRBAR;
  711. } ETH_TypeDef;


  712. typedef struct
  713. {
  714.   __IO uint32_t IMR;
  715.   __IO uint32_t EMR;
  716.   __IO uint32_t RTSR;
  717.   __IO uint32_t FTSR;
  718.   __IO uint32_t SWIER;
  719.   __IO uint32_t PR;
  720. } EXTI_TypeDef;


  721. typedef struct
  722. {
  723.   __IO uint32_t ACR;
  724.   __IO uint32_t KEYR;
  725.   __IO uint32_t OPTKEYR;
  726.   __IO uint32_t SR;
  727.   __IO uint32_t CR;
  728.   __IO uint32_t AR;
  729.   __IO uint32_t RESERVED;
  730.   __IO uint32_t OBR;
  731.   __IO uint32_t WRPR;
  732. #ifdef STM32F10X_XL
  733.   uint32_t RESERVED1[8];
  734.   __IO uint32_t KEYR2;
  735.   uint32_t RESERVED2;   
  736.   __IO uint32_t SR2;
  737.   __IO uint32_t CR2;
  738.   __IO uint32_t AR2;
  739. #endif  
  740. } FLASH_TypeDef;

  741.   
  742. typedef struct
  743. {
  744.   __IO uint16_t RDP;
  745.   __IO uint16_t USER;
  746.   __IO uint16_t Data0;
  747.   __IO uint16_t Data1;
  748.   __IO uint16_t WRP0;
  749.   __IO uint16_t WRP1;
  750.   __IO uint16_t WRP2;
  751.   __IO uint16_t WRP3;
  752. } OB_TypeDef;


  753. typedef struct
  754. {
  755.   __IO uint32_t BTCR[8];   
  756. } FSMC_Bank1_TypeDef;

  757.   
  758. typedef struct
  759. {
  760.   __IO uint32_t BWTR[7];
  761. } FSMC_Bank1E_TypeDef;

  762.   
  763. typedef struct
  764. {
  765.   __IO uint32_t PCR2;
  766.   __IO uint32_t SR2;
  767.   __IO uint32_t PMEM2;
  768.   __IO uint32_t PATT2;
  769.   uint32_t  RESERVED0;   
  770.   __IO uint32_t ECCR2;
  771. } FSMC_Bank2_TypeDef;  

  772.   
  773. typedef struct
  774. {
  775.   __IO uint32_t PCR3;
  776.   __IO uint32_t SR3;
  777.   __IO uint32_t PMEM3;
  778.   __IO uint32_t PATT3;
  779.   uint32_t  RESERVED0;   
  780.   __IO uint32_t ECCR3;
  781. } FSMC_Bank3_TypeDef;

  782.   
  783. typedef struct
  784. {
  785.   __IO uint32_t PCR4;
  786.   __IO uint32_t SR4;
  787.   __IO uint32_t PMEM4;
  788.   __IO uint32_t PATT4;
  789.   __IO uint32_t PIO4;
  790. } FSMC_Bank4_TypeDef;


  791. typedef struct
  792. {
  793.   __IO uint32_t CRL;
  794.   __IO uint32_t CRH;
  795.   __IO uint32_t IDR;
  796.   __IO uint32_t ODR;
  797.   __IO uint32_t BSRR;
  798.   __IO uint32_t BRR;
  799.   __IO uint32_t LCKR;
  800. } GPIO_TypeDef;


  801. typedef struct
  802. {
  803.   __IO uint32_t EVCR;
  804.   __IO uint32_t MAPR;
  805.   __IO uint32_t EXTICR[4];
  806.   uint32_t RESERVED0;
  807.   __IO uint32_t MAPR2;  
  808. } AFIO_TypeDef;

  809. typedef struct
  810. {
  811.   __IO uint16_t CR1;
  812.   uint16_t  RESERVED0;
  813.   __IO uint16_t CR2;
  814.   uint16_t  RESERVED1;
  815.   __IO uint16_t OAR1;
  816.   uint16_t  RESERVED2;
  817.   __IO uint16_t OAR2;
  818.   uint16_t  RESERVED3;
  819.   __IO uint16_t DR;
  820.   uint16_t  RESERVED4;
  821.   __IO uint16_t SR1;
  822.   uint16_t  RESERVED5;
  823.   __IO uint16_t SR2;
  824.   uint16_t  RESERVED6;
  825.   __IO uint16_t CCR;
  826.   uint16_t  RESERVED7;
  827.   __IO uint16_t TRISE;
  828.   uint16_t  RESERVED8;
  829. } I2C_TypeDef;


  830. typedef struct
  831. {
  832.   __IO uint32_t KR;
  833.   __IO uint32_t PR;
  834.   __IO uint32_t RLR;
  835.   __IO uint32_t SR;
  836. } IWDG_TypeDef;


  837. typedef struct
  838. {
  839.   __IO uint32_t CR;
  840.   __IO uint32_t CSR;
  841. } PWR_TypeDef;


  842. typedef struct
  843. {
  844.   __IO uint32_t CR;
  845.   __IO uint32_t CFGR;
  846.   __IO uint32_t CIR;
  847.   __IO uint32_t APB2RSTR;
  848.   __IO uint32_t APB1RSTR;
  849.   __IO uint32_t AHBENR;
  850.   __IO uint32_t APB2ENR;
  851.   __IO uint32_t APB1ENR;
  852.   __IO uint32_t BDCR;
  853.   __IO uint32_t CSR;

  854. #ifdef STM32F10X_CL  
  855.   __IO uint32_t AHBRSTR;
  856.   __IO uint32_t CFGR2;
  857. #endif  

  858. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)   
  859.   uint32_t RESERVED0;
  860.   __IO uint32_t CFGR2;
  861. #endif  
  862. } RCC_TypeDef;


  863. typedef struct
  864. {
  865.   __IO uint16_t CRH;
  866.   uint16_t  RESERVED0;
  867.   __IO uint16_t CRL;
  868.   uint16_t  RESERVED1;
  869.   __IO uint16_t PRLH;
  870.   uint16_t  RESERVED2;
  871.   __IO uint16_t PRLL;
  872.   uint16_t  RESERVED3;
  873.   __IO uint16_t DIVH;
  874.   uint16_t  RESERVED4;
  875.   __IO uint16_t DIVL;
  876.   uint16_t  RESERVED5;
  877.   __IO uint16_t CNTH;
  878.   uint16_t  RESERVED6;
  879.   __IO uint16_t CNTL;
  880.   uint16_t  RESERVED7;
  881.   __IO uint16_t ALRH;
  882.   uint16_t  RESERVED8;
  883.   __IO uint16_t ALRL;
  884.   uint16_t  RESERVED9;
  885. } RTC_TypeDef;


  886. typedef struct
  887. {
  888.   __IO uint32_t POWER;
  889.   __IO uint32_t CLKCR;
  890.   __IO uint32_t ARG;
  891.   __IO uint32_t CMD;
  892.   __I uint32_t RESPCMD;
  893.   __I uint32_t RESP1;
  894.   __I uint32_t RESP2;
  895.   __I uint32_t RESP3;
  896.   __I uint32_t RESP4;
  897.   __IO uint32_t DTIMER;
  898.   __IO uint32_t DLEN;
  899.   __IO uint32_t DCTRL;
  900.   __I uint32_t DCOUNT;
  901.   __I uint32_t STA;
  902.   __IO uint32_t ICR;
  903.   __IO uint32_t MASK;
  904.   uint32_t  RESERVED0[2];
  905.   __I uint32_t FIFOCNT;
  906.   uint32_t  RESERVED1[13];
  907.   __IO uint32_t FIFO;
  908. } SDIO_TypeDef;


  909. typedef struct
  910. {
  911.   __IO uint16_t CR1;
  912.   uint16_t  RESERVED0;
  913.   __IO uint16_t CR2;
  914.   uint16_t  RESERVED1;
  915.   __IO uint16_t SR;
  916.   uint16_t  RESERVED2;
  917.   __IO uint16_t DR;
  918.   uint16_t  RESERVED3;
  919.   __IO uint16_t CRCPR;
  920.   uint16_t  RESERVED4;
  921.   __IO uint16_t RXCRCR;
  922.   uint16_t  RESERVED5;
  923.   __IO uint16_t TXCRCR;
  924.   uint16_t  RESERVED6;
  925.   __IO uint16_t I2SCFGR;
  926.   uint16_t  RESERVED7;
  927.   __IO uint16_t I2SPR;
  928.   uint16_t  RESERVED8;  
  929. } SPI_TypeDef;


  930. typedef struct
  931. {
  932.   __IO uint16_t CR1;
  933.   uint16_t  RESERVED0;
  934.   __IO uint16_t CR2;
  935.   uint16_t  RESERVED1;
  936.   __IO uint16_t SMCR;
  937.   uint16_t  RESERVED2;
  938.   __IO uint16_t DIER;
  939.   uint16_t  RESERVED3;
  940.   __IO uint16_t SR;
  941.   uint16_t  RESERVED4;
  942.   __IO uint16_t EGR;
  943.   uint16_t  RESERVED5;
  944.   __IO uint16_t CCMR1;
  945.   uint16_t  RESERVED6;
  946.   __IO uint16_t CCMR2;
  947.   uint16_t  RESERVED7;
  948.   __IO uint16_t CCER;
  949.   uint16_t  RESERVED8;
  950.   __IO uint16_t CNT;
  951.   uint16_t  RESERVED9;
  952.   __IO uint16_t PSC;
  953.   uint16_t  RESERVED10;
  954.   __IO uint16_t ARR;
  955.   uint16_t  RESERVED11;
  956.   __IO uint16_t RCR;
  957.   uint16_t  RESERVED12;
  958.   __IO uint16_t CCR1;
  959.   uint16_t  RESERVED13;
  960.   __IO uint16_t CCR2;
  961.   uint16_t  RESERVED14;
  962.   __IO uint16_t CCR3;
  963.   uint16_t  RESERVED15;
  964.   __IO uint16_t CCR4;
  965.   uint16_t  RESERVED16;
  966.   __IO uint16_t BDTR;
  967.   uint16_t  RESERVED17;
  968.   __IO uint16_t DCR;
  969.   uint16_t  RESERVED18;
  970.   __IO uint16_t DMAR;
  971.   uint16_t  RESERVED19;
  972. } TIM_TypeDef;


  973. typedef struct
  974. {
  975.   __IO uint16_t SR;
  976.   uint16_t  RESERVED0;
  977.   __IO uint16_t DR;
  978.   uint16_t  RESERVED1;
  979.   __IO uint16_t BRR;
  980.   uint16_t  RESERVED2;
  981.   __IO uint16_t CR1;
  982.   uint16_t  RESERVED3;
  983.   __IO uint16_t CR2;
  984.   uint16_t  RESERVED4;
  985.   __IO uint16_t CR3;
  986.   uint16_t  RESERVED5;
  987.   __IO uint16_t GTPR;
  988.   uint16_t  RESERVED6;
  989. } USART_TypeDef;


  990. typedef struct
  991. {
  992.   __IO uint32_t CR;
  993.   __IO uint32_t CFR;
  994.   __IO uint32_t SR;
  995. } WWDG_TypeDef;

  996.   


  997. #define FLASH_BASE            ((uint32_t)0x08000000)
  998. #define SRAM_BASE             ((uint32_t)0x20000000)
  999. #define PERIPH_BASE           ((uint32_t)0x40000000)

  1000. #define SRAM_BB_BASE          ((uint32_t)0x22000000)
  1001. #define PERIPH_BB_BASE        ((uint32_t)0x42000000)

  1002. #define FSMC_R_BASE           ((uint32_t)0xA0000000)

  1003. #define APB1PERIPH_BASE       PERIPH_BASE
  1004. #define APB2PERIPH_BASE       (PERIPH_BASE + 0x10000)
  1005. #define AHBPERIPH_BASE        (PERIPH_BASE + 0x20000)

  1006. #define TIM2_BASE             (APB1PERIPH_BASE + 0x0000)
  1007. #define TIM3_BASE             (APB1PERIPH_BASE + 0x0400)
  1008. #define TIM4_BASE             (APB1PERIPH_BASE + 0x0800)
  1009. #define TIM5_BASE             (APB1PERIPH_BASE + 0x0C00)
  1010. #define TIM6_BASE             (APB1PERIPH_BASE + 0x1000)
  1011. #define TIM7_BASE             (APB1PERIPH_BASE + 0x1400)
  1012. #define TIM12_BASE            (APB1PERIPH_BASE + 0x1800)
  1013. #define TIM13_BASE            (APB1PERIPH_BASE + 0x1C00)
  1014. #define TIM14_BASE            (APB1PERIPH_BASE + 0x2000)
  1015. #define RTC_BASE              (APB1PERIPH_BASE + 0x2800)
  1016. #define WWDG_BASE             (APB1PERIPH_BASE + 0x2C00)
  1017. #define IWDG_BASE             (APB1PERIPH_BASE + 0x3000)
  1018. #define SPI2_BASE             (APB1PERIPH_BASE + 0x3800)
  1019. #define SPI3_BASE             (APB1PERIPH_BASE + 0x3C00)
  1020. #define USART2_BASE           (APB1PERIPH_BASE + 0x4400)
  1021. #define USART3_BASE           (APB1PERIPH_BASE + 0x4800)
  1022. #define UART4_BASE            (APB1PERIPH_BASE + 0x4C00)
  1023. #define UART5_BASE            (APB1PERIPH_BASE + 0x5000)
  1024. #define I2C1_BASE             (APB1PERIPH_BASE + 0x5400)
  1025. #define I2C2_BASE             (APB1PERIPH_BASE + 0x5800)
  1026. #define CAN1_BASE             (APB1PERIPH_BASE + 0x6400)
  1027. #define CAN2_BASE             (APB1PERIPH_BASE + 0x6800)
  1028. #define BKP_BASE              (APB1PERIPH_BASE + 0x6C00)
  1029. #define PWR_BASE              (APB1PERIPH_BASE + 0x7000)
  1030. #define DAC_BASE              (APB1PERIPH_BASE + 0x7400)
  1031. #define CEC_BASE              (APB1PERIPH_BASE + 0x7800)

  1032. #define AFIO_BASE             (APB2PERIPH_BASE + 0x0000)
  1033. #define EXTI_BASE             (APB2PERIPH_BASE + 0x0400)
  1034. #define GPIOA_BASE            (APB2PERIPH_BASE + 0x0800)
  1035. #define GPIOB_BASE            (APB2PERIPH_BASE + 0x0C00)
  1036. #define GPIOC_BASE            (APB2PERIPH_BASE + 0x1000)
  1037. #define GPIOD_BASE            (APB2PERIPH_BASE + 0x1400)
  1038. #define GPIOE_BASE            (APB2PERIPH_BASE + 0x1800)
  1039. #define GPIOF_BASE            (APB2PERIPH_BASE + 0x1C00)
  1040. #define GPIOG_BASE            (APB2PERIPH_BASE + 0x2000)
  1041. #define ADC1_BASE             (APB2PERIPH_BASE + 0x2400)
  1042. #define ADC2_BASE             (APB2PERIPH_BASE + 0x2800)
  1043. #define TIM1_BASE             (APB2PERIPH_BASE + 0x2C00)
  1044. #define SPI1_BASE             (APB2PERIPH_BASE + 0x3000)
  1045. #define TIM8_BASE             (APB2PERIPH_BASE + 0x3400)
  1046. #define USART1_BASE           (APB2PERIPH_BASE + 0x3800)
  1047. #define ADC3_BASE             (APB2PERIPH_BASE + 0x3C00)
  1048. #define TIM15_BASE            (APB2PERIPH_BASE + 0x4000)
  1049. #define TIM16_BASE            (APB2PERIPH_BASE + 0x4400)
  1050. #define TIM17_BASE            (APB2PERIPH_BASE + 0x4800)
  1051. #define TIM9_BASE             (APB2PERIPH_BASE + 0x4C00)
  1052. #define TIM10_BASE            (APB2PERIPH_BASE + 0x5000)
  1053. #define TIM11_BASE            (APB2PERIPH_BASE + 0x5400)

  1054. #define SDIO_BASE             (PERIPH_BASE + 0x18000)

  1055. #define DMA1_BASE             (AHBPERIPH_BASE + 0x0000)
  1056. #define DMA1_Channel1_BASE    (AHBPERIPH_BASE + 0x0008)
  1057. #define DMA1_Channel2_BASE    (AHBPERIPH_BASE + 0x001C)
  1058. #define DMA1_Channel3_BASE    (AHBPERIPH_BASE + 0x0030)
  1059. #define DMA1_Channel4_BASE    (AHBPERIPH_BASE + 0x0044)
  1060. #define DMA1_Channel5_BASE    (AHBPERIPH_BASE + 0x0058)
  1061. #define DMA1_Channel6_BASE    (AHBPERIPH_BASE + 0x006C)
  1062. #define DMA1_Channel7_BASE    (AHBPERIPH_BASE + 0x0080)
  1063. #define DMA2_BASE             (AHBPERIPH_BASE + 0x0400)
  1064. #define DMA2_Channel1_BASE    (AHBPERIPH_BASE + 0x0408)
  1065. #define DMA2_Channel2_BASE    (AHBPERIPH_BASE + 0x041C)
  1066. #define DMA2_Channel3_BASE    (AHBPERIPH_BASE + 0x0430)
  1067. #define DMA2_Channel4_BASE    (AHBPERIPH_BASE + 0x0444)
  1068. #define DMA2_Channel5_BASE    (AHBPERIPH_BASE + 0x0458)
  1069. #define RCC_BASE              (AHBPERIPH_BASE + 0x1000)
  1070. #define CRC_BASE              (AHBPERIPH_BASE + 0x3000)

  1071. #define FLASH_R_BASE          (AHBPERIPH_BASE + 0x2000)
  1072. #define OB_BASE               ((uint32_t)0x1FFFF800)   

  1073. #define ETH_BASE              (AHBPERIPH_BASE + 0x8000)
  1074. #define ETH_MAC_BASE          (ETH_BASE)
  1075. #define ETH_MMC_BASE          (ETH_BASE + 0x0100)
  1076. #define ETH_PTP_BASE          (ETH_BASE + 0x0700)
  1077. #define ETH_DMA_BASE          (ETH_BASE + 0x1000)

  1078. #define FSMC_Bank1_R_BASE     (FSMC_R_BASE + 0x0000)
  1079. #define FSMC_Bank1E_R_BASE    (FSMC_R_BASE + 0x0104)
  1080. #define FSMC_Bank2_R_BASE     (FSMC_R_BASE + 0x0060)
  1081. #define FSMC_Bank3_R_BASE     (FSMC_R_BASE + 0x0080)
  1082. #define FSMC_Bank4_R_BASE     (FSMC_R_BASE + 0x00A0)

  1083. #define DBGMCU_BASE          ((uint32_t)0xE0042000)

  1084.   


  1085. #define TIM2                ((TIM_TypeDef *) TIM2_BASE)
  1086. #define TIM3                ((TIM_TypeDef *) TIM3_BASE)
  1087. #define TIM4                ((TIM_TypeDef *) TIM4_BASE)
  1088. #define TIM5                ((TIM_TypeDef *) TIM5_BASE)
  1089. #define TIM6                ((TIM_TypeDef *) TIM6_BASE)
  1090. #define TIM7                ((TIM_TypeDef *) TIM7_BASE)
  1091. #define TIM12               ((TIM_TypeDef *) TIM12_BASE)
  1092. #define TIM13               ((TIM_TypeDef *) TIM13_BASE)
  1093. #define TIM14               ((TIM_TypeDef *) TIM14_BASE)
  1094. #define RTC                 ((RTC_TypeDef *) RTC_BASE)
  1095. #define WWDG                ((WWDG_TypeDef *) WWDG_BASE)
  1096. #define IWDG                ((IWDG_TypeDef *) IWDG_BASE)
  1097. #define SPI2                ((SPI_TypeDef *) SPI2_BASE)
  1098. #define SPI3                ((SPI_TypeDef *) SPI3_BASE)
  1099. #define USART2              ((USART_TypeDef *) USART2_BASE)
  1100. #define USART3              ((USART_TypeDef *) USART3_BASE)
  1101. #define UART4               ((USART_TypeDef *) UART4_BASE)
  1102. #define UART5               ((USART_TypeDef *) UART5_BASE)
  1103. #define I2C1                ((I2C_TypeDef *) I2C1_BASE)
  1104. #define I2C2                ((I2C_TypeDef *) I2C2_BASE)
  1105. #define CAN1                ((CAN_TypeDef *) CAN1_BASE)
  1106. #define CAN2                ((CAN_TypeDef *) CAN2_BASE)
  1107. #define BKP                 ((BKP_TypeDef *) BKP_BASE)
  1108. #define PWR                 ((PWR_TypeDef *) PWR_BASE)
  1109. #define DAC                 ((DAC_TypeDef *) DAC_BASE)
  1110. #define CEC                 ((CEC_TypeDef *) CEC_BASE)
  1111. #define AFIO                ((AFIO_TypeDef *) AFIO_BASE)
  1112. #define EXTI                ((EXTI_TypeDef *) EXTI_BASE)
  1113. #define GPIOA               ((GPIO_TypeDef *) GPIOA_BASE)
  1114. #define GPIOB               ((GPIO_TypeDef *) GPIOB_BASE)
  1115. #define GPIOC               ((GPIO_TypeDef *) GPIOC_BASE)
  1116. #define GPIOD               ((GPIO_TypeDef *) GPIOD_BASE)
  1117. #define GPIOE               ((GPIO_TypeDef *) GPIOE_BASE)
  1118. #define GPIOF               ((GPIO_TypeDef *) GPIOF_BASE)
  1119. #define GPIOG               ((GPIO_TypeDef *) GPIOG_BASE)
  1120. #define ADC1                ((ADC_TypeDef *) ADC1_BASE)
  1121. #define ADC2                ((ADC_TypeDef *) ADC2_BASE)
  1122. #define TIM1                ((TIM_TypeDef *) TIM1_BASE)
  1123. #define SPI1                ((SPI_TypeDef *) SPI1_BASE)
  1124. #define TIM8                ((TIM_TypeDef *) TIM8_BASE)
  1125. #define USART1              ((USART_TypeDef *) USART1_BASE)
  1126. #define ADC3                ((ADC_TypeDef *) ADC3_BASE)
  1127. #define TIM15               ((TIM_TypeDef *) TIM15_BASE)
  1128. #define TIM16               ((TIM_TypeDef *) TIM16_BASE)
  1129. #define TIM17               ((TIM_TypeDef *) TIM17_BASE)
  1130. #define TIM9                ((TIM_TypeDef *) TIM9_BASE)
  1131. #define TIM10               ((TIM_TypeDef *) TIM10_BASE)
  1132. #define TIM11               ((TIM_TypeDef *) TIM11_BASE)
  1133. #define SDIO                ((SDIO_TypeDef *) SDIO_BASE)
  1134. #define DMA1                ((DMA_TypeDef *) DMA1_BASE)
  1135. #define DMA2                ((DMA_TypeDef *) DMA2_BASE)
  1136. #define DMA1_Channel1       ((DMA_Channel_TypeDef *) DMA1_Channel1_BASE)
  1137. #define DMA1_Channel2       ((DMA_Channel_TypeDef *) DMA1_Channel2_BASE)
  1138. #define DMA1_Channel3       ((DMA_Channel_TypeDef *) DMA1_Channel3_BASE)
  1139. #define DMA1_Channel4       ((DMA_Channel_TypeDef *) DMA1_Channel4_BASE)
  1140. #define DMA1_Channel5       ((DMA_Channel_TypeDef *) DMA1_Channel5_BASE)
  1141. #define DMA1_Channel6       ((DMA_Channel_TypeDef *) DMA1_Channel6_BASE)
  1142. #define DMA1_Channel7       ((DMA_Channel_TypeDef *) DMA1_Channel7_BASE)
  1143. #define DMA2_Channel1       ((DMA_Channel_TypeDef *) DMA2_Channel1_BASE)
  1144. #define DMA2_Channel2       ((DMA_Channel_TypeDef *) DMA2_Channel2_BASE)
  1145. #define DMA2_Channel3       ((DMA_Channel_TypeDef *) DMA2_Channel3_BASE)
  1146. #define DMA2_Channel4       ((DMA_Channel_TypeDef *) DMA2_Channel4_BASE)
  1147. #define DMA2_Channel5       ((DMA_Channel_TypeDef *) DMA2_Channel5_BASE)
  1148. #define RCC                 ((RCC_TypeDef *) RCC_BASE)
  1149. #define CRC                 ((CRC_TypeDef *) CRC_BASE)
  1150. #define FLASH               ((FLASH_TypeDef *) FLASH_R_BASE)
  1151. #define OB                  ((OB_TypeDef *) OB_BASE)
  1152. #define ETH                 ((ETH_TypeDef *) ETH_BASE)
  1153. #define FSMC_Bank1          ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE)
  1154. #define FSMC_Bank1E         ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE)
  1155. #define FSMC_Bank2          ((FSMC_Bank2_TypeDef *) FSMC_Bank2_R_BASE)
  1156. #define FSMC_Bank3          ((FSMC_Bank3_TypeDef *) FSMC_Bank3_R_BASE)
  1157. #define FSMC_Bank4          ((FSMC_Bank4_TypeDef *) FSMC_Bank4_R_BASE)
  1158. #define DBGMCU              ((DBGMCU_TypeDef *) DBGMCU_BASE)


  1159.   

  1160.    


  1161. #define  CRC_DR_DR                           ((uint32_t)0xFFFFFFFF)


  1162. #define  CRC_IDR_IDR                         ((uint8_t)0xFF)        


  1163. #define  CRC_CR_RESET                        ((uint8_t)0x01)        


  1164. #define  PWR_CR_LPDS                         ((uint16_t)0x0001)   
  1165. #define  PWR_CR_PDDS                         ((uint16_t)0x0002)   
  1166. #define  PWR_CR_CWUF                         ((uint16_t)0x0004)   
  1167. #define  PWR_CR_CSBF                         ((uint16_t)0x0008)   
  1168. #define  PWR_CR_PVDE                         ((uint16_t)0x0010)   

  1169. #define  PWR_CR_PLS                          ((uint16_t)0x00E0)   
  1170. #define  PWR_CR_PLS_0                        ((uint16_t)0x0020)   
  1171. #define  PWR_CR_PLS_1                        ((uint16_t)0x0040)   
  1172. #define  PWR_CR_PLS_2                        ((uint16_t)0x0080)   

  1173. #define  PWR_CR_PLS_2V2                      ((uint16_t)0x0000)   
  1174. #define  PWR_CR_PLS_2V3                      ((uint16_t)0x0020)   
  1175. #define  PWR_CR_PLS_2V4                      ((uint16_t)0x0040)   
  1176. #define  PWR_CR_PLS_2V5                      ((uint16_t)0x0060)   
  1177. #define  PWR_CR_PLS_2V6                      ((uint16_t)0x0080)   
  1178. #define  PWR_CR_PLS_2V7                      ((uint16_t)0x00A0)   
  1179. #define  PWR_CR_PLS_2V8                      ((uint16_t)0x00C0)   
  1180. #define  PWR_CR_PLS_2V9                      ((uint16_t)0x00E0)   

  1181. #define  PWR_CR_DBP                          ((uint16_t)0x0100)   


  1182. #define  PWR_CSR_WUF                         ((uint16_t)0x0001)   
  1183. #define  PWR_CSR_SBF                         ((uint16_t)0x0002)   
  1184. #define  PWR_CSR_PVDO                        ((uint16_t)0x0004)   
  1185. #define  PWR_CSR_EWUP                        ((uint16_t)0x0100)   


  1186. #define  BKP_DR1_D                           ((uint16_t)0xFFFF)   

  1187. #define  BKP_DR2_D                           ((uint16_t)0xFFFF)   

  1188. #define  BKP_DR3_D                           ((uint16_t)0xFFFF)   

  1189. #define  BKP_DR4_D                           ((uint16_t)0xFFFF)   

  1190. #define  BKP_DR5_D                           ((uint16_t)0xFFFF)   

  1191. #define  BKP_DR6_D                           ((uint16_t)0xFFFF)   

  1192. #define  BKP_DR7_D                           ((uint16_t)0xFFFF)   

  1193. #define  BKP_DR8_D                           ((uint16_t)0xFFFF)   

  1194. #define  BKP_DR9_D                           ((uint16_t)0xFFFF)   

  1195. #define  BKP_DR10_D                          ((uint16_t)0xFFFF)   

  1196. #define  BKP_DR11_D                          ((uint16_t)0xFFFF)   

  1197. #define  BKP_DR12_D                          ((uint16_t)0xFFFF)   

  1198. #define  BKP_DR13_D                          ((uint16_t)0xFFFF)   

  1199. #define  BKP_DR14_D                          ((uint16_t)0xFFFF)   

  1200. #define  BKP_DR15_D                          ((uint16_t)0xFFFF)   

  1201. #define  BKP_DR16_D                          ((uint16_t)0xFFFF)   

  1202. #define  BKP_DR17_D                          ((uint16_t)0xFFFF)   

  1203. #define  BKP_DR18_D                          ((uint16_t)0xFFFF)   

  1204. #define  BKP_DR19_D                          ((uint16_t)0xFFFF)   

  1205. #define  BKP_DR20_D                          ((uint16_t)0xFFFF)   

  1206. #define  BKP_DR21_D                          ((uint16_t)0xFFFF)   

  1207. #define  BKP_DR22_D                          ((uint16_t)0xFFFF)   

  1208. #define  BKP_DR23_D                          ((uint16_t)0xFFFF)   

  1209. #define  BKP_DR24_D                          ((uint16_t)0xFFFF)   

  1210. #define  BKP_DR25_D                          ((uint16_t)0xFFFF)   

  1211. #define  BKP_DR26_D                          ((uint16_t)0xFFFF)   

  1212. #define  BKP_DR27_D                          ((uint16_t)0xFFFF)   

  1213. #define  BKP_DR28_D                          ((uint16_t)0xFFFF)   

  1214. #define  BKP_DR29_D                          ((uint16_t)0xFFFF)   

  1215. #define  BKP_DR30_D                          ((uint16_t)0xFFFF)   

  1216. #define  BKP_DR31_D                          ((uint16_t)0xFFFF)   

  1217. #define  BKP_DR32_D                          ((uint16_t)0xFFFF)   

  1218. #define  BKP_DR33_D                          ((uint16_t)0xFFFF)   

  1219. #define  BKP_DR34_D                          ((uint16_t)0xFFFF)   

  1220. #define  BKP_DR35_D                          ((uint16_t)0xFFFF)   

  1221. #define  BKP_DR36_D                          ((uint16_t)0xFFFF)   

  1222. #define  BKP_DR37_D                          ((uint16_t)0xFFFF)   

  1223. #define  BKP_DR38_D                          ((uint16_t)0xFFFF)   

  1224. #define  BKP_DR39_D                          ((uint16_t)0xFFFF)   

  1225. #define  BKP_DR40_D                          ((uint16_t)0xFFFF)   

  1226. #define  BKP_DR41_D                          ((uint16_t)0xFFFF)   

  1227. #define  BKP_DR42_D                          ((uint16_t)0xFFFF)   

  1228. #define  BKP_RTCCR_CAL                       ((uint16_t)0x007F)   
  1229. #define  BKP_RTCCR_CCO                       ((uint16_t)0x0080)   
  1230. #define  BKP_RTCCR_ASOE                      ((uint16_t)0x0100)   
  1231. #define  BKP_RTCCR_ASOS                      ((uint16_t)0x0200)   

  1232. #define  BKP_CR_TPE                          ((uint8_t)0x01)        
  1233. #define  BKP_CR_TPAL                         ((uint8_t)0x02)        

  1234. #define  BKP_CSR_CTE                         ((uint16_t)0x0001)   
  1235. #define  BKP_CSR_CTI                         ((uint16_t)0x0002)   
  1236. #define  BKP_CSR_TPIE                        ((uint16_t)0x0004)   
  1237. #define  BKP_CSR_TEF                         ((uint16_t)0x0100)   
  1238. #define  BKP_CSR_TIF                         ((uint16_t)0x0200)   


  1239. #define  RCC_CR_HSION                        ((uint32_t)0x00000001)        
  1240. #define  RCC_CR_HSIRDY                       ((uint32_t)0x00000002)        
  1241. #define  RCC_CR_HSITRIM                      ((uint32_t)0x000000F8)        
  1242. #define  RCC_CR_HSICAL                       ((uint32_t)0x0000FF00)        
  1243. #define  RCC_CR_HSEON                        ((uint32_t)0x00010000)        
  1244. #define  RCC_CR_HSERDY                       ((uint32_t)0x00020000)        
  1245. #define  RCC_CR_HSEBYP                       ((uint32_t)0x00040000)        
  1246. #define  RCC_CR_CSSON                        ((uint32_t)0x00080000)        
  1247. #define  RCC_CR_PLLON                        ((uint32_t)0x01000000)        
  1248. #define  RCC_CR_PLLRDY                       ((uint32_t)0x02000000)        

  1249. #ifdef STM32F10X_CL
  1250. #define  RCC_CR_PLL2ON                       ((uint32_t)0x04000000)        
  1251. #define  RCC_CR_PLL2RDY                      ((uint32_t)0x08000000)        
  1252. #define  RCC_CR_PLL3ON                       ((uint32_t)0x10000000)        
  1253. #define  RCC_CR_PLL3RDY                      ((uint32_t)0x20000000)        
  1254. #endif

  1255. #define  RCC_CFGR_SW                         ((uint32_t)0x00000003)        
  1256. #define  RCC_CFGR_SW_0                       ((uint32_t)0x00000001)        
  1257. #define  RCC_CFGR_SW_1                       ((uint32_t)0x00000002)        

  1258. #define  RCC_CFGR_SW_HSI                     ((uint32_t)0x00000000)        
  1259. #define  RCC_CFGR_SW_HSE                     ((uint32_t)0x00000001)        
  1260. #define  RCC_CFGR_SW_PLL                     ((uint32_t)0x00000002)        

  1261. #define  RCC_CFGR_SWS                        ((uint32_t)0x0000000C)        
  1262. #define  RCC_CFGR_SWS_0                      ((uint32_t)0x00000004)        
  1263. #define  RCC_CFGR_SWS_1                      ((uint32_t)0x00000008)        

  1264. #define  RCC_CFGR_SWS_HSI                    ((uint32_t)0x00000000)        
  1265. #define  RCC_CFGR_SWS_HSE                    ((uint32_t)0x00000004)        
  1266. #define  RCC_CFGR_SWS_PLL                    ((uint32_t)0x00000008)        

  1267. #define  RCC_CFGR_HPRE                       ((uint32_t)0x000000F0)        
  1268. #define  RCC_CFGR_HPRE_0                     ((uint32_t)0x00000010)        
  1269. #define  RCC_CFGR_HPRE_1                     ((uint32_t)0x00000020)        
  1270. #define  RCC_CFGR_HPRE_2                     ((uint32_t)0x00000040)        
  1271. #define  RCC_CFGR_HPRE_3                     ((uint32_t)0x00000080)        

  1272. #define  RCC_CFGR_HPRE_DIV1                  ((uint32_t)0x00000000)        
  1273. #define  RCC_CFGR_HPRE_DIV2                  ((uint32_t)0x00000080)        
  1274. #define  RCC_CFGR_HPRE_DIV4                  ((uint32_t)0x00000090)        
  1275. #define  RCC_CFGR_HPRE_DIV8                  ((uint32_t)0x000000A0)        
  1276. #define  RCC_CFGR_HPRE_DIV16                 ((uint32_t)0x000000B0)        
  1277. #define  RCC_CFGR_HPRE_DIV64                 ((uint32_t)0x000000C0)        
  1278. #define  RCC_CFGR_HPRE_DIV128                ((uint32_t)0x000000D0)        
  1279. #define  RCC_CFGR_HPRE_DIV256                ((uint32_t)0x000000E0)        
  1280. #define  RCC_CFGR_HPRE_DIV512                ((uint32_t)0x000000F0)        

  1281. #define  RCC_CFGR_PPRE1                      ((uint32_t)0x00000700)        
  1282. #define  RCC_CFGR_PPRE1_0                    ((uint32_t)0x00000100)        
  1283. #define  RCC_CFGR_PPRE1_1                    ((uint32_t)0x00000200)        
  1284. #define  RCC_CFGR_PPRE1_2                    ((uint32_t)0x00000400)        

  1285. #define  RCC_CFGR_PPRE1_DIV1                 ((uint32_t)0x00000000)        
  1286. #define  RCC_CFGR_PPRE1_DIV2                 ((uint32_t)0x00000400)        
  1287. #define  RCC_CFGR_PPRE1_DIV4                 ((uint32_t)0x00000500)        
  1288. #define  RCC_CFGR_PPRE1_DIV8                 ((uint32_t)0x00000600)        
  1289. #define  RCC_CFGR_PPRE1_DIV16                ((uint32_t)0x00000700)        

  1290. #define  RCC_CFGR_PPRE2                      ((uint32_t)0x00003800)        
  1291. #define  RCC_CFGR_PPRE2_0                    ((uint32_t)0x00000800)        
  1292. #define  RCC_CFGR_PPRE2_1                    ((uint32_t)0x00001000)        
  1293. #define  RCC_CFGR_PPRE2_2                    ((uint32_t)0x00002000)        

  1294. #define  RCC_CFGR_PPRE2_DIV1                 ((uint32_t)0x00000000)        
  1295. #define  RCC_CFGR_PPRE2_DIV2                 ((uint32_t)0x00002000)        
  1296. #define  RCC_CFGR_PPRE2_DIV4                 ((uint32_t)0x00002800)        
  1297. #define  RCC_CFGR_PPRE2_DIV8                 ((uint32_t)0x00003000)        
  1298. #define  RCC_CFGR_PPRE2_DIV16                ((uint32_t)0x00003800)        

  1299. #define  RCC_CFGR_ADCPRE                     ((uint32_t)0x0000C000)        
  1300. #define  RCC_CFGR_ADCPRE_0                   ((uint32_t)0x00004000)        
  1301. #define  RCC_CFGR_ADCPRE_1                   ((uint32_t)0x00008000)        

  1302. #define  RCC_CFGR_ADCPRE_DIV2                ((uint32_t)0x00000000)        
  1303. #define  RCC_CFGR_ADCPRE_DIV4                ((uint32_t)0x00004000)        
  1304. #define  RCC_CFGR_ADCPRE_DIV6                ((uint32_t)0x00008000)        
  1305. #define  RCC_CFGR_ADCPRE_DIV8                ((uint32_t)0x0000C000)        

  1306. #define  RCC_CFGR_PLLSRC                     ((uint32_t)0x00010000)        

  1307. #define  RCC_CFGR_PLLXTPRE                   ((uint32_t)0x00020000)        

  1308. #define  RCC_CFGR_PLLMULL                    ((uint32_t)0x003C0000)        
  1309. #define  RCC_CFGR_PLLMULL_0                  ((uint32_t)0x00040000)        
  1310. #define  RCC_CFGR_PLLMULL_1                  ((uint32_t)0x00080000)        
  1311. #define  RCC_CFGR_PLLMULL_2                  ((uint32_t)0x00100000)        
  1312. #define  RCC_CFGR_PLLMULL_3                  ((uint32_t)0x00200000)        

  1313. #ifdef STM32F10X_CL
  1314. #define  RCC_CFGR_PLLSRC_HSI_Div2           ((uint32_t)0x00000000)        
  1315. #define  RCC_CFGR_PLLSRC_PREDIV1            ((uint32_t)0x00010000)        

  1316. #define  RCC_CFGR_PLLXTPRE_PREDIV1          ((uint32_t)0x00000000)        
  1317. #define  RCC_CFGR_PLLXTPRE_PREDIV1_Div2     ((uint32_t)0x00020000)        

  1318. #define  RCC_CFGR_PLLMULL4                  ((uint32_t)0x00080000)        
  1319. #define  RCC_CFGR_PLLMULL5                  ((uint32_t)0x000C0000)        
  1320. #define  RCC_CFGR_PLLMULL6                  ((uint32_t)0x00100000)        
  1321. #define  RCC_CFGR_PLLMULL7                  ((uint32_t)0x00140000)        
  1322. #define  RCC_CFGR_PLLMULL8                  ((uint32_t)0x00180000)        
  1323. #define  RCC_CFGR_PLLMULL9                  ((uint32_t)0x001C0000)        
  1324. #define  RCC_CFGR_PLLMULL6_5                ((uint32_t)0x00340000)        

  1325. #define  RCC_CFGR_OTGFSPRE                  ((uint32_t)0x00400000)        

  1326. #define  RCC_CFGR_MCO                       ((uint32_t)0x0F000000)        
  1327. #define  RCC_CFGR_MCO_0                     ((uint32_t)0x01000000)        
  1328. #define  RCC_CFGR_MCO_1                     ((uint32_t)0x02000000)        
  1329. #define  RCC_CFGR_MCO_2                     ((uint32_t)0x04000000)        
  1330. #define  RCC_CFGR_MCO_3                     ((uint32_t)0x08000000)        

  1331. #define  RCC_CFGR_MCO_NOCLOCK               ((uint32_t)0x00000000)        
  1332. #define  RCC_CFGR_MCO_SYSCLK                ((uint32_t)0x04000000)        
  1333. #define  RCC_CFGR_MCO_HSI                   ((uint32_t)0x05000000)        
  1334. #define  RCC_CFGR_MCO_HSE                   ((uint32_t)0x06000000)        
  1335. #define  RCC_CFGR_MCO_PLLCLK_Div2           ((uint32_t)0x07000000)        
  1336. #define  RCC_CFGR_MCO_PLL2CLK               ((uint32_t)0x08000000)        
  1337. #define  RCC_CFGR_MCO_PLL3CLK_Div2          ((uint32_t)0x09000000)        
  1338. #define  RCC_CFGR_MCO_Ext_HSE               ((uint32_t)0x0A000000)        
  1339. #define  RCC_CFGR_MCO_PLL3CLK               ((uint32_t)0x0B000000)        
  1340. #elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  1341. #define  RCC_CFGR_PLLSRC_HSI_Div2           ((uint32_t)0x00000000)        
  1342. #define  RCC_CFGR_PLLSRC_PREDIV1            ((uint32_t)0x00010000)        

  1343. #define  RCC_CFGR_PLLXTPRE_PREDIV1          ((uint32_t)0x00000000)        
  1344. #define  RCC_CFGR_PLLXTPRE_PREDIV1_Div2     ((uint32_t)0x00020000)        

  1345. #define  RCC_CFGR_PLLMULL2                  ((uint32_t)0x00000000)        
  1346. #define  RCC_CFGR_PLLMULL3                  ((uint32_t)0x00040000)        
  1347. #define  RCC_CFGR_PLLMULL4                  ((uint32_t)0x00080000)        
  1348. #define  RCC_CFGR_PLLMULL5                  ((uint32_t)0x000C0000)        
  1349. #define  RCC_CFGR_PLLMULL6                  ((uint32_t)0x00100000)        
  1350. #define  RCC_CFGR_PLLMULL7                  ((uint32_t)0x00140000)        
  1351. #define  RCC_CFGR_PLLMULL8                  ((uint32_t)0x00180000)        
  1352. #define  RCC_CFGR_PLLMULL9                  ((uint32_t)0x001C0000)        
  1353. #define  RCC_CFGR_PLLMULL10                 ((uint32_t)0x00200000)        
  1354. #define  RCC_CFGR_PLLMULL11                 ((uint32_t)0x00240000)        
  1355. #define  RCC_CFGR_PLLMULL12                 ((uint32_t)0x00280000)        
  1356. #define  RCC_CFGR_PLLMULL13                 ((uint32_t)0x002C0000)        
  1357. #define  RCC_CFGR_PLLMULL14                 ((uint32_t)0x00300000)        
  1358. #define  RCC_CFGR_PLLMULL15                 ((uint32_t)0x00340000)        
  1359. #define  RCC_CFGR_PLLMULL16                 ((uint32_t)0x00380000)        

  1360. #define  RCC_CFGR_MCO                       ((uint32_t)0x07000000)        
  1361. #define  RCC_CFGR_MCO_0                     ((uint32_t)0x01000000)        
  1362. #define  RCC_CFGR_MCO_1                     ((uint32_t)0x02000000)        
  1363. #define  RCC_CFGR_MCO_2                     ((uint32_t)0x04000000)        

  1364. #define  RCC_CFGR_MCO_NOCLOCK               ((uint32_t)0x00000000)        
  1365. #define  RCC_CFGR_MCO_SYSCLK                ((uint32_t)0x04000000)        
  1366. #define  RCC_CFGR_MCO_HSI                   ((uint32_t)0x05000000)        
  1367. #define  RCC_CFGR_MCO_HSE                   ((uint32_t)0x06000000)        
  1368. #define  RCC_CFGR_MCO_PLL                   ((uint32_t)0x07000000)        
  1369. #else
  1370. #define  RCC_CFGR_PLLSRC_HSI_Div2           ((uint32_t)0x00000000)        
  1371. #define  RCC_CFGR_PLLSRC_HSE                ((uint32_t)0x00010000)        

  1372. #define  RCC_CFGR_PLLXTPRE_HSE              ((uint32_t)0x00000000)        
  1373. #define  RCC_CFGR_PLLXTPRE_HSE_Div2         ((uint32_t)0x00020000)        

  1374. #define  RCC_CFGR_PLLMULL2                  ((uint32_t)0x00000000)        
  1375. #define  RCC_CFGR_PLLMULL3                  ((uint32_t)0x00040000)        
  1376. #define  RCC_CFGR_PLLMULL4                  ((uint32_t)0x00080000)        
  1377. #define  RCC_CFGR_PLLMULL5                  ((uint32_t)0x000C0000)        
  1378. #define  RCC_CFGR_PLLMULL6                  ((uint32_t)0x00100000)        
  1379. #define  RCC_CFGR_PLLMULL7                  ((uint32_t)0x00140000)        
  1380. #define  RCC_CFGR_PLLMULL8                  ((uint32_t)0x00180000)        
  1381. #define  RCC_CFGR_PLLMULL9                  ((uint32_t)0x001C0000)        
  1382. #define  RCC_CFGR_PLLMULL10                 ((uint32_t)0x00200000)        
  1383. #define  RCC_CFGR_PLLMULL11                 ((uint32_t)0x00240000)        
  1384. #define  RCC_CFGR_PLLMULL12                 ((uint32_t)0x00280000)        
  1385. #define  RCC_CFGR_PLLMULL13                 ((uint32_t)0x002C0000)        
  1386. #define  RCC_CFGR_PLLMULL14                 ((uint32_t)0x00300000)        
  1387. #define  RCC_CFGR_PLLMULL15                 ((uint32_t)0x00340000)        
  1388. #define  RCC_CFGR_PLLMULL16                 ((uint32_t)0x00380000)        
  1389. #define  RCC_CFGR_USBPRE                    ((uint32_t)0x00400000)        

  1390. #define  RCC_CFGR_MCO                       ((uint32_t)0x07000000)        
  1391. #define  RCC_CFGR_MCO_0                     ((uint32_t)0x01000000)        
  1392. #define  RCC_CFGR_MCO_1                     ((uint32_t)0x02000000)        
  1393. #define  RCC_CFGR_MCO_2                     ((uint32_t)0x04000000)        

  1394. #define  RCC_CFGR_MCO_NOCLOCK               ((uint32_t)0x00000000)        
  1395. #define  RCC_CFGR_MCO_SYSCLK                ((uint32_t)0x04000000)        
  1396. #define  RCC_CFGR_MCO_HSI                   ((uint32_t)0x05000000)        
  1397. #define  RCC_CFGR_MCO_HSE                   ((uint32_t)0x06000000)        
  1398. #define  RCC_CFGR_MCO_PLL                   ((uint32_t)0x07000000)        
  1399. #endif

  1400. #define  RCC_CIR_LSIRDYF                     ((uint32_t)0x00000001)        
  1401. #define  RCC_CIR_LSERDYF                     ((uint32_t)0x00000002)        
  1402. #define  RCC_CIR_HSIRDYF                     ((uint32_t)0x00000004)        
  1403. #define  RCC_CIR_HSERDYF                     ((uint32_t)0x00000008)        
  1404. #define  RCC_CIR_PLLRDYF                     ((uint32_t)0x00000010)        
  1405. #define  RCC_CIR_CSSF                        ((uint32_t)0x00000080)        
  1406. #define  RCC_CIR_LSIRDYIE                    ((uint32_t)0x00000100)        
  1407. #define  RCC_CIR_LSERDYIE                    ((uint32_t)0x00000200)        
  1408. #define  RCC_CIR_HSIRDYIE                    ((uint32_t)0x00000400)        
  1409. #define  RCC_CIR_HSERDYIE                    ((uint32_t)0x00000800)        
  1410. #define  RCC_CIR_PLLRDYIE                    ((uint32_t)0x00001000)        
  1411. #define  RCC_CIR_LSIRDYC                     ((uint32_t)0x00010000)        
  1412. #define  RCC_CIR_LSERDYC                     ((uint32_t)0x00020000)        
  1413. #define  RCC_CIR_HSIRDYC                     ((uint32_t)0x00040000)        
  1414. #define  RCC_CIR_HSERDYC                     ((uint32_t)0x00080000)        
  1415. #define  RCC_CIR_PLLRDYC                     ((uint32_t)0x00100000)        
  1416. #define  RCC_CIR_CSSC                        ((uint32_t)0x00800000)        

  1417. #ifdef STM32F10X_CL
  1418. #define  RCC_CIR_PLL2RDYF                    ((uint32_t)0x00000020)        
  1419. #define  RCC_CIR_PLL3RDYF                    ((uint32_t)0x00000040)        
  1420. #define  RCC_CIR_PLL2RDYIE                   ((uint32_t)0x00002000)        
  1421. #define  RCC_CIR_PLL3RDYIE                   ((uint32_t)0x00004000)        
  1422. #define  RCC_CIR_PLL2RDYC                    ((uint32_t)0x00200000)        
  1423. #define  RCC_CIR_PLL3RDYC                    ((uint32_t)0x00400000)        
  1424. #endif

  1425. #define  RCC_APB2RSTR_AFIORST                ((uint32_t)0x00000001)        
  1426. #define  RCC_APB2RSTR_IOPARST                ((uint32_t)0x00000004)        
  1427. #define  RCC_APB2RSTR_IOPBRST                ((uint32_t)0x00000008)        
  1428. #define  RCC_APB2RSTR_IOPCRST                ((uint32_t)0x00000010)        
  1429. #define  RCC_APB2RSTR_IOPDRST                ((uint32_t)0x00000020)        
  1430. #define  RCC_APB2RSTR_ADC1RST                ((uint32_t)0x00000200)        

  1431. #if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL)
  1432. #define  RCC_APB2RSTR_ADC2RST                ((uint32_t)0x00000400)        
  1433. #endif

  1434. #define  RCC_APB2RSTR_TIM1RST                ((uint32_t)0x00000800)        
  1435. #define  RCC_APB2RSTR_SPI1RST                ((uint32_t)0x00001000)        
  1436. #define  RCC_APB2RSTR_USART1RST              ((uint32_t)0x00004000)        

  1437. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  1438. #define  RCC_APB2RSTR_TIM15RST               ((uint32_t)0x00010000)        
  1439. #define  RCC_APB2RSTR_TIM16RST               ((uint32_t)0x00020000)        
  1440. #define  RCC_APB2RSTR_TIM17RST               ((uint32_t)0x00040000)        
  1441. #endif

  1442. #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL)
  1443. #define  RCC_APB2RSTR_IOPERST               ((uint32_t)0x00000040)        
  1444. #endif

  1445. #if defined (STM32F10X_HD) || defined (STM32F10X_XL)
  1446. #define  RCC_APB2RSTR_IOPFRST               ((uint32_t)0x00000080)        
  1447. #define  RCC_APB2RSTR_IOPGRST               ((uint32_t)0x00000100)        
  1448. #define  RCC_APB2RSTR_TIM8RST               ((uint32_t)0x00002000)        
  1449. #define  RCC_APB2RSTR_ADC3RST               ((uint32_t)0x00008000)        
  1450. #endif

  1451. #if defined (STM32F10X_HD_VL)
  1452. #define  RCC_APB2RSTR_IOPFRST               ((uint32_t)0x00000080)        
  1453. #define  RCC_APB2RSTR_IOPGRST               ((uint32_t)0x00000100)        
  1454. #endif

  1455. #ifdef STM32F10X_XL
  1456. #define  RCC_APB2RSTR_TIM9RST               ((uint32_t)0x00080000)        
  1457. #define  RCC_APB2RSTR_TIM10RST              ((uint32_t)0x00100000)        
  1458. #define  RCC_APB2RSTR_TIM11RST              ((uint32_t)0x00200000)        
  1459. #endif

  1460. #define  RCC_APB1RSTR_TIM2RST                ((uint32_t)0x00000001)        
  1461. #define  RCC_APB1RSTR_TIM3RST                ((uint32_t)0x00000002)        
  1462. #define  RCC_APB1RSTR_WWDGRST                ((uint32_t)0x00000800)        
  1463. #define  RCC_APB1RSTR_USART2RST              ((uint32_t)0x00020000)        
  1464. #define  RCC_APB1RSTR_I2C1RST                ((uint32_t)0x00200000)        

  1465. #if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL)
  1466. #define  RCC_APB1RSTR_CAN1RST                ((uint32_t)0x02000000)        
  1467. #endif

  1468. #define  RCC_APB1RSTR_BKPRST                 ((uint32_t)0x08000000)        
  1469. #define  RCC_APB1RSTR_PWRRST                 ((uint32_t)0x10000000)        

  1470. #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL)
  1471. #define  RCC_APB1RSTR_TIM4RST               ((uint32_t)0x00000004)        
  1472. #define  RCC_APB1RSTR_SPI2RST               ((uint32_t)0x00004000)        
  1473. #define  RCC_APB1RSTR_USART3RST             ((uint32_t)0x00040000)        
  1474. #define  RCC_APB1RSTR_I2C2RST               ((uint32_t)0x00400000)        
  1475. #endif

  1476. #if defined (STM32F10X_HD) || defined (STM32F10X_MD) || defined (STM32F10X_LD) || defined  (STM32F10X_XL)
  1477. #define  RCC_APB1RSTR_USBRST                ((uint32_t)0x00800000)        
  1478. #endif

  1479. #if defined (STM32F10X_HD) || defined  (STM32F10X_CL) || defined  (STM32F10X_XL)
  1480. #define  RCC_APB1RSTR_TIM5RST                ((uint32_t)0x00000008)        
  1481. #define  RCC_APB1RSTR_TIM6RST                ((uint32_t)0x00000010)        
  1482. #define  RCC_APB1RSTR_TIM7RST                ((uint32_t)0x00000020)        
  1483. #define  RCC_APB1RSTR_SPI3RST                ((uint32_t)0x00008000)        
  1484. #define  RCC_APB1RSTR_UART4RST               ((uint32_t)0x00080000)        
  1485. #define  RCC_APB1RSTR_UART5RST               ((uint32_t)0x00100000)        
  1486. #define  RCC_APB1RSTR_DACRST                 ((uint32_t)0x20000000)        
  1487. #endif

  1488. #if defined (STM32F10X_LD_VL) || defined  (STM32F10X_MD_VL) || defined  (STM32F10X_HD_VL)
  1489. #define  RCC_APB1RSTR_TIM6RST                ((uint32_t)0x00000010)        
  1490. #define  RCC_APB1RSTR_TIM7RST                ((uint32_t)0x00000020)        
  1491. #define  RCC_APB1RSTR_DACRST                 ((uint32_t)0x20000000)        
  1492. #define  RCC_APB1RSTR_CECRST                 ((uint32_t)0x40000000)         
  1493. #endif

  1494. #if defined  (STM32F10X_HD_VL)
  1495. #define  RCC_APB1RSTR_TIM5RST                ((uint32_t)0x00000008)        
  1496. #define  RCC_APB1RSTR_TIM12RST               ((uint32_t)0x00000040)        
  1497. #define  RCC_APB1RSTR_TIM13RST               ((uint32_t)0x00000080)        
  1498. #define  RCC_APB1RSTR_TIM14RST               ((uint32_t)0x00000100)        
  1499. #define  RCC_APB1RSTR_SPI3RST                ((uint32_t)0x00008000)         
  1500. #define  RCC_APB1RSTR_UART4RST               ((uint32_t)0x00080000)        
  1501. #define  RCC_APB1RSTR_UART5RST               ((uint32_t)0x00100000)         
  1502. #endif

  1503. #ifdef STM32F10X_CL
  1504. #define  RCC_APB1RSTR_CAN2RST                ((uint32_t)0x04000000)        
  1505. #endif

  1506. #ifdef STM32F10X_XL
  1507. #define  RCC_APB1RSTR_TIM12RST               ((uint32_t)0x00000040)        
  1508. #define  RCC_APB1RSTR_TIM13RST               ((uint32_t)0x00000080)        
  1509. #define  RCC_APB1RSTR_TIM14RST               ((uint32_t)0x00000100)        
  1510. #endif

  1511. #define  RCC_AHBENR_DMA1EN                   ((uint16_t)0x0001)            
  1512. #define  RCC_AHBENR_SRAMEN                   ((uint16_t)0x0004)            
  1513. #define  RCC_AHBENR_FLITFEN                  ((uint16_t)0x0010)            
  1514. #define  RCC_AHBENR_CRCEN                    ((uint16_t)0x0040)            

  1515. #if defined (STM32F10X_HD) || defined  (STM32F10X_CL) || defined  (STM32F10X_HD_VL)
  1516. #define  RCC_AHBENR_DMA2EN                  ((uint16_t)0x0002)            
  1517. #endif

  1518. #if defined (STM32F10X_HD) || defined (STM32F10X_XL)
  1519. #define  RCC_AHBENR_FSMCEN                  ((uint16_t)0x0100)            
  1520. #define  RCC_AHBENR_SDIOEN                  ((uint16_t)0x0400)            
  1521. #endif

  1522. #if defined (STM32F10X_HD_VL)
  1523. #define  RCC_AHBENR_FSMCEN                  ((uint16_t)0x0100)            
  1524. #endif

  1525. #ifdef STM32F10X_CL
  1526. #define  RCC_AHBENR_OTGFSEN                 ((uint32_t)0x00001000)        
  1527. #define  RCC_AHBENR_ETHMACEN                ((uint32_t)0x00004000)        
  1528. #define  RCC_AHBENR_ETHMACTXEN              ((uint32_t)0x00008000)        
  1529. #define  RCC_AHBENR_ETHMACRXEN              ((uint32_t)0x00010000)        
  1530. #endif

  1531. #define  RCC_APB2ENR_AFIOEN                  ((uint32_t)0x00000001)        
  1532. #define  RCC_APB2ENR_IOPAEN                  ((uint32_t)0x00000004)        
  1533. #define  RCC_APB2ENR_IOPBEN                  ((uint32_t)0x00000008)        
  1534. #define  RCC_APB2ENR_IOPCEN                  ((uint32_t)0x00000010)        
  1535. #define  RCC_APB2ENR_IOPDEN                  ((uint32_t)0x00000020)        
  1536. #define  RCC_APB2ENR_ADC1EN                  ((uint32_t)0x00000200)        

  1537. #if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL)
  1538. #define  RCC_APB2ENR_ADC2EN                  ((uint32_t)0x00000400)        
  1539. #endif

  1540. #define  RCC_APB2ENR_TIM1EN                  ((uint32_t)0x00000800)        
  1541. #define  RCC_APB2ENR_SPI1EN                  ((uint32_t)0x00001000)        
  1542. #define  RCC_APB2ENR_USART1EN                ((uint32_t)0x00004000)        

  1543. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  1544. #define  RCC_APB2ENR_TIM15EN                 ((uint32_t)0x00010000)        
  1545. #define  RCC_APB2ENR_TIM16EN                 ((uint32_t)0x00020000)        
  1546. #define  RCC_APB2ENR_TIM17EN                 ((uint32_t)0x00040000)        
  1547. #endif

  1548. #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL)
  1549. #define  RCC_APB2ENR_IOPEEN                 ((uint32_t)0x00000040)        
  1550. #endif

  1551. #if defined (STM32F10X_HD) || defined (STM32F10X_XL)
  1552. #define  RCC_APB2ENR_IOPFEN                 ((uint32_t)0x00000080)        
  1553. #define  RCC_APB2ENR_IOPGEN                 ((uint32_t)0x00000100)        
  1554. #define  RCC_APB2ENR_TIM8EN                 ((uint32_t)0x00002000)        
  1555. #define  RCC_APB2ENR_ADC3EN                 ((uint32_t)0x00008000)        
  1556. #endif

  1557. #if defined (STM32F10X_HD_VL)
  1558. #define  RCC_APB2ENR_IOPFEN                 ((uint32_t)0x00000080)        
  1559. #define  RCC_APB2ENR_IOPGEN                 ((uint32_t)0x00000100)        
  1560. #endif

  1561. #ifdef STM32F10X_XL
  1562. #define  RCC_APB2ENR_TIM9EN                 ((uint32_t)0x00080000)        
  1563. #define  RCC_APB2ENR_TIM10EN                ((uint32_t)0x00100000)        
  1564. #define  RCC_APB2ENR_TIM11EN                ((uint32_t)0x00200000)        
  1565. #endif

  1566. #define  RCC_APB1ENR_TIM2EN                  ((uint32_t)0x00000001)        
  1567. #define  RCC_APB1ENR_TIM3EN                  ((uint32_t)0x00000002)        
  1568. #define  RCC_APB1ENR_WWDGEN                  ((uint32_t)0x00000800)        
  1569. #define  RCC_APB1ENR_USART2EN                ((uint32_t)0x00020000)        
  1570. #define  RCC_APB1ENR_I2C1EN                  ((uint32_t)0x00200000)        

  1571. #if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL)
  1572. #define  RCC_APB1ENR_CAN1EN                  ((uint32_t)0x02000000)        
  1573. #endif

  1574. #define  RCC_APB1ENR_BKPEN                   ((uint32_t)0x08000000)        
  1575. #define  RCC_APB1ENR_PWREN                   ((uint32_t)0x10000000)        

  1576. #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL)
  1577. #define  RCC_APB1ENR_TIM4EN                 ((uint32_t)0x00000004)        
  1578. #define  RCC_APB1ENR_SPI2EN                 ((uint32_t)0x00004000)        
  1579. #define  RCC_APB1ENR_USART3EN               ((uint32_t)0x00040000)        
  1580. #define  RCC_APB1ENR_I2C2EN                 ((uint32_t)0x00400000)        
  1581. #endif

  1582. #if defined (STM32F10X_HD) || defined (STM32F10X_MD) || defined  (STM32F10X_LD)
  1583. #define  RCC_APB1ENR_USBEN                  ((uint32_t)0x00800000)        
  1584. #endif

  1585. #if defined (STM32F10X_HD) || defined  (STM32F10X_CL)
  1586. #define  RCC_APB1ENR_TIM5EN                 ((uint32_t)0x00000008)        
  1587. #define  RCC_APB1ENR_TIM6EN                 ((uint32_t)0x00000010)        
  1588. #define  RCC_APB1ENR_TIM7EN                 ((uint32_t)0x00000020)        
  1589. #define  RCC_APB1ENR_SPI3EN                 ((uint32_t)0x00008000)        
  1590. #define  RCC_APB1ENR_UART4EN                ((uint32_t)0x00080000)        
  1591. #define  RCC_APB1ENR_UART5EN                ((uint32_t)0x00100000)        
  1592. #define  RCC_APB1ENR_DACEN                  ((uint32_t)0x20000000)        
  1593. #endif

  1594. #if defined (STM32F10X_LD_VL) || defined  (STM32F10X_MD_VL) || defined  (STM32F10X_HD_VL)
  1595. #define  RCC_APB1ENR_TIM6EN                 ((uint32_t)0x00000010)        
  1596. #define  RCC_APB1ENR_TIM7EN                 ((uint32_t)0x00000020)        
  1597. #define  RCC_APB1ENR_DACEN                  ((uint32_t)0x20000000)        
  1598. #define  RCC_APB1ENR_CECEN                  ((uint32_t)0x40000000)         
  1599. #endif

  1600. #ifdef STM32F10X_HD_VL
  1601. #define  RCC_APB1ENR_TIM5EN                 ((uint32_t)0x00000008)        
  1602. #define  RCC_APB1ENR_TIM12EN                ((uint32_t)0x00000040)        
  1603. #define  RCC_APB1ENR_TIM13EN                ((uint32_t)0x00000080)        
  1604. #define  RCC_APB1ENR_TIM14EN                ((uint32_t)0x00000100)        
  1605. #define  RCC_APB1ENR_SPI3EN                 ((uint32_t)0x00008000)        
  1606. #define  RCC_APB1ENR_UART4EN                ((uint32_t)0x00080000)        
  1607. #define  RCC_APB1ENR_UART5EN                ((uint32_t)0x00100000)         
  1608. #endif

  1609. #ifdef STM32F10X_CL
  1610. #define  RCC_APB1ENR_CAN2EN                  ((uint32_t)0x04000000)        
  1611. #endif

  1612. #ifdef STM32F10X_XL
  1613. #define  RCC_APB1ENR_TIM12EN                ((uint32_t)0x00000040)        
  1614. #define  RCC_APB1ENR_TIM13EN                ((uint32_t)0x00000080)        
  1615. #define  RCC_APB1ENR_TIM14EN                ((uint32_t)0x00000100)        
  1616. #endif

  1617. #define  RCC_BDCR_LSEON                      ((uint32_t)0x00000001)        
  1618. #define  RCC_BDCR_LSERDY                     ((uint32_t)0x00000002)        
  1619. #define  RCC_BDCR_LSEBYP                     ((uint32_t)0x00000004)        

  1620. #define  RCC_BDCR_RTCSEL                     ((uint32_t)0x00000300)        
  1621. #define  RCC_BDCR_RTCSEL_0                   ((uint32_t)0x00000100)        
  1622. #define  RCC_BDCR_RTCSEL_1                   ((uint32_t)0x00000200)        

  1623. #define  RCC_BDCR_RTCSEL_NOCLOCK             ((uint32_t)0x00000000)        
  1624. #define  RCC_BDCR_RTCSEL_LSE                 ((uint32_t)0x00000100)        
  1625. #define  RCC_BDCR_RTCSEL_LSI                 ((uint32_t)0x00000200)        
  1626. #define  RCC_BDCR_RTCSEL_HSE                 ((uint32_t)0x00000300)        

  1627. #define  RCC_BDCR_RTCEN                      ((uint32_t)0x00008000)        
  1628. #define  RCC_BDCR_BDRST                      ((uint32_t)0x00010000)        


  1629. #define  RCC_CSR_LSION                       ((uint32_t)0x00000001)        
  1630. #define  RCC_CSR_LSIRDY                      ((uint32_t)0x00000002)        
  1631. #define  RCC_CSR_RMVF                        ((uint32_t)0x01000000)        
  1632. #define  RCC_CSR_PINRSTF                     ((uint32_t)0x04000000)        
  1633. #define  RCC_CSR_PORRSTF                     ((uint32_t)0x08000000)        
  1634. #define  RCC_CSR_SFTRSTF                     ((uint32_t)0x10000000)        
  1635. #define  RCC_CSR_IWDGRSTF                    ((uint32_t)0x20000000)        
  1636. #define  RCC_CSR_WWDGRSTF                    ((uint32_t)0x40000000)        
  1637. #define  RCC_CSR_LPWRRSTF                    ((uint32_t)0x80000000)        

  1638. #ifdef STM32F10X_CL
  1639. #define  RCC_AHBRSTR_OTGFSRST               ((uint32_t)0x00001000)        
  1640. #define  RCC_AHBRSTR_ETHMACRST              ((uint32_t)0x00004000)        

  1641. #define  RCC_CFGR2_PREDIV1                  ((uint32_t)0x0000000F)        
  1642. #define  RCC_CFGR2_PREDIV1_0                ((uint32_t)0x00000001)        
  1643. #define  RCC_CFGR2_PREDIV1_1                ((uint32_t)0x00000002)        
  1644. #define  RCC_CFGR2_PREDIV1_2                ((uint32_t)0x00000004)        
  1645. #define  RCC_CFGR2_PREDIV1_3                ((uint32_t)0x00000008)        

  1646. #define  RCC_CFGR2_PREDIV1_DIV1             ((uint32_t)0x00000000)        
  1647. #define  RCC_CFGR2_PREDIV1_DIV2             ((uint32_t)0x00000001)        
  1648. #define  RCC_CFGR2_PREDIV1_DIV3             ((uint32_t)0x00000002)        
  1649. #define  RCC_CFGR2_PREDIV1_DIV4             ((uint32_t)0x00000003)        
  1650. #define  RCC_CFGR2_PREDIV1_DIV5             ((uint32_t)0x00000004)        
  1651. #define  RCC_CFGR2_PREDIV1_DIV6             ((uint32_t)0x00000005)        
  1652. #define  RCC_CFGR2_PREDIV1_DIV7             ((uint32_t)0x00000006)        
  1653. #define  RCC_CFGR2_PREDIV1_DIV8             ((uint32_t)0x00000007)        
  1654. #define  RCC_CFGR2_PREDIV1_DIV9             ((uint32_t)0x00000008)        
  1655. #define  RCC_CFGR2_PREDIV1_DIV10            ((uint32_t)0x00000009)        
  1656. #define  RCC_CFGR2_PREDIV1_DIV11            ((uint32_t)0x0000000A)        
  1657. #define  RCC_CFGR2_PREDIV1_DIV12            ((uint32_t)0x0000000B)        
  1658. #define  RCC_CFGR2_PREDIV1_DIV13            ((uint32_t)0x0000000C)        
  1659. #define  RCC_CFGR2_PREDIV1_DIV14            ((uint32_t)0x0000000D)        
  1660. #define  RCC_CFGR2_PREDIV1_DIV15            ((uint32_t)0x0000000E)        
  1661. #define  RCC_CFGR2_PREDIV1_DIV16            ((uint32_t)0x0000000F)        

  1662. #define  RCC_CFGR2_PREDIV2                  ((uint32_t)0x000000F0)        
  1663. #define  RCC_CFGR2_PREDIV2_0                ((uint32_t)0x00000010)        
  1664. #define  RCC_CFGR2_PREDIV2_1                ((uint32_t)0x00000020)        
  1665. #define  RCC_CFGR2_PREDIV2_2                ((uint32_t)0x00000040)        
  1666. #define  RCC_CFGR2_PREDIV2_3                ((uint32_t)0x00000080)        

  1667. #define  RCC_CFGR2_PREDIV2_DIV1             ((uint32_t)0x00000000)        
  1668. #define  RCC_CFGR2_PREDIV2_DIV2             ((uint32_t)0x00000010)        
  1669. #define  RCC_CFGR2_PREDIV2_DIV3             ((uint32_t)0x00000020)        
  1670. #define  RCC_CFGR2_PREDIV2_DIV4             ((uint32_t)0x00000030)        
  1671. #define  RCC_CFGR2_PREDIV2_DIV5             ((uint32_t)0x00000040)        
  1672. #define  RCC_CFGR2_PREDIV2_DIV6             ((uint32_t)0x00000050)        
  1673. #define  RCC_CFGR2_PREDIV2_DIV7             ((uint32_t)0x00000060)        
  1674. #define  RCC_CFGR2_PREDIV2_DIV8             ((uint32_t)0x00000070)        
  1675. #define  RCC_CFGR2_PREDIV2_DIV9             ((uint32_t)0x00000080)        
  1676. #define  RCC_CFGR2_PREDIV2_DIV10            ((uint32_t)0x00000090)        
  1677. #define  RCC_CFGR2_PREDIV2_DIV11            ((uint32_t)0x000000A0)        
  1678. #define  RCC_CFGR2_PREDIV2_DIV12            ((uint32_t)0x000000B0)        
  1679. #define  RCC_CFGR2_PREDIV2_DIV13            ((uint32_t)0x000000C0)        
  1680. #define  RCC_CFGR2_PREDIV2_DIV14            ((uint32_t)0x000000D0)        
  1681. #define  RCC_CFGR2_PREDIV2_DIV15            ((uint32_t)0x000000E0)        
  1682. #define  RCC_CFGR2_PREDIV2_DIV16            ((uint32_t)0x000000F0)        

  1683. #define  RCC_CFGR2_PLL2MUL                  ((uint32_t)0x00000F00)        
  1684. #define  RCC_CFGR2_PLL2MUL_0                ((uint32_t)0x00000100)        
  1685. #define  RCC_CFGR2_PLL2MUL_1                ((uint32_t)0x00000200)        
  1686. #define  RCC_CFGR2_PLL2MUL_2                ((uint32_t)0x00000400)        
  1687. #define  RCC_CFGR2_PLL2MUL_3                ((uint32_t)0x00000800)        

  1688. #define  RCC_CFGR2_PLL2MUL8                 ((uint32_t)0x00000600)        
  1689. #define  RCC_CFGR2_PLL2MUL9                 ((uint32_t)0x00000700)        
  1690. #define  RCC_CFGR2_PLL2MUL10                ((uint32_t)0x00000800)        
  1691. #define  RCC_CFGR2_PLL2MUL11                ((uint32_t)0x00000900)        
  1692. #define  RCC_CFGR2_PLL2MUL12                ((uint32_t)0x00000A00)        
  1693. #define  RCC_CFGR2_PLL2MUL13                ((uint32_t)0x00000B00)        
  1694. #define  RCC_CFGR2_PLL2MUL14                ((uint32_t)0x00000C00)        
  1695. #define  RCC_CFGR2_PLL2MUL16                ((uint32_t)0x00000E00)        
  1696. #define  RCC_CFGR2_PLL2MUL20                ((uint32_t)0x00000F00)        

  1697. #define  RCC_CFGR2_PLL3MUL                  ((uint32_t)0x0000F000)        
  1698. #define  RCC_CFGR2_PLL3MUL_0                ((uint32_t)0x00001000)        
  1699. #define  RCC_CFGR2_PLL3MUL_1                ((uint32_t)0x00002000)        
  1700. #define  RCC_CFGR2_PLL3MUL_2                ((uint32_t)0x00004000)        
  1701. #define  RCC_CFGR2_PLL3MUL_3                ((uint32_t)0x00008000)        

  1702. #define  RCC_CFGR2_PLL3MUL8                 ((uint32_t)0x00006000)        
  1703. #define  RCC_CFGR2_PLL3MUL9                 ((uint32_t)0x00007000)        
  1704. #define  RCC_CFGR2_PLL3MUL10                ((uint32_t)0x00008000)        
  1705. #define  RCC_CFGR2_PLL3MUL11                ((uint32_t)0x00009000)        
  1706. #define  RCC_CFGR2_PLL3MUL12                ((uint32_t)0x0000A000)        
  1707. #define  RCC_CFGR2_PLL3MUL13                ((uint32_t)0x0000B000)        
  1708. #define  RCC_CFGR2_PLL3MUL14                ((uint32_t)0x0000C000)        
  1709. #define  RCC_CFGR2_PLL3MUL16                ((uint32_t)0x0000E000)        
  1710. #define  RCC_CFGR2_PLL3MUL20                ((uint32_t)0x0000F000)        

  1711. #define  RCC_CFGR2_PREDIV1SRC               ((uint32_t)0x00010000)        
  1712. #define  RCC_CFGR2_PREDIV1SRC_PLL2          ((uint32_t)0x00010000)        
  1713. #define  RCC_CFGR2_PREDIV1SRC_HSE           ((uint32_t)0x00000000)        
  1714. #define  RCC_CFGR2_I2S2SRC                  ((uint32_t)0x00020000)        
  1715. #define  RCC_CFGR2_I2S3SRC                  ((uint32_t)0x00040000)        
  1716. #endif

  1717. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  1718. #define  RCC_CFGR2_PREDIV1                  ((uint32_t)0x0000000F)        
  1719. #define  RCC_CFGR2_PREDIV1_0                ((uint32_t)0x00000001)        
  1720. #define  RCC_CFGR2_PREDIV1_1                ((uint32_t)0x00000002)        
  1721. #define  RCC_CFGR2_PREDIV1_2                ((uint32_t)0x00000004)        
  1722. #define  RCC_CFGR2_PREDIV1_3                ((uint32_t)0x00000008)        

  1723. #define  RCC_CFGR2_PREDIV1_DIV1             ((uint32_t)0x00000000)        
  1724. #define  RCC_CFGR2_PREDIV1_DIV2             ((uint32_t)0x00000001)        
  1725. #define  RCC_CFGR2_PREDIV1_DIV3             ((uint32_t)0x00000002)        
  1726. #define  RCC_CFGR2_PREDIV1_DIV4             ((uint32_t)0x00000003)        
  1727. #define  RCC_CFGR2_PREDIV1_DIV5             ((uint32_t)0x00000004)        
  1728. #define  RCC_CFGR2_PREDIV1_DIV6             ((uint32_t)0x00000005)        
  1729. #define  RCC_CFGR2_PREDIV1_DIV7             ((uint32_t)0x00000006)        
  1730. #define  RCC_CFGR2_PREDIV1_DIV8             ((uint32_t)0x00000007)        
  1731. #define  RCC_CFGR2_PREDIV1_DIV9             ((uint32_t)0x00000008)        
  1732. #define  RCC_CFGR2_PREDIV1_DIV10            ((uint32_t)0x00000009)        
  1733. #define  RCC_CFGR2_PREDIV1_DIV11            ((uint32_t)0x0000000A)        
  1734. #define  RCC_CFGR2_PREDIV1_DIV12            ((uint32_t)0x0000000B)        
  1735. #define  RCC_CFGR2_PREDIV1_DIV13            ((uint32_t)0x0000000C)        
  1736. #define  RCC_CFGR2_PREDIV1_DIV14            ((uint32_t)0x0000000D)        
  1737. #define  RCC_CFGR2_PREDIV1_DIV15            ((uint32_t)0x0000000E)        
  1738. #define  RCC_CFGR2_PREDIV1_DIV16            ((uint32_t)0x0000000F)        
  1739. #endif
复制代码


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:583390 发表于 2019-10-24 09:19 | 只看该作者
感谢楼主分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表