Advertisement
Guest User

stm32f10x.h

a guest
Jan 6th, 2018
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 378.35 KB | None | 0 0
  1. //PlaylistNumbering = ye2
  2. /**
  3.   ******************************************************************************
  4.   Released into the public domain.
  5.   This work is free: you can redistribute it and/or modify it under the terms of
  6.   Creative Commons Zero license v1.0
  7.   This work is licensed under the Creative Commons Zero 1.0 United States License.
  8.   To view a copy of this license, visit http://creativecommons.org/publicdomain/zero/1.0/
  9.   or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco,
  10.   California, 94105, USA.
  11.   This program is distributed in the hope that it will be useful,
  12.   but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  13.   or FITNESS FOR A PARTICULAR PURPOSE.
  14.   ******************************************************************************
  15.   */
  16.  
  17.  
  18. /** @addtogroup CMSIS
  19.   * @{
  20.   */
  21.  
  22. /** @addtogroup stm32f10x
  23.   * @{
  24.   */
  25.    
  26. #ifndef __STM32F10x_H
  27. #define __STM32F10x_H
  28.  
  29. #ifdef __cplusplus
  30.  extern "C" {
  31. #endif /* __cplusplus */
  32.  
  33. /** @addtogroup Library_configuration_section
  34.   * @{
  35.   */
  36.  
  37. /* Uncomment the line below according to the target STM32 device used in your
  38.    application
  39.   */
  40.  
  41. #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)
  42.   /* #define STM32F10X_LD */     /*!< STM32F10X_LD: STM32 Low density devices */
  43.   /* #define STM32F10X_LD_VL */  /*!< STM32F10X_LD_VL: STM32 Low density Value Line devices */  
  44.      #define STM32F10X_MD        /*!< STM32F10X_MD: STM32 Medium density devices */
  45.   /* #define STM32F10X_MD_VL */  /*!< STM32F10X_MD_VL: STM32 Medium density Value Line devices */  
  46.   /* #define STM32F10X_HD */     /*!< STM32F10X_HD: STM32 High density devices */
  47.   /* #define STM32F10X_HD_VL */  /*!< STM32F10X_HD_VL: STM32 High density value line devices */  
  48.   /* #define STM32F10X_XL */     /*!< STM32F10X_XL: STM32 XL-density devices */
  49.   /* #define STM32F10X_CL */     /*!< STM32F10X_CL: STM32 Connectivity line devices */
  50. #endif
  51. /*  Tip: To avoid modifying this file each time you need to switch between these
  52.         devices, you can define the device in your toolchain compiler preprocessor.
  53.  - Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers
  54.    where the Flash memory density ranges between 16 and 32 Kbytes.
  55.  - Low-density value line devices are STM32F100xx microcontrollers where the Flash
  56.    memory density ranges between 16 and 32 Kbytes.
  57.  - Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers
  58.    where the Flash memory density ranges between 64 and 128 Kbytes.
  59.  - Medium-density value line devices are STM32F100xx microcontrollers where the
  60.    Flash memory density ranges between 64 and 128 Kbytes.  
  61.  - High-density devices are STM32F101xx and STM32F103xx microcontrollers where
  62.    the Flash memory density ranges between 256 and 512 Kbytes.
  63.  - High-density value line devices are STM32F100xx microcontrollers where the
  64.    Flash memory density ranges between 256 and 512 Kbytes.  
  65.  - XL-density devices are STM32F101xx and STM32F103xx microcontrollers where
  66.    the Flash memory density ranges between 512 and 1024 Kbytes.
  67.  - Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
  68.   */
  69.  
  70. #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)
  71.  #error "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"
  72. #endif
  73.  
  74. #if !defined  (USE_STDPERIPH_DRIVER)
  75. /**
  76.  * @brief Comment the line below if you will not use the peripherals drivers.
  77.    In this case, these drivers will not be included and the application code will
  78.    be based on direct access to peripherals registers
  79.    */
  80.   /*#define USE_STDPERIPH_DRIVER*/
  81. #endif /* USE_STDPERIPH_DRIVER */
  82.  
  83. /**
  84.  * @brief In the following line adjust the value of External High Speed oscillator (HSE)
  85.    used in your application
  86.    
  87.    Tip: To avoid modifying this file each time you need to use different HSE, you
  88.         can define the HSE value in your toolchain compiler preprocessor.
  89.   */          
  90. #if !defined  HSE_VALUE
  91.  #ifdef STM32F10X_CL  
  92.   #define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
  93.  #else
  94.   #define HSE_VALUE    ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
  95.  #endif /* STM32F10X_CL */
  96. #endif /* HSE_VALUE */
  97.  
  98. /**
  99.  * @brief In the following line adjust the External High Speed oscillator (HSE) Startup
  100.    Timeout value
  101.    */
  102. #if !defined  (HSE_STARTUP_TIMEOUT)
  103.   #define HSE_STARTUP_TIMEOUT    ((uint16_t)0x0500)   /*!< Time out for HSE start up */
  104. #endif /* HSE_STARTUP_TIMEOUT */
  105.  
  106. #if !defined  (HSI_VALUE)  
  107.   #define HSI_VALUE    ((uint32_t)8000000) /*!< Value of the Internal oscillator in Hz*/
  108. #endif /* HSI_VALUE */
  109.  
  110. /**
  111.  * @brief STM32F10x Standard Peripheral Library version number
  112.    */
  113. #define __STM32F10X_STDPERIPH_VERSION_MAIN   (0x03) /*!< [31:24] main version */
  114. #define __STM32F10X_STDPERIPH_VERSION_SUB1   (0x06) /*!< [23:16] sub1 version */
  115. #define __STM32F10X_STDPERIPH_VERSION_SUB2   (0x01) /*!< [15:8]  sub2 version */
  116. #define __STM32F10X_STDPERIPH_VERSION_RC     (0x00) /*!< [7:0]  release candidate */
  117. #define __STM32F10X_STDPERIPH_VERSION        ((__STM32F10X_STDPERIPH_VERSION_MAIN << 24)\
  118.                                              |(__STM32F10X_STDPERIPH_VERSION_SUB1 << 16)\
  119.                                              |(__STM32F10X_STDPERIPH_VERSION_SUB2 << 8)\
  120.                                              |(__STM32F10X_STDPERIPH_VERSION_RC))
  121.  
  122. /**
  123.   * @}
  124.   */
  125.  
  126. /** @addtogroup Configuration_section_for_CMSIS
  127.   * @{
  128.   */
  129.  
  130. /**
  131.  * @brief Configuration of the Cortex-M3 Processor and Core Peripherals
  132.  */
  133. #ifdef STM32F10X_XL
  134.  #define __MPU_PRESENT             1      /*!< STM32 XL-density devices provide an MPU      */
  135. #else
  136.  #define __MPU_PRESENT             0      /*!< Other STM32 devices does not provide an MPU  */
  137. #endif /* STM32F10X_XL */
  138. #define __CM3_REV                 0x0200  /*!< Core Revision r2p0                           */
  139. #define __NVIC_PRIO_BITS          4       /*!< STM32 uses 4 Bits for the Priority Levels    */
  140. #define __Vendor_SysTickConfig    0       /*!< Set to 1 if different SysTick Config is used */
  141.  
  142. /**
  143.  * @brief STM32F10x Interrupt Number Definition, according to the selected device
  144.  *        in @ref Library_configuration_section
  145.  */
  146. typedef enum IRQn
  147. {
  148. /******  Cortex-M3 Processor Exceptions Numbers ***************************************************/
  149.   NonMaskableInt_IRQn         = -14,    /*!< 2 Non Maskable Interrupt                             */
  150.   MemoryManagement_IRQn       = -12,    /*!< 4 Cortex-M3 Memory Management Interrupt              */
  151.   BusFault_IRQn               = -11,    /*!< 5 Cortex-M3 Bus Fault Interrupt                      */
  152.   UsageFault_IRQn             = -10,    /*!< 6 Cortex-M3 Usage Fault Interrupt                    */
  153.   SVCall_IRQn                 = -5,     /*!< 11 Cortex-M3 SV Call Interrupt                       */
  154.   DebugMonitor_IRQn           = -4,     /*!< 12 Cortex-M3 Debug Monitor Interrupt                 */
  155.   PendSV_IRQn                 = -2,     /*!< 14 Cortex-M3 Pend SV Interrupt                       */
  156.   SysTick_IRQn                = -1,     /*!< 15 Cortex-M3 System Tick Interrupt                   */
  157.  
  158. /******  STM32 specific Interrupt Numbers *********************************************************/
  159.   WWDG_IRQn                   = 0,      /*!< Window WatchDog Interrupt                            */
  160.   PVD_IRQn                    = 1,      /*!< PVD through EXTI Line detection Interrupt            */
  161.   TAMPER_IRQn                 = 2,      /*!< Tamper Interrupt                                     */
  162.   RTC_IRQn                    = 3,      /*!< RTC global Interrupt                                 */
  163.   FLASH_IRQn                  = 4,      /*!< FLASH global Interrupt                               */
  164.   RCC_IRQn                    = 5,      /*!< RCC global Interrupt                                 */
  165.   EXTI0_IRQn                  = 6,      /*!< EXTI Line0 Interrupt                                 */
  166.   EXTI1_IRQn                  = 7,      /*!< EXTI Line1 Interrupt                                 */
  167.   EXTI2_IRQn                  = 8,      /*!< EXTI Line2 Interrupt                                 */
  168.   EXTI3_IRQn                  = 9,      /*!< EXTI Line3 Interrupt                                 */
  169.   EXTI4_IRQn                  = 10,     /*!< EXTI Line4 Interrupt                                 */
  170.   DMA1_Channel1_IRQn          = 11,     /*!< DMA1 Channel 1 global Interrupt                      */
  171.   DMA1_Channel2_IRQn          = 12,     /*!< DMA1 Channel 2 global Interrupt                      */
  172.   DMA1_Channel3_IRQn          = 13,     /*!< DMA1 Channel 3 global Interrupt                      */
  173.   DMA1_Channel4_IRQn          = 14,     /*!< DMA1 Channel 4 global Interrupt                      */
  174.   DMA1_Channel5_IRQn          = 15,     /*!< DMA1 Channel 5 global Interrupt                      */
  175.   DMA1_Channel6_IRQn          = 16,     /*!< DMA1 Channel 6 global Interrupt                      */
  176.   DMA1_Channel7_IRQn          = 17,     /*!< DMA1 Channel 7 global Interrupt                      */
  177.  
  178. #ifdef STM32F10X_LD
  179.   ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
  180.   USB_HP_CAN1_TX_IRQn         = 19,     /*!< USB Device High Priority or CAN1 TX Interrupts       */
  181.   USB_LP_CAN1_RX0_IRQn        = 20,     /*!< USB Device Low Priority or CAN1 RX0 Interrupts       */
  182.   CAN1_RX1_IRQn               = 21,     /*!< CAN1 RX1 Interrupt                                   */
  183.   CAN1_SCE_IRQn               = 22,     /*!< CAN1 SCE Interrupt                                   */
  184.   EXTI9_5_IRQn                = 23,     /*!< External Line[9:5] Interrupts                        */
  185.   TIM1_BRK_IRQn               = 24,     /*!< TIM1 Break Interrupt                                 */
  186.   TIM1_UP_IRQn                = 25,     /*!< TIM1 Update Interrupt                                */
  187.   TIM1_TRG_COM_IRQn           = 26,     /*!< TIM1 Trigger and Commutation Interrupt               */
  188.   TIM1_CC_IRQn                = 27,     /*!< TIM1 Capture Compare Interrupt                       */
  189.   TIM2_IRQn                   = 28,     /*!< TIM2 global Interrupt                                */
  190.   TIM3_IRQn                   = 29,     /*!< TIM3 global Interrupt                                */
  191.   I2C1_EV_IRQn                = 31,     /*!< I2C1 Event Interrupt                                 */
  192.   I2C1_ER_IRQn                = 32,     /*!< I2C1 Error Interrupt                                 */
  193.   SPI1_IRQn                   = 35,     /*!< SPI1 global Interrupt                                */
  194.   USART1_IRQn                 = 37,     /*!< USART1 global Interrupt                              */
  195.   USART2_IRQn                 = 38,     /*!< USART2 global Interrupt                              */
  196.   EXTI15_10_IRQn              = 40,     /*!< External Line[15:10] Interrupts                      */
  197.   RTCAlarm_IRQn               = 41,     /*!< RTC Alarm through EXTI Line Interrupt                */
  198.   USBWakeUp_IRQn              = 42      /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */    
  199. #endif /* STM32F10X_LD */  
  200.  
  201. #ifdef STM32F10X_LD_VL
  202.   ADC1_IRQn                   = 18,     /*!< ADC1 global Interrupt                                */
  203.   EXTI9_5_IRQn                = 23,     /*!< External Line[9:5] Interrupts                        */
  204.   TIM1_BRK_TIM15_IRQn         = 24,     /*!< TIM1 Break and TIM15 Interrupts                      */
  205.   TIM1_UP_TIM16_IRQn          = 25,     /*!< TIM1 Update and TIM16 Interrupts                     */
  206.   TIM1_TRG_COM_TIM17_IRQn     = 26,     /*!< TIM1 Trigger and Commutation and TIM17 Interrupt     */
  207.   TIM1_CC_IRQn                = 27,     /*!< TIM1 Capture Compare Interrupt                       */
  208.   TIM2_IRQn                   = 28,     /*!< TIM2 global Interrupt                                */
  209.   TIM3_IRQn                   = 29,     /*!< TIM3 global Interrupt                                */
  210.   I2C1_EV_IRQn                = 31,     /*!< I2C1 Event Interrupt                                 */
  211.   I2C1_ER_IRQn                = 32,     /*!< I2C1 Error Interrupt                                 */
  212.   SPI1_IRQn                   = 35,     /*!< SPI1 global Interrupt                                */
  213.   USART1_IRQn                 = 37,     /*!< USART1 global Interrupt                              */
  214.   USART2_IRQn                 = 38,     /*!< USART2 global Interrupt                              */
  215.   EXTI15_10_IRQn              = 40,     /*!< External Line[15:10] Interrupts                      */
  216.   RTCAlarm_IRQn               = 41,     /*!< RTC Alarm through EXTI Line Interrupt                */
  217.   CEC_IRQn                    = 42,     /*!< HDMI-CEC Interrupt                                   */
  218.   TIM6_DAC_IRQn               = 54,     /*!< TIM6 and DAC underrun Interrupt                      */
  219.   TIM7_IRQn                   = 55      /*!< TIM7 Interrupt                                       */      
  220. #endif /* STM32F10X_LD_VL */
  221.  
  222. #ifdef STM32F10X_MD
  223.   ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
  224.   USB_HP_CAN1_TX_IRQn         = 19,     /*!< USB Device High Priority or CAN1 TX Interrupts       */
  225.   USB_LP_CAN1_RX0_IRQn        = 20,     /*!< USB Device Low Priority or CAN1 RX0 Interrupts       */
  226.   CAN1_RX1_IRQn               = 21,     /*!< CAN1 RX1 Interrupt                                   */
  227.   CAN1_SCE_IRQn               = 22,     /*!< CAN1 SCE Interrupt                                   */
  228.   EXTI9_5_IRQn                = 23,     /*!< External Line[9:5] Interrupts                        */
  229.   TIM1_BRK_IRQn               = 24,     /*!< TIM1 Break Interrupt                                 */
  230.   TIM1_UP_IRQn                = 25,     /*!< TIM1 Update Interrupt                                */
  231.   TIM1_TRG_COM_IRQn           = 26,     /*!< TIM1 Trigger and Commutation Interrupt               */
  232.   TIM1_CC_IRQn                = 27,     /*!< TIM1 Capture Compare Interrupt                       */
  233.   TIM2_IRQn                   = 28,     /*!< TIM2 global Interrupt                                */
  234.   TIM3_IRQn                   = 29,     /*!< TIM3 global Interrupt                                */
  235.   TIM4_IRQn                   = 30,     /*!< TIM4 global Interrupt                                */
  236.   I2C1_EV_IRQn                = 31,     /*!< I2C1 Event Interrupt                                 */
  237.   I2C1_ER_IRQn                = 32,     /*!< I2C1 Error Interrupt                                 */
  238.   I2C2_EV_IRQn                = 33,     /*!< I2C2 Event Interrupt                                 */
  239.   I2C2_ER_IRQn                = 34,     /*!< I2C2 Error Interrupt                                 */
  240.   SPI1_IRQn                   = 35,     /*!< SPI1 global Interrupt                                */
  241.   SPI2_IRQn                   = 36,     /*!< SPI2 global Interrupt                                */
  242.   USART1_IRQn                 = 37,     /*!< USART1 global Interrupt                              */
  243.   USART2_IRQn                 = 38,     /*!< USART2 global Interrupt                              */
  244.   USART3_IRQn                 = 39,     /*!< USART3 global Interrupt                              */
  245.   EXTI15_10_IRQn              = 40,     /*!< External Line[15:10] Interrupts                      */
  246.   RTCAlarm_IRQn               = 41,     /*!< RTC Alarm through EXTI Line Interrupt                */
  247.   USBWakeUp_IRQn              = 42      /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */  
  248. #endif /* STM32F10X_MD */  
  249.  
  250. #ifdef STM32F10X_MD_VL
  251.   ADC1_IRQn                   = 18,     /*!< ADC1 global Interrupt                                */
  252.   EXTI9_5_IRQn                = 23,     /*!< External Line[9:5] Interrupts                        */
  253.   TIM1_BRK_TIM15_IRQn         = 24,     /*!< TIM1 Break and TIM15 Interrupts                      */
  254.   TIM1_UP_TIM16_IRQn          = 25,     /*!< TIM1 Update and TIM16 Interrupts                     */
  255.   TIM1_TRG_COM_TIM17_IRQn     = 26,     /*!< TIM1 Trigger and Commutation and TIM17 Interrupt     */
  256.   TIM1_CC_IRQn                = 27,     /*!< TIM1 Capture Compare Interrupt                       */
  257.   TIM2_IRQn                   = 28,     /*!< TIM2 global Interrupt                                */
  258.   TIM3_IRQn                   = 29,     /*!< TIM3 global Interrupt                                */
  259.   TIM4_IRQn                   = 30,     /*!< TIM4 global Interrupt                                */
  260.   I2C1_EV_IRQn                = 31,     /*!< I2C1 Event Interrupt                                 */
  261.   I2C1_ER_IRQn                = 32,     /*!< I2C1 Error Interrupt                                 */
  262.   I2C2_EV_IRQn                = 33,     /*!< I2C2 Event Interrupt                                 */
  263.   I2C2_ER_IRQn                = 34,     /*!< I2C2 Error Interrupt                                 */
  264.   SPI1_IRQn                   = 35,     /*!< SPI1 global Interrupt                                */
  265.   SPI2_IRQn                   = 36,     /*!< SPI2 global Interrupt                                */
  266.   USART1_IRQn                 = 37,     /*!< USART1 global Interrupt                              */
  267.   USART2_IRQn                 = 38,     /*!< USART2 global Interrupt                              */
  268.   USART3_IRQn                 = 39,     /*!< USART3 global Interrupt                              */
  269.   EXTI15_10_IRQn              = 40,     /*!< External Line[15:10] Interrupts                      */
  270.   RTCAlarm_IRQn               = 41,     /*!< RTC Alarm through EXTI Line Interrupt                */
  271.   CEC_IRQn                    = 42,     /*!< HDMI-CEC Interrupt                                   */
  272.   TIM6_DAC_IRQn               = 54,     /*!< TIM6 and DAC underrun Interrupt                      */
  273.   TIM7_IRQn                   = 55      /*!< TIM7 Interrupt                                       */      
  274. #endif /* STM32F10X_MD_VL */
  275.  
  276. #ifdef STM32F10X_HD
  277.   ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
  278.   USB_HP_CAN1_TX_IRQn         = 19,     /*!< USB Device High Priority or CAN1 TX Interrupts       */
  279.   USB_LP_CAN1_RX0_IRQn        = 20,     /*!< USB Device Low Priority or CAN1 RX0 Interrupts       */
  280.   CAN1_RX1_IRQn               = 21,     /*!< CAN1 RX1 Interrupt                                   */
  281.   CAN1_SCE_IRQn               = 22,     /*!< CAN1 SCE Interrupt                                   */
  282.   EXTI9_5_IRQn                = 23,     /*!< External Line[9:5] Interrupts                        */
  283.   TIM1_BRK_IRQn               = 24,     /*!< TIM1 Break Interrupt                                 */
  284.   TIM1_UP_IRQn                = 25,     /*!< TIM1 Update Interrupt                                */
  285.   TIM1_TRG_COM_IRQn           = 26,     /*!< TIM1 Trigger and Commutation Interrupt               */
  286.   TIM1_CC_IRQn                = 27,     /*!< TIM1 Capture Compare Interrupt                       */
  287.   TIM2_IRQn                   = 28,     /*!< TIM2 global Interrupt                                */
  288.   TIM3_IRQn                   = 29,     /*!< TIM3 global Interrupt                                */
  289.   TIM4_IRQn                   = 30,     /*!< TIM4 global Interrupt                                */
  290.   I2C1_EV_IRQn                = 31,     /*!< I2C1 Event Interrupt                                 */
  291.   I2C1_ER_IRQn                = 32,     /*!< I2C1 Error Interrupt                                 */
  292.   I2C2_EV_IRQn                = 33,     /*!< I2C2 Event Interrupt                                 */
  293.   I2C2_ER_IRQn                = 34,     /*!< I2C2 Error Interrupt                                 */
  294.   SPI1_IRQn                   = 35,     /*!< SPI1 global Interrupt                                */
  295.   SPI2_IRQn                   = 36,     /*!< SPI2 global Interrupt                                */
  296.   USART1_IRQn                 = 37,     /*!< USART1 global Interrupt                              */
  297.   USART2_IRQn                 = 38,     /*!< USART2 global Interrupt                              */
  298.   USART3_IRQn                 = 39,     /*!< USART3 global Interrupt                              */
  299.   EXTI15_10_IRQn              = 40,     /*!< External Line[15:10] Interrupts                      */
  300.   RTCAlarm_IRQn               = 41,     /*!< RTC Alarm through EXTI Line Interrupt                */
  301.   USBWakeUp_IRQn              = 42,     /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */
  302.   TIM8_BRK_IRQn               = 43,     /*!< TIM8 Break Interrupt                                 */
  303.   TIM8_UP_IRQn                = 44,     /*!< TIM8 Update Interrupt                                */
  304.   TIM8_TRG_COM_IRQn           = 45,     /*!< TIM8 Trigger and Commutation Interrupt               */
  305.   TIM8_CC_IRQn                = 46,     /*!< TIM8 Capture Compare Interrupt                       */
  306.   ADC3_IRQn                   = 47,     /*!< ADC3 global Interrupt                                */
  307.   FSMC_IRQn                   = 48,     /*!< FSMC global Interrupt                                */
  308.   SDIO_IRQn                   = 49,     /*!< SDIO global Interrupt                                */
  309.   TIM5_IRQn                   = 50,     /*!< TIM5 global Interrupt                                */
  310.   SPI3_IRQn                   = 51,     /*!< SPI3 global Interrupt                                */
  311.   UART4_IRQn                  = 52,     /*!< UART4 global Interrupt                               */
  312.   UART5_IRQn                  = 53,     /*!< UART5 global Interrupt                               */
  313.   TIM6_IRQn                   = 54,     /*!< TIM6 global Interrupt                                */
  314.   TIM7_IRQn                   = 55,     /*!< TIM7 global Interrupt                                */
  315.   DMA2_Channel1_IRQn          = 56,     /*!< DMA2 Channel 1 global Interrupt                      */
  316.   DMA2_Channel2_IRQn          = 57,     /*!< DMA2 Channel 2 global Interrupt                      */
  317.   DMA2_Channel3_IRQn          = 58,     /*!< DMA2 Channel 3 global Interrupt                      */
  318.   DMA2_Channel4_5_IRQn        = 59      /*!< DMA2 Channel 4 and Channel 5 global Interrupt        */
  319. #endif /* STM32F10X_HD */  
  320.  
  321. #ifdef STM32F10X_HD_VL
  322.   ADC1_IRQn                   = 18,     /*!< ADC1 global Interrupt                                */
  323.   EXTI9_5_IRQn                = 23,     /*!< External Line[9:5] Interrupts                        */
  324.   TIM1_BRK_TIM15_IRQn         = 24,     /*!< TIM1 Break and TIM15 Interrupts                      */
  325.   TIM1_UP_TIM16_IRQn          = 25,     /*!< TIM1 Update and TIM16 Interrupts                     */
  326.   TIM1_TRG_COM_TIM17_IRQn     = 26,     /*!< TIM1 Trigger and Commutation and TIM17 Interrupt     */
  327.   TIM1_CC_IRQn                = 27,     /*!< TIM1 Capture Compare Interrupt                       */
  328.   TIM2_IRQn                   = 28,     /*!< TIM2 global Interrupt                                */
  329.   TIM3_IRQn                   = 29,     /*!< TIM3 global Interrupt                                */
  330.   TIM4_IRQn                   = 30,     /*!< TIM4 global Interrupt                                */
  331.   I2C1_EV_IRQn                = 31,     /*!< I2C1 Event Interrupt                                 */
  332.   I2C1_ER_IRQn                = 32,     /*!< I2C1 Error Interrupt                                 */
  333.   I2C2_EV_IRQn                = 33,     /*!< I2C2 Event Interrupt                                 */
  334.   I2C2_ER_IRQn                = 34,     /*!< I2C2 Error Interrupt                                 */
  335.   SPI1_IRQn                   = 35,     /*!< SPI1 global Interrupt                                */
  336.   SPI2_IRQn                   = 36,     /*!< SPI2 global Interrupt                                */
  337.   USART1_IRQn                 = 37,     /*!< USART1 global Interrupt                              */
  338.   USART2_IRQn                 = 38,     /*!< USART2 global Interrupt                              */
  339.   USART3_IRQn                 = 39,     /*!< USART3 global Interrupt                              */
  340.   EXTI15_10_IRQn              = 40,     /*!< External Line[15:10] Interrupts                      */
  341.   RTCAlarm_IRQn               = 41,     /*!< RTC Alarm through EXTI Line Interrupt                */
  342.   CEC_IRQn                    = 42,     /*!< HDMI-CEC Interrupt                                   */
  343.   TIM12_IRQn                  = 43,     /*!< TIM12 global Interrupt                               */
  344.   TIM13_IRQn                  = 44,     /*!< TIM13 global Interrupt                               */
  345.   TIM14_IRQn                  = 45,     /*!< TIM14 global Interrupt                               */
  346.   TIM5_IRQn                   = 50,     /*!< TIM5 global Interrupt                                */
  347.   SPI3_IRQn                   = 51,     /*!< SPI3 global Interrupt                                */
  348.   UART4_IRQn                  = 52,     /*!< UART4 global Interrupt                               */
  349.   UART5_IRQn                  = 53,     /*!< UART5 global Interrupt                               */  
  350.   TIM6_DAC_IRQn               = 54,     /*!< TIM6 and DAC underrun Interrupt                      */
  351.   TIM7_IRQn                   = 55,     /*!< TIM7 Interrupt                                       */  
  352.   DMA2_Channel1_IRQn          = 56,     /*!< DMA2 Channel 1 global Interrupt                      */
  353.   DMA2_Channel2_IRQn          = 57,     /*!< DMA2 Channel 2 global Interrupt                      */
  354.   DMA2_Channel3_IRQn          = 58,     /*!< DMA2 Channel 3 global Interrupt                      */
  355.   DMA2_Channel4_5_IRQn        = 59,     /*!< DMA2 Channel 4 and Channel 5 global Interrupt        */
  356.   DMA2_Channel5_IRQn          = 60      /*!< DMA2 Channel 5 global Interrupt (DMA2 Channel 5 is
  357.                                              mapped at position 60 only if the MISC_REMAP bit in
  358.                                              the AFIO_MAPR2 register is set)                      */      
  359. #endif /* STM32F10X_HD_VL */
  360.  
  361. #ifdef STM32F10X_XL
  362.   ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
  363.   USB_HP_CAN1_TX_IRQn         = 19,     /*!< USB Device High Priority or CAN1 TX Interrupts       */
  364.   USB_LP_CAN1_RX0_IRQn        = 20,     /*!< USB Device Low Priority or CAN1 RX0 Interrupts       */
  365.   CAN1_RX1_IRQn               = 21,     /*!< CAN1 RX1 Interrupt                                   */
  366.   CAN1_SCE_IRQn               = 22,     /*!< CAN1 SCE Interrupt                                   */
  367.   EXTI9_5_IRQn                = 23,     /*!< External Line[9:5] Interrupts                        */
  368.   TIM1_BRK_TIM9_IRQn          = 24,     /*!< TIM1 Break Interrupt and TIM9 global Interrupt       */
  369.   TIM1_UP_TIM10_IRQn          = 25,     /*!< TIM1 Update Interrupt and TIM10 global Interrupt     */
  370.   TIM1_TRG_COM_TIM11_IRQn     = 26,     /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */
  371.   TIM1_CC_IRQn                = 27,     /*!< TIM1 Capture Compare Interrupt                       */
  372.   TIM2_IRQn                   = 28,     /*!< TIM2 global Interrupt                                */
  373.   TIM3_IRQn                   = 29,     /*!< TIM3 global Interrupt                                */
  374.   TIM4_IRQn                   = 30,     /*!< TIM4 global Interrupt                                */
  375.   I2C1_EV_IRQn                = 31,     /*!< I2C1 Event Interrupt                                 */
  376.   I2C1_ER_IRQn                = 32,     /*!< I2C1 Error Interrupt                                 */
  377.   I2C2_EV_IRQn                = 33,     /*!< I2C2 Event Interrupt                                 */
  378.   I2C2_ER_IRQn                = 34,     /*!< I2C2 Error Interrupt                                 */
  379.   SPI1_IRQn                   = 35,     /*!< SPI1 global Interrupt                                */
  380.   SPI2_IRQn                   = 36,     /*!< SPI2 global Interrupt                                */
  381.   USART1_IRQn                 = 37,     /*!< USART1 global Interrupt                              */
  382.   USART2_IRQn                 = 38,     /*!< USART2 global Interrupt                              */
  383.   USART3_IRQn                 = 39,     /*!< USART3 global Interrupt                              */
  384.   EXTI15_10_IRQn              = 40,     /*!< External Line[15:10] Interrupts                      */
  385.   RTCAlarm_IRQn               = 41,     /*!< RTC Alarm through EXTI Line Interrupt                */
  386.   USBWakeUp_IRQn              = 42,     /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */
  387.   TIM8_BRK_TIM12_IRQn         = 43,     /*!< TIM8 Break Interrupt and TIM12 global Interrupt      */
  388.   TIM8_UP_TIM13_IRQn          = 44,     /*!< TIM8 Update Interrupt and TIM13 global Interrupt     */
  389.   TIM8_TRG_COM_TIM14_IRQn     = 45,     /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */
  390.   TIM8_CC_IRQn                = 46,     /*!< TIM8 Capture Compare Interrupt                       */
  391.   ADC3_IRQn                   = 47,     /*!< ADC3 global Interrupt                                */
  392.   FSMC_IRQn                   = 48,     /*!< FSMC global Interrupt                                */
  393.   SDIO_IRQn                   = 49,     /*!< SDIO global Interrupt                                */
  394.   TIM5_IRQn                   = 50,     /*!< TIM5 global Interrupt                                */
  395.   SPI3_IRQn                   = 51,     /*!< SPI3 global Interrupt                                */
  396.   UART4_IRQn                  = 52,     /*!< UART4 global Interrupt                               */
  397.   UART5_IRQn                  = 53,     /*!< UART5 global Interrupt                               */
  398.   TIM6_IRQn                   = 54,     /*!< TIM6 global Interrupt                                */
  399.   TIM7_IRQn                   = 55,     /*!< TIM7 global Interrupt                                */
  400.   DMA2_Channel1_IRQn          = 56,     /*!< DMA2 Channel 1 global Interrupt                      */
  401.   DMA2_Channel2_IRQn          = 57,     /*!< DMA2 Channel 2 global Interrupt                      */
  402.   DMA2_Channel3_IRQn          = 58,     /*!< DMA2 Channel 3 global Interrupt                      */
  403.   DMA2_Channel4_5_IRQn        = 59      /*!< DMA2 Channel 4 and Channel 5 global Interrupt        */
  404. #endif /* STM32F10X_XL */  
  405.  
  406. #ifdef STM32F10X_CL
  407.   ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
  408.   CAN1_TX_IRQn                = 19,     /*!< USB Device High Priority or CAN1 TX Interrupts       */
  409.   CAN1_RX0_IRQn               = 20,     /*!< USB Device Low Priority or CAN1 RX0 Interrupts       */
  410.   CAN1_RX1_IRQn               = 21,     /*!< CAN1 RX1 Interrupt                                   */
  411.   CAN1_SCE_IRQn               = 22,     /*!< CAN1 SCE Interrupt                                   */
  412.   EXTI9_5_IRQn                = 23,     /*!< External Line[9:5] Interrupts                        */
  413.   TIM1_BRK_IRQn               = 24,     /*!< TIM1 Break Interrupt                                 */
  414.   TIM1_UP_IRQn                = 25,     /*!< TIM1 Update Interrupt                                */
  415.   TIM1_TRG_COM_IRQn           = 26,     /*!< TIM1 Trigger and Commutation Interrupt               */
  416.   TIM1_CC_IRQn                = 27,     /*!< TIM1 Capture Compare Interrupt                       */
  417.   TIM2_IRQn                   = 28,     /*!< TIM2 global Interrupt                                */
  418.   TIM3_IRQn                   = 29,     /*!< TIM3 global Interrupt                                */
  419.   TIM4_IRQn                   = 30,     /*!< TIM4 global Interrupt                                */
  420.   I2C1_EV_IRQn                = 31,     /*!< I2C1 Event Interrupt                                 */
  421.   I2C1_ER_IRQn                = 32,     /*!< I2C1 Error Interrupt                                 */
  422.   I2C2_EV_IRQn                = 33,     /*!< I2C2 Event Interrupt                                 */
  423.   I2C2_ER_IRQn                = 34,     /*!< I2C2 Error Interrupt                                 */
  424.   SPI1_IRQn                   = 35,     /*!< SPI1 global Interrupt                                */
  425.   SPI2_IRQn                   = 36,     /*!< SPI2 global Interrupt                                */
  426.   USART1_IRQn                 = 37,     /*!< USART1 global Interrupt                              */
  427.   USART2_IRQn                 = 38,     /*!< USART2 global Interrupt                              */
  428.   USART3_IRQn                 = 39,     /*!< USART3 global Interrupt                              */
  429.   EXTI15_10_IRQn              = 40,     /*!< External Line[15:10] Interrupts                      */
  430.   RTCAlarm_IRQn               = 41,     /*!< RTC Alarm through EXTI Line Interrupt                */
  431.   OTG_FS_WKUP_IRQn            = 42,     /*!< USB OTG FS WakeUp from suspend through EXTI Line Interrupt */
  432.   TIM5_IRQn                   = 50,     /*!< TIM5 global Interrupt                                */
  433.   SPI3_IRQn                   = 51,     /*!< SPI3 global Interrupt                                */
  434.   UART4_IRQn                  = 52,     /*!< UART4 global Interrupt                               */
  435.   UART5_IRQn                  = 53,     /*!< UART5 global Interrupt                               */
  436.   TIM6_IRQn                   = 54,     /*!< TIM6 global Interrupt                                */
  437.   TIM7_IRQn                   = 55,     /*!< TIM7 global Interrupt                                */
  438.   DMA2_Channel1_IRQn          = 56,     /*!< DMA2 Channel 1 global Interrupt                      */
  439.   DMA2_Channel2_IRQn          = 57,     /*!< DMA2 Channel 2 global Interrupt                      */
  440.   DMA2_Channel3_IRQn          = 58,     /*!< DMA2 Channel 3 global Interrupt                      */
  441.   DMA2_Channel4_IRQn          = 59,     /*!< DMA2 Channel 4 global Interrupt                      */
  442.   DMA2_Channel5_IRQn          = 60,     /*!< DMA2 Channel 5 global Interrupt                      */
  443.   ETH_IRQn                    = 61,     /*!< Ethernet global Interrupt                            */
  444.   ETH_WKUP_IRQn               = 62,     /*!< Ethernet Wakeup through EXTI line Interrupt          */
  445.   CAN2_TX_IRQn                = 63,     /*!< CAN2 TX Interrupt                                    */
  446.   CAN2_RX0_IRQn               = 64,     /*!< CAN2 RX0 Interrupt                                   */
  447.   CAN2_RX1_IRQn               = 65,     /*!< CAN2 RX1 Interrupt                                   */
  448.   CAN2_SCE_IRQn               = 66,     /*!< CAN2 SCE Interrupt                                   */
  449.   OTG_FS_IRQn                 = 67      /*!< USB OTG FS global Interrupt                          */
  450. #endif /* STM32F10X_CL */    
  451. } IRQn_Type;
  452.  
  453. /**
  454.   * @}
  455.   */
  456.  
  457. #include "core_cm3.h"
  458. #include "system_stm32f10x.h"
  459. #include <stdint.h>
  460.  
  461. /** @addtogroup Exported_types
  462.   * @{
  463.   */  
  464.  
  465. /*!< STM32F10x Standard Peripheral Library old types (maintained for legacy purpose) */
  466. typedef int32_t  s32;
  467. typedef int16_t s16;
  468. typedef int8_t  s8;
  469.  
  470. typedef const int32_t sc32;  /*!< Read Only */
  471. typedef const int16_t sc16;  /*!< Read Only */
  472. typedef const int8_t sc8;   /*!< Read Only */
  473.  
  474. typedef __IO int32_t  vs32;
  475. typedef __IO int16_t  vs16;
  476. typedef __IO int8_t   vs8;
  477.  
  478. typedef __I int32_t vsc32;  /*!< Read Only */
  479. typedef __I int16_t vsc16;  /*!< Read Only */
  480. typedef __I int8_t vsc8;   /*!< Read Only */
  481.  
  482. typedef uint32_t  u32;
  483. typedef uint16_t u16;
  484. typedef uint8_t  u8;
  485.  
  486. typedef const uint32_t uc32;  /*!< Read Only */
  487. typedef const uint16_t uc16;  /*!< Read Only */
  488. typedef const uint8_t uc8;   /*!< Read Only */
  489.  
  490. typedef __IO uint32_t  vu32;
  491. typedef __IO uint16_t vu16;
  492. typedef __IO uint8_t  vu8;
  493.  
  494. typedef __I uint32_t vuc32;  /*!< Read Only */
  495. typedef __I uint16_t vuc16;  /*!< Read Only */
  496. typedef __I uint8_t vuc8;   /*!< Read Only */
  497.  
  498. typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
  499.  
  500. typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
  501. #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
  502.  
  503. typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
  504.  
  505. /*!< STM32F10x Standard Peripheral Library old definitions (maintained for legacy purpose) */
  506. #define HSEStartUp_TimeOut   HSE_STARTUP_TIMEOUT
  507. #define HSE_Value            HSE_VALUE
  508. #define HSI_Value            HSI_VALUE
  509. /**
  510.   * @}
  511.   */
  512.  
  513. /** @addtogroup Peripheral_registers_structures
  514.   * @{
  515.   */  
  516.  
  517. /**
  518.   * @brief Analog to Digital Converter  
  519.   */
  520.  
  521. typedef struct
  522. {
  523.   __IO uint32_t SR;
  524.   __IO uint32_t CR1;
  525.   __IO uint32_t CR2;
  526.   __IO uint32_t SMPR1;
  527.   __IO uint32_t SMPR2;
  528.   __IO uint32_t JOFR1;
  529.   __IO uint32_t JOFR2;
  530.   __IO uint32_t JOFR3;
  531.   __IO uint32_t JOFR4;
  532.   __IO uint32_t HTR;
  533.   __IO uint32_t LTR;
  534.   __IO uint32_t SQR1;
  535.   __IO uint32_t SQR2;
  536.   __IO uint32_t SQR3;
  537.   __IO uint32_t JSQR;
  538.   __IO uint32_t JDR1;
  539.   __IO uint32_t JDR2;
  540.   __IO uint32_t JDR3;
  541.   __IO uint32_t JDR4;
  542.   __IO uint32_t DR;
  543. } ADC_TypeDef;
  544.  
  545. /**
  546.   * @brief Backup Registers  
  547.   */
  548.  
  549. typedef struct
  550. {
  551.   uint32_t  RESERVED0;
  552.   __IO uint16_t DR1;
  553.   uint16_t  RESERVED1;
  554.   __IO uint16_t DR2;
  555.   uint16_t  RESERVED2;
  556.   __IO uint16_t DR3;
  557.   uint16_t  RESERVED3;
  558.   __IO uint16_t DR4;
  559.   uint16_t  RESERVED4;
  560.   __IO uint16_t DR5;
  561.   uint16_t  RESERVED5;
  562.   __IO uint16_t DR6;
  563.   uint16_t  RESERVED6;
  564.   __IO uint16_t DR7;
  565.   uint16_t  RESERVED7;
  566.   __IO uint16_t DR8;
  567.   uint16_t  RESERVED8;
  568.   __IO uint16_t DR9;
  569.   uint16_t  RESERVED9;
  570.   __IO uint16_t DR10;
  571.   uint16_t  RESERVED10;
  572.   __IO uint16_t RTCCR;
  573.   uint16_t  RESERVED11;
  574.   __IO uint16_t CR;
  575.   uint16_t  RESERVED12;
  576.   __IO uint16_t CSR;
  577.   uint16_t  RESERVED13[5];
  578.   __IO uint16_t DR11;
  579.   uint16_t  RESERVED14;
  580.   __IO uint16_t DR12;
  581.   uint16_t  RESERVED15;
  582.   __IO uint16_t DR13;
  583.   uint16_t  RESERVED16;
  584.   __IO uint16_t DR14;
  585.   uint16_t  RESERVED17;
  586.   __IO uint16_t DR15;
  587.   uint16_t  RESERVED18;
  588.   __IO uint16_t DR16;
  589.   uint16_t  RESERVED19;
  590.   __IO uint16_t DR17;
  591.   uint16_t  RESERVED20;
  592.   __IO uint16_t DR18;
  593.   uint16_t  RESERVED21;
  594.   __IO uint16_t DR19;
  595.   uint16_t  RESERVED22;
  596.   __IO uint16_t DR20;
  597.   uint16_t  RESERVED23;
  598.   __IO uint16_t DR21;
  599.   uint16_t  RESERVED24;
  600.   __IO uint16_t DR22;
  601.   uint16_t  RESERVED25;
  602.   __IO uint16_t DR23;
  603.   uint16_t  RESERVED26;
  604.   __IO uint16_t DR24;
  605.   uint16_t  RESERVED27;
  606.   __IO uint16_t DR25;
  607.   uint16_t  RESERVED28;
  608.   __IO uint16_t DR26;
  609.   uint16_t  RESERVED29;
  610.   __IO uint16_t DR27;
  611.   uint16_t  RESERVED30;
  612.   __IO uint16_t DR28;
  613.   uint16_t  RESERVED31;
  614.   __IO uint16_t DR29;
  615.   uint16_t  RESERVED32;
  616.   __IO uint16_t DR30;
  617.   uint16_t  RESERVED33;
  618.   __IO uint16_t DR31;
  619.   uint16_t  RESERVED34;
  620.   __IO uint16_t DR32;
  621.   uint16_t  RESERVED35;
  622.   __IO uint16_t DR33;
  623.   uint16_t  RESERVED36;
  624.   __IO uint16_t DR34;
  625.   uint16_t  RESERVED37;
  626.   __IO uint16_t DR35;
  627.   uint16_t  RESERVED38;
  628.   __IO uint16_t DR36;
  629.   uint16_t  RESERVED39;
  630.   __IO uint16_t DR37;
  631.   uint16_t  RESERVED40;
  632.   __IO uint16_t DR38;
  633.   uint16_t  RESERVED41;
  634.   __IO uint16_t DR39;
  635.   uint16_t  RESERVED42;
  636.   __IO uint16_t DR40;
  637.   uint16_t  RESERVED43;
  638.   __IO uint16_t DR41;
  639.   uint16_t  RESERVED44;
  640.   __IO uint16_t DR42;
  641.   uint16_t  RESERVED45;    
  642. } BKP_TypeDef;
  643.  
  644. /**
  645.   * @brief Controller Area Network TxMailBox
  646.   */
  647.  
  648. typedef struct
  649. {
  650.   __IO uint32_t TIR;
  651.   __IO uint32_t TDTR;
  652.   __IO uint32_t TDLR;
  653.   __IO uint32_t TDHR;
  654. } CAN_TxMailBox_TypeDef;
  655.  
  656. /**
  657.   * @brief Controller Area Network FIFOMailBox
  658.   */
  659.  
  660. typedef struct
  661. {
  662.   __IO uint32_t RIR;
  663.   __IO uint32_t RDTR;
  664.   __IO uint32_t RDLR;
  665.   __IO uint32_t RDHR;
  666. } CAN_FIFOMailBox_TypeDef;
  667.  
  668. /**
  669.   * @brief Controller Area Network FilterRegister
  670.   */
  671.  
  672. typedef struct
  673. {
  674.   __IO uint32_t FR1;
  675.   __IO uint32_t FR2;
  676. } CAN_FilterRegister_TypeDef;
  677.  
  678. /**
  679.   * @brief Controller Area Network
  680.   */
  681.  
  682. typedef struct
  683. {
  684.   __IO uint32_t MCR;
  685.   __IO uint32_t MSR;
  686.   __IO uint32_t TSR;
  687.   __IO uint32_t RF0R;
  688.   __IO uint32_t RF1R;
  689.   __IO uint32_t IER;
  690.   __IO uint32_t ESR;
  691.   __IO uint32_t BTR;
  692.   uint32_t  RESERVED0[88];
  693.   CAN_TxMailBox_TypeDef sTxMailBox[3];
  694.   CAN_FIFOMailBox_TypeDef sFIFOMailBox[2];
  695.   uint32_t  RESERVED1[12];
  696.   __IO uint32_t FMR;
  697.   __IO uint32_t FM1R;
  698.   uint32_t  RESERVED2;
  699.   __IO uint32_t FS1R;
  700.   uint32_t  RESERVED3;
  701.   __IO uint32_t FFA1R;
  702.   uint32_t  RESERVED4;
  703.   __IO uint32_t FA1R;
  704.   uint32_t  RESERVED5[8];
  705. #ifndef STM32F10X_CL
  706.   CAN_FilterRegister_TypeDef sFilterRegister[14];
  707. #else
  708.   CAN_FilterRegister_TypeDef sFilterRegister[28];
  709. #endif /* STM32F10X_CL */  
  710. } CAN_TypeDef;
  711.  
  712. /**
  713.   * @brief Consumer Electronics Control (CEC)
  714.   */
  715. typedef struct
  716. {
  717.   __IO uint32_t CFGR;
  718.   __IO uint32_t OAR;
  719.   __IO uint32_t PRES;
  720.   __IO uint32_t ESR;
  721.   __IO uint32_t CSR;
  722.   __IO uint32_t TXD;
  723.   __IO uint32_t RXD;  
  724. } CEC_TypeDef;
  725.  
  726. /**
  727.   * @brief CRC calculation unit
  728.   */
  729.  
  730. typedef struct
  731. {
  732.   __IO uint32_t DR;
  733.   __IO uint8_t  IDR;
  734.   uint8_t   RESERVED0;
  735.   uint16_t  RESERVED1;
  736.   __IO uint32_t CR;
  737. } CRC_TypeDef;
  738.  
  739. /**
  740.   * @brief Digital to Analog Converter
  741.   */
  742.  
  743. typedef struct
  744. {
  745.   __IO uint32_t CR;
  746.   __IO uint32_t SWTRIGR;
  747.   __IO uint32_t DHR12R1;
  748.   __IO uint32_t DHR12L1;
  749.   __IO uint32_t DHR8R1;
  750.   __IO uint32_t DHR12R2;
  751.   __IO uint32_t DHR12L2;
  752.   __IO uint32_t DHR8R2;
  753.   __IO uint32_t DHR12RD;
  754.   __IO uint32_t DHR12LD;
  755.   __IO uint32_t DHR8RD;
  756.   __IO uint32_t DOR1;
  757.   __IO uint32_t DOR2;
  758. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  759.   __IO uint32_t SR;
  760. #endif
  761. } DAC_TypeDef;
  762.  
  763. /**
  764.   * @brief Debug MCU
  765.   */
  766.  
  767. typedef struct
  768. {
  769.   __IO uint32_t IDCODE;
  770.   __IO uint32_t CR;
  771. }DBGMCU_TypeDef;
  772.  
  773. /**
  774.   * @brief DMA Controller
  775.   */
  776.  
  777. typedef struct
  778. {
  779.   __IO uint32_t CCR;
  780.   __IO uint32_t CNDTR;
  781.   __IO uint32_t CPAR;
  782.   __IO uint32_t CMAR;
  783. } DMA_Channel_TypeDef;
  784.  
  785. typedef struct
  786. {
  787.   __IO uint32_t ISR;
  788.   __IO uint32_t IFCR;
  789. } DMA_TypeDef;
  790.  
  791. /**
  792.   * @brief Ethernet MAC
  793.   */
  794.  
  795. typedef struct
  796. {
  797.   __IO uint32_t MACCR;
  798.   __IO uint32_t MACFFR;
  799.   __IO uint32_t MACHTHR;
  800.   __IO uint32_t MACHTLR;
  801.   __IO uint32_t MACMIIAR;
  802.   __IO uint32_t MACMIIDR;
  803.   __IO uint32_t MACFCR;
  804.   __IO uint32_t MACVLANTR;             /*    8 */
  805.        uint32_t RESERVED0[2];
  806.   __IO uint32_t MACRWUFFR;             /*   11 */
  807.   __IO uint32_t MACPMTCSR;
  808.        uint32_t RESERVED1[2];
  809.   __IO uint32_t MACSR;                 /*   15 */
  810.   __IO uint32_t MACIMR;
  811.   __IO uint32_t MACA0HR;
  812.   __IO uint32_t MACA0LR;
  813.   __IO uint32_t MACA1HR;
  814.   __IO uint32_t MACA1LR;
  815.   __IO uint32_t MACA2HR;
  816.   __IO uint32_t MACA2LR;
  817.   __IO uint32_t MACA3HR;
  818.   __IO uint32_t MACA3LR;               /*   24 */
  819.        uint32_t RESERVED2[40];
  820.   __IO uint32_t MMCCR;                 /*   65 */
  821.   __IO uint32_t MMCRIR;
  822.   __IO uint32_t MMCTIR;
  823.   __IO uint32_t MMCRIMR;
  824.   __IO uint32_t MMCTIMR;               /*   69 */
  825.        uint32_t RESERVED3[14];
  826.   __IO uint32_t MMCTGFSCCR;            /*   84 */
  827.   __IO uint32_t MMCTGFMSCCR;
  828.        uint32_t RESERVED4[5];
  829.   __IO uint32_t MMCTGFCR;
  830.        uint32_t RESERVED5[10];
  831.   __IO uint32_t MMCRFCECR;
  832.   __IO uint32_t MMCRFAECR;
  833.        uint32_t RESERVED6[10];
  834.   __IO uint32_t MMCRGUFCR;
  835.        uint32_t RESERVED7[334];
  836.   __IO uint32_t PTPTSCR;
  837.   __IO uint32_t PTPSSIR;
  838.   __IO uint32_t PTPTSHR;
  839.   __IO uint32_t PTPTSLR;
  840.   __IO uint32_t PTPTSHUR;
  841.   __IO uint32_t PTPTSLUR;
  842.   __IO uint32_t PTPTSAR;
  843.   __IO uint32_t PTPTTHR;
  844.   __IO uint32_t PTPTTLR;
  845.        uint32_t RESERVED8[567];
  846.   __IO uint32_t DMABMR;
  847.   __IO uint32_t DMATPDR;
  848.   __IO uint32_t DMARPDR;
  849.   __IO uint32_t DMARDLAR;
  850.   __IO uint32_t DMATDLAR;
  851.   __IO uint32_t DMASR;
  852.   __IO uint32_t DMAOMR;
  853.   __IO uint32_t DMAIER;
  854.   __IO uint32_t DMAMFBOCR;
  855.        uint32_t RESERVED9[9];
  856.   __IO uint32_t DMACHTDR;
  857.   __IO uint32_t DMACHRDR;
  858.   __IO uint32_t DMACHTBAR;
  859.   __IO uint32_t DMACHRBAR;
  860. } ETH_TypeDef;
  861.  
  862. /**
  863.   * @brief External Interrupt/Event Controller
  864.   */
  865.  
  866. typedef struct
  867. {
  868.   __IO uint32_t IMR;
  869.   __IO uint32_t EMR;
  870.   __IO uint32_t RTSR;
  871.   __IO uint32_t FTSR;
  872.   __IO uint32_t SWIER;
  873.   __IO uint32_t PR;
  874. } EXTI_TypeDef;
  875.  
  876. /**
  877.   * @brief FLASH Registers
  878.   */
  879.  
  880. typedef struct
  881. {
  882.   __IO uint32_t ACR;
  883.   __IO uint32_t KEYR;
  884.   __IO uint32_t OPTKEYR;
  885.   __IO uint32_t SR;
  886.   __IO uint32_t CR;
  887.   __IO uint32_t AR;
  888.   __IO uint32_t RESERVED;
  889.   __IO uint32_t OBR;
  890.   __IO uint32_t WRPR;
  891. #ifdef STM32F10X_XL
  892.   uint32_t RESERVED1[8];
  893.   __IO uint32_t KEYR2;
  894.   uint32_t RESERVED2;  
  895.   __IO uint32_t SR2;
  896.   __IO uint32_t CR2;
  897.   __IO uint32_t AR2;
  898. #endif /* STM32F10X_XL */  
  899. } FLASH_TypeDef;
  900.  
  901. /**
  902.   * @brief Option Bytes Registers
  903.   */
  904.  
  905. typedef struct
  906. {
  907.   __IO uint16_t RDP;
  908.   __IO uint16_t USER;
  909.   __IO uint16_t Data0;
  910.   __IO uint16_t Data1;
  911.   __IO uint16_t WRP0;
  912.   __IO uint16_t WRP1;
  913.   __IO uint16_t WRP2;
  914.   __IO uint16_t WRP3;
  915. } OB_TypeDef;
  916.  
  917. /**
  918.   * @brief Flexible Static Memory Controller
  919.   */
  920.  
  921. typedef struct
  922. {
  923.   __IO uint32_t BTCR[8];  
  924. } FSMC_Bank1_TypeDef;
  925.  
  926. /**
  927.   * @brief Flexible Static Memory Controller Bank1E
  928.   */
  929.  
  930. typedef struct
  931. {
  932.   __IO uint32_t BWTR[7];
  933. } FSMC_Bank1E_TypeDef;
  934.  
  935. /**
  936.   * @brief Flexible Static Memory Controller Bank2
  937.   */
  938.  
  939. typedef struct
  940. {
  941.   __IO uint32_t PCR2;
  942.   __IO uint32_t SR2;
  943.   __IO uint32_t PMEM2;
  944.   __IO uint32_t PATT2;
  945.   uint32_t  RESERVED0;  
  946.   __IO uint32_t ECCR2;
  947. } FSMC_Bank2_TypeDef;  
  948.  
  949. /**
  950.   * @brief Flexible Static Memory Controller Bank3
  951.   */
  952.  
  953. typedef struct
  954. {
  955.   __IO uint32_t PCR3;
  956.   __IO uint32_t SR3;
  957.   __IO uint32_t PMEM3;
  958.   __IO uint32_t PATT3;
  959.   uint32_t  RESERVED0;  
  960.   __IO uint32_t ECCR3;
  961. } FSMC_Bank3_TypeDef;
  962.  
  963. /**
  964.   * @brief Flexible Static Memory Controller Bank4
  965.   */
  966.  
  967. typedef struct
  968. {
  969.   __IO uint32_t PCR4;
  970.   __IO uint32_t SR4;
  971.   __IO uint32_t PMEM4;
  972.   __IO uint32_t PATT4;
  973.   __IO uint32_t PIO4;
  974. } FSMC_Bank4_TypeDef;
  975.  
  976. /**
  977.   * @brief General Purpose I/O
  978.   */
  979.  
  980. typedef struct
  981. {
  982.   __IO uint32_t CRL;
  983.   __IO uint32_t CRH;
  984.   __IO uint32_t IDR;
  985.   __IO uint32_t ODR;
  986.   __IO uint32_t BSRR;
  987.   __IO uint32_t BRR;
  988.   __IO uint32_t LCKR;
  989. } GPIO_TypeDef;
  990.  
  991. /**
  992.   * @brief Alternate Function I/O
  993.   */
  994.  
  995. typedef struct
  996. {
  997.   __IO uint32_t EVCR;
  998.   __IO uint32_t MAPR;
  999.   __IO uint32_t EXTICR[4];
  1000.   uint32_t RESERVED0;
  1001.   __IO uint32_t MAPR2;  
  1002. } AFIO_TypeDef;
  1003. /**
  1004.   * @brief Inter Integrated Circuit Interface
  1005.   */
  1006.  
  1007. typedef struct
  1008. {
  1009.   __IO uint16_t CR1;
  1010.   uint16_t  RESERVED0;
  1011.   __IO uint16_t CR2;
  1012.   uint16_t  RESERVED1;
  1013.   __IO uint16_t OAR1;
  1014.   uint16_t  RESERVED2;
  1015.   __IO uint16_t OAR2;
  1016.   uint16_t  RESERVED3;
  1017.   __IO uint16_t DR;
  1018.   uint16_t  RESERVED4;
  1019.   __IO uint16_t SR1;
  1020.   uint16_t  RESERVED5;
  1021.   __IO uint16_t SR2;
  1022.   uint16_t  RESERVED6;
  1023.   __IO uint16_t CCR;
  1024.   uint16_t  RESERVED7;
  1025.   __IO uint16_t TRISE;
  1026.   uint16_t  RESERVED8;
  1027. } I2C_TypeDef;
  1028.  
  1029. /**
  1030.   * @brief Independent WATCHDOG
  1031.   */
  1032.  
  1033. typedef struct
  1034. {
  1035.   __IO uint32_t KR;
  1036.   __IO uint32_t PR;
  1037.   __IO uint32_t RLR;
  1038.   __IO uint32_t SR;
  1039. } IWDG_TypeDef;
  1040.  
  1041. /**
  1042.   * @brief Power Control
  1043.   */
  1044.  
  1045. typedef struct
  1046. {
  1047.   __IO uint32_t CR;
  1048.   __IO uint32_t CSR;
  1049. } PWR_TypeDef;
  1050.  
  1051. /**
  1052.   * @brief Reset and Clock Control
  1053.   */
  1054.  
  1055. typedef struct
  1056. {
  1057.   __IO uint32_t CR;
  1058.   __IO uint32_t CFGR;
  1059.   __IO uint32_t CIR;
  1060.   __IO uint32_t APB2RSTR;
  1061.   __IO uint32_t APB1RSTR;
  1062.   __IO uint32_t AHBENR;
  1063.   __IO uint32_t APB2ENR;
  1064.   __IO uint32_t APB1ENR;
  1065.   __IO uint32_t BDCR;
  1066.   __IO uint32_t CSR;
  1067.  
  1068. #ifdef STM32F10X_CL  
  1069.   __IO uint32_t AHBRSTR;
  1070.   __IO uint32_t CFGR2;
  1071. #endif /* STM32F10X_CL */
  1072.  
  1073. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)  
  1074.   uint32_t RESERVED0;
  1075.   __IO uint32_t CFGR2;
  1076. #endif /* STM32F10X_LD_VL || STM32F10X_MD_VL || STM32F10X_HD_VL */
  1077. } RCC_TypeDef;
  1078.  
  1079. /**
  1080.   * @brief Real-Time Clock
  1081.   */
  1082.  
  1083. typedef struct
  1084. {
  1085.   __IO uint16_t CRH;
  1086.   uint16_t  RESERVED0;
  1087.   __IO uint16_t CRL;
  1088.   uint16_t  RESERVED1;
  1089.   __IO uint16_t PRLH;
  1090.   uint16_t  RESERVED2;
  1091.   __IO uint16_t PRLL;
  1092.   uint16_t  RESERVED3;
  1093.   __IO uint16_t DIVH;
  1094.   uint16_t  RESERVED4;
  1095.   __IO uint16_t DIVL;
  1096.   uint16_t  RESERVED5;
  1097.   __IO uint16_t CNTH;
  1098.   uint16_t  RESERVED6;
  1099.   __IO uint16_t CNTL;
  1100.   uint16_t  RESERVED7;
  1101.   __IO uint16_t ALRH;
  1102.   uint16_t  RESERVED8;
  1103.   __IO uint16_t ALRL;
  1104.   uint16_t  RESERVED9;
  1105. } RTC_TypeDef;
  1106.  
  1107. /**
  1108.   * @brief SD host Interface
  1109.   */
  1110.  
  1111. typedef struct
  1112. {
  1113.   __IO uint32_t POWER;
  1114.   __IO uint32_t CLKCR;
  1115.   __IO uint32_t ARG;
  1116.   __IO uint32_t CMD;
  1117.   __I uint32_t RESPCMD;
  1118.   __I uint32_t RESP1;
  1119.   __I uint32_t RESP2;
  1120.   __I uint32_t RESP3;
  1121.   __I uint32_t RESP4;
  1122.   __IO uint32_t DTIMER;
  1123.   __IO uint32_t DLEN;
  1124.   __IO uint32_t DCTRL;
  1125.   __I uint32_t DCOUNT;
  1126.   __I uint32_t STA;
  1127.   __IO uint32_t ICR;
  1128.   __IO uint32_t MASK;
  1129.   uint32_t  RESERVED0[2];
  1130.   __I uint32_t FIFOCNT;
  1131.   uint32_t  RESERVED1[13];
  1132.   __IO uint32_t FIFO;
  1133. } SDIO_TypeDef;
  1134.  
  1135. /**
  1136.   * @brief Serial Peripheral Interface
  1137.   */
  1138.  
  1139. typedef struct
  1140. {
  1141.   __IO uint16_t CR1;
  1142.   uint16_t  RESERVED0;
  1143.   __IO uint16_t CR2;
  1144.   uint16_t  RESERVED1;
  1145.   __IO uint16_t SR;
  1146.   uint16_t  RESERVED2;
  1147.   __IO uint16_t DR;
  1148.   uint16_t  RESERVED3;
  1149.   __IO uint16_t CRCPR;
  1150.   uint16_t  RESERVED4;
  1151.   __IO uint16_t RXCRCR;
  1152.   uint16_t  RESERVED5;
  1153.   __IO uint16_t TXCRCR;
  1154.   uint16_t  RESERVED6;
  1155.   __IO uint16_t I2SCFGR;
  1156.   uint16_t  RESERVED7;
  1157.   __IO uint16_t I2SPR;
  1158.   uint16_t  RESERVED8;  
  1159. } SPI_TypeDef;
  1160.  
  1161. /**
  1162.   * @brief TIM
  1163.   */
  1164.  
  1165. typedef struct
  1166. {
  1167.   __IO uint16_t CR1;
  1168.   uint16_t  RESERVED0;
  1169.   __IO uint16_t CR2;
  1170.   uint16_t  RESERVED1;
  1171.   __IO uint16_t SMCR;
  1172.   uint16_t  RESERVED2;
  1173.   __IO uint16_t DIER;
  1174.   uint16_t  RESERVED3;
  1175.   __IO uint16_t SR;
  1176.   uint16_t  RESERVED4;
  1177.   __IO uint16_t EGR;
  1178.   uint16_t  RESERVED5;
  1179.   __IO uint16_t CCMR1;
  1180.   uint16_t  RESERVED6;
  1181.   __IO uint16_t CCMR2;
  1182.   uint16_t  RESERVED7;
  1183.   __IO uint16_t CCER;
  1184.   uint16_t  RESERVED8;
  1185.   __IO uint16_t CNT;
  1186.   uint16_t  RESERVED9;
  1187.   __IO uint16_t PSC;
  1188.   uint16_t  RESERVED10;
  1189.   __IO uint16_t ARR;
  1190.   uint16_t  RESERVED11;
  1191.   __IO uint16_t RCR;
  1192.   uint16_t  RESERVED12;
  1193.   __IO uint16_t CCR1;
  1194.   uint16_t  RESERVED13;
  1195.   __IO uint16_t CCR2;
  1196.   uint16_t  RESERVED14;
  1197.   __IO uint16_t CCR3;
  1198.   uint16_t  RESERVED15;
  1199.   __IO uint16_t CCR4;
  1200.   uint16_t  RESERVED16;
  1201.   __IO uint16_t BDTR;
  1202.   uint16_t  RESERVED17;
  1203.   __IO uint16_t DCR;
  1204.   uint16_t  RESERVED18;
  1205.   __IO uint16_t DMAR;
  1206.   uint16_t  RESERVED19;
  1207. } TIM_TypeDef;
  1208.  
  1209. /**
  1210.   * @brief Universal Synchronous Asynchronous Receiver Transmitter
  1211.   */
  1212.  
  1213. typedef struct
  1214. {
  1215.   __IO uint16_t SR;
  1216.   uint16_t  RESERVED0;
  1217.   __IO uint16_t DR;
  1218.   uint16_t  RESERVED1;
  1219.   __IO uint16_t BRR;
  1220.   uint16_t  RESERVED2;
  1221.   __IO uint16_t CR1;
  1222.   uint16_t  RESERVED3;
  1223.   __IO uint16_t CR2;
  1224.   uint16_t  RESERVED4;
  1225.   __IO uint16_t CR3;
  1226.   uint16_t  RESERVED5;
  1227.   __IO uint16_t GTPR;
  1228.   uint16_t  RESERVED6;
  1229. } USART_TypeDef;
  1230.  
  1231. /**
  1232.   * @brief Window WATCHDOG
  1233.   */
  1234.  
  1235. typedef struct
  1236. {
  1237.   __IO uint32_t CR;
  1238.   __IO uint32_t CFR;
  1239.   __IO uint32_t SR;
  1240. } WWDG_TypeDef;
  1241.  
  1242. /**
  1243.   * @}
  1244.   */
  1245.  
  1246. /** @addtogroup Peripheral_memory_map
  1247.   * @{
  1248.   */
  1249.  
  1250.  
  1251. #define FLASH_BASE            ((uint32_t)0x08000000) /*!< FLASH base address in the alias region */
  1252. #define SRAM_BASE             ((uint32_t)0x20000000) /*!< SRAM base address in the alias region */
  1253. #define PERIPH_BASE           ((uint32_t)0x40000000) /*!< Peripheral base address in the alias region */
  1254.  
  1255. #define SRAM_BB_BASE          ((uint32_t)0x22000000) /*!< SRAM base address in the bit-band region */
  1256. #define PERIPH_BB_BASE        ((uint32_t)0x42000000) /*!< Peripheral base address in the bit-band region */
  1257.  
  1258. #define FSMC_R_BASE           ((uint32_t)0xA0000000) /*!< FSMC registers base address */
  1259.  
  1260. /*!< Peripheral memory map */
  1261. #define APB1PERIPH_BASE       PERIPH_BASE
  1262. #define APB2PERIPH_BASE       (PERIPH_BASE + 0x10000)
  1263. #define AHBPERIPH_BASE        (PERIPH_BASE + 0x20000)
  1264.  
  1265. #define TIM2_BASE             (APB1PERIPH_BASE + 0x0000)
  1266. #define TIM3_BASE             (APB1PERIPH_BASE + 0x0400)
  1267. #define TIM4_BASE             (APB1PERIPH_BASE + 0x0800)
  1268. #define TIM5_BASE             (APB1PERIPH_BASE + 0x0C00)
  1269. #define TIM6_BASE             (APB1PERIPH_BASE + 0x1000)
  1270. #define TIM7_BASE             (APB1PERIPH_BASE + 0x1400)
  1271. #define TIM12_BASE            (APB1PERIPH_BASE + 0x1800)
  1272. #define TIM13_BASE            (APB1PERIPH_BASE + 0x1C00)
  1273. #define TIM14_BASE            (APB1PERIPH_BASE + 0x2000)
  1274. #define RTC_BASE              (APB1PERIPH_BASE + 0x2800)
  1275. #define WWDG_BASE             (APB1PERIPH_BASE + 0x2C00)
  1276. #define IWDG_BASE             (APB1PERIPH_BASE + 0x3000)
  1277. #define SPI2_BASE             (APB1PERIPH_BASE + 0x3800)
  1278. #define SPI3_BASE             (APB1PERIPH_BASE + 0x3C00)
  1279. #define USART2_BASE           (APB1PERIPH_BASE + 0x4400)
  1280. #define USART3_BASE           (APB1PERIPH_BASE + 0x4800)
  1281. #define UART4_BASE            (APB1PERIPH_BASE + 0x4C00)
  1282. #define UART5_BASE            (APB1PERIPH_BASE + 0x5000)
  1283. #define I2C1_BASE             (APB1PERIPH_BASE + 0x5400)
  1284. #define I2C2_BASE             (APB1PERIPH_BASE + 0x5800)
  1285. #define CAN1_BASE             (APB1PERIPH_BASE + 0x6400)
  1286. #define CAN2_BASE             (APB1PERIPH_BASE + 0x6800)
  1287. #define BKP_BASE              (APB1PERIPH_BASE + 0x6C00)
  1288. #define PWR_BASE              (APB1PERIPH_BASE + 0x7000)
  1289. #define DAC_BASE              (APB1PERIPH_BASE + 0x7400)
  1290. #define CEC_BASE              (APB1PERIPH_BASE + 0x7800)
  1291.  
  1292. #define AFIO_BASE             (APB2PERIPH_BASE + 0x0000)
  1293. #define EXTI_BASE             (APB2PERIPH_BASE + 0x0400)
  1294. #define GPIOA_BASE            (APB2PERIPH_BASE + 0x0800)
  1295. #define GPIOB_BASE            (APB2PERIPH_BASE + 0x0C00)
  1296. #define GPIOC_BASE            (APB2PERIPH_BASE + 0x1000)
  1297. #define GPIOD_BASE            (APB2PERIPH_BASE + 0x1400)
  1298. #define GPIOE_BASE            (APB2PERIPH_BASE + 0x1800)
  1299. #define GPIOF_BASE            (APB2PERIPH_BASE + 0x1C00)
  1300. #define GPIOG_BASE            (APB2PERIPH_BASE + 0x2000)
  1301. #define ADC1_BASE             (APB2PERIPH_BASE + 0x2400)
  1302. #define ADC2_BASE             (APB2PERIPH_BASE + 0x2800)
  1303. #define TIM1_BASE             (APB2PERIPH_BASE + 0x2C00)
  1304. #define SPI1_BASE             (APB2PERIPH_BASE + 0x3000)
  1305. #define TIM8_BASE             (APB2PERIPH_BASE + 0x3400)
  1306. #define USART1_BASE           (APB2PERIPH_BASE + 0x3800)
  1307. #define ADC3_BASE             (APB2PERIPH_BASE + 0x3C00)
  1308. #define TIM15_BASE            (APB2PERIPH_BASE + 0x4000)
  1309. #define TIM16_BASE            (APB2PERIPH_BASE + 0x4400)
  1310. #define TIM17_BASE            (APB2PERIPH_BASE + 0x4800)
  1311. #define TIM9_BASE             (APB2PERIPH_BASE + 0x4C00)
  1312. #define TIM10_BASE            (APB2PERIPH_BASE + 0x5000)
  1313. #define TIM11_BASE            (APB2PERIPH_BASE + 0x5400)
  1314.  
  1315. #define SDIO_BASE             (PERIPH_BASE + 0x18000)
  1316.  
  1317. #define DMA1_BASE             (AHBPERIPH_BASE + 0x0000)
  1318. #define DMA1_Channel1_BASE    (AHBPERIPH_BASE + 0x0008)
  1319. #define DMA1_Channel2_BASE    (AHBPERIPH_BASE + 0x001C)
  1320. #define DMA1_Channel3_BASE    (AHBPERIPH_BASE + 0x0030)
  1321. #define DMA1_Channel4_BASE    (AHBPERIPH_BASE + 0x0044)
  1322. #define DMA1_Channel5_BASE    (AHBPERIPH_BASE + 0x0058)
  1323. #define DMA1_Channel6_BASE    (AHBPERIPH_BASE + 0x006C)
  1324. #define DMA1_Channel7_BASE    (AHBPERIPH_BASE + 0x0080)
  1325. #define DMA2_BASE             (AHBPERIPH_BASE + 0x0400)
  1326. #define DMA2_Channel1_BASE    (AHBPERIPH_BASE + 0x0408)
  1327. #define DMA2_Channel2_BASE    (AHBPERIPH_BASE + 0x041C)
  1328. #define DMA2_Channel3_BASE    (AHBPERIPH_BASE + 0x0430)
  1329. #define DMA2_Channel4_BASE    (AHBPERIPH_BASE + 0x0444)
  1330. #define DMA2_Channel5_BASE    (AHBPERIPH_BASE + 0x0458)
  1331. #define RCC_BASE              (AHBPERIPH_BASE + 0x1000)
  1332. #define CRC_BASE              (AHBPERIPH_BASE + 0x3000)
  1333.  
  1334. #define FLASH_R_BASE          (AHBPERIPH_BASE + 0x2000) /*!< Flash registers base address */
  1335. #define OB_BASE               ((uint32_t)0x1FFFF800)    /*!< Flash Option Bytes base address */
  1336.  
  1337. #define ETH_BASE              (AHBPERIPH_BASE + 0x8000)
  1338. #define ETH_MAC_BASE          (ETH_BASE)
  1339. #define ETH_MMC_BASE          (ETH_BASE + 0x0100)
  1340. #define ETH_PTP_BASE          (ETH_BASE + 0x0700)
  1341. #define ETH_DMA_BASE          (ETH_BASE + 0x1000)
  1342.  
  1343. #define FSMC_Bank1_R_BASE     (FSMC_R_BASE + 0x0000) /*!< FSMC Bank1 registers base address */
  1344. #define FSMC_Bank1E_R_BASE    (FSMC_R_BASE + 0x0104) /*!< FSMC Bank1E registers base address */
  1345. #define FSMC_Bank2_R_BASE     (FSMC_R_BASE + 0x0060) /*!< FSMC Bank2 registers base address */
  1346. #define FSMC_Bank3_R_BASE     (FSMC_R_BASE + 0x0080) /*!< FSMC Bank3 registers base address */
  1347. #define FSMC_Bank4_R_BASE     (FSMC_R_BASE + 0x00A0) /*!< FSMC Bank4 registers base address */
  1348.  
  1349. #define DBGMCU_BASE          ((uint32_t)0xE0042000) /*!< Debug MCU registers base address */
  1350.  
  1351. /**
  1352.   * @}
  1353.   */
  1354.  
  1355. /** @addtogroup Peripheral_declaration
  1356.   * @{
  1357.   */  
  1358.  
  1359. #define TIM2                ((TIM_TypeDef *) TIM2_BASE)
  1360. #define TIM3                ((TIM_TypeDef *) TIM3_BASE)
  1361. #define TIM4                ((TIM_TypeDef *) TIM4_BASE)
  1362. #define TIM5                ((TIM_TypeDef *) TIM5_BASE)
  1363. #define TIM6                ((TIM_TypeDef *) TIM6_BASE)
  1364. #define TIM7                ((TIM_TypeDef *) TIM7_BASE)
  1365. #define TIM12               ((TIM_TypeDef *) TIM12_BASE)
  1366. #define TIM13               ((TIM_TypeDef *) TIM13_BASE)
  1367. #define TIM14               ((TIM_TypeDef *) TIM14_BASE)
  1368. #define RTC                 ((RTC_TypeDef *) RTC_BASE)
  1369. #define WWDG                ((WWDG_TypeDef *) WWDG_BASE)
  1370. #define IWDG                ((IWDG_TypeDef *) IWDG_BASE)
  1371. #define SPI2                ((SPI_TypeDef *) SPI2_BASE)
  1372. #define SPI3                ((SPI_TypeDef *) SPI3_BASE)
  1373. #define USART2              ((USART_TypeDef *) USART2_BASE)
  1374. #define USART3              ((USART_TypeDef *) USART3_BASE)
  1375. #define UART4               ((USART_TypeDef *) UART4_BASE)
  1376. #define UART5               ((USART_TypeDef *) UART5_BASE)
  1377. #define I2C1                ((I2C_TypeDef *) I2C1_BASE)
  1378. #define I2C2                ((I2C_TypeDef *) I2C2_BASE)
  1379. #define CAN1                ((CAN_TypeDef *) CAN1_BASE)
  1380. #define CAN2                ((CAN_TypeDef *) CAN2_BASE)
  1381. #define BKP                 ((BKP_TypeDef *) BKP_BASE)
  1382. #define PWR                 ((PWR_TypeDef *) PWR_BASE)
  1383. #define DAC                 ((DAC_TypeDef *) DAC_BASE)
  1384. #define CEC                 ((CEC_TypeDef *) CEC_BASE)
  1385. #define AFIO                ((AFIO_TypeDef *) AFIO_BASE)
  1386. #define EXTI                ((EXTI_TypeDef *) EXTI_BASE)
  1387. #define GPIOA               ((GPIO_TypeDef *) GPIOA_BASE)
  1388. #define GPIOB               ((GPIO_TypeDef *) GPIOB_BASE)
  1389. #define GPIOC               ((GPIO_TypeDef *) GPIOC_BASE)
  1390. #define GPIOD               ((GPIO_TypeDef *) GPIOD_BASE)
  1391. #define GPIOE               ((GPIO_TypeDef *) GPIOE_BASE)
  1392. #define GPIOF               ((GPIO_TypeDef *) GPIOF_BASE)
  1393. #define GPIOG               ((GPIO_TypeDef *) GPIOG_BASE)
  1394. #define ADC1                ((ADC_TypeDef *) ADC1_BASE)
  1395. #define ADC2                ((ADC_TypeDef *) ADC2_BASE)
  1396. #define TIM1                ((TIM_TypeDef *) TIM1_BASE)
  1397. #define SPI1                ((SPI_TypeDef *) SPI1_BASE)
  1398. #define TIM8                ((TIM_TypeDef *) TIM8_BASE)
  1399. #define USART1              ((USART_TypeDef *) USART1_BASE)
  1400. #define ADC3                ((ADC_TypeDef *) ADC3_BASE)
  1401. #define TIM15               ((TIM_TypeDef *) TIM15_BASE)
  1402. #define TIM16               ((TIM_TypeDef *) TIM16_BASE)
  1403. #define TIM17               ((TIM_TypeDef *) TIM17_BASE)
  1404. #define TIM9                ((TIM_TypeDef *) TIM9_BASE)
  1405. #define TIM10               ((TIM_TypeDef *) TIM10_BASE)
  1406. #define TIM11               ((TIM_TypeDef *) TIM11_BASE)
  1407. #define SDIO                ((SDIO_TypeDef *) SDIO_BASE)
  1408. #define DMA1                ((DMA_TypeDef *) DMA1_BASE)
  1409. #define DMA2                ((DMA_TypeDef *) DMA2_BASE)
  1410. #define DMA1_Channel1       ((DMA_Channel_TypeDef *) DMA1_Channel1_BASE)
  1411. #define DMA1_Channel2       ((DMA_Channel_TypeDef *) DMA1_Channel2_BASE)
  1412. #define DMA1_Channel3       ((DMA_Channel_TypeDef *) DMA1_Channel3_BASE)
  1413. #define DMA1_Channel4       ((DMA_Channel_TypeDef *) DMA1_Channel4_BASE)
  1414. #define DMA1_Channel5       ((DMA_Channel_TypeDef *) DMA1_Channel5_BASE)
  1415. #define DMA1_Channel6       ((DMA_Channel_TypeDef *) DMA1_Channel6_BASE)
  1416. #define DMA1_Channel7       ((DMA_Channel_TypeDef *) DMA1_Channel7_BASE)
  1417. #define DMA2_Channel1       ((DMA_Channel_TypeDef *) DMA2_Channel1_BASE)
  1418. #define DMA2_Channel2       ((DMA_Channel_TypeDef *) DMA2_Channel2_BASE)
  1419. #define DMA2_Channel3       ((DMA_Channel_TypeDef *) DMA2_Channel3_BASE)
  1420. #define DMA2_Channel4       ((DMA_Channel_TypeDef *) DMA2_Channel4_BASE)
  1421. #define DMA2_Channel5       ((DMA_Channel_TypeDef *) DMA2_Channel5_BASE)
  1422. #define RCC                 ((RCC_TypeDef *) RCC_BASE)
  1423. #define CRC                 ((CRC_TypeDef *) CRC_BASE)
  1424. #define FLASH               ((FLASH_TypeDef *) FLASH_R_BASE)
  1425. #define OB                  ((OB_TypeDef *) OB_BASE)
  1426. #define ETH                 ((ETH_TypeDef *) ETH_BASE)
  1427. #define FSMC_Bank1          ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE)
  1428. #define FSMC_Bank1E         ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE)
  1429. #define FSMC_Bank2          ((FSMC_Bank2_TypeDef *) FSMC_Bank2_R_BASE)
  1430. #define FSMC_Bank3          ((FSMC_Bank3_TypeDef *) FSMC_Bank3_R_BASE)
  1431. #define FSMC_Bank4          ((FSMC_Bank4_TypeDef *) FSMC_Bank4_R_BASE)
  1432. #define DBGMCU              ((DBGMCU_TypeDef *) DBGMCU_BASE)
  1433.  
  1434. /**
  1435.   * @}
  1436.   */
  1437.  
  1438. /** @addtogroup Exported_constants
  1439.   * @{
  1440.   */
  1441.  
  1442.   /** @addtogroup Peripheral_Registers_Bits_Definition
  1443.   * @{
  1444.   */
  1445.    
  1446. /******************************************************************************/
  1447. /*                         Peripheral Registers_Bits_Definition               */
  1448. /******************************************************************************/
  1449.  
  1450. /******************************************************************************/
  1451. /*                                                                            */
  1452. /*                          CRC calculation unit                              */
  1453. /*                                                                            */
  1454. /******************************************************************************/
  1455.  
  1456. /*******************  Bit definition for CRC_DR register  *********************/
  1457. #define  CRC_DR_DR                           ((uint32_t)0xFFFFFFFF) /*!< Data register bits */
  1458.  
  1459.  
  1460. /*******************  Bit definition for CRC_IDR register  ********************/
  1461. #define  CRC_IDR_IDR                         ((uint8_t)0xFF)        /*!< General-purpose 8-bit data register bits */
  1462.  
  1463.  
  1464. /********************  Bit definition for CRC_CR register  ********************/
  1465. #define  CRC_CR_RESET                        ((uint8_t)0x01)        /*!< RESET bit */
  1466.  
  1467. /******************************************************************************/
  1468. /*                                                                            */
  1469. /*                             Power Control                                  */
  1470. /*                                                                            */
  1471. /******************************************************************************/
  1472.  
  1473. /********************  Bit definition for PWR_CR register  ********************/
  1474. #define  PWR_CR_LPDS                         ((uint16_t)0x0001)     /*!< Low-Power Deepsleep */
  1475. #define  PWR_CR_PDDS                         ((uint16_t)0x0002)     /*!< Power Down Deepsleep */
  1476. #define  PWR_CR_CWUF                         ((uint16_t)0x0004)     /*!< Clear Wakeup Flag */
  1477. #define  PWR_CR_CSBF                         ((uint16_t)0x0008)     /*!< Clear Standby Flag */
  1478. #define  PWR_CR_PVDE                         ((uint16_t)0x0010)     /*!< Power Voltage Detector Enable */
  1479.  
  1480. #define  PWR_CR_PLS                          ((uint16_t)0x00E0)     /*!< PLS[2:0] bits (PVD Level Selection) */
  1481. #define  PWR_CR_PLS_0                        ((uint16_t)0x0020)     /*!< Bit 0 */
  1482. #define  PWR_CR_PLS_1                        ((uint16_t)0x0040)     /*!< Bit 1 */
  1483. #define  PWR_CR_PLS_2                        ((uint16_t)0x0080)     /*!< Bit 2 */
  1484.  
  1485. /*!< PVD level configuration */
  1486. #define  PWR_CR_PLS_2V2                      ((uint16_t)0x0000)     /*!< PVD level 2.2V */
  1487. #define  PWR_CR_PLS_2V3                      ((uint16_t)0x0020)     /*!< PVD level 2.3V */
  1488. #define  PWR_CR_PLS_2V4                      ((uint16_t)0x0040)     /*!< PVD level 2.4V */
  1489. #define  PWR_CR_PLS_2V5                      ((uint16_t)0x0060)     /*!< PVD level 2.5V */
  1490. #define  PWR_CR_PLS_2V6                      ((uint16_t)0x0080)     /*!< PVD level 2.6V */
  1491. #define  PWR_CR_PLS_2V7                      ((uint16_t)0x00A0)     /*!< PVD level 2.7V */
  1492. #define  PWR_CR_PLS_2V8                      ((uint16_t)0x00C0)     /*!< PVD level 2.8V */
  1493. #define  PWR_CR_PLS_2V9                      ((uint16_t)0x00E0)     /*!< PVD level 2.9V */
  1494.  
  1495. #define  PWR_CR_DBP                          ((uint16_t)0x0100)     /*!< Disable Backup Domain write protection */
  1496.  
  1497.  
  1498. /*******************  Bit definition for PWR_CSR register  ********************/
  1499. #define  PWR_CSR_WUF                         ((uint16_t)0x0001)     /*!< Wakeup Flag */
  1500. #define  PWR_CSR_SBF                         ((uint16_t)0x0002)     /*!< Standby Flag */
  1501. #define  PWR_CSR_PVDO                        ((uint16_t)0x0004)     /*!< PVD Output */
  1502. #define  PWR_CSR_EWUP                        ((uint16_t)0x0100)     /*!< Enable WKUP pin */
  1503.  
  1504. /******************************************************************************/
  1505. /*                                                                            */
  1506. /*                            Backup registers                                */
  1507. /*                                                                            */
  1508. /******************************************************************************/
  1509.  
  1510. /*******************  Bit definition for BKP_DR1 register  ********************/
  1511. #define  BKP_DR1_D                           ((uint16_t)0xFFFF)     /*!< Backup data */
  1512.  
  1513. /*******************  Bit definition for BKP_DR2 register  ********************/
  1514. #define  BKP_DR2_D                           ((uint16_t)0xFFFF)     /*!< Backup data */
  1515.  
  1516. /*******************  Bit definition for BKP_DR3 register  ********************/
  1517. #define  BKP_DR3_D                           ((uint16_t)0xFFFF)     /*!< Backup data */
  1518.  
  1519. /*******************  Bit definition for BKP_DR4 register  ********************/
  1520. #define  BKP_DR4_D                           ((uint16_t)0xFFFF)     /*!< Backup data */
  1521.  
  1522. /*******************  Bit definition for BKP_DR5 register  ********************/
  1523. #define  BKP_DR5_D                           ((uint16_t)0xFFFF)     /*!< Backup data */
  1524.  
  1525. /*******************  Bit definition for BKP_DR6 register  ********************/
  1526. #define  BKP_DR6_D                           ((uint16_t)0xFFFF)     /*!< Backup data */
  1527.  
  1528. /*******************  Bit definition for BKP_DR7 register  ********************/
  1529. #define  BKP_DR7_D                           ((uint16_t)0xFFFF)     /*!< Backup data */
  1530.  
  1531. /*******************  Bit definition for BKP_DR8 register  ********************/
  1532. #define  BKP_DR8_D                           ((uint16_t)0xFFFF)     /*!< Backup data */
  1533.  
  1534. /*******************  Bit definition for BKP_DR9 register  ********************/
  1535. #define  BKP_DR9_D                           ((uint16_t)0xFFFF)     /*!< Backup data */
  1536.  
  1537. /*******************  Bit definition for BKP_DR10 register  *******************/
  1538. #define  BKP_DR10_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1539.  
  1540. /*******************  Bit definition for BKP_DR11 register  *******************/
  1541. #define  BKP_DR11_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1542.  
  1543. /*******************  Bit definition for BKP_DR12 register  *******************/
  1544. #define  BKP_DR12_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1545.  
  1546. /*******************  Bit definition for BKP_DR13 register  *******************/
  1547. #define  BKP_DR13_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1548.  
  1549. /*******************  Bit definition for BKP_DR14 register  *******************/
  1550. #define  BKP_DR14_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1551.  
  1552. /*******************  Bit definition for BKP_DR15 register  *******************/
  1553. #define  BKP_DR15_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1554.  
  1555. /*******************  Bit definition for BKP_DR16 register  *******************/
  1556. #define  BKP_DR16_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1557.  
  1558. /*******************  Bit definition for BKP_DR17 register  *******************/
  1559. #define  BKP_DR17_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1560.  
  1561. /******************  Bit definition for BKP_DR18 register  ********************/
  1562. #define  BKP_DR18_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1563.  
  1564. /*******************  Bit definition for BKP_DR19 register  *******************/
  1565. #define  BKP_DR19_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1566.  
  1567. /*******************  Bit definition for BKP_DR20 register  *******************/
  1568. #define  BKP_DR20_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1569.  
  1570. /*******************  Bit definition for BKP_DR21 register  *******************/
  1571. #define  BKP_DR21_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1572.  
  1573. /*******************  Bit definition for BKP_DR22 register  *******************/
  1574. #define  BKP_DR22_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1575.  
  1576. /*******************  Bit definition for BKP_DR23 register  *******************/
  1577. #define  BKP_DR23_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1578.  
  1579. /*******************  Bit definition for BKP_DR24 register  *******************/
  1580. #define  BKP_DR24_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1581.  
  1582. /*******************  Bit definition for BKP_DR25 register  *******************/
  1583. #define  BKP_DR25_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1584.  
  1585. /*******************  Bit definition for BKP_DR26 register  *******************/
  1586. #define  BKP_DR26_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1587.  
  1588. /*******************  Bit definition for BKP_DR27 register  *******************/
  1589. #define  BKP_DR27_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1590.  
  1591. /*******************  Bit definition for BKP_DR28 register  *******************/
  1592. #define  BKP_DR28_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1593.  
  1594. /*******************  Bit definition for BKP_DR29 register  *******************/
  1595. #define  BKP_DR29_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1596.  
  1597. /*******************  Bit definition for BKP_DR30 register  *******************/
  1598. #define  BKP_DR30_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1599.  
  1600. /*******************  Bit definition for BKP_DR31 register  *******************/
  1601. #define  BKP_DR31_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1602.  
  1603. /*******************  Bit definition for BKP_DR32 register  *******************/
  1604. #define  BKP_DR32_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1605.  
  1606. /*******************  Bit definition for BKP_DR33 register  *******************/
  1607. #define  BKP_DR33_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1608.  
  1609. /*******************  Bit definition for BKP_DR34 register  *******************/
  1610. #define  BKP_DR34_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1611.  
  1612. /*******************  Bit definition for BKP_DR35 register  *******************/
  1613. #define  BKP_DR35_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1614.  
  1615. /*******************  Bit definition for BKP_DR36 register  *******************/
  1616. #define  BKP_DR36_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1617.  
  1618. /*******************  Bit definition for BKP_DR37 register  *******************/
  1619. #define  BKP_DR37_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1620.  
  1621. /*******************  Bit definition for BKP_DR38 register  *******************/
  1622. #define  BKP_DR38_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1623.  
  1624. /*******************  Bit definition for BKP_DR39 register  *******************/
  1625. #define  BKP_DR39_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1626.  
  1627. /*******************  Bit definition for BKP_DR40 register  *******************/
  1628. #define  BKP_DR40_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1629.  
  1630. /*******************  Bit definition for BKP_DR41 register  *******************/
  1631. #define  BKP_DR41_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1632.  
  1633. /*******************  Bit definition for BKP_DR42 register  *******************/
  1634. #define  BKP_DR42_D                          ((uint16_t)0xFFFF)     /*!< Backup data */
  1635.  
  1636. /******************  Bit definition for BKP_RTCCR register  *******************/
  1637. #define  BKP_RTCCR_CAL                       ((uint16_t)0x007F)     /*!< Calibration value */
  1638. #define  BKP_RTCCR_CCO                       ((uint16_t)0x0080)     /*!< Calibration Clock Output */
  1639. #define  BKP_RTCCR_ASOE                      ((uint16_t)0x0100)     /*!< Alarm or Second Output Enable */
  1640. #define  BKP_RTCCR_ASOS                      ((uint16_t)0x0200)     /*!< Alarm or Second Output Selection */
  1641.  
  1642. /********************  Bit definition for BKP_CR register  ********************/
  1643. #define  BKP_CR_TPE                          ((uint8_t)0x01)        /*!< TAMPER pin enable */
  1644. #define  BKP_CR_TPAL                         ((uint8_t)0x02)        /*!< TAMPER pin active level */
  1645.  
  1646. /*******************  Bit definition for BKP_CSR register  ********************/
  1647. #define  BKP_CSR_CTE                         ((uint16_t)0x0001)     /*!< Clear Tamper event */
  1648. #define  BKP_CSR_CTI                         ((uint16_t)0x0002)     /*!< Clear Tamper Interrupt */
  1649. #define  BKP_CSR_TPIE                        ((uint16_t)0x0004)     /*!< TAMPER Pin interrupt enable */
  1650. #define  BKP_CSR_TEF                         ((uint16_t)0x0100)     /*!< Tamper Event Flag */
  1651. #define  BKP_CSR_TIF                         ((uint16_t)0x0200)     /*!< Tamper Interrupt Flag */
  1652.  
  1653. /******************************************************************************/
  1654. /*                                                                            */
  1655. /*                         Reset and Clock Control                            */
  1656. /*                                                                            */
  1657. /******************************************************************************/
  1658.  
  1659. /********************  Bit definition for RCC_CR register  ********************/
  1660. #define  RCC_CR_HSION                        ((uint32_t)0x00000001)        /*!< Internal High Speed clock enable */
  1661. #define  RCC_CR_HSIRDY                       ((uint32_t)0x00000002)        /*!< Internal High Speed clock ready flag */
  1662. #define  RCC_CR_HSITRIM                      ((uint32_t)0x000000F8)        /*!< Internal High Speed clock trimming */
  1663. #define  RCC_CR_HSICAL                       ((uint32_t)0x0000FF00)        /*!< Internal High Speed clock Calibration */
  1664. #define  RCC_CR_HSEON                        ((uint32_t)0x00010000)        /*!< External High Speed clock enable */
  1665. #define  RCC_CR_HSERDY                       ((uint32_t)0x00020000)        /*!< External High Speed clock ready flag */
  1666. #define  RCC_CR_HSEBYP                       ((uint32_t)0x00040000)        /*!< External High Speed clock Bypass */
  1667. #define  RCC_CR_CSSON                        ((uint32_t)0x00080000)        /*!< Clock Security System enable */
  1668. #define  RCC_CR_PLLON                        ((uint32_t)0x01000000)        /*!< PLL enable */
  1669. #define  RCC_CR_PLLRDY                       ((uint32_t)0x02000000)        /*!< PLL clock ready flag */
  1670.  
  1671. #ifdef STM32F10X_CL
  1672.  #define  RCC_CR_PLL2ON                       ((uint32_t)0x04000000)        /*!< PLL2 enable */
  1673.  #define  RCC_CR_PLL2RDY                      ((uint32_t)0x08000000)        /*!< PLL2 clock ready flag */
  1674.  #define  RCC_CR_PLL3ON                       ((uint32_t)0x10000000)        /*!< PLL3 enable */
  1675.  #define  RCC_CR_PLL3RDY                      ((uint32_t)0x20000000)        /*!< PLL3 clock ready flag */
  1676. #endif /* STM32F10X_CL */
  1677.  
  1678. /*******************  Bit definition for RCC_CFGR register  *******************/
  1679. /*!< SW configuration */
  1680. #define  RCC_CFGR_SW                         ((uint32_t)0x00000003)        /*!< SW[1:0] bits (System clock Switch) */
  1681. #define  RCC_CFGR_SW_0                       ((uint32_t)0x00000001)        /*!< Bit 0 */
  1682. #define  RCC_CFGR_SW_1                       ((uint32_t)0x00000002)        /*!< Bit 1 */
  1683.  
  1684. #define  RCC_CFGR_SW_HSI                     ((uint32_t)0x00000000)        /*!< HSI selected as system clock */
  1685. #define  RCC_CFGR_SW_HSE                     ((uint32_t)0x00000001)        /*!< HSE selected as system clock */
  1686. #define  RCC_CFGR_SW_PLL                     ((uint32_t)0x00000002)        /*!< PLL selected as system clock */
  1687.  
  1688. /*!< SWS configuration */
  1689. #define  RCC_CFGR_SWS                        ((uint32_t)0x0000000C)        /*!< SWS[1:0] bits (System Clock Switch Status) */
  1690. #define  RCC_CFGR_SWS_0                      ((uint32_t)0x00000004)        /*!< Bit 0 */
  1691. #define  RCC_CFGR_SWS_1                      ((uint32_t)0x00000008)        /*!< Bit 1 */
  1692.  
  1693. #define  RCC_CFGR_SWS_HSI                    ((uint32_t)0x00000000)        /*!< HSI oscillator used as system clock */
  1694. #define  RCC_CFGR_SWS_HSE                    ((uint32_t)0x00000004)        /*!< HSE oscillator used as system clock */
  1695. #define  RCC_CFGR_SWS_PLL                    ((uint32_t)0x00000008)        /*!< PLL used as system clock */
  1696.  
  1697. /*!< HPRE configuration */
  1698. #define  RCC_CFGR_HPRE                       ((uint32_t)0x000000F0)        /*!< HPRE[3:0] bits (AHB prescaler) */
  1699. #define  RCC_CFGR_HPRE_0                     ((uint32_t)0x00000010)        /*!< Bit 0 */
  1700. #define  RCC_CFGR_HPRE_1                     ((uint32_t)0x00000020)        /*!< Bit 1 */
  1701. #define  RCC_CFGR_HPRE_2                     ((uint32_t)0x00000040)        /*!< Bit 2 */
  1702. #define  RCC_CFGR_HPRE_3                     ((uint32_t)0x00000080)        /*!< Bit 3 */
  1703.  
  1704. #define  RCC_CFGR_HPRE_DIV1                  ((uint32_t)0x00000000)        /*!< SYSCLK not divided */
  1705. #define  RCC_CFGR_HPRE_DIV2                  ((uint32_t)0x00000080)        /*!< SYSCLK divided by 2 */
  1706. #define  RCC_CFGR_HPRE_DIV4                  ((uint32_t)0x00000090)        /*!< SYSCLK divided by 4 */
  1707. #define  RCC_CFGR_HPRE_DIV8                  ((uint32_t)0x000000A0)        /*!< SYSCLK divided by 8 */
  1708. #define  RCC_CFGR_HPRE_DIV16                 ((uint32_t)0x000000B0)        /*!< SYSCLK divided by 16 */
  1709. #define  RCC_CFGR_HPRE_DIV64                 ((uint32_t)0x000000C0)        /*!< SYSCLK divided by 64 */
  1710. #define  RCC_CFGR_HPRE_DIV128                ((uint32_t)0x000000D0)        /*!< SYSCLK divided by 128 */
  1711. #define  RCC_CFGR_HPRE_DIV256                ((uint32_t)0x000000E0)        /*!< SYSCLK divided by 256 */
  1712. #define  RCC_CFGR_HPRE_DIV512                ((uint32_t)0x000000F0)        /*!< SYSCLK divided by 512 */
  1713.  
  1714. /*!< PPRE1 configuration */
  1715. #define  RCC_CFGR_PPRE1                      ((uint32_t)0x00000700)        /*!< PRE1[2:0] bits (APB1 prescaler) */
  1716. #define  RCC_CFGR_PPRE1_0                    ((uint32_t)0x00000100)        /*!< Bit 0 */
  1717. #define  RCC_CFGR_PPRE1_1                    ((uint32_t)0x00000200)        /*!< Bit 1 */
  1718. #define  RCC_CFGR_PPRE1_2                    ((uint32_t)0x00000400)        /*!< Bit 2 */
  1719.  
  1720. #define  RCC_CFGR_PPRE1_DIV1                 ((uint32_t)0x00000000)        /*!< HCLK not divided */
  1721. #define  RCC_CFGR_PPRE1_DIV2                 ((uint32_t)0x00000400)        /*!< HCLK divided by 2 */
  1722. #define  RCC_CFGR_PPRE1_DIV4                 ((uint32_t)0x00000500)        /*!< HCLK divided by 4 */
  1723. #define  RCC_CFGR_PPRE1_DIV8                 ((uint32_t)0x00000600)        /*!< HCLK divided by 8 */
  1724. #define  RCC_CFGR_PPRE1_DIV16                ((uint32_t)0x00000700)        /*!< HCLK divided by 16 */
  1725.  
  1726. /*!< PPRE2 configuration */
  1727. #define  RCC_CFGR_PPRE2                      ((uint32_t)0x00003800)        /*!< PRE2[2:0] bits (APB2 prescaler) */
  1728. #define  RCC_CFGR_PPRE2_0                    ((uint32_t)0x00000800)        /*!< Bit 0 */
  1729. #define  RCC_CFGR_PPRE2_1                    ((uint32_t)0x00001000)        /*!< Bit 1 */
  1730. #define  RCC_CFGR_PPRE2_2                    ((uint32_t)0x00002000)        /*!< Bit 2 */
  1731.  
  1732. #define  RCC_CFGR_PPRE2_DIV1                 ((uint32_t)0x00000000)        /*!< HCLK not divided */
  1733. #define  RCC_CFGR_PPRE2_DIV2                 ((uint32_t)0x00002000)        /*!< HCLK divided by 2 */
  1734. #define  RCC_CFGR_PPRE2_DIV4                 ((uint32_t)0x00002800)        /*!< HCLK divided by 4 */
  1735. #define  RCC_CFGR_PPRE2_DIV8                 ((uint32_t)0x00003000)        /*!< HCLK divided by 8 */
  1736. #define  RCC_CFGR_PPRE2_DIV16                ((uint32_t)0x00003800)        /*!< HCLK divided by 16 */
  1737.  
  1738. /*!< ADCPPRE configuration */
  1739. #define  RCC_CFGR_ADCPRE                     ((uint32_t)0x0000C000)        /*!< ADCPRE[1:0] bits (ADC prescaler) */
  1740. #define  RCC_CFGR_ADCPRE_0                   ((uint32_t)0x00004000)        /*!< Bit 0 */
  1741. #define  RCC_CFGR_ADCPRE_1                   ((uint32_t)0x00008000)        /*!< Bit 1 */
  1742.  
  1743. #define  RCC_CFGR_ADCPRE_DIV2                ((uint32_t)0x00000000)        /*!< PCLK2 divided by 2 */
  1744. #define  RCC_CFGR_ADCPRE_DIV4                ((uint32_t)0x00004000)        /*!< PCLK2 divided by 4 */
  1745. #define  RCC_CFGR_ADCPRE_DIV6                ((uint32_t)0x00008000)        /*!< PCLK2 divided by 6 */
  1746. #define  RCC_CFGR_ADCPRE_DIV8                ((uint32_t)0x0000C000)        /*!< PCLK2 divided by 8 */
  1747.  
  1748. #define  RCC_CFGR_PLLSRC                     ((uint32_t)0x00010000)        /*!< PLL entry clock source */
  1749.  
  1750. #define  RCC_CFGR_PLLXTPRE                   ((uint32_t)0x00020000)        /*!< HSE divider for PLL entry */
  1751.  
  1752. /*!< PLLMUL configuration */
  1753. #define  RCC_CFGR_PLLMULL                    ((uint32_t)0x003C0000)        /*!< PLLMUL[3:0] bits (PLL multiplication factor) */
  1754. #define  RCC_CFGR_PLLMULL_0                  ((uint32_t)0x00040000)        /*!< Bit 0 */
  1755. #define  RCC_CFGR_PLLMULL_1                  ((uint32_t)0x00080000)        /*!< Bit 1 */
  1756. #define  RCC_CFGR_PLLMULL_2                  ((uint32_t)0x00100000)        /*!< Bit 2 */
  1757. #define  RCC_CFGR_PLLMULL_3                  ((uint32_t)0x00200000)        /*!< Bit 3 */
  1758.  
  1759. #ifdef STM32F10X_CL
  1760.  #define  RCC_CFGR_PLLSRC_HSI_Div2           ((uint32_t)0x00000000)        /*!< HSI clock divided by 2 selected as PLL entry clock source */
  1761.  #define  RCC_CFGR_PLLSRC_PREDIV1            ((uint32_t)0x00010000)        /*!< PREDIV1 clock selected as PLL entry clock source */
  1762.  
  1763.  #define  RCC_CFGR_PLLXTPRE_PREDIV1          ((uint32_t)0x00000000)        /*!< PREDIV1 clock not divided for PLL entry */
  1764.  #define  RCC_CFGR_PLLXTPRE_PREDIV1_Div2     ((uint32_t)0x00020000)        /*!< PREDIV1 clock divided by 2 for PLL entry */
  1765.  
  1766.  #define  RCC_CFGR_PLLMULL4                  ((uint32_t)0x00080000)        /*!< PLL input clock * 4 */
  1767.  #define  RCC_CFGR_PLLMULL5                  ((uint32_t)0x000C0000)        /*!< PLL input clock * 5 */
  1768.  #define  RCC_CFGR_PLLMULL6                  ((uint32_t)0x00100000)        /*!< PLL input clock * 6 */
  1769.  #define  RCC_CFGR_PLLMULL7                  ((uint32_t)0x00140000)        /*!< PLL input clock * 7 */
  1770.  #define  RCC_CFGR_PLLMULL8                  ((uint32_t)0x00180000)        /*!< PLL input clock * 8 */
  1771.  #define  RCC_CFGR_PLLMULL9                  ((uint32_t)0x001C0000)        /*!< PLL input clock * 9 */
  1772.  #define  RCC_CFGR_PLLMULL6_5                ((uint32_t)0x00340000)        /*!< PLL input clock * 6.5 */
  1773.  
  1774.  #define  RCC_CFGR_OTGFSPRE                  ((uint32_t)0x00400000)        /*!< USB OTG FS prescaler */
  1775.  
  1776. /*!< MCO configuration */
  1777.  #define  RCC_CFGR_MCO                       ((uint32_t)0x0F000000)        /*!< MCO[3:0] bits (Microcontroller Clock Output) */
  1778.  #define  RCC_CFGR_MCO_0                     ((uint32_t)0x01000000)        /*!< Bit 0 */
  1779.  #define  RCC_CFGR_MCO_1                     ((uint32_t)0x02000000)        /*!< Bit 1 */
  1780.  #define  RCC_CFGR_MCO_2                     ((uint32_t)0x04000000)        /*!< Bit 2 */
  1781.  #define  RCC_CFGR_MCO_3                     ((uint32_t)0x08000000)        /*!< Bit 3 */
  1782.  
  1783.  #define  RCC_CFGR_MCO_NOCLOCK               ((uint32_t)0x00000000)        /*!< No clock */
  1784.  #define  RCC_CFGR_MCO_SYSCLK                ((uint32_t)0x04000000)        /*!< System clock selected as MCO source */
  1785.  #define  RCC_CFGR_MCO_HSI                   ((uint32_t)0x05000000)        /*!< HSI clock selected as MCO source */
  1786.  #define  RCC_CFGR_MCO_HSE                   ((uint32_t)0x06000000)        /*!< HSE clock selected as MCO source */
  1787.  #define  RCC_CFGR_MCO_PLLCLK_Div2           ((uint32_t)0x07000000)        /*!< PLL clock divided by 2 selected as MCO source */
  1788.  #define  RCC_CFGR_MCO_PLL2CLK               ((uint32_t)0x08000000)        /*!< PLL2 clock selected as MCO source*/
  1789.  #define  RCC_CFGR_MCO_PLL3CLK_Div2          ((uint32_t)0x09000000)        /*!< PLL3 clock divided by 2 selected as MCO source*/
  1790.  #define  RCC_CFGR_MCO_Ext_HSE               ((uint32_t)0x0A000000)        /*!< XT1 external 3-25 MHz oscillator clock selected as MCO source */
  1791.  #define  RCC_CFGR_MCO_PLL3CLK               ((uint32_t)0x0B000000)        /*!< PLL3 clock selected as MCO source */
  1792. #elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  1793.  #define  RCC_CFGR_PLLSRC_HSI_Div2           ((uint32_t)0x00000000)        /*!< HSI clock divided by 2 selected as PLL entry clock source */
  1794.  #define  RCC_CFGR_PLLSRC_PREDIV1            ((uint32_t)0x00010000)        /*!< PREDIV1 clock selected as PLL entry clock source */
  1795.  
  1796.  #define  RCC_CFGR_PLLXTPRE_PREDIV1          ((uint32_t)0x00000000)        /*!< PREDIV1 clock not divided for PLL entry */
  1797.  #define  RCC_CFGR_PLLXTPRE_PREDIV1_Div2     ((uint32_t)0x00020000)        /*!< PREDIV1 clock divided by 2 for PLL entry */
  1798.  
  1799.  #define  RCC_CFGR_PLLMULL2                  ((uint32_t)0x00000000)        /*!< PLL input clock*2 */
  1800.  #define  RCC_CFGR_PLLMULL3                  ((uint32_t)0x00040000)        /*!< PLL input clock*3 */
  1801.  #define  RCC_CFGR_PLLMULL4                  ((uint32_t)0x00080000)        /*!< PLL input clock*4 */
  1802.  #define  RCC_CFGR_PLLMULL5                  ((uint32_t)0x000C0000)        /*!< PLL input clock*5 */
  1803.  #define  RCC_CFGR_PLLMULL6                  ((uint32_t)0x00100000)        /*!< PLL input clock*6 */
  1804.  #define  RCC_CFGR_PLLMULL7                  ((uint32_t)0x00140000)        /*!< PLL input clock*7 */
  1805.  #define  RCC_CFGR_PLLMULL8                  ((uint32_t)0x00180000)        /*!< PLL input clock*8 */
  1806.  #define  RCC_CFGR_PLLMULL9                  ((uint32_t)0x001C0000)        /*!< PLL input clock*9 */
  1807.  #define  RCC_CFGR_PLLMULL10                 ((uint32_t)0x00200000)        /*!< PLL input clock10 */
  1808.  #define  RCC_CFGR_PLLMULL11                 ((uint32_t)0x00240000)        /*!< PLL input clock*11 */
  1809.  #define  RCC_CFGR_PLLMULL12                 ((uint32_t)0x00280000)        /*!< PLL input clock*12 */
  1810.  #define  RCC_CFGR_PLLMULL13                 ((uint32_t)0x002C0000)        /*!< PLL input clock*13 */
  1811.  #define  RCC_CFGR_PLLMULL14                 ((uint32_t)0x00300000)        /*!< PLL input clock*14 */
  1812.  #define  RCC_CFGR_PLLMULL15                 ((uint32_t)0x00340000)        /*!< PLL input clock*15 */
  1813.  #define  RCC_CFGR_PLLMULL16                 ((uint32_t)0x00380000)        /*!< PLL input clock*16 */
  1814.  
  1815. /*!< MCO configuration */
  1816.  #define  RCC_CFGR_MCO                       ((uint32_t)0x07000000)        /*!< MCO[2:0] bits (Microcontroller Clock Output) */
  1817.  #define  RCC_CFGR_MCO_0                     ((uint32_t)0x01000000)        /*!< Bit 0 */
  1818.  #define  RCC_CFGR_MCO_1                     ((uint32_t)0x02000000)        /*!< Bit 1 */
  1819.  #define  RCC_CFGR_MCO_2                     ((uint32_t)0x04000000)        /*!< Bit 2 */
  1820.  
  1821.  #define  RCC_CFGR_MCO_NOCLOCK               ((uint32_t)0x00000000)        /*!< No clock */
  1822.  #define  RCC_CFGR_MCO_SYSCLK                ((uint32_t)0x04000000)        /*!< System clock selected as MCO source */
  1823.  #define  RCC_CFGR_MCO_HSI                   ((uint32_t)0x05000000)        /*!< HSI clock selected as MCO source */
  1824.  #define  RCC_CFGR_MCO_HSE                   ((uint32_t)0x06000000)        /*!< HSE clock selected as MCO source  */
  1825.  #define  RCC_CFGR_MCO_PLL                   ((uint32_t)0x07000000)        /*!< PLL clock divided by 2 selected as MCO source */
  1826. #else
  1827.  #define  RCC_CFGR_PLLSRC_HSI_Div2           ((uint32_t)0x00000000)        /*!< HSI clock divided by 2 selected as PLL entry clock source */
  1828.  #define  RCC_CFGR_PLLSRC_HSE                ((uint32_t)0x00010000)        /*!< HSE clock selected as PLL entry clock source */
  1829.  
  1830.  #define  RCC_CFGR_PLLXTPRE_HSE              ((uint32_t)0x00000000)        /*!< HSE clock not divided for PLL entry */
  1831.  #define  RCC_CFGR_PLLXTPRE_HSE_Div2         ((uint32_t)0x00020000)        /*!< HSE clock divided by 2 for PLL entry */
  1832.  
  1833.  #define  RCC_CFGR_PLLMULL2                  ((uint32_t)0x00000000)        /*!< PLL input clock*2 */
  1834.  #define  RCC_CFGR_PLLMULL3                  ((uint32_t)0x00040000)        /*!< PLL input clock*3 */
  1835.  #define  RCC_CFGR_PLLMULL4                  ((uint32_t)0x00080000)        /*!< PLL input clock*4 */
  1836.  #define  RCC_CFGR_PLLMULL5                  ((uint32_t)0x000C0000)        /*!< PLL input clock*5 */
  1837.  #define  RCC_CFGR_PLLMULL6                  ((uint32_t)0x00100000)        /*!< PLL input clock*6 */
  1838.  #define  RCC_CFGR_PLLMULL7                  ((uint32_t)0x00140000)        /*!< PLL input clock*7 */
  1839.  #define  RCC_CFGR_PLLMULL8                  ((uint32_t)0x00180000)        /*!< PLL input clock*8 */
  1840.  #define  RCC_CFGR_PLLMULL9                  ((uint32_t)0x001C0000)        /*!< PLL input clock*9 */
  1841.  #define  RCC_CFGR_PLLMULL10                 ((uint32_t)0x00200000)        /*!< PLL input clock10 */
  1842.  #define  RCC_CFGR_PLLMULL11                 ((uint32_t)0x00240000)        /*!< PLL input clock*11 */
  1843.  #define  RCC_CFGR_PLLMULL12                 ((uint32_t)0x00280000)        /*!< PLL input clock*12 */
  1844.  #define  RCC_CFGR_PLLMULL13                 ((uint32_t)0x002C0000)        /*!< PLL input clock*13 */
  1845.  #define  RCC_CFGR_PLLMULL14                 ((uint32_t)0x00300000)        /*!< PLL input clock*14 */
  1846.  #define  RCC_CFGR_PLLMULL15                 ((uint32_t)0x00340000)        /*!< PLL input clock*15 */
  1847.  #define  RCC_CFGR_PLLMULL16                 ((uint32_t)0x00380000)        /*!< PLL input clock*16 */
  1848.  #define  RCC_CFGR_USBPRE                    ((uint32_t)0x00400000)        /*!< USB Device prescaler */
  1849.  
  1850. /*!< MCO configuration */
  1851.  #define  RCC_CFGR_MCO                       ((uint32_t)0x07000000)        /*!< MCO[2:0] bits (Microcontroller Clock Output) */
  1852.  #define  RCC_CFGR_MCO_0                     ((uint32_t)0x01000000)        /*!< Bit 0 */
  1853.  #define  RCC_CFGR_MCO_1                     ((uint32_t)0x02000000)        /*!< Bit 1 */
  1854.  #define  RCC_CFGR_MCO_2                     ((uint32_t)0x04000000)        /*!< Bit 2 */
  1855.  
  1856.  #define  RCC_CFGR_MCO_NOCLOCK               ((uint32_t)0x00000000)        /*!< No clock */
  1857.  #define  RCC_CFGR_MCO_SYSCLK                ((uint32_t)0x04000000)        /*!< System clock selected as MCO source */
  1858.  #define  RCC_CFGR_MCO_HSI                   ((uint32_t)0x05000000)        /*!< HSI clock selected as MCO source */
  1859.  #define  RCC_CFGR_MCO_HSE                   ((uint32_t)0x06000000)        /*!< HSE clock selected as MCO source  */
  1860.  #define  RCC_CFGR_MCO_PLL                   ((uint32_t)0x07000000)        /*!< PLL clock divided by 2 selected as MCO source */
  1861. #endif /* STM32F10X_CL */
  1862.  
  1863. /*!<******************  Bit definition for RCC_CIR register  ********************/
  1864. #define  RCC_CIR_LSIRDYF                     ((uint32_t)0x00000001)        /*!< LSI Ready Interrupt flag */
  1865. #define  RCC_CIR_LSERDYF                     ((uint32_t)0x00000002)        /*!< LSE Ready Interrupt flag */
  1866. #define  RCC_CIR_HSIRDYF                     ((uint32_t)0x00000004)        /*!< HSI Ready Interrupt flag */
  1867. #define  RCC_CIR_HSERDYF                     ((uint32_t)0x00000008)        /*!< HSE Ready Interrupt flag */
  1868. #define  RCC_CIR_PLLRDYF                     ((uint32_t)0x00000010)        /*!< PLL Ready Interrupt flag */
  1869. #define  RCC_CIR_CSSF                        ((uint32_t)0x00000080)        /*!< Clock Security System Interrupt flag */
  1870. #define  RCC_CIR_LSIRDYIE                    ((uint32_t)0x00000100)        /*!< LSI Ready Interrupt Enable */
  1871. #define  RCC_CIR_LSERDYIE                    ((uint32_t)0x00000200)        /*!< LSE Ready Interrupt Enable */
  1872. #define  RCC_CIR_HSIRDYIE                    ((uint32_t)0x00000400)        /*!< HSI Ready Interrupt Enable */
  1873. #define  RCC_CIR_HSERDYIE                    ((uint32_t)0x00000800)        /*!< HSE Ready Interrupt Enable */
  1874. #define  RCC_CIR_PLLRDYIE                    ((uint32_t)0x00001000)        /*!< PLL Ready Interrupt Enable */
  1875. #define  RCC_CIR_LSIRDYC                     ((uint32_t)0x00010000)        /*!< LSI Ready Interrupt Clear */
  1876. #define  RCC_CIR_LSERDYC                     ((uint32_t)0x00020000)        /*!< LSE Ready Interrupt Clear */
  1877. #define  RCC_CIR_HSIRDYC                     ((uint32_t)0x00040000)        /*!< HSI Ready Interrupt Clear */
  1878. #define  RCC_CIR_HSERDYC                     ((uint32_t)0x00080000)        /*!< HSE Ready Interrupt Clear */
  1879. #define  RCC_CIR_PLLRDYC                     ((uint32_t)0x00100000)        /*!< PLL Ready Interrupt Clear */
  1880. #define  RCC_CIR_CSSC                        ((uint32_t)0x00800000)        /*!< Clock Security System Interrupt Clear */
  1881.  
  1882. #ifdef STM32F10X_CL
  1883.  #define  RCC_CIR_PLL2RDYF                    ((uint32_t)0x00000020)        /*!< PLL2 Ready Interrupt flag */
  1884.  #define  RCC_CIR_PLL3RDYF                    ((uint32_t)0x00000040)        /*!< PLL3 Ready Interrupt flag */
  1885.  #define  RCC_CIR_PLL2RDYIE                   ((uint32_t)0x00002000)        /*!< PLL2 Ready Interrupt Enable */
  1886.  #define  RCC_CIR_PLL3RDYIE                   ((uint32_t)0x00004000)        /*!< PLL3 Ready Interrupt Enable */
  1887.  #define  RCC_CIR_PLL2RDYC                    ((uint32_t)0x00200000)        /*!< PLL2 Ready Interrupt Clear */
  1888.  #define  RCC_CIR_PLL3RDYC                    ((uint32_t)0x00400000)        /*!< PLL3 Ready Interrupt Clear */
  1889. #endif /* STM32F10X_CL */
  1890.  
  1891. /*****************  Bit definition for RCC_APB2RSTR register  *****************/
  1892. #define  RCC_APB2RSTR_AFIORST                ((uint32_t)0x00000001)        /*!< Alternate Function I/O reset */
  1893. #define  RCC_APB2RSTR_IOPARST                ((uint32_t)0x00000004)        /*!< I/O port A reset */
  1894. #define  RCC_APB2RSTR_IOPBRST                ((uint32_t)0x00000008)        /*!< I/O port B reset */
  1895. #define  RCC_APB2RSTR_IOPCRST                ((uint32_t)0x00000010)        /*!< I/O port C reset */
  1896. #define  RCC_APB2RSTR_IOPDRST                ((uint32_t)0x00000020)        /*!< I/O port D reset */
  1897. #define  RCC_APB2RSTR_ADC1RST                ((uint32_t)0x00000200)        /*!< ADC 1 interface reset */
  1898.  
  1899. #if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL)
  1900. #define  RCC_APB2RSTR_ADC2RST                ((uint32_t)0x00000400)        /*!< ADC 2 interface reset */
  1901. #endif
  1902.  
  1903. #define  RCC_APB2RSTR_TIM1RST                ((uint32_t)0x00000800)        /*!< TIM1 Timer reset */
  1904. #define  RCC_APB2RSTR_SPI1RST                ((uint32_t)0x00001000)        /*!< SPI 1 reset */
  1905. #define  RCC_APB2RSTR_USART1RST              ((uint32_t)0x00004000)        /*!< USART1 reset */
  1906.  
  1907. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  1908. #define  RCC_APB2RSTR_TIM15RST               ((uint32_t)0x00010000)        /*!< TIM15 Timer reset */
  1909. #define  RCC_APB2RSTR_TIM16RST               ((uint32_t)0x00020000)        /*!< TIM16 Timer reset */
  1910. #define  RCC_APB2RSTR_TIM17RST               ((uint32_t)0x00040000)        /*!< TIM17 Timer reset */
  1911. #endif
  1912.  
  1913. #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL)
  1914.  #define  RCC_APB2RSTR_IOPERST               ((uint32_t)0x00000040)        /*!< I/O port E reset */
  1915. #endif /* STM32F10X_LD && STM32F10X_LD_VL */
  1916.  
  1917. #if defined (STM32F10X_HD) || defined (STM32F10X_XL)
  1918.  #define  RCC_APB2RSTR_IOPFRST               ((uint32_t)0x00000080)        /*!< I/O port F reset */
  1919.  #define  RCC_APB2RSTR_IOPGRST               ((uint32_t)0x00000100)        /*!< I/O port G reset */
  1920.  #define  RCC_APB2RSTR_TIM8RST               ((uint32_t)0x00002000)        /*!< TIM8 Timer reset */
  1921.  #define  RCC_APB2RSTR_ADC3RST               ((uint32_t)0x00008000)        /*!< ADC3 interface reset */
  1922. #endif
  1923.  
  1924. #if defined (STM32F10X_HD_VL)
  1925.  #define  RCC_APB2RSTR_IOPFRST               ((uint32_t)0x00000080)        /*!< I/O port F reset */
  1926.  #define  RCC_APB2RSTR_IOPGRST               ((uint32_t)0x00000100)        /*!< I/O port G reset */
  1927. #endif
  1928.  
  1929. #ifdef STM32F10X_XL
  1930.  #define  RCC_APB2RSTR_TIM9RST               ((uint32_t)0x00080000)         /*!< TIM9 Timer reset */
  1931.  #define  RCC_APB2RSTR_TIM10RST              ((uint32_t)0x00100000)         /*!< TIM10 Timer reset */
  1932.  #define  RCC_APB2RSTR_TIM11RST              ((uint32_t)0x00200000)         /*!< TIM11 Timer reset */
  1933. #endif /* STM32F10X_XL */
  1934.  
  1935. /*****************  Bit definition for RCC_APB1RSTR register  *****************/
  1936. #define  RCC_APB1RSTR_TIM2RST                ((uint32_t)0x00000001)        /*!< Timer 2 reset */
  1937. #define  RCC_APB1RSTR_TIM3RST                ((uint32_t)0x00000002)        /*!< Timer 3 reset */
  1938. #define  RCC_APB1RSTR_WWDGRST                ((uint32_t)0x00000800)        /*!< Window Watchdog reset */
  1939. #define  RCC_APB1RSTR_USART2RST              ((uint32_t)0x00020000)        /*!< USART 2 reset */
  1940. #define  RCC_APB1RSTR_I2C1RST                ((uint32_t)0x00200000)        /*!< I2C 1 reset */
  1941.  
  1942. #if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL)
  1943. #define  RCC_APB1RSTR_CAN1RST                ((uint32_t)0x02000000)        /*!< CAN1 reset */
  1944. #endif
  1945.  
  1946. #define  RCC_APB1RSTR_BKPRST                 ((uint32_t)0x08000000)        /*!< Backup interface reset */
  1947. #define  RCC_APB1RSTR_PWRRST                 ((uint32_t)0x10000000)        /*!< Power interface reset */
  1948.  
  1949. #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL)
  1950.  #define  RCC_APB1RSTR_TIM4RST               ((uint32_t)0x00000004)        /*!< Timer 4 reset */
  1951.  #define  RCC_APB1RSTR_SPI2RST               ((uint32_t)0x00004000)        /*!< SPI 2 reset */
  1952.  #define  RCC_APB1RSTR_USART3RST             ((uint32_t)0x00040000)        /*!< USART 3 reset */
  1953.  #define  RCC_APB1RSTR_I2C2RST               ((uint32_t)0x00400000)        /*!< I2C 2 reset */
  1954. #endif /* STM32F10X_LD && STM32F10X_LD_VL */
  1955.  
  1956. #if defined (STM32F10X_HD) || defined (STM32F10X_MD) || defined (STM32F10X_LD) || defined  (STM32F10X_XL)
  1957.  #define  RCC_APB1RSTR_USBRST                ((uint32_t)0x00800000)        /*!< USB Device reset */
  1958. #endif
  1959.  
  1960. #if defined (STM32F10X_HD) || defined  (STM32F10X_CL) || defined  (STM32F10X_XL)
  1961.  #define  RCC_APB1RSTR_TIM5RST                ((uint32_t)0x00000008)        /*!< Timer 5 reset */
  1962.  #define  RCC_APB1RSTR_TIM6RST                ((uint32_t)0x00000010)        /*!< Timer 6 reset */
  1963.  #define  RCC_APB1RSTR_TIM7RST                ((uint32_t)0x00000020)        /*!< Timer 7 reset */
  1964.  #define  RCC_APB1RSTR_SPI3RST                ((uint32_t)0x00008000)        /*!< SPI 3 reset */
  1965.  #define  RCC_APB1RSTR_UART4RST               ((uint32_t)0x00080000)        /*!< UART 4 reset */
  1966.  #define  RCC_APB1RSTR_UART5RST               ((uint32_t)0x00100000)        /*!< UART 5 reset */
  1967.  #define  RCC_APB1RSTR_DACRST                 ((uint32_t)0x20000000)        /*!< DAC interface reset */
  1968. #endif
  1969.  
  1970. #if defined (STM32F10X_LD_VL) || defined  (STM32F10X_MD_VL) || defined  (STM32F10X_HD_VL)
  1971.  #define  RCC_APB1RSTR_TIM6RST                ((uint32_t)0x00000010)        /*!< Timer 6 reset */
  1972.  #define  RCC_APB1RSTR_TIM7RST                ((uint32_t)0x00000020)        /*!< Timer 7 reset */
  1973.  #define  RCC_APB1RSTR_DACRST                 ((uint32_t)0x20000000)        /*!< DAC interface reset */
  1974.  #define  RCC_APB1RSTR_CECRST                 ((uint32_t)0x40000000)        /*!< CEC interface reset */
  1975. #endif
  1976.  
  1977. #if defined  (STM32F10X_HD_VL)
  1978.  #define  RCC_APB1RSTR_TIM5RST                ((uint32_t)0x00000008)        /*!< Timer 5 reset */
  1979.  #define  RCC_APB1RSTR_TIM12RST               ((uint32_t)0x00000040)        /*!< TIM12 Timer reset */
  1980.  #define  RCC_APB1RSTR_TIM13RST               ((uint32_t)0x00000080)        /*!< TIM13 Timer reset */
  1981.  #define  RCC_APB1RSTR_TIM14RST               ((uint32_t)0x00000100)        /*!< TIM14 Timer reset */
  1982.  #define  RCC_APB1RSTR_SPI3RST                ((uint32_t)0x00008000)        /*!< SPI 3 reset */
  1983.  #define  RCC_APB1RSTR_UART4RST               ((uint32_t)0x00080000)        /*!< UART 4 reset */
  1984.  #define  RCC_APB1RSTR_UART5RST               ((uint32_t)0x00100000)        /*!< UART 5 reset */
  1985. #endif
  1986.  
  1987. #ifdef STM32F10X_CL
  1988.  #define  RCC_APB1RSTR_CAN2RST                ((uint32_t)0x04000000)        /*!< CAN2 reset */
  1989. #endif /* STM32F10X_CL */
  1990.  
  1991. #ifdef STM32F10X_XL
  1992.  #define  RCC_APB1RSTR_TIM12RST               ((uint32_t)0x00000040)         /*!< TIM12 Timer reset */
  1993.  #define  RCC_APB1RSTR_TIM13RST               ((uint32_t)0x00000080)         /*!< TIM13 Timer reset */
  1994.  #define  RCC_APB1RSTR_TIM14RST               ((uint32_t)0x00000100)         /*!< TIM14 Timer reset */
  1995. #endif /* STM32F10X_XL */
  1996.  
  1997. /******************  Bit definition for RCC_AHBENR register  ******************/
  1998. #define  RCC_AHBENR_DMA1EN                   ((uint16_t)0x0001)            /*!< DMA1 clock enable */
  1999. #define  RCC_AHBENR_SRAMEN                   ((uint16_t)0x0004)            /*!< SRAM interface clock enable */
  2000. #define  RCC_AHBENR_FLITFEN                  ((uint16_t)0x0010)            /*!< FLITF clock enable */
  2001. #define  RCC_AHBENR_CRCEN                    ((uint16_t)0x0040)            /*!< CRC clock enable */
  2002.  
  2003. #if defined (STM32F10X_HD) || defined (STM32F10X_XL) || defined  (STM32F10X_CL) || defined  (STM32F10X_HD_VL)
  2004.  #define  RCC_AHBENR_DMA2EN                  ((uint16_t)0x0002)            /*!< DMA2 clock enable */
  2005. #endif
  2006.  
  2007. #if defined (STM32F10X_HD) || defined (STM32F10X_XL)
  2008.  #define  RCC_AHBENR_FSMCEN                  ((uint16_t)0x0100)            /*!< FSMC clock enable */
  2009.  #define  RCC_AHBENR_SDIOEN                  ((uint16_t)0x0400)            /*!< SDIO clock enable */
  2010. #endif
  2011.  
  2012. #if defined (STM32F10X_HD_VL)
  2013.  #define  RCC_AHBENR_FSMCEN                  ((uint16_t)0x0100)            /*!< FSMC clock enable */
  2014. #endif
  2015.  
  2016. #ifdef STM32F10X_CL
  2017.  #define  RCC_AHBENR_OTGFSEN                 ((uint32_t)0x00001000)         /*!< USB OTG FS clock enable */
  2018.  #define  RCC_AHBENR_ETHMACEN                ((uint32_t)0x00004000)         /*!< ETHERNET MAC clock enable */
  2019.  #define  RCC_AHBENR_ETHMACTXEN              ((uint32_t)0x00008000)         /*!< ETHERNET MAC Tx clock enable */
  2020.  #define  RCC_AHBENR_ETHMACRXEN              ((uint32_t)0x00010000)         /*!< ETHERNET MAC Rx clock enable */
  2021. #endif /* STM32F10X_CL */
  2022.  
  2023. /******************  Bit definition for RCC_APB2ENR register  *****************/
  2024. #define  RCC_APB2ENR_AFIOEN                  ((uint32_t)0x00000001)         /*!< Alternate Function I/O clock enable */
  2025. #define  RCC_APB2ENR_IOPAEN                  ((uint32_t)0x00000004)         /*!< I/O port A clock enable */
  2026. #define  RCC_APB2ENR_IOPBEN                  ((uint32_t)0x00000008)         /*!< I/O port B clock enable */
  2027. #define  RCC_APB2ENR_IOPCEN                  ((uint32_t)0x00000010)         /*!< I/O port C clock enable */
  2028. #define  RCC_APB2ENR_IOPDEN                  ((uint32_t)0x00000020)         /*!< I/O port D clock enable */
  2029. #define  RCC_APB2ENR_ADC1EN                  ((uint32_t)0x00000200)         /*!< ADC 1 interface clock enable */
  2030.  
  2031. #if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL)
  2032. #define  RCC_APB2ENR_ADC2EN                  ((uint32_t)0x00000400)         /*!< ADC 2 interface clock enable */
  2033. #endif
  2034.  
  2035. #define  RCC_APB2ENR_TIM1EN                  ((uint32_t)0x00000800)         /*!< TIM1 Timer clock enable */
  2036. #define  RCC_APB2ENR_SPI1EN                  ((uint32_t)0x00001000)         /*!< SPI 1 clock enable */
  2037. #define  RCC_APB2ENR_USART1EN                ((uint32_t)0x00004000)         /*!< USART1 clock enable */
  2038.  
  2039. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  2040. #define  RCC_APB2ENR_TIM15EN                 ((uint32_t)0x00010000)         /*!< TIM15 Timer clock enable */
  2041. #define  RCC_APB2ENR_TIM16EN                 ((uint32_t)0x00020000)         /*!< TIM16 Timer clock enable */
  2042. #define  RCC_APB2ENR_TIM17EN                 ((uint32_t)0x00040000)         /*!< TIM17 Timer clock enable */
  2043. #endif
  2044.  
  2045. #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL)
  2046.  #define  RCC_APB2ENR_IOPEEN                 ((uint32_t)0x00000040)         /*!< I/O port E clock enable */
  2047. #endif /* STM32F10X_LD && STM32F10X_LD_VL */
  2048.  
  2049. #if defined (STM32F10X_HD) || defined (STM32F10X_XL)
  2050.  #define  RCC_APB2ENR_IOPFEN                 ((uint32_t)0x00000080)         /*!< I/O port F clock enable */
  2051.  #define  RCC_APB2ENR_IOPGEN                 ((uint32_t)0x00000100)         /*!< I/O port G clock enable */
  2052.  #define  RCC_APB2ENR_TIM8EN                 ((uint32_t)0x00002000)         /*!< TIM8 Timer clock enable */
  2053.  #define  RCC_APB2ENR_ADC3EN                 ((uint32_t)0x00008000)         /*!< DMA1 clock enable */
  2054. #endif
  2055.  
  2056. #if defined (STM32F10X_HD_VL)
  2057.  #define  RCC_APB2ENR_IOPFEN                 ((uint32_t)0x00000080)         /*!< I/O port F clock enable */
  2058.  #define  RCC_APB2ENR_IOPGEN                 ((uint32_t)0x00000100)         /*!< I/O port G clock enable */
  2059. #endif
  2060.  
  2061. #ifdef STM32F10X_XL
  2062.  #define  RCC_APB2ENR_TIM9EN                 ((uint32_t)0x00080000)         /*!< TIM9 Timer clock enable  */
  2063.  #define  RCC_APB2ENR_TIM10EN                ((uint32_t)0x00100000)         /*!< TIM10 Timer clock enable  */
  2064.  #define  RCC_APB2ENR_TIM11EN                ((uint32_t)0x00200000)         /*!< TIM11 Timer clock enable */
  2065. #endif
  2066.  
  2067. /*****************  Bit definition for RCC_APB1ENR register  ******************/
  2068. #define  RCC_APB1ENR_TIM2EN                  ((uint32_t)0x00000001)        /*!< Timer 2 clock enabled*/
  2069. #define  RCC_APB1ENR_TIM3EN                  ((uint32_t)0x00000002)        /*!< Timer 3 clock enable */
  2070. #define  RCC_APB1ENR_WWDGEN                  ((uint32_t)0x00000800)        /*!< Window Watchdog clock enable */
  2071. #define  RCC_APB1ENR_USART2EN                ((uint32_t)0x00020000)        /*!< USART 2 clock enable */
  2072. #define  RCC_APB1ENR_I2C1EN                  ((uint32_t)0x00200000)        /*!< I2C 1 clock enable */
  2073.  
  2074. #if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL)
  2075. #define  RCC_APB1ENR_CAN1EN                  ((uint32_t)0x02000000)        /*!< CAN1 clock enable */
  2076. #endif
  2077.  
  2078. #define  RCC_APB1ENR_BKPEN                   ((uint32_t)0x08000000)        /*!< Backup interface clock enable */
  2079. #define  RCC_APB1ENR_PWREN                   ((uint32_t)0x10000000)        /*!< Power interface clock enable */
  2080.  
  2081. #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL)
  2082.  #define  RCC_APB1ENR_TIM4EN                 ((uint32_t)0x00000004)        /*!< Timer 4 clock enable */
  2083.  #define  RCC_APB1ENR_SPI2EN                 ((uint32_t)0x00004000)        /*!< SPI 2 clock enable */
  2084.  #define  RCC_APB1ENR_USART3EN               ((uint32_t)0x00040000)        /*!< USART 3 clock enable */
  2085.  #define  RCC_APB1ENR_I2C2EN                 ((uint32_t)0x00400000)        /*!< I2C 2 clock enable */
  2086. #endif /* STM32F10X_LD && STM32F10X_LD_VL */
  2087.  
  2088. #if defined (STM32F10X_HD) || defined (STM32F10X_MD) || defined  (STM32F10X_LD)
  2089.  #define  RCC_APB1ENR_USBEN                  ((uint32_t)0x00800000)        /*!< USB Device clock enable */
  2090. #endif
  2091.  
  2092. #if defined (STM32F10X_HD) || defined  (STM32F10X_CL)
  2093.  #define  RCC_APB1ENR_TIM5EN                 ((uint32_t)0x00000008)        /*!< Timer 5 clock enable */
  2094.  #define  RCC_APB1ENR_TIM6EN                 ((uint32_t)0x00000010)        /*!< Timer 6 clock enable */
  2095.  #define  RCC_APB1ENR_TIM7EN                 ((uint32_t)0x00000020)        /*!< Timer 7 clock enable */
  2096.  #define  RCC_APB1ENR_SPI3EN                 ((uint32_t)0x00008000)        /*!< SPI 3 clock enable */
  2097.  #define  RCC_APB1ENR_UART4EN                ((uint32_t)0x00080000)        /*!< UART 4 clock enable */
  2098.  #define  RCC_APB1ENR_UART5EN                ((uint32_t)0x00100000)        /*!< UART 5 clock enable */
  2099.  #define  RCC_APB1ENR_DACEN                  ((uint32_t)0x20000000)        /*!< DAC interface clock enable */
  2100. #endif
  2101.  
  2102. #if defined (STM32F10X_LD_VL) || defined  (STM32F10X_MD_VL) || defined  (STM32F10X_HD_VL)
  2103.  #define  RCC_APB1ENR_TIM6EN                 ((uint32_t)0x00000010)        /*!< Timer 6 clock enable */
  2104.  #define  RCC_APB1ENR_TIM7EN                 ((uint32_t)0x00000020)        /*!< Timer 7 clock enable */
  2105.  #define  RCC_APB1ENR_DACEN                  ((uint32_t)0x20000000)        /*!< DAC interface clock enable */
  2106.  #define  RCC_APB1ENR_CECEN                  ((uint32_t)0x40000000)        /*!< CEC interface clock enable */
  2107. #endif
  2108.  
  2109. #ifdef STM32F10X_HD_VL
  2110.  #define  RCC_APB1ENR_TIM5EN                 ((uint32_t)0x00000008)        /*!< Timer 5 clock enable */
  2111.  #define  RCC_APB1ENR_TIM12EN                ((uint32_t)0x00000040)         /*!< TIM12 Timer clock enable  */
  2112.  #define  RCC_APB1ENR_TIM13EN                ((uint32_t)0x00000080)         /*!< TIM13 Timer clock enable  */
  2113.  #define  RCC_APB1ENR_TIM14EN                ((uint32_t)0x00000100)         /*!< TIM14 Timer clock enable */
  2114.  #define  RCC_APB1ENR_SPI3EN                 ((uint32_t)0x00008000)        /*!< SPI 3 clock enable */
  2115.  #define  RCC_APB1ENR_UART4EN                ((uint32_t)0x00080000)        /*!< UART 4 clock enable */
  2116.  #define  RCC_APB1ENR_UART5EN                ((uint32_t)0x00100000)        /*!< UART 5 clock enable */
  2117. #endif /* STM32F10X_HD_VL */
  2118.  
  2119. #ifdef STM32F10X_CL
  2120.  #define  RCC_APB1ENR_CAN2EN                  ((uint32_t)0x04000000)        /*!< CAN2 clock enable */
  2121. #endif /* STM32F10X_CL */
  2122.  
  2123. #ifdef STM32F10X_XL
  2124.  #define  RCC_APB1ENR_TIM12EN                ((uint32_t)0x00000040)         /*!< TIM12 Timer clock enable  */
  2125.  #define  RCC_APB1ENR_TIM13EN                ((uint32_t)0x00000080)         /*!< TIM13 Timer clock enable  */
  2126.  #define  RCC_APB1ENR_TIM14EN                ((uint32_t)0x00000100)         /*!< TIM14 Timer clock enable */
  2127. #endif /* STM32F10X_XL */
  2128.  
  2129. /*******************  Bit definition for RCC_BDCR register  *******************/
  2130. #define  RCC_BDCR_LSEON                      ((uint32_t)0x00000001)        /*!< External Low Speed oscillator enable */
  2131. #define  RCC_BDCR_LSERDY                     ((uint32_t)0x00000002)        /*!< External Low Speed oscillator Ready */
  2132. #define  RCC_BDCR_LSEBYP                     ((uint32_t)0x00000004)        /*!< External Low Speed oscillator Bypass */
  2133.  
  2134. #define  RCC_BDCR_RTCSEL                     ((uint32_t)0x00000300)        /*!< RTCSEL[1:0] bits (RTC clock source selection) */
  2135. #define  RCC_BDCR_RTCSEL_0                   ((uint32_t)0x00000100)        /*!< Bit 0 */
  2136. #define  RCC_BDCR_RTCSEL_1                   ((uint32_t)0x00000200)        /*!< Bit 1 */
  2137.  
  2138. /*!< RTC congiguration */
  2139. #define  RCC_BDCR_RTCSEL_NOCLOCK             ((uint32_t)0x00000000)        /*!< No clock */
  2140. #define  RCC_BDCR_RTCSEL_LSE                 ((uint32_t)0x00000100)        /*!< LSE oscillator clock used as RTC clock */
  2141. #define  RCC_BDCR_RTCSEL_LSI                 ((uint32_t)0x00000200)        /*!< LSI oscillator clock used as RTC clock */
  2142. #define  RCC_BDCR_RTCSEL_HSE                 ((uint32_t)0x00000300)        /*!< HSE oscillator clock divided by 128 used as RTC clock */
  2143.  
  2144. #define  RCC_BDCR_RTCEN                      ((uint32_t)0x00008000)        /*!< RTC clock enable */
  2145. #define  RCC_BDCR_BDRST                      ((uint32_t)0x00010000)        /*!< Backup domain software reset  */
  2146.  
  2147. /*******************  Bit definition for RCC_CSR register  ********************/  
  2148. #define  RCC_CSR_LSION                       ((uint32_t)0x00000001)        /*!< Internal Low Speed oscillator enable */
  2149. #define  RCC_CSR_LSIRDY                      ((uint32_t)0x00000002)        /*!< Internal Low Speed oscillator Ready */
  2150. #define  RCC_CSR_RMVF                        ((uint32_t)0x01000000)        /*!< Remove reset flag */
  2151. #define  RCC_CSR_PINRSTF                     ((uint32_t)0x04000000)        /*!< PIN reset flag */
  2152. #define  RCC_CSR_PORRSTF                     ((uint32_t)0x08000000)        /*!< POR/PDR reset flag */
  2153. #define  RCC_CSR_SFTRSTF                     ((uint32_t)0x10000000)        /*!< Software Reset flag */
  2154. #define  RCC_CSR_IWDGRSTF                    ((uint32_t)0x20000000)        /*!< Independent Watchdog reset flag */
  2155. #define  RCC_CSR_WWDGRSTF                    ((uint32_t)0x40000000)        /*!< Window watchdog reset flag */
  2156. #define  RCC_CSR_LPWRRSTF                    ((uint32_t)0x80000000)        /*!< Low-Power reset flag */
  2157.  
  2158. #ifdef STM32F10X_CL
  2159. /*******************  Bit definition for RCC_AHBRSTR register  ****************/
  2160.  #define  RCC_AHBRSTR_OTGFSRST               ((uint32_t)0x00001000)         /*!< USB OTG FS reset */
  2161.  #define  RCC_AHBRSTR_ETHMACRST              ((uint32_t)0x00004000)         /*!< ETHERNET MAC reset */
  2162.  
  2163. /*******************  Bit definition for RCC_CFGR2 register  ******************/
  2164. /*!< PREDIV1 configuration */
  2165.  #define  RCC_CFGR2_PREDIV1                  ((uint32_t)0x0000000F)        /*!< PREDIV1[3:0] bits */
  2166.  #define  RCC_CFGR2_PREDIV1_0                ((uint32_t)0x00000001)        /*!< Bit 0 */
  2167.  #define  RCC_CFGR2_PREDIV1_1                ((uint32_t)0x00000002)        /*!< Bit 1 */
  2168.  #define  RCC_CFGR2_PREDIV1_2                ((uint32_t)0x00000004)        /*!< Bit 2 */
  2169.  #define  RCC_CFGR2_PREDIV1_3                ((uint32_t)0x00000008)        /*!< Bit 3 */
  2170.  
  2171.  #define  RCC_CFGR2_PREDIV1_DIV1             ((uint32_t)0x00000000)        /*!< PREDIV1 input clock not divided */
  2172.  #define  RCC_CFGR2_PREDIV1_DIV2             ((uint32_t)0x00000001)        /*!< PREDIV1 input clock divided by 2 */
  2173.  #define  RCC_CFGR2_PREDIV1_DIV3             ((uint32_t)0x00000002)        /*!< PREDIV1 input clock divided by 3 */
  2174.  #define  RCC_CFGR2_PREDIV1_DIV4             ((uint32_t)0x00000003)        /*!< PREDIV1 input clock divided by 4 */
  2175.  #define  RCC_CFGR2_PREDIV1_DIV5             ((uint32_t)0x00000004)        /*!< PREDIV1 input clock divided by 5 */
  2176.  #define  RCC_CFGR2_PREDIV1_DIV6             ((uint32_t)0x00000005)        /*!< PREDIV1 input clock divided by 6 */
  2177.  #define  RCC_CFGR2_PREDIV1_DIV7             ((uint32_t)0x00000006)        /*!< PREDIV1 input clock divided by 7 */
  2178.  #define  RCC_CFGR2_PREDIV1_DIV8             ((uint32_t)0x00000007)        /*!< PREDIV1 input clock divided by 8 */
  2179.  #define  RCC_CFGR2_PREDIV1_DIV9             ((uint32_t)0x00000008)        /*!< PREDIV1 input clock divided by 9 */
  2180.  #define  RCC_CFGR2_PREDIV1_DIV10            ((uint32_t)0x00000009)        /*!< PREDIV1 input clock divided by 10 */
  2181.  #define  RCC_CFGR2_PREDIV1_DIV11            ((uint32_t)0x0000000A)        /*!< PREDIV1 input clock divided by 11 */
  2182.  #define  RCC_CFGR2_PREDIV1_DIV12            ((uint32_t)0x0000000B)        /*!< PREDIV1 input clock divided by 12 */
  2183.  #define  RCC_CFGR2_PREDIV1_DIV13            ((uint32_t)0x0000000C)        /*!< PREDIV1 input clock divided by 13 */
  2184.  #define  RCC_CFGR2_PREDIV1_DIV14            ((uint32_t)0x0000000D)        /*!< PREDIV1 input clock divided by 14 */
  2185.  #define  RCC_CFGR2_PREDIV1_DIV15            ((uint32_t)0x0000000E)        /*!< PREDIV1 input clock divided by 15 */
  2186.  #define  RCC_CFGR2_PREDIV1_DIV16            ((uint32_t)0x0000000F)        /*!< PREDIV1 input clock divided by 16 */
  2187.  
  2188. /*!< PREDIV2 configuration */
  2189.  #define  RCC_CFGR2_PREDIV2                  ((uint32_t)0x000000F0)        /*!< PREDIV2[3:0] bits */
  2190.  #define  RCC_CFGR2_PREDIV2_0                ((uint32_t)0x00000010)        /*!< Bit 0 */
  2191.  #define  RCC_CFGR2_PREDIV2_1                ((uint32_t)0x00000020)        /*!< Bit 1 */
  2192.  #define  RCC_CFGR2_PREDIV2_2                ((uint32_t)0x00000040)        /*!< Bit 2 */
  2193.  #define  RCC_CFGR2_PREDIV2_3                ((uint32_t)0x00000080)        /*!< Bit 3 */
  2194.  
  2195.  #define  RCC_CFGR2_PREDIV2_DIV1             ((uint32_t)0x00000000)        /*!< PREDIV2 input clock not divided */
  2196.  #define  RCC_CFGR2_PREDIV2_DIV2             ((uint32_t)0x00000010)        /*!< PREDIV2 input clock divided by 2 */
  2197.  #define  RCC_CFGR2_PREDIV2_DIV3             ((uint32_t)0x00000020)        /*!< PREDIV2 input clock divided by 3 */
  2198.  #define  RCC_CFGR2_PREDIV2_DIV4             ((uint32_t)0x00000030)        /*!< PREDIV2 input clock divided by 4 */
  2199.  #define  RCC_CFGR2_PREDIV2_DIV5             ((uint32_t)0x00000040)        /*!< PREDIV2 input clock divided by 5 */
  2200.  #define  RCC_CFGR2_PREDIV2_DIV6             ((uint32_t)0x00000050)        /*!< PREDIV2 input clock divided by 6 */
  2201.  #define  RCC_CFGR2_PREDIV2_DIV7             ((uint32_t)0x00000060)        /*!< PREDIV2 input clock divided by 7 */
  2202.  #define  RCC_CFGR2_PREDIV2_DIV8             ((uint32_t)0x00000070)        /*!< PREDIV2 input clock divided by 8 */
  2203.  #define  RCC_CFGR2_PREDIV2_DIV9             ((uint32_t)0x00000080)        /*!< PREDIV2 input clock divided by 9 */
  2204.  #define  RCC_CFGR2_PREDIV2_DIV10            ((uint32_t)0x00000090)        /*!< PREDIV2 input clock divided by 10 */
  2205.  #define  RCC_CFGR2_PREDIV2_DIV11            ((uint32_t)0x000000A0)        /*!< PREDIV2 input clock divided by 11 */
  2206.  #define  RCC_CFGR2_PREDIV2_DIV12            ((uint32_t)0x000000B0)        /*!< PREDIV2 input clock divided by 12 */
  2207.  #define  RCC_CFGR2_PREDIV2_DIV13            ((uint32_t)0x000000C0)        /*!< PREDIV2 input clock divided by 13 */
  2208.  #define  RCC_CFGR2_PREDIV2_DIV14            ((uint32_t)0x000000D0)        /*!< PREDIV2 input clock divided by 14 */
  2209.  #define  RCC_CFGR2_PREDIV2_DIV15            ((uint32_t)0x000000E0)        /*!< PREDIV2 input clock divided by 15 */
  2210.  #define  RCC_CFGR2_PREDIV2_DIV16            ((uint32_t)0x000000F0)        /*!< PREDIV2 input clock divided by 16 */
  2211.  
  2212. /*!< PLL2MUL configuration */
  2213.  #define  RCC_CFGR2_PLL2MUL                  ((uint32_t)0x00000F00)        /*!< PLL2MUL[3:0] bits */
  2214.  #define  RCC_CFGR2_PLL2MUL_0                ((uint32_t)0x00000100)        /*!< Bit 0 */
  2215.  #define  RCC_CFGR2_PLL2MUL_1                ((uint32_t)0x00000200)        /*!< Bit 1 */
  2216.  #define  RCC_CFGR2_PLL2MUL_2                ((uint32_t)0x00000400)        /*!< Bit 2 */
  2217.  #define  RCC_CFGR2_PLL2MUL_3                ((uint32_t)0x00000800)        /*!< Bit 3 */
  2218.  
  2219.  #define  RCC_CFGR2_PLL2MUL8                 ((uint32_t)0x00000600)        /*!< PLL2 input clock * 8 */
  2220.  #define  RCC_CFGR2_PLL2MUL9                 ((uint32_t)0x00000700)        /*!< PLL2 input clock * 9 */
  2221.  #define  RCC_CFGR2_PLL2MUL10                ((uint32_t)0x00000800)        /*!< PLL2 input clock * 10 */
  2222.  #define  RCC_CFGR2_PLL2MUL11                ((uint32_t)0x00000900)        /*!< PLL2 input clock * 11 */
  2223.  #define  RCC_CFGR2_PLL2MUL12                ((uint32_t)0x00000A00)        /*!< PLL2 input clock * 12 */
  2224.  #define  RCC_CFGR2_PLL2MUL13                ((uint32_t)0x00000B00)        /*!< PLL2 input clock * 13 */
  2225.  #define  RCC_CFGR2_PLL2MUL14                ((uint32_t)0x00000C00)        /*!< PLL2 input clock * 14 */
  2226.  #define  RCC_CFGR2_PLL2MUL16                ((uint32_t)0x00000E00)        /*!< PLL2 input clock * 16 */
  2227.  #define  RCC_CFGR2_PLL2MUL20                ((uint32_t)0x00000F00)        /*!< PLL2 input clock * 20 */
  2228.  
  2229. /*!< PLL3MUL configuration */
  2230.  #define  RCC_CFGR2_PLL3MUL                  ((uint32_t)0x0000F000)        /*!< PLL3MUL[3:0] bits */
  2231.  #define  RCC_CFGR2_PLL3MUL_0                ((uint32_t)0x00001000)        /*!< Bit 0 */
  2232.  #define  RCC_CFGR2_PLL3MUL_1                ((uint32_t)0x00002000)        /*!< Bit 1 */
  2233.  #define  RCC_CFGR2_PLL3MUL_2                ((uint32_t)0x00004000)        /*!< Bit 2 */
  2234.  #define  RCC_CFGR2_PLL3MUL_3                ((uint32_t)0x00008000)        /*!< Bit 3 */
  2235.  
  2236.  #define  RCC_CFGR2_PLL3MUL8                 ((uint32_t)0x00006000)        /*!< PLL3 input clock * 8 */
  2237.  #define  RCC_CFGR2_PLL3MUL9                 ((uint32_t)0x00007000)        /*!< PLL3 input clock * 9 */
  2238.  #define  RCC_CFGR2_PLL3MUL10                ((uint32_t)0x00008000)        /*!< PLL3 input clock * 10 */
  2239.  #define  RCC_CFGR2_PLL3MUL11                ((uint32_t)0x00009000)        /*!< PLL3 input clock * 11 */
  2240.  #define  RCC_CFGR2_PLL3MUL12                ((uint32_t)0x0000A000)        /*!< PLL3 input clock * 12 */
  2241.  #define  RCC_CFGR2_PLL3MUL13                ((uint32_t)0x0000B000)        /*!< PLL3 input clock * 13 */
  2242.  #define  RCC_CFGR2_PLL3MUL14                ((uint32_t)0x0000C000)        /*!< PLL3 input clock * 14 */
  2243.  #define  RCC_CFGR2_PLL3MUL16                ((uint32_t)0x0000E000)        /*!< PLL3 input clock * 16 */
  2244.  #define  RCC_CFGR2_PLL3MUL20                ((uint32_t)0x0000F000)        /*!< PLL3 input clock * 20 */
  2245.  
  2246.  #define  RCC_CFGR2_PREDIV1SRC               ((uint32_t)0x00010000)        /*!< PREDIV1 entry clock source */
  2247.  #define  RCC_CFGR2_PREDIV1SRC_PLL2          ((uint32_t)0x00010000)        /*!< PLL2 selected as PREDIV1 entry clock source */
  2248.  #define  RCC_CFGR2_PREDIV1SRC_HSE           ((uint32_t)0x00000000)        /*!< HSE selected as PREDIV1 entry clock source */
  2249.  #define  RCC_CFGR2_I2S2SRC                  ((uint32_t)0x00020000)        /*!< I2S2 entry clock source */
  2250.  #define  RCC_CFGR2_I2S3SRC                  ((uint32_t)0x00040000)        /*!< I2S3 clock source */
  2251. #endif /* STM32F10X_CL */
  2252.  
  2253. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  2254. /*******************  Bit definition for RCC_CFGR2 register  ******************/
  2255. /*!< PREDIV1 configuration */
  2256.  #define  RCC_CFGR2_PREDIV1                  ((uint32_t)0x0000000F)        /*!< PREDIV1[3:0] bits */
  2257.  #define  RCC_CFGR2_PREDIV1_0                ((uint32_t)0x00000001)        /*!< Bit 0 */
  2258.  #define  RCC_CFGR2_PREDIV1_1                ((uint32_t)0x00000002)        /*!< Bit 1 */
  2259.  #define  RCC_CFGR2_PREDIV1_2                ((uint32_t)0x00000004)        /*!< Bit 2 */
  2260.  #define  RCC_CFGR2_PREDIV1_3                ((uint32_t)0x00000008)        /*!< Bit 3 */
  2261.  
  2262.  #define  RCC_CFGR2_PREDIV1_DIV1             ((uint32_t)0x00000000)        /*!< PREDIV1 input clock not divided */
  2263.  #define  RCC_CFGR2_PREDIV1_DIV2             ((uint32_t)0x00000001)        /*!< PREDIV1 input clock divided by 2 */
  2264.  #define  RCC_CFGR2_PREDIV1_DIV3             ((uint32_t)0x00000002)        /*!< PREDIV1 input clock divided by 3 */
  2265.  #define  RCC_CFGR2_PREDIV1_DIV4             ((uint32_t)0x00000003)        /*!< PREDIV1 input clock divided by 4 */
  2266.  #define  RCC_CFGR2_PREDIV1_DIV5             ((uint32_t)0x00000004)        /*!< PREDIV1 input clock divided by 5 */
  2267.  #define  RCC_CFGR2_PREDIV1_DIV6             ((uint32_t)0x00000005)        /*!< PREDIV1 input clock divided by 6 */
  2268.  #define  RCC_CFGR2_PREDIV1_DIV7             ((uint32_t)0x00000006)        /*!< PREDIV1 input clock divided by 7 */
  2269.  #define  RCC_CFGR2_PREDIV1_DIV8             ((uint32_t)0x00000007)        /*!< PREDIV1 input clock divided by 8 */
  2270.  #define  RCC_CFGR2_PREDIV1_DIV9             ((uint32_t)0x00000008)        /*!< PREDIV1 input clock divided by 9 */
  2271.  #define  RCC_CFGR2_PREDIV1_DIV10            ((uint32_t)0x00000009)        /*!< PREDIV1 input clock divided by 10 */
  2272.  #define  RCC_CFGR2_PREDIV1_DIV11            ((uint32_t)0x0000000A)        /*!< PREDIV1 input clock divided by 11 */
  2273.  #define  RCC_CFGR2_PREDIV1_DIV12            ((uint32_t)0x0000000B)        /*!< PREDIV1 input clock divided by 12 */
  2274.  #define  RCC_CFGR2_PREDIV1_DIV13            ((uint32_t)0x0000000C)        /*!< PREDIV1 input clock divided by 13 */
  2275.  #define  RCC_CFGR2_PREDIV1_DIV14            ((uint32_t)0x0000000D)        /*!< PREDIV1 input clock divided by 14 */
  2276.  #define  RCC_CFGR2_PREDIV1_DIV15            ((uint32_t)0x0000000E)        /*!< PREDIV1 input clock divided by 15 */
  2277.  #define  RCC_CFGR2_PREDIV1_DIV16            ((uint32_t)0x0000000F)        /*!< PREDIV1 input clock divided by 16 */
  2278. #endif
  2279.  
  2280. /******************************************************************************/
  2281. /*                                                                            */
  2282. /*                General Purpose and Alternate Function I/O                  */
  2283. /*                                                                            */
  2284. /******************************************************************************/
  2285.  
  2286. /*******************  Bit definition for GPIO_CRL register  *******************/
  2287. #define  GPIO_CRL_MODE                       ((uint32_t)0x33333333)        /*!< Port x mode bits */
  2288.  
  2289. #define  GPIO_CRL_MODE0                      ((uint32_t)0x00000003)        /*!< MODE0[1:0] bits (Port x mode bits, pin 0) */
  2290. #define  GPIO_CRL_MODE0_0                    ((uint32_t)0x00000001)        /*!< Bit 0 */
  2291. #define  GPIO_CRL_MODE0_1                    ((uint32_t)0x00000002)        /*!< Bit 1 */
  2292.  
  2293. #define  GPIO_CRL_MODE1                      ((uint32_t)0x00000030)        /*!< MODE1[1:0] bits (Port x mode bits, pin 1) */
  2294. #define  GPIO_CRL_MODE1_0                    ((uint32_t)0x00000010)        /*!< Bit 0 */
  2295. #define  GPIO_CRL_MODE1_1                    ((uint32_t)0x00000020)        /*!< Bit 1 */
  2296.  
  2297. #define  GPIO_CRL_MODE2                      ((uint32_t)0x00000300)        /*!< MODE2[1:0] bits (Port x mode bits, pin 2) */
  2298. #define  GPIO_CRL_MODE2_0                    ((uint32_t)0x00000100)        /*!< Bit 0 */
  2299. #define  GPIO_CRL_MODE2_1                    ((uint32_t)0x00000200)        /*!< Bit 1 */
  2300.  
  2301. #define  GPIO_CRL_MODE3                      ((uint32_t)0x00003000)        /*!< MODE3[1:0] bits (Port x mode bits, pin 3) */
  2302. #define  GPIO_CRL_MODE3_0                    ((uint32_t)0x00001000)        /*!< Bit 0 */
  2303. #define  GPIO_CRL_MODE3_1                    ((uint32_t)0x00002000)        /*!< Bit 1 */
  2304.  
  2305. #define  GPIO_CRL_MODE4                      ((uint32_t)0x00030000)        /*!< MODE4[1:0] bits (Port x mode bits, pin 4) */
  2306. #define  GPIO_CRL_MODE4_0                    ((uint32_t)0x00010000)        /*!< Bit 0 */
  2307. #define  GPIO_CRL_MODE4_1                    ((uint32_t)0x00020000)        /*!< Bit 1 */
  2308.  
  2309. #define  GPIO_CRL_MODE5                      ((uint32_t)0x00300000)        /*!< MODE5[1:0] bits (Port x mode bits, pin 5) */
  2310. #define  GPIO_CRL_MODE5_0                    ((uint32_t)0x00100000)        /*!< Bit 0 */
  2311. #define  GPIO_CRL_MODE5_1                    ((uint32_t)0x00200000)        /*!< Bit 1 */
  2312.  
  2313. #define  GPIO_CRL_MODE6                      ((uint32_t)0x03000000)        /*!< MODE6[1:0] bits (Port x mode bits, pin 6) */
  2314. #define  GPIO_CRL_MODE6_0                    ((uint32_t)0x01000000)        /*!< Bit 0 */
  2315. #define  GPIO_CRL_MODE6_1                    ((uint32_t)0x02000000)        /*!< Bit 1 */
  2316.  
  2317. #define  GPIO_CRL_MODE7                      ((uint32_t)0x30000000)        /*!< MODE7[1:0] bits (Port x mode bits, pin 7) */
  2318. #define  GPIO_CRL_MODE7_0                    ((uint32_t)0x10000000)        /*!< Bit 0 */
  2319. #define  GPIO_CRL_MODE7_1                    ((uint32_t)0x20000000)        /*!< Bit 1 */
  2320.  
  2321. #define  GPIO_CRL_CNF                        ((uint32_t)0xCCCCCCCC)        /*!< Port x configuration bits */
  2322.  
  2323. #define  GPIO_CRL_CNF0                       ((uint32_t)0x0000000C)        /*!< CNF0[1:0] bits (Port x configuration bits, pin 0) */
  2324. #define  GPIO_CRL_CNF0_0                     ((uint32_t)0x00000004)        /*!< Bit 0 */
  2325. #define  GPIO_CRL_CNF0_1                     ((uint32_t)0x00000008)        /*!< Bit 1 */
  2326.  
  2327. #define  GPIO_CRL_CNF1                       ((uint32_t)0x000000C0)        /*!< CNF1[1:0] bits (Port x configuration bits, pin 1) */
  2328. #define  GPIO_CRL_CNF1_0                     ((uint32_t)0x00000040)        /*!< Bit 0 */
  2329. #define  GPIO_CRL_CNF1_1                     ((uint32_t)0x00000080)        /*!< Bit 1 */
  2330.  
  2331. #define  GPIO_CRL_CNF2                       ((uint32_t)0x00000C00)        /*!< CNF2[1:0] bits (Port x configuration bits, pin 2) */
  2332. #define  GPIO_CRL_CNF2_0                     ((uint32_t)0x00000400)        /*!< Bit 0 */
  2333. #define  GPIO_CRL_CNF2_1                     ((uint32_t)0x00000800)        /*!< Bit 1 */
  2334.  
  2335. #define  GPIO_CRL_CNF3                       ((uint32_t)0x0000C000)        /*!< CNF3[1:0] bits (Port x configuration bits, pin 3) */
  2336. #define  GPIO_CRL_CNF3_0                     ((uint32_t)0x00004000)        /*!< Bit 0 */
  2337. #define  GPIO_CRL_CNF3_1                     ((uint32_t)0x00008000)        /*!< Bit 1 */
  2338.  
  2339. #define  GPIO_CRL_CNF4                       ((uint32_t)0x000C0000)        /*!< CNF4[1:0] bits (Port x configuration bits, pin 4) */
  2340. #define  GPIO_CRL_CNF4_0                     ((uint32_t)0x00040000)        /*!< Bit 0 */
  2341. #define  GPIO_CRL_CNF4_1                     ((uint32_t)0x00080000)        /*!< Bit 1 */
  2342.  
  2343. #define  GPIO_CRL_CNF5                       ((uint32_t)0x00C00000)        /*!< CNF5[1:0] bits (Port x configuration bits, pin 5) */
  2344. #define  GPIO_CRL_CNF5_0                     ((uint32_t)0x00400000)        /*!< Bit 0 */
  2345. #define  GPIO_CRL_CNF5_1                     ((uint32_t)0x00800000)        /*!< Bit 1 */
  2346.  
  2347. #define  GPIO_CRL_CNF6                       ((uint32_t)0x0C000000)        /*!< CNF6[1:0] bits (Port x configuration bits, pin 6) */
  2348. #define  GPIO_CRL_CNF6_0                     ((uint32_t)0x04000000)        /*!< Bit 0 */
  2349. #define  GPIO_CRL_CNF6_1                     ((uint32_t)0x08000000)        /*!< Bit 1 */
  2350.  
  2351. #define  GPIO_CRL_CNF7                       ((uint32_t)0xC0000000)        /*!< CNF7[1:0] bits (Port x configuration bits, pin 7) */
  2352. #define  GPIO_CRL_CNF7_0                     ((uint32_t)0x40000000)        /*!< Bit 0 */
  2353. #define  GPIO_CRL_CNF7_1                     ((uint32_t)0x80000000)        /*!< Bit 1 */
  2354.  
  2355. /*******************  Bit definition for GPIO_CRH register  *******************/
  2356. #define  GPIO_CRH_MODE                       ((uint32_t)0x33333333)        /*!< Port x mode bits */
  2357.  
  2358. #define  GPIO_CRH_MODE8                      ((uint32_t)0x00000003)        /*!< MODE8[1:0] bits (Port x mode bits, pin 8) */
  2359. #define  GPIO_CRH_MODE8_0                    ((uint32_t)0x00000001)        /*!< Bit 0 */
  2360. #define  GPIO_CRH_MODE8_1                    ((uint32_t)0x00000002)        /*!< Bit 1 */
  2361.  
  2362. #define  GPIO_CRH_MODE9                      ((uint32_t)0x00000030)        /*!< MODE9[1:0] bits (Port x mode bits, pin 9) */
  2363. #define  GPIO_CRH_MODE9_0                    ((uint32_t)0x00000010)        /*!< Bit 0 */
  2364. #define  GPIO_CRH_MODE9_1                    ((uint32_t)0x00000020)        /*!< Bit 1 */
  2365.  
  2366. #define  GPIO_CRH_MODE10                     ((uint32_t)0x00000300)        /*!< MODE10[1:0] bits (Port x mode bits, pin 10) */
  2367. #define  GPIO_CRH_MODE10_0                   ((uint32_t)0x00000100)        /*!< Bit 0 */
  2368. #define  GPIO_CRH_MODE10_1                   ((uint32_t)0x00000200)        /*!< Bit 1 */
  2369.  
  2370. #define  GPIO_CRH_MODE11                     ((uint32_t)0x00003000)        /*!< MODE11[1:0] bits (Port x mode bits, pin 11) */
  2371. #define  GPIO_CRH_MODE11_0                   ((uint32_t)0x00001000)        /*!< Bit 0 */
  2372. #define  GPIO_CRH_MODE11_1                   ((uint32_t)0x00002000)        /*!< Bit 1 */
  2373.  
  2374. #define  GPIO_CRH_MODE12                     ((uint32_t)0x00030000)        /*!< MODE12[1:0] bits (Port x mode bits, pin 12) */
  2375. #define  GPIO_CRH_MODE12_0                   ((uint32_t)0x00010000)        /*!< Bit 0 */
  2376. #define  GPIO_CRH_MODE12_1                   ((uint32_t)0x00020000)        /*!< Bit 1 */
  2377.  
  2378. #define  GPIO_CRH_MODE13                     ((uint32_t)0x00300000)        /*!< MODE13[1:0] bits (Port x mode bits, pin 13) */
  2379. #define  GPIO_CRH_MODE13_0                   ((uint32_t)0x00100000)        /*!< Bit 0 */
  2380. #define  GPIO_CRH_MODE13_1                   ((uint32_t)0x00200000)        /*!< Bit 1 */
  2381.  
  2382. #define  GPIO_CRH_MODE14                     ((uint32_t)0x03000000)        /*!< MODE14[1:0] bits (Port x mode bits, pin 14) */
  2383. #define  GPIO_CRH_MODE14_0                   ((uint32_t)0x01000000)        /*!< Bit 0 */
  2384. #define  GPIO_CRH_MODE14_1                   ((uint32_t)0x02000000)        /*!< Bit 1 */
  2385.  
  2386. #define  GPIO_CRH_MODE15                     ((uint32_t)0x30000000)        /*!< MODE15[1:0] bits (Port x mode bits, pin 15) */
  2387. #define  GPIO_CRH_MODE15_0                   ((uint32_t)0x10000000)        /*!< Bit 0 */
  2388. #define  GPIO_CRH_MODE15_1                   ((uint32_t)0x20000000)        /*!< Bit 1 */
  2389.  
  2390. #define  GPIO_CRH_CNF                        ((uint32_t)0xCCCCCCCC)        /*!< Port x configuration bits */
  2391.  
  2392. #define  GPIO_CRH_CNF8                       ((uint32_t)0x0000000C)        /*!< CNF8[1:0] bits (Port x configuration bits, pin 8) */
  2393. #define  GPIO_CRH_CNF8_0                     ((uint32_t)0x00000004)        /*!< Bit 0 */
  2394. #define  GPIO_CRH_CNF8_1                     ((uint32_t)0x00000008)        /*!< Bit 1 */
  2395.  
  2396. #define  GPIO_CRH_CNF9                       ((uint32_t)0x000000C0)        /*!< CNF9[1:0] bits (Port x configuration bits, pin 9) */
  2397. #define  GPIO_CRH_CNF9_0                     ((uint32_t)0x00000040)        /*!< Bit 0 */
  2398. #define  GPIO_CRH_CNF9_1                     ((uint32_t)0x00000080)        /*!< Bit 1 */
  2399.  
  2400. #define  GPIO_CRH_CNF10                      ((uint32_t)0x00000C00)        /*!< CNF10[1:0] bits (Port x configuration bits, pin 10) */
  2401. #define  GPIO_CRH_CNF10_0                    ((uint32_t)0x00000400)        /*!< Bit 0 */
  2402. #define  GPIO_CRH_CNF10_1                    ((uint32_t)0x00000800)        /*!< Bit 1 */
  2403.  
  2404. #define  GPIO_CRH_CNF11                      ((uint32_t)0x0000C000)        /*!< CNF11[1:0] bits (Port x configuration bits, pin 11) */
  2405. #define  GPIO_CRH_CNF11_0                    ((uint32_t)0x00004000)        /*!< Bit 0 */
  2406. #define  GPIO_CRH_CNF11_1                    ((uint32_t)0x00008000)        /*!< Bit 1 */
  2407.  
  2408. #define  GPIO_CRH_CNF12                      ((uint32_t)0x000C0000)        /*!< CNF12[1:0] bits (Port x configuration bits, pin 12) */
  2409. #define  GPIO_CRH_CNF12_0                    ((uint32_t)0x00040000)        /*!< Bit 0 */
  2410. #define  GPIO_CRH_CNF12_1                    ((uint32_t)0x00080000)        /*!< Bit 1 */
  2411.  
  2412. #define  GPIO_CRH_CNF13                      ((uint32_t)0x00C00000)        /*!< CNF13[1:0] bits (Port x configuration bits, pin 13) */
  2413. #define  GPIO_CRH_CNF13_0                    ((uint32_t)0x00400000)        /*!< Bit 0 */
  2414. #define  GPIO_CRH_CNF13_1                    ((uint32_t)0x00800000)        /*!< Bit 1 */
  2415.  
  2416. #define  GPIO_CRH_CNF14                      ((uint32_t)0x0C000000)        /*!< CNF14[1:0] bits (Port x configuration bits, pin 14) */
  2417. #define  GPIO_CRH_CNF14_0                    ((uint32_t)0x04000000)        /*!< Bit 0 */
  2418. #define  GPIO_CRH_CNF14_1                    ((uint32_t)0x08000000)        /*!< Bit 1 */
  2419.  
  2420. #define  GPIO_CRH_CNF15                      ((uint32_t)0xC0000000)        /*!< CNF15[1:0] bits (Port x configuration bits, pin 15) */
  2421. #define  GPIO_CRH_CNF15_0                    ((uint32_t)0x40000000)        /*!< Bit 0 */
  2422. #define  GPIO_CRH_CNF15_1                    ((uint32_t)0x80000000)        /*!< Bit 1 */
  2423.  
  2424. /*!<******************  Bit definition for GPIO_IDR register  *******************/
  2425. #define GPIO_IDR_IDR0                        ((uint16_t)0x0001)            /*!< Port input data, bit 0 */
  2426. #define GPIO_IDR_IDR1                        ((uint16_t)0x0002)            /*!< Port input data, bit 1 */
  2427. #define GPIO_IDR_IDR2                        ((uint16_t)0x0004)            /*!< Port input data, bit 2 */
  2428. #define GPIO_IDR_IDR3                        ((uint16_t)0x0008)            /*!< Port input data, bit 3 */
  2429. #define GPIO_IDR_IDR4                        ((uint16_t)0x0010)            /*!< Port input data, bit 4 */
  2430. #define GPIO_IDR_IDR5                        ((uint16_t)0x0020)            /*!< Port input data, bit 5 */
  2431. #define GPIO_IDR_IDR6                        ((uint16_t)0x0040)            /*!< Port input data, bit 6 */
  2432. #define GPIO_IDR_IDR7                        ((uint16_t)0x0080)            /*!< Port input data, bit 7 */
  2433. #define GPIO_IDR_IDR8                        ((uint16_t)0x0100)            /*!< Port input data, bit 8 */
  2434. #define GPIO_IDR_IDR9                        ((uint16_t)0x0200)            /*!< Port input data, bit 9 */
  2435. #define GPIO_IDR_IDR10                       ((uint16_t)0x0400)            /*!< Port input data, bit 10 */
  2436. #define GPIO_IDR_IDR11                       ((uint16_t)0x0800)            /*!< Port input data, bit 11 */
  2437. #define GPIO_IDR_IDR12                       ((uint16_t)0x1000)            /*!< Port input data, bit 12 */
  2438. #define GPIO_IDR_IDR13                       ((uint16_t)0x2000)            /*!< Port input data, bit 13 */
  2439. #define GPIO_IDR_IDR14                       ((uint16_t)0x4000)            /*!< Port input data, bit 14 */
  2440. #define GPIO_IDR_IDR15                       ((uint16_t)0x8000)            /*!< Port input data, bit 15 */
  2441.  
  2442. /*******************  Bit definition for GPIO_ODR register  *******************/
  2443. #define GPIO_ODR_ODR0                        ((uint16_t)0x0001)            /*!< Port output data, bit 0 */
  2444. #define GPIO_ODR_ODR1                        ((uint16_t)0x0002)            /*!< Port output data, bit 1 */
  2445. #define GPIO_ODR_ODR2                        ((uint16_t)0x0004)            /*!< Port output data, bit 2 */
  2446. #define GPIO_ODR_ODR3                        ((uint16_t)0x0008)            /*!< Port output data, bit 3 */
  2447. #define GPIO_ODR_ODR4                        ((uint16_t)0x0010)            /*!< Port output data, bit 4 */
  2448. #define GPIO_ODR_ODR5                        ((uint16_t)0x0020)            /*!< Port output data, bit 5 */
  2449. #define GPIO_ODR_ODR6                        ((uint16_t)0x0040)            /*!< Port output data, bit 6 */
  2450. #define GPIO_ODR_ODR7                        ((uint16_t)0x0080)            /*!< Port output data, bit 7 */
  2451. #define GPIO_ODR_ODR8                        ((uint16_t)0x0100)            /*!< Port output data, bit 8 */
  2452. #define GPIO_ODR_ODR9                        ((uint16_t)0x0200)            /*!< Port output data, bit 9 */
  2453. #define GPIO_ODR_ODR10                       ((uint16_t)0x0400)            /*!< Port output data, bit 10 */
  2454. #define GPIO_ODR_ODR11                       ((uint16_t)0x0800)            /*!< Port output data, bit 11 */
  2455. #define GPIO_ODR_ODR12                       ((uint16_t)0x1000)            /*!< Port output data, bit 12 */
  2456. #define GPIO_ODR_ODR13                       ((uint16_t)0x2000)            /*!< Port output data, bit 13 */
  2457. #define GPIO_ODR_ODR14                       ((uint16_t)0x4000)            /*!< Port output data, bit 14 */
  2458. #define GPIO_ODR_ODR15                       ((uint16_t)0x8000)            /*!< Port output data, bit 15 */
  2459.  
  2460. /******************  Bit definition for GPIO_BSRR register  *******************/
  2461. #define GPIO_BSRR_BS0                        ((uint32_t)0x00000001)        /*!< Port x Set bit 0 */
  2462. #define GPIO_BSRR_BS1                        ((uint32_t)0x00000002)        /*!< Port x Set bit 1 */
  2463. #define GPIO_BSRR_BS2                        ((uint32_t)0x00000004)        /*!< Port x Set bit 2 */
  2464. #define GPIO_BSRR_BS3                        ((uint32_t)0x00000008)        /*!< Port x Set bit 3 */
  2465. #define GPIO_BSRR_BS4                        ((uint32_t)0x00000010)        /*!< Port x Set bit 4 */
  2466. #define GPIO_BSRR_BS5                        ((uint32_t)0x00000020)        /*!< Port x Set bit 5 */
  2467. #define GPIO_BSRR_BS6                        ((uint32_t)0x00000040)        /*!< Port x Set bit 6 */
  2468. #define GPIO_BSRR_BS7                        ((uint32_t)0x00000080)        /*!< Port x Set bit 7 */
  2469. #define GPIO_BSRR_BS8                        ((uint32_t)0x00000100)        /*!< Port x Set bit 8 */
  2470. #define GPIO_BSRR_BS9                        ((uint32_t)0x00000200)        /*!< Port x Set bit 9 */
  2471. #define GPIO_BSRR_BS10                       ((uint32_t)0x00000400)        /*!< Port x Set bit 10 */
  2472. #define GPIO_BSRR_BS11                       ((uint32_t)0x00000800)        /*!< Port x Set bit 11 */
  2473. #define GPIO_BSRR_BS12                       ((uint32_t)0x00001000)        /*!< Port x Set bit 12 */
  2474. #define GPIO_BSRR_BS13                       ((uint32_t)0x00002000)        /*!< Port x Set bit 13 */
  2475. #define GPIO_BSRR_BS14                       ((uint32_t)0x00004000)        /*!< Port x Set bit 14 */
  2476. #define GPIO_BSRR_BS15                       ((uint32_t)0x00008000)        /*!< Port x Set bit 15 */
  2477.  
  2478. #define GPIO_BSRR_BR0                        ((uint32_t)0x00010000)        /*!< Port x Reset bit 0 */
  2479. #define GPIO_BSRR_BR1                        ((uint32_t)0x00020000)        /*!< Port x Reset bit 1 */
  2480. #define GPIO_BSRR_BR2                        ((uint32_t)0x00040000)        /*!< Port x Reset bit 2 */
  2481. #define GPIO_BSRR_BR3                        ((uint32_t)0x00080000)        /*!< Port x Reset bit 3 */
  2482. #define GPIO_BSRR_BR4                        ((uint32_t)0x00100000)        /*!< Port x Reset bit 4 */
  2483. #define GPIO_BSRR_BR5                        ((uint32_t)0x00200000)        /*!< Port x Reset bit 5 */
  2484. #define GPIO_BSRR_BR6                        ((uint32_t)0x00400000)        /*!< Port x Reset bit 6 */
  2485. #define GPIO_BSRR_BR7                        ((uint32_t)0x00800000)        /*!< Port x Reset bit 7 */
  2486. #define GPIO_BSRR_BR8                        ((uint32_t)0x01000000)        /*!< Port x Reset bit 8 */
  2487. #define GPIO_BSRR_BR9                        ((uint32_t)0x02000000)        /*!< Port x Reset bit 9 */
  2488. #define GPIO_BSRR_BR10                       ((uint32_t)0x04000000)        /*!< Port x Reset bit 10 */
  2489. #define GPIO_BSRR_BR11                       ((uint32_t)0x08000000)        /*!< Port x Reset bit 11 */
  2490. #define GPIO_BSRR_BR12                       ((uint32_t)0x10000000)        /*!< Port x Reset bit 12 */
  2491. #define GPIO_BSRR_BR13                       ((uint32_t)0x20000000)        /*!< Port x Reset bit 13 */
  2492. #define GPIO_BSRR_BR14                       ((uint32_t)0x40000000)        /*!< Port x Reset bit 14 */
  2493. #define GPIO_BSRR_BR15                       ((uint32_t)0x80000000)        /*!< Port x Reset bit 15 */
  2494.  
  2495. /*******************  Bit definition for GPIO_BRR register  *******************/
  2496. #define GPIO_BRR_BR0                         ((uint16_t)0x0001)            /*!< Port x Reset bit 0 */
  2497. #define GPIO_BRR_BR1                         ((uint16_t)0x0002)            /*!< Port x Reset bit 1 */
  2498. #define GPIO_BRR_BR2                         ((uint16_t)0x0004)            /*!< Port x Reset bit 2 */
  2499. #define GPIO_BRR_BR3                         ((uint16_t)0x0008)            /*!< Port x Reset bit 3 */
  2500. #define GPIO_BRR_BR4                         ((uint16_t)0x0010)            /*!< Port x Reset bit 4 */
  2501. #define GPIO_BRR_BR5                         ((uint16_t)0x0020)            /*!< Port x Reset bit 5 */
  2502. #define GPIO_BRR_BR6                         ((uint16_t)0x0040)            /*!< Port x Reset bit 6 */
  2503. #define GPIO_BRR_BR7                         ((uint16_t)0x0080)            /*!< Port x Reset bit 7 */
  2504. #define GPIO_BRR_BR8                         ((uint16_t)0x0100)            /*!< Port x Reset bit 8 */
  2505. #define GPIO_BRR_BR9                         ((uint16_t)0x0200)            /*!< Port x Reset bit 9 */
  2506. #define GPIO_BRR_BR10                        ((uint16_t)0x0400)            /*!< Port x Reset bit 10 */
  2507. #define GPIO_BRR_BR11                        ((uint16_t)0x0800)            /*!< Port x Reset bit 11 */
  2508. #define GPIO_BRR_BR12                        ((uint16_t)0x1000)            /*!< Port x Reset bit 12 */
  2509. #define GPIO_BRR_BR13                        ((uint16_t)0x2000)            /*!< Port x Reset bit 13 */
  2510. #define GPIO_BRR_BR14                        ((uint16_t)0x4000)            /*!< Port x Reset bit 14 */
  2511. #define GPIO_BRR_BR15                        ((uint16_t)0x8000)            /*!< Port x Reset bit 15 */
  2512.  
  2513. /******************  Bit definition for GPIO_LCKR register  *******************/
  2514. #define GPIO_LCKR_LCK0                       ((uint32_t)0x00000001)        /*!< Port x Lock bit 0 */
  2515. #define GPIO_LCKR_LCK1                       ((uint32_t)0x00000002)        /*!< Port x Lock bit 1 */
  2516. #define GPIO_LCKR_LCK2                       ((uint32_t)0x00000004)        /*!< Port x Lock bit 2 */
  2517. #define GPIO_LCKR_LCK3                       ((uint32_t)0x00000008)        /*!< Port x Lock bit 3 */
  2518. #define GPIO_LCKR_LCK4                       ((uint32_t)0x00000010)        /*!< Port x Lock bit 4 */
  2519. #define GPIO_LCKR_LCK5                       ((uint32_t)0x00000020)        /*!< Port x Lock bit 5 */
  2520. #define GPIO_LCKR_LCK6                       ((uint32_t)0x00000040)        /*!< Port x Lock bit 6 */
  2521. #define GPIO_LCKR_LCK7                       ((uint32_t)0x00000080)        /*!< Port x Lock bit 7 */
  2522. #define GPIO_LCKR_LCK8                       ((uint32_t)0x00000100)        /*!< Port x Lock bit 8 */
  2523. #define GPIO_LCKR_LCK9                       ((uint32_t)0x00000200)        /*!< Port x Lock bit 9 */
  2524. #define GPIO_LCKR_LCK10                      ((uint32_t)0x00000400)        /*!< Port x Lock bit 10 */
  2525. #define GPIO_LCKR_LCK11                      ((uint32_t)0x00000800)        /*!< Port x Lock bit 11 */
  2526. #define GPIO_LCKR_LCK12                      ((uint32_t)0x00001000)        /*!< Port x Lock bit 12 */
  2527. #define GPIO_LCKR_LCK13                      ((uint32_t)0x00002000)        /*!< Port x Lock bit 13 */
  2528. #define GPIO_LCKR_LCK14                      ((uint32_t)0x00004000)        /*!< Port x Lock bit 14 */
  2529. #define GPIO_LCKR_LCK15                      ((uint32_t)0x00008000)        /*!< Port x Lock bit 15 */
  2530. #define GPIO_LCKR_LCKK                       ((uint32_t)0x00010000)        /*!< Lock key */
  2531.  
  2532. /*----------------------------------------------------------------------------*/
  2533.  
  2534. /******************  Bit definition for AFIO_EVCR register  *******************/
  2535. #define AFIO_EVCR_PIN                        ((uint8_t)0x0F)               /*!< PIN[3:0] bits (Pin selection) */
  2536. #define AFIO_EVCR_PIN_0                      ((uint8_t)0x01)               /*!< Bit 0 */
  2537. #define AFIO_EVCR_PIN_1                      ((uint8_t)0x02)               /*!< Bit 1 */
  2538. #define AFIO_EVCR_PIN_2                      ((uint8_t)0x04)               /*!< Bit 2 */
  2539. #define AFIO_EVCR_PIN_3                      ((uint8_t)0x08)               /*!< Bit 3 */
  2540.  
  2541. /*!< PIN configuration */
  2542. #define AFIO_EVCR_PIN_PX0                    ((uint8_t)0x00)               /*!< Pin 0 selected */
  2543. #define AFIO_EVCR_PIN_PX1                    ((uint8_t)0x01)               /*!< Pin 1 selected */
  2544. #define AFIO_EVCR_PIN_PX2                    ((uint8_t)0x02)               /*!< Pin 2 selected */
  2545. #define AFIO_EVCR_PIN_PX3                    ((uint8_t)0x03)               /*!< Pin 3 selected */
  2546. #define AFIO_EVCR_PIN_PX4                    ((uint8_t)0x04)               /*!< Pin 4 selected */
  2547. #define AFIO_EVCR_PIN_PX5                    ((uint8_t)0x05)               /*!< Pin 5 selected */
  2548. #define AFIO_EVCR_PIN_PX6                    ((uint8_t)0x06)               /*!< Pin 6 selected */
  2549. #define AFIO_EVCR_PIN_PX7                    ((uint8_t)0x07)               /*!< Pin 7 selected */
  2550. #define AFIO_EVCR_PIN_PX8                    ((uint8_t)0x08)               /*!< Pin 8 selected */
  2551. #define AFIO_EVCR_PIN_PX9                    ((uint8_t)0x09)               /*!< Pin 9 selected */
  2552. #define AFIO_EVCR_PIN_PX10                   ((uint8_t)0x0A)               /*!< Pin 10 selected */
  2553. #define AFIO_EVCR_PIN_PX11                   ((uint8_t)0x0B)               /*!< Pin 11 selected */
  2554. #define AFIO_EVCR_PIN_PX12                   ((uint8_t)0x0C)               /*!< Pin 12 selected */
  2555. #define AFIO_EVCR_PIN_PX13                   ((uint8_t)0x0D)               /*!< Pin 13 selected */
  2556. #define AFIO_EVCR_PIN_PX14                   ((uint8_t)0x0E)               /*!< Pin 14 selected */
  2557. #define AFIO_EVCR_PIN_PX15                   ((uint8_t)0x0F)               /*!< Pin 15 selected */
  2558.  
  2559. #define AFIO_EVCR_PORT                       ((uint8_t)0x70)               /*!< PORT[2:0] bits (Port selection) */
  2560. #define AFIO_EVCR_PORT_0                     ((uint8_t)0x10)               /*!< Bit 0 */
  2561. #define AFIO_EVCR_PORT_1                     ((uint8_t)0x20)               /*!< Bit 1 */
  2562. #define AFIO_EVCR_PORT_2                     ((uint8_t)0x40)               /*!< Bit 2 */
  2563.  
  2564. /*!< PORT configuration */
  2565. #define AFIO_EVCR_PORT_PA                    ((uint8_t)0x00)               /*!< Port A selected */
  2566. #define AFIO_EVCR_PORT_PB                    ((uint8_t)0x10)               /*!< Port B selected */
  2567. #define AFIO_EVCR_PORT_PC                    ((uint8_t)0x20)               /*!< Port C selected */
  2568. #define AFIO_EVCR_PORT_PD                    ((uint8_t)0x30)               /*!< Port D selected */
  2569. #define AFIO_EVCR_PORT_PE                    ((uint8_t)0x40)               /*!< Port E selected */
  2570.  
  2571. #define AFIO_EVCR_EVOE                       ((uint8_t)0x80)               /*!< Event Output Enable */
  2572.  
  2573. /******************  Bit definition for AFIO_MAPR register  *******************/
  2574. #define AFIO_MAPR_SPI1_REMAP                 ((uint32_t)0x00000001)        /*!< SPI1 remapping */
  2575. #define AFIO_MAPR_I2C1_REMAP                 ((uint32_t)0x00000002)        /*!< I2C1 remapping */
  2576. #define AFIO_MAPR_USART1_REMAP               ((uint32_t)0x00000004)        /*!< USART1 remapping */
  2577. #define AFIO_MAPR_USART2_REMAP               ((uint32_t)0x00000008)        /*!< USART2 remapping */
  2578.  
  2579. #define AFIO_MAPR_USART3_REMAP               ((uint32_t)0x00000030)        /*!< USART3_REMAP[1:0] bits (USART3 remapping) */
  2580. #define AFIO_MAPR_USART3_REMAP_0             ((uint32_t)0x00000010)        /*!< Bit 0 */
  2581. #define AFIO_MAPR_USART3_REMAP_1             ((uint32_t)0x00000020)        /*!< Bit 1 */
  2582.  
  2583. /* USART3_REMAP configuration */
  2584. #define AFIO_MAPR_USART3_REMAP_NOREMAP       ((uint32_t)0x00000000)        /*!< No remap (TX/PB10, RX/PB11, CK/PB12, CTS/PB13, RTS/PB14) */
  2585. #define AFIO_MAPR_USART3_REMAP_PARTIALREMAP  ((uint32_t)0x00000010)        /*!< Partial remap (TX/PC10, RX/PC11, CK/PC12, CTS/PB13, RTS/PB14) */
  2586. #define AFIO_MAPR_USART3_REMAP_FULLREMAP     ((uint32_t)0x00000030)        /*!< Full remap (TX/PD8, RX/PD9, CK/PD10, CTS/PD11, RTS/PD12) */
  2587.  
  2588. #define AFIO_MAPR_TIM1_REMAP                 ((uint32_t)0x000000C0)        /*!< TIM1_REMAP[1:0] bits (TIM1 remapping) */
  2589. #define AFIO_MAPR_TIM1_REMAP_0               ((uint32_t)0x00000040)        /*!< Bit 0 */
  2590. #define AFIO_MAPR_TIM1_REMAP_1               ((uint32_t)0x00000080)        /*!< Bit 1 */
  2591.  
  2592. /*!< TIM1_REMAP configuration */
  2593. #define AFIO_MAPR_TIM1_REMAP_NOREMAP         ((uint32_t)0x00000000)        /*!< No remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PB12, CH1N/PB13, CH2N/PB14, CH3N/PB15) */
  2594. #define AFIO_MAPR_TIM1_REMAP_PARTIALREMAP    ((uint32_t)0x00000040)        /*!< Partial remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PA6, CH1N/PA7, CH2N/PB0, CH3N/PB1) */
  2595. #define AFIO_MAPR_TIM1_REMAP_FULLREMAP       ((uint32_t)0x000000C0)        /*!< Full remap (ETR/PE7, CH1/PE9, CH2/PE11, CH3/PE13, CH4/PE14, BKIN/PE15, CH1N/PE8, CH2N/PE10, CH3N/PE12) */
  2596.  
  2597. #define AFIO_MAPR_TIM2_REMAP                 ((uint32_t)0x00000300)        /*!< TIM2_REMAP[1:0] bits (TIM2 remapping) */
  2598. #define AFIO_MAPR_TIM2_REMAP_0               ((uint32_t)0x00000100)        /*!< Bit 0 */
  2599. #define AFIO_MAPR_TIM2_REMAP_1               ((uint32_t)0x00000200)        /*!< Bit 1 */
  2600.  
  2601. /*!< TIM2_REMAP configuration */
  2602. #define AFIO_MAPR_TIM2_REMAP_NOREMAP         ((uint32_t)0x00000000)        /*!< No remap (CH1/ETR/PA0, CH2/PA1, CH3/PA2, CH4/PA3) */
  2603. #define AFIO_MAPR_TIM2_REMAP_PARTIALREMAP1   ((uint32_t)0x00000100)        /*!< Partial remap (CH1/ETR/PA15, CH2/PB3, CH3/PA2, CH4/PA3) */
  2604. #define AFIO_MAPR_TIM2_REMAP_PARTIALREMAP2   ((uint32_t)0x00000200)        /*!< Partial remap (CH1/ETR/PA0, CH2/PA1, CH3/PB10, CH4/PB11) */
  2605. #define AFIO_MAPR_TIM2_REMAP_FULLREMAP       ((uint32_t)0x00000300)        /*!< Full remap (CH1/ETR/PA15, CH2/PB3, CH3/PB10, CH4/PB11) */
  2606.  
  2607. #define AFIO_MAPR_TIM3_REMAP                 ((uint32_t)0x00000C00)        /*!< TIM3_REMAP[1:0] bits (TIM3 remapping) */
  2608. #define AFIO_MAPR_TIM3_REMAP_0               ((uint32_t)0x00000400)        /*!< Bit 0 */
  2609. #define AFIO_MAPR_TIM3_REMAP_1               ((uint32_t)0x00000800)        /*!< Bit 1 */
  2610.  
  2611. /*!< TIM3_REMAP configuration */
  2612. #define AFIO_MAPR_TIM3_REMAP_NOREMAP         ((uint32_t)0x00000000)        /*!< No remap (CH1/PA6, CH2/PA7, CH3/PB0, CH4/PB1) */
  2613. #define AFIO_MAPR_TIM3_REMAP_PARTIALREMAP    ((uint32_t)0x00000800)        /*!< Partial remap (CH1/PB4, CH2/PB5, CH3/PB0, CH4/PB1) */
  2614. #define AFIO_MAPR_TIM3_REMAP_FULLREMAP       ((uint32_t)0x00000C00)        /*!< Full remap (CH1/PC6, CH2/PC7, CH3/PC8, CH4/PC9) */
  2615.  
  2616. #define AFIO_MAPR_TIM4_REMAP                 ((uint32_t)0x00001000)        /*!< TIM4_REMAP bit (TIM4 remapping) */
  2617.  
  2618. #define AFIO_MAPR_CAN_REMAP                  ((uint32_t)0x00006000)        /*!< CAN_REMAP[1:0] bits (CAN Alternate function remapping) */
  2619. #define AFIO_MAPR_CAN_REMAP_0                ((uint32_t)0x00002000)        /*!< Bit 0 */
  2620. #define AFIO_MAPR_CAN_REMAP_1                ((uint32_t)0x00004000)        /*!< Bit 1 */
  2621.  
  2622. /*!< CAN_REMAP configuration */
  2623. #define AFIO_MAPR_CAN_REMAP_REMAP1           ((uint32_t)0x00000000)        /*!< CANRX mapped to PA11, CANTX mapped to PA12 */
  2624. #define AFIO_MAPR_CAN_REMAP_REMAP2           ((uint32_t)0x00004000)        /*!< CANRX mapped to PB8, CANTX mapped to PB9 */
  2625. #define AFIO_MAPR_CAN_REMAP_REMAP3           ((uint32_t)0x00006000)        /*!< CANRX mapped to PD0, CANTX mapped to PD1 */
  2626.  
  2627. #define AFIO_MAPR_PD01_REMAP                 ((uint32_t)0x00008000)        /*!< Port D0/Port D1 mapping on OSC_IN/OSC_OUT */
  2628. #define AFIO_MAPR_TIM5CH4_IREMAP             ((uint32_t)0x00010000)        /*!< TIM5 Channel4 Internal Remap */
  2629. #define AFIO_MAPR_ADC1_ETRGINJ_REMAP         ((uint32_t)0x00020000)        /*!< ADC 1 External Trigger Injected Conversion remapping */
  2630. #define AFIO_MAPR_ADC1_ETRGREG_REMAP         ((uint32_t)0x00040000)        /*!< ADC 1 External Trigger Regular Conversion remapping */
  2631. #define AFIO_MAPR_ADC2_ETRGINJ_REMAP         ((uint32_t)0x00080000)        /*!< ADC 2 External Trigger Injected Conversion remapping */
  2632. #define AFIO_MAPR_ADC2_ETRGREG_REMAP         ((uint32_t)0x00100000)        /*!< ADC 2 External Trigger Regular Conversion remapping */
  2633.  
  2634. /*!< SWJ_CFG configuration */
  2635. #define AFIO_MAPR_SWJ_CFG                    ((uint32_t)0x07000000)        /*!< SWJ_CFG[2:0] bits (Serial Wire JTAG configuration) */
  2636. #define AFIO_MAPR_SWJ_CFG_0                  ((uint32_t)0x01000000)        /*!< Bit 0 */
  2637. #define AFIO_MAPR_SWJ_CFG_1                  ((uint32_t)0x02000000)        /*!< Bit 1 */
  2638. #define AFIO_MAPR_SWJ_CFG_2                  ((uint32_t)0x04000000)        /*!< Bit 2 */
  2639.  
  2640. #define AFIO_MAPR_SWJ_CFG_RESET              ((uint32_t)0x00000000)        /*!< Full SWJ (JTAG-DP + SW-DP) : Reset State */
  2641. #define AFIO_MAPR_SWJ_CFG_NOJNTRST           ((uint32_t)0x01000000)        /*!< Full SWJ (JTAG-DP + SW-DP) but without JNTRST */
  2642. #define AFIO_MAPR_SWJ_CFG_JTAGDISABLE        ((uint32_t)0x02000000)        /*!< JTAG-DP Disabled and SW-DP Enabled */
  2643. #define AFIO_MAPR_SWJ_CFG_DISABLE            ((uint32_t)0x04000000)        /*!< JTAG-DP Disabled and SW-DP Disabled */
  2644.  
  2645. #ifdef STM32F10X_CL
  2646. /*!< ETH_REMAP configuration */
  2647.  #define AFIO_MAPR_ETH_REMAP                  ((uint32_t)0x00200000)        /*!< SPI3_REMAP bit (Ethernet MAC I/O remapping) */
  2648.  
  2649. /*!< CAN2_REMAP configuration */
  2650.  #define AFIO_MAPR_CAN2_REMAP                 ((uint32_t)0x00400000)        /*!< CAN2_REMAP bit (CAN2 I/O remapping) */
  2651.  
  2652. /*!< MII_RMII_SEL configuration */
  2653.  #define AFIO_MAPR_MII_RMII_SEL               ((uint32_t)0x00800000)        /*!< MII_RMII_SEL bit (Ethernet MII or RMII selection) */
  2654.  
  2655. /*!< SPI3_REMAP configuration */
  2656.  #define AFIO_MAPR_SPI3_REMAP                 ((uint32_t)0x10000000)        /*!< SPI3_REMAP bit (SPI3 remapping) */
  2657.  
  2658. /*!< TIM2ITR1_IREMAP configuration */
  2659.  #define AFIO_MAPR_TIM2ITR1_IREMAP            ((uint32_t)0x20000000)        /*!< TIM2ITR1_IREMAP bit (TIM2 internal trigger 1 remapping) */
  2660.  
  2661. /*!< PTP_PPS_REMAP configuration */
  2662.  #define AFIO_MAPR_PTP_PPS_REMAP              ((uint32_t)0x40000000)        /*!< PTP_PPS_REMAP bit (Ethernet PTP PPS remapping) */
  2663. #endif
  2664.  
  2665. /*****************  Bit definition for AFIO_EXTICR1 register  *****************/
  2666. #define AFIO_EXTICR1_EXTI0                   ((uint16_t)0x000F)            /*!< EXTI 0 configuration */
  2667. #define AFIO_EXTICR1_EXTI1                   ((uint16_t)0x00F0)            /*!< EXTI 1 configuration */
  2668. #define AFIO_EXTICR1_EXTI2                   ((uint16_t)0x0F00)            /*!< EXTI 2 configuration */
  2669. #define AFIO_EXTICR1_EXTI3                   ((uint16_t)0xF000)            /*!< EXTI 3 configuration */
  2670.  
  2671. /*!< EXTI0 configuration */
  2672. #define AFIO_EXTICR1_EXTI0_PA                ((uint16_t)0x0000)            /*!< PA[0] pin */
  2673. #define AFIO_EXTICR1_EXTI0_PB                ((uint16_t)0x0001)            /*!< PB[0] pin */
  2674. #define AFIO_EXTICR1_EXTI0_PC                ((uint16_t)0x0002)            /*!< PC[0] pin */
  2675. #define AFIO_EXTICR1_EXTI0_PD                ((uint16_t)0x0003)            /*!< PD[0] pin */
  2676. #define AFIO_EXTICR1_EXTI0_PE                ((uint16_t)0x0004)            /*!< PE[0] pin */
  2677. #define AFIO_EXTICR1_EXTI0_PF                ((uint16_t)0x0005)            /*!< PF[0] pin */
  2678. #define AFIO_EXTICR1_EXTI0_PG                ((uint16_t)0x0006)            /*!< PG[0] pin */
  2679.  
  2680. /*!< EXTI1 configuration */
  2681. #define AFIO_EXTICR1_EXTI1_PA                ((uint16_t)0x0000)            /*!< PA[1] pin */
  2682. #define AFIO_EXTICR1_EXTI1_PB                ((uint16_t)0x0010)            /*!< PB[1] pin */
  2683. #define AFIO_EXTICR1_EXTI1_PC                ((uint16_t)0x0020)            /*!< PC[1] pin */
  2684. #define AFIO_EXTICR1_EXTI1_PD                ((uint16_t)0x0030)            /*!< PD[1] pin */
  2685. #define AFIO_EXTICR1_EXTI1_PE                ((uint16_t)0x0040)            /*!< PE[1] pin */
  2686. #define AFIO_EXTICR1_EXTI1_PF                ((uint16_t)0x0050)            /*!< PF[1] pin */
  2687. #define AFIO_EXTICR1_EXTI1_PG                ((uint16_t)0x0060)            /*!< PG[1] pin */
  2688.  
  2689. /*!< EXTI2 configuration */  
  2690. #define AFIO_EXTICR1_EXTI2_PA                ((uint16_t)0x0000)            /*!< PA[2] pin */
  2691. #define AFIO_EXTICR1_EXTI2_PB                ((uint16_t)0x0100)            /*!< PB[2] pin */
  2692. #define AFIO_EXTICR1_EXTI2_PC                ((uint16_t)0x0200)            /*!< PC[2] pin */
  2693. #define AFIO_EXTICR1_EXTI2_PD                ((uint16_t)0x0300)            /*!< PD[2] pin */
  2694. #define AFIO_EXTICR1_EXTI2_PE                ((uint16_t)0x0400)            /*!< PE[2] pin */
  2695. #define AFIO_EXTICR1_EXTI2_PF                ((uint16_t)0x0500)            /*!< PF[2] pin */
  2696. #define AFIO_EXTICR1_EXTI2_PG                ((uint16_t)0x0600)            /*!< PG[2] pin */
  2697.  
  2698. /*!< EXTI3 configuration */
  2699. #define AFIO_EXTICR1_EXTI3_PA                ((uint16_t)0x0000)            /*!< PA[3] pin */
  2700. #define AFIO_EXTICR1_EXTI3_PB                ((uint16_t)0x1000)            /*!< PB[3] pin */
  2701. #define AFIO_EXTICR1_EXTI3_PC                ((uint16_t)0x2000)            /*!< PC[3] pin */
  2702. #define AFIO_EXTICR1_EXTI3_PD                ((uint16_t)0x3000)            /*!< PD[3] pin */
  2703. #define AFIO_EXTICR1_EXTI3_PE                ((uint16_t)0x4000)            /*!< PE[3] pin */
  2704. #define AFIO_EXTICR1_EXTI3_PF                ((uint16_t)0x5000)            /*!< PF[3] pin */
  2705. #define AFIO_EXTICR1_EXTI3_PG                ((uint16_t)0x6000)            /*!< PG[3] pin */
  2706.  
  2707. /*****************  Bit definition for AFIO_EXTICR2 register  *****************/
  2708. #define AFIO_EXTICR2_EXTI4                   ((uint16_t)0x000F)            /*!< EXTI 4 configuration */
  2709. #define AFIO_EXTICR2_EXTI5                   ((uint16_t)0x00F0)            /*!< EXTI 5 configuration */
  2710. #define AFIO_EXTICR2_EXTI6                   ((uint16_t)0x0F00)            /*!< EXTI 6 configuration */
  2711. #define AFIO_EXTICR2_EXTI7                   ((uint16_t)0xF000)            /*!< EXTI 7 configuration */
  2712.  
  2713. /*!< EXTI4 configuration */
  2714. #define AFIO_EXTICR2_EXTI4_PA                ((uint16_t)0x0000)            /*!< PA[4] pin */
  2715. #define AFIO_EXTICR2_EXTI4_PB                ((uint16_t)0x0001)            /*!< PB[4] pin */
  2716. #define AFIO_EXTICR2_EXTI4_PC                ((uint16_t)0x0002)            /*!< PC[4] pin */
  2717. #define AFIO_EXTICR2_EXTI4_PD                ((uint16_t)0x0003)            /*!< PD[4] pin */
  2718. #define AFIO_EXTICR2_EXTI4_PE                ((uint16_t)0x0004)            /*!< PE[4] pin */
  2719. #define AFIO_EXTICR2_EXTI4_PF                ((uint16_t)0x0005)            /*!< PF[4] pin */
  2720. #define AFIO_EXTICR2_EXTI4_PG                ((uint16_t)0x0006)            /*!< PG[4] pin */
  2721.  
  2722. /* EXTI5 configuration */
  2723. #define AFIO_EXTICR2_EXTI5_PA                ((uint16_t)0x0000)            /*!< PA[5] pin */
  2724. #define AFIO_EXTICR2_EXTI5_PB                ((uint16_t)0x0010)            /*!< PB[5] pin */
  2725. #define AFIO_EXTICR2_EXTI5_PC                ((uint16_t)0x0020)            /*!< PC[5] pin */
  2726. #define AFIO_EXTICR2_EXTI5_PD                ((uint16_t)0x0030)            /*!< PD[5] pin */
  2727. #define AFIO_EXTICR2_EXTI5_PE                ((uint16_t)0x0040)            /*!< PE[5] pin */
  2728. #define AFIO_EXTICR2_EXTI5_PF                ((uint16_t)0x0050)            /*!< PF[5] pin */
  2729. #define AFIO_EXTICR2_EXTI5_PG                ((uint16_t)0x0060)            /*!< PG[5] pin */
  2730.  
  2731. /*!< EXTI6 configuration */  
  2732. #define AFIO_EXTICR2_EXTI6_PA                ((uint16_t)0x0000)            /*!< PA[6] pin */
  2733. #define AFIO_EXTICR2_EXTI6_PB                ((uint16_t)0x0100)            /*!< PB[6] pin */
  2734. #define AFIO_EXTICR2_EXTI6_PC                ((uint16_t)0x0200)            /*!< PC[6] pin */
  2735. #define AFIO_EXTICR2_EXTI6_PD                ((uint16_t)0x0300)            /*!< PD[6] pin */
  2736. #define AFIO_EXTICR2_EXTI6_PE                ((uint16_t)0x0400)            /*!< PE[6] pin */
  2737. #define AFIO_EXTICR2_EXTI6_PF                ((uint16_t)0x0500)            /*!< PF[6] pin */
  2738. #define AFIO_EXTICR2_EXTI6_PG                ((uint16_t)0x0600)            /*!< PG[6] pin */
  2739.  
  2740. /*!< EXTI7 configuration */
  2741. #define AFIO_EXTICR2_EXTI7_PA                ((uint16_t)0x0000)            /*!< PA[7] pin */
  2742. #define AFIO_EXTICR2_EXTI7_PB                ((uint16_t)0x1000)            /*!< PB[7] pin */
  2743. #define AFIO_EXTICR2_EXTI7_PC                ((uint16_t)0x2000)            /*!< PC[7] pin */
  2744. #define AFIO_EXTICR2_EXTI7_PD                ((uint16_t)0x3000)            /*!< PD[7] pin */
  2745. #define AFIO_EXTICR2_EXTI7_PE                ((uint16_t)0x4000)            /*!< PE[7] pin */
  2746. #define AFIO_EXTICR2_EXTI7_PF                ((uint16_t)0x5000)            /*!< PF[7] pin */
  2747. #define AFIO_EXTICR2_EXTI7_PG                ((uint16_t)0x6000)            /*!< PG[7] pin */
  2748.  
  2749. /*****************  Bit definition for AFIO_EXTICR3 register  *****************/
  2750. #define AFIO_EXTICR3_EXTI8                   ((uint16_t)0x000F)            /*!< EXTI 8 configuration */
  2751. #define AFIO_EXTICR3_EXTI9                   ((uint16_t)0x00F0)            /*!< EXTI 9 configuration */
  2752. #define AFIO_EXTICR3_EXTI10                  ((uint16_t)0x0F00)            /*!< EXTI 10 configuration */
  2753. #define AFIO_EXTICR3_EXTI11                  ((uint16_t)0xF000)            /*!< EXTI 11 configuration */
  2754.  
  2755. /*!< EXTI8 configuration */
  2756. #define AFIO_EXTICR3_EXTI8_PA                ((uint16_t)0x0000)            /*!< PA[8] pin */
  2757. #define AFIO_EXTICR3_EXTI8_PB                ((uint16_t)0x0001)            /*!< PB[8] pin */
  2758. #define AFIO_EXTICR3_EXTI8_PC                ((uint16_t)0x0002)            /*!< PC[8] pin */
  2759. #define AFIO_EXTICR3_EXTI8_PD                ((uint16_t)0x0003)            /*!< PD[8] pin */
  2760. #define AFIO_EXTICR3_EXTI8_PE                ((uint16_t)0x0004)            /*!< PE[8] pin */
  2761. #define AFIO_EXTICR3_EXTI8_PF                ((uint16_t)0x0005)            /*!< PF[8] pin */
  2762. #define AFIO_EXTICR3_EXTI8_PG                ((uint16_t)0x0006)            /*!< PG[8] pin */
  2763.  
  2764. /*!< EXTI9 configuration */
  2765. #define AFIO_EXTICR3_EXTI9_PA                ((uint16_t)0x0000)            /*!< PA[9] pin */
  2766. #define AFIO_EXTICR3_EXTI9_PB                ((uint16_t)0x0010)            /*!< PB[9] pin */
  2767. #define AFIO_EXTICR3_EXTI9_PC                ((uint16_t)0x0020)            /*!< PC[9] pin */
  2768. #define AFIO_EXTICR3_EXTI9_PD                ((uint16_t)0x0030)            /*!< PD[9] pin */
  2769. #define AFIO_EXTICR3_EXTI9_PE                ((uint16_t)0x0040)            /*!< PE[9] pin */
  2770. #define AFIO_EXTICR3_EXTI9_PF                ((uint16_t)0x0050)            /*!< PF[9] pin */
  2771. #define AFIO_EXTICR3_EXTI9_PG                ((uint16_t)0x0060)            /*!< PG[9] pin */
  2772.  
  2773. /*!< EXTI10 configuration */  
  2774. #define AFIO_EXTICR3_EXTI10_PA               ((uint16_t)0x0000)            /*!< PA[10] pin */
  2775. #define AFIO_EXTICR3_EXTI10_PB               ((uint16_t)0x0100)            /*!< PB[10] pin */
  2776. #define AFIO_EXTICR3_EXTI10_PC               ((uint16_t)0x0200)            /*!< PC[10] pin */
  2777. #define AFIO_EXTICR3_EXTI10_PD               ((uint16_t)0x0300)            /*!< PD[10] pin */
  2778. #define AFIO_EXTICR3_EXTI10_PE               ((uint16_t)0x0400)            /*!< PE[10] pin */
  2779. #define AFIO_EXTICR3_EXTI10_PF               ((uint16_t)0x0500)            /*!< PF[10] pin */
  2780. #define AFIO_EXTICR3_EXTI10_PG               ((uint16_t)0x0600)            /*!< PG[10] pin */
  2781.  
  2782. /*!< EXTI11 configuration */
  2783. #define AFIO_EXTICR3_EXTI11_PA               ((uint16_t)0x0000)            /*!< PA[11] pin */
  2784. #define AFIO_EXTICR3_EXTI11_PB               ((uint16_t)0x1000)            /*!< PB[11] pin */
  2785. #define AFIO_EXTICR3_EXTI11_PC               ((uint16_t)0x2000)            /*!< PC[11] pin */
  2786. #define AFIO_EXTICR3_EXTI11_PD               ((uint16_t)0x3000)            /*!< PD[11] pin */
  2787. #define AFIO_EXTICR3_EXTI11_PE               ((uint16_t)0x4000)            /*!< PE[11] pin */
  2788. #define AFIO_EXTICR3_EXTI11_PF               ((uint16_t)0x5000)            /*!< PF[11] pin */
  2789. #define AFIO_EXTICR3_EXTI11_PG               ((uint16_t)0x6000)            /*!< PG[11] pin */
  2790.  
  2791. /*****************  Bit definition for AFIO_EXTICR4 register  *****************/
  2792. #define AFIO_EXTICR4_EXTI12                  ((uint16_t)0x000F)            /*!< EXTI 12 configuration */
  2793. #define AFIO_EXTICR4_EXTI13                  ((uint16_t)0x00F0)            /*!< EXTI 13 configuration */
  2794. #define AFIO_EXTICR4_EXTI14                  ((uint16_t)0x0F00)            /*!< EXTI 14 configuration */
  2795. #define AFIO_EXTICR4_EXTI15                  ((uint16_t)0xF000)            /*!< EXTI 15 configuration */
  2796.  
  2797. /* EXTI12 configuration */
  2798. #define AFIO_EXTICR4_EXTI12_PA               ((uint16_t)0x0000)            /*!< PA[12] pin */
  2799. #define AFIO_EXTICR4_EXTI12_PB               ((uint16_t)0x0001)            /*!< PB[12] pin */
  2800. #define AFIO_EXTICR4_EXTI12_PC               ((uint16_t)0x0002)            /*!< PC[12] pin */
  2801. #define AFIO_EXTICR4_EXTI12_PD               ((uint16_t)0x0003)            /*!< PD[12] pin */
  2802. #define AFIO_EXTICR4_EXTI12_PE               ((uint16_t)0x0004)            /*!< PE[12] pin */
  2803. #define AFIO_EXTICR4_EXTI12_PF               ((uint16_t)0x0005)            /*!< PF[12] pin */
  2804. #define AFIO_EXTICR4_EXTI12_PG               ((uint16_t)0x0006)            /*!< PG[12] pin */
  2805.  
  2806. /* EXTI13 configuration */
  2807. #define AFIO_EXTICR4_EXTI13_PA               ((uint16_t)0x0000)            /*!< PA[13] pin */
  2808. #define AFIO_EXTICR4_EXTI13_PB               ((uint16_t)0x0010)            /*!< PB[13] pin */
  2809. #define AFIO_EXTICR4_EXTI13_PC               ((uint16_t)0x0020)            /*!< PC[13] pin */
  2810. #define AFIO_EXTICR4_EXTI13_PD               ((uint16_t)0x0030)            /*!< PD[13] pin */
  2811. #define AFIO_EXTICR4_EXTI13_PE               ((uint16_t)0x0040)            /*!< PE[13] pin */
  2812. #define AFIO_EXTICR4_EXTI13_PF               ((uint16_t)0x0050)            /*!< PF[13] pin */
  2813. #define AFIO_EXTICR4_EXTI13_PG               ((uint16_t)0x0060)            /*!< PG[13] pin */
  2814.  
  2815. /*!< EXTI14 configuration */  
  2816. #define AFIO_EXTICR4_EXTI14_PA               ((uint16_t)0x0000)            /*!< PA[14] pin */
  2817. #define AFIO_EXTICR4_EXTI14_PB               ((uint16_t)0x0100)            /*!< PB[14] pin */
  2818. #define AFIO_EXTICR4_EXTI14_PC               ((uint16_t)0x0200)            /*!< PC[14] pin */
  2819. #define AFIO_EXTICR4_EXTI14_PD               ((uint16_t)0x0300)            /*!< PD[14] pin */
  2820. #define AFIO_EXTICR4_EXTI14_PE               ((uint16_t)0x0400)            /*!< PE[14] pin */
  2821. #define AFIO_EXTICR4_EXTI14_PF               ((uint16_t)0x0500)            /*!< PF[14] pin */
  2822. #define AFIO_EXTICR4_EXTI14_PG               ((uint16_t)0x0600)            /*!< PG[14] pin */
  2823.  
  2824. /*!< EXTI15 configuration */
  2825. #define AFIO_EXTICR4_EXTI15_PA               ((uint16_t)0x0000)            /*!< PA[15] pin */
  2826. #define AFIO_EXTICR4_EXTI15_PB               ((uint16_t)0x1000)            /*!< PB[15] pin */
  2827. #define AFIO_EXTICR4_EXTI15_PC               ((uint16_t)0x2000)            /*!< PC[15] pin */
  2828. #define AFIO_EXTICR4_EXTI15_PD               ((uint16_t)0x3000)            /*!< PD[15] pin */
  2829. #define AFIO_EXTICR4_EXTI15_PE               ((uint16_t)0x4000)            /*!< PE[15] pin */
  2830. #define AFIO_EXTICR4_EXTI15_PF               ((uint16_t)0x5000)            /*!< PF[15] pin */
  2831. #define AFIO_EXTICR4_EXTI15_PG               ((uint16_t)0x6000)            /*!< PG[15] pin */
  2832.  
  2833. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  2834. /******************  Bit definition for AFIO_MAPR2 register  ******************/
  2835. #define AFIO_MAPR2_TIM15_REMAP               ((uint32_t)0x00000001)        /*!< TIM15 remapping */
  2836. #define AFIO_MAPR2_TIM16_REMAP               ((uint32_t)0x00000002)        /*!< TIM16 remapping */
  2837. #define AFIO_MAPR2_TIM17_REMAP               ((uint32_t)0x00000004)        /*!< TIM17 remapping */
  2838. #define AFIO_MAPR2_CEC_REMAP                 ((uint32_t)0x00000008)        /*!< CEC remapping */
  2839. #define AFIO_MAPR2_TIM1_DMA_REMAP            ((uint32_t)0x00000010)        /*!< TIM1_DMA remapping */
  2840. #endif
  2841.  
  2842. #ifdef STM32F10X_HD_VL
  2843. #define AFIO_MAPR2_TIM13_REMAP               ((uint32_t)0x00000100)        /*!< TIM13 remapping */
  2844. #define AFIO_MAPR2_TIM14_REMAP               ((uint32_t)0x00000200)        /*!< TIM14 remapping */
  2845. #define AFIO_MAPR2_FSMC_NADV_REMAP           ((uint32_t)0x00000400)        /*!< FSMC NADV remapping */
  2846. #define AFIO_MAPR2_TIM67_DAC_DMA_REMAP       ((uint32_t)0x00000800)        /*!< TIM6/TIM7 and DAC DMA remapping */
  2847. #define AFIO_MAPR2_TIM12_REMAP               ((uint32_t)0x00001000)        /*!< TIM12 remapping */
  2848. #define AFIO_MAPR2_MISC_REMAP                ((uint32_t)0x00002000)        /*!< Miscellaneous remapping */
  2849. #endif
  2850.  
  2851. #ifdef STM32F10X_XL
  2852. /******************  Bit definition for AFIO_MAPR2 register  ******************/
  2853. #define AFIO_MAPR2_TIM9_REMAP                ((uint32_t)0x00000020)        /*!< TIM9 remapping */
  2854. #define AFIO_MAPR2_TIM10_REMAP               ((uint32_t)0x00000040)        /*!< TIM10 remapping */
  2855. #define AFIO_MAPR2_TIM11_REMAP               ((uint32_t)0x00000080)        /*!< TIM11 remapping */
  2856. #define AFIO_MAPR2_TIM13_REMAP               ((uint32_t)0x00000100)        /*!< TIM13 remapping */
  2857. #define AFIO_MAPR2_TIM14_REMAP               ((uint32_t)0x00000200)        /*!< TIM14 remapping */
  2858. #define AFIO_MAPR2_FSMC_NADV_REMAP           ((uint32_t)0x00000400)        /*!< FSMC NADV remapping */
  2859. #endif
  2860.  
  2861. /******************************************************************************/
  2862. /*                                                                            */
  2863. /*                               SystemTick                                   */
  2864. /*                                                                            */
  2865. /******************************************************************************/
  2866.  
  2867. /*****************  Bit definition for SysTick_CTRL register  *****************/
  2868. #define  SysTick_CTRL_ENABLE                 ((uint32_t)0x00000001)        /*!< Counter enable */
  2869. #define  SysTick_CTRL_TICKINT                ((uint32_t)0x00000002)        /*!< Counting down to 0 pends the SysTick handler */
  2870. #define  SysTick_CTRL_CLKSOURCE              ((uint32_t)0x00000004)        /*!< Clock source */
  2871. #define  SysTick_CTRL_COUNTFLAG              ((uint32_t)0x00010000)        /*!< Count Flag */
  2872.  
  2873. /*****************  Bit definition for SysTick_LOAD register  *****************/
  2874. #define  SysTick_LOAD_RELOAD                 ((uint32_t)0x00FFFFFF)        /*!< Value to load into the SysTick Current Value Register when the counter reaches 0 */
  2875.  
  2876. /*****************  Bit definition for SysTick_VAL register  ******************/
  2877. #define  SysTick_VAL_CURRENT                 ((uint32_t)0x00FFFFFF)        /*!< Current value at the time the register is accessed */
  2878.  
  2879. /*****************  Bit definition for SysTick_CALIB register  ****************/
  2880. #define  SysTick_CALIB_TENMS                 ((uint32_t)0x00FFFFFF)        /*!< Reload value to use for 10ms timing */
  2881. #define  SysTick_CALIB_SKEW                  ((uint32_t)0x40000000)        /*!< Calibration value is not exactly 10 ms */
  2882. #define  SysTick_CALIB_NOREF                 ((uint32_t)0x80000000)        /*!< The reference clock is not provided */
  2883.  
  2884. /******************************************************************************/
  2885. /*                                                                            */
  2886. /*                  Nested Vectored Interrupt Controller                      */
  2887. /*                                                                            */
  2888. /******************************************************************************/
  2889.  
  2890. /******************  Bit definition for NVIC_ISER register  *******************/
  2891. #define  NVIC_ISER_SETENA                    ((uint32_t)0xFFFFFFFF)        /*!< Interrupt set enable bits */
  2892. #define  NVIC_ISER_SETENA_0                  ((uint32_t)0x00000001)        /*!< bit 0 */
  2893. #define  NVIC_ISER_SETENA_1                  ((uint32_t)0x00000002)        /*!< bit 1 */
  2894. #define  NVIC_ISER_SETENA_2                  ((uint32_t)0x00000004)        /*!< bit 2 */
  2895. #define  NVIC_ISER_SETENA_3                  ((uint32_t)0x00000008)        /*!< bit 3 */
  2896. #define  NVIC_ISER_SETENA_4                  ((uint32_t)0x00000010)        /*!< bit 4 */
  2897. #define  NVIC_ISER_SETENA_5                  ((uint32_t)0x00000020)        /*!< bit 5 */
  2898. #define  NVIC_ISER_SETENA_6                  ((uint32_t)0x00000040)        /*!< bit 6 */
  2899. #define  NVIC_ISER_SETENA_7                  ((uint32_t)0x00000080)        /*!< bit 7 */
  2900. #define  NVIC_ISER_SETENA_8                  ((uint32_t)0x00000100)        /*!< bit 8 */
  2901. #define  NVIC_ISER_SETENA_9                  ((uint32_t)0x00000200)        /*!< bit 9 */
  2902. #define  NVIC_ISER_SETENA_10                 ((uint32_t)0x00000400)        /*!< bit 10 */
  2903. #define  NVIC_ISER_SETENA_11                 ((uint32_t)0x00000800)        /*!< bit 11 */
  2904. #define  NVIC_ISER_SETENA_12                 ((uint32_t)0x00001000)        /*!< bit 12 */
  2905. #define  NVIC_ISER_SETENA_13                 ((uint32_t)0x00002000)        /*!< bit 13 */
  2906. #define  NVIC_ISER_SETENA_14                 ((uint32_t)0x00004000)        /*!< bit 14 */
  2907. #define  NVIC_ISER_SETENA_15                 ((uint32_t)0x00008000)        /*!< bit 15 */
  2908. #define  NVIC_ISER_SETENA_16                 ((uint32_t)0x00010000)        /*!< bit 16 */
  2909. #define  NVIC_ISER_SETENA_17                 ((uint32_t)0x00020000)        /*!< bit 17 */
  2910. #define  NVIC_ISER_SETENA_18                 ((uint32_t)0x00040000)        /*!< bit 18 */
  2911. #define  NVIC_ISER_SETENA_19                 ((uint32_t)0x00080000)        /*!< bit 19 */
  2912. #define  NVIC_ISER_SETENA_20                 ((uint32_t)0x00100000)        /*!< bit 20 */
  2913. #define  NVIC_ISER_SETENA_21                 ((uint32_t)0x00200000)        /*!< bit 21 */
  2914. #define  NVIC_ISER_SETENA_22                 ((uint32_t)0x00400000)        /*!< bit 22 */
  2915. #define  NVIC_ISER_SETENA_23                 ((uint32_t)0x00800000)        /*!< bit 23 */
  2916. #define  NVIC_ISER_SETENA_24                 ((uint32_t)0x01000000)        /*!< bit 24 */
  2917. #define  NVIC_ISER_SETENA_25                 ((uint32_t)0x02000000)        /*!< bit 25 */
  2918. #define  NVIC_ISER_SETENA_26                 ((uint32_t)0x04000000)        /*!< bit 26 */
  2919. #define  NVIC_ISER_SETENA_27                 ((uint32_t)0x08000000)        /*!< bit 27 */
  2920. #define  NVIC_ISER_SETENA_28                 ((uint32_t)0x10000000)        /*!< bit 28 */
  2921. #define  NVIC_ISER_SETENA_29                 ((uint32_t)0x20000000)        /*!< bit 29 */
  2922. #define  NVIC_ISER_SETENA_30                 ((uint32_t)0x40000000)        /*!< bit 30 */
  2923. #define  NVIC_ISER_SETENA_31                 ((uint32_t)0x80000000)        /*!< bit 31 */
  2924.  
  2925. /******************  Bit definition for NVIC_ICER register  *******************/
  2926. #define  NVIC_ICER_CLRENA                   ((uint32_t)0xFFFFFFFF)        /*!< Interrupt clear-enable bits */
  2927. #define  NVIC_ICER_CLRENA_0                  ((uint32_t)0x00000001)        /*!< bit 0 */
  2928. #define  NVIC_ICER_CLRENA_1                  ((uint32_t)0x00000002)        /*!< bit 1 */
  2929. #define  NVIC_ICER_CLRENA_2                  ((uint32_t)0x00000004)        /*!< bit 2 */
  2930. #define  NVIC_ICER_CLRENA_3                  ((uint32_t)0x00000008)        /*!< bit 3 */
  2931. #define  NVIC_ICER_CLRENA_4                  ((uint32_t)0x00000010)        /*!< bit 4 */
  2932. #define  NVIC_ICER_CLRENA_5                  ((uint32_t)0x00000020)        /*!< bit 5 */
  2933. #define  NVIC_ICER_CLRENA_6                  ((uint32_t)0x00000040)        /*!< bit 6 */
  2934. #define  NVIC_ICER_CLRENA_7                  ((uint32_t)0x00000080)        /*!< bit 7 */
  2935. #define  NVIC_ICER_CLRENA_8                  ((uint32_t)0x00000100)        /*!< bit 8 */
  2936. #define  NVIC_ICER_CLRENA_9                  ((uint32_t)0x00000200)        /*!< bit 9 */
  2937. #define  NVIC_ICER_CLRENA_10                 ((uint32_t)0x00000400)        /*!< bit 10 */
  2938. #define  NVIC_ICER_CLRENA_11                 ((uint32_t)0x00000800)        /*!< bit 11 */
  2939. #define  NVIC_ICER_CLRENA_12                 ((uint32_t)0x00001000)        /*!< bit 12 */
  2940. #define  NVIC_ICER_CLRENA_13                 ((uint32_t)0x00002000)        /*!< bit 13 */
  2941. #define  NVIC_ICER_CLRENA_14                 ((uint32_t)0x00004000)        /*!< bit 14 */
  2942. #define  NVIC_ICER_CLRENA_15                 ((uint32_t)0x00008000)        /*!< bit 15 */
  2943. #define  NVIC_ICER_CLRENA_16                 ((uint32_t)0x00010000)        /*!< bit 16 */
  2944. #define  NVIC_ICER_CLRENA_17                 ((uint32_t)0x00020000)        /*!< bit 17 */
  2945. #define  NVIC_ICER_CLRENA_18                 ((uint32_t)0x00040000)        /*!< bit 18 */
  2946. #define  NVIC_ICER_CLRENA_19                 ((uint32_t)0x00080000)        /*!< bit 19 */
  2947. #define  NVIC_ICER_CLRENA_20                 ((uint32_t)0x00100000)        /*!< bit 20 */
  2948. #define  NVIC_ICER_CLRENA_21                 ((uint32_t)0x00200000)        /*!< bit 21 */
  2949. #define  NVIC_ICER_CLRENA_22                 ((uint32_t)0x00400000)        /*!< bit 22 */
  2950. #define  NVIC_ICER_CLRENA_23                 ((uint32_t)0x00800000)        /*!< bit 23 */
  2951. #define  NVIC_ICER_CLRENA_24                 ((uint32_t)0x01000000)        /*!< bit 24 */
  2952. #define  NVIC_ICER_CLRENA_25                 ((uint32_t)0x02000000)        /*!< bit 25 */
  2953. #define  NVIC_ICER_CLRENA_26                 ((uint32_t)0x04000000)        /*!< bit 26 */
  2954. #define  NVIC_ICER_CLRENA_27                 ((uint32_t)0x08000000)        /*!< bit 27 */
  2955. #define  NVIC_ICER_CLRENA_28                 ((uint32_t)0x10000000)        /*!< bit 28 */
  2956. #define  NVIC_ICER_CLRENA_29                 ((uint32_t)0x20000000)        /*!< bit 29 */
  2957. #define  NVIC_ICER_CLRENA_30                 ((uint32_t)0x40000000)        /*!< bit 30 */
  2958. #define  NVIC_ICER_CLRENA_31                 ((uint32_t)0x80000000)        /*!< bit 31 */
  2959.  
  2960. /******************  Bit definition for NVIC_ISPR register  *******************/
  2961. #define  NVIC_ISPR_SETPEND                   ((uint32_t)0xFFFFFFFF)        /*!< Interrupt set-pending bits */
  2962. #define  NVIC_ISPR_SETPEND_0                 ((uint32_t)0x00000001)        /*!< bit 0 */
  2963. #define  NVIC_ISPR_SETPEND_1                 ((uint32_t)0x00000002)        /*!< bit 1 */
  2964. #define  NVIC_ISPR_SETPEND_2                 ((uint32_t)0x00000004)        /*!< bit 2 */
  2965. #define  NVIC_ISPR_SETPEND_3                 ((uint32_t)0x00000008)        /*!< bit 3 */
  2966. #define  NVIC_ISPR_SETPEND_4                 ((uint32_t)0x00000010)        /*!< bit 4 */
  2967. #define  NVIC_ISPR_SETPEND_5                 ((uint32_t)0x00000020)        /*!< bit 5 */
  2968. #define  NVIC_ISPR_SETPEND_6                 ((uint32_t)0x00000040)        /*!< bit 6 */
  2969. #define  NVIC_ISPR_SETPEND_7                 ((uint32_t)0x00000080)        /*!< bit 7 */
  2970. #define  NVIC_ISPR_SETPEND_8                 ((uint32_t)0x00000100)        /*!< bit 8 */
  2971. #define  NVIC_ISPR_SETPEND_9                 ((uint32_t)0x00000200)        /*!< bit 9 */
  2972. #define  NVIC_ISPR_SETPEND_10                ((uint32_t)0x00000400)        /*!< bit 10 */
  2973. #define  NVIC_ISPR_SETPEND_11                ((uint32_t)0x00000800)        /*!< bit 11 */
  2974. #define  NVIC_ISPR_SETPEND_12                ((uint32_t)0x00001000)        /*!< bit 12 */
  2975. #define  NVIC_ISPR_SETPEND_13                ((uint32_t)0x00002000)        /*!< bit 13 */
  2976. #define  NVIC_ISPR_SETPEND_14                ((uint32_t)0x00004000)        /*!< bit 14 */
  2977. #define  NVIC_ISPR_SETPEND_15                ((uint32_t)0x00008000)        /*!< bit 15 */
  2978. #define  NVIC_ISPR_SETPEND_16                ((uint32_t)0x00010000)        /*!< bit 16 */
  2979. #define  NVIC_ISPR_SETPEND_17                ((uint32_t)0x00020000)        /*!< bit 17 */
  2980. #define  NVIC_ISPR_SETPEND_18                ((uint32_t)0x00040000)        /*!< bit 18 */
  2981. #define  NVIC_ISPR_SETPEND_19                ((uint32_t)0x00080000)        /*!< bit 19 */
  2982. #define  NVIC_ISPR_SETPEND_20                ((uint32_t)0x00100000)        /*!< bit 20 */
  2983. #define  NVIC_ISPR_SETPEND_21                ((uint32_t)0x00200000)        /*!< bit 21 */
  2984. #define  NVIC_ISPR_SETPEND_22                ((uint32_t)0x00400000)        /*!< bit 22 */
  2985. #define  NVIC_ISPR_SETPEND_23                ((uint32_t)0x00800000)        /*!< bit 23 */
  2986. #define  NVIC_ISPR_SETPEND_24                ((uint32_t)0x01000000)        /*!< bit 24 */
  2987. #define  NVIC_ISPR_SETPEND_25                ((uint32_t)0x02000000)        /*!< bit 25 */
  2988. #define  NVIC_ISPR_SETPEND_26                ((uint32_t)0x04000000)        /*!< bit 26 */
  2989. #define  NVIC_ISPR_SETPEND_27                ((uint32_t)0x08000000)        /*!< bit 27 */
  2990. #define  NVIC_ISPR_SETPEND_28                ((uint32_t)0x10000000)        /*!< bit 28 */
  2991. #define  NVIC_ISPR_SETPEND_29                ((uint32_t)0x20000000)        /*!< bit 29 */
  2992. #define  NVIC_ISPR_SETPEND_30                ((uint32_t)0x40000000)        /*!< bit 30 */
  2993. #define  NVIC_ISPR_SETPEND_31                ((uint32_t)0x80000000)        /*!< bit 31 */
  2994.  
  2995. /******************  Bit definition for NVIC_ICPR register  *******************/
  2996. #define  NVIC_ICPR_CLRPEND                   ((uint32_t)0xFFFFFFFF)        /*!< Interrupt clear-pending bits */
  2997. #define  NVIC_ICPR_CLRPEND_0                 ((uint32_t)0x00000001)        /*!< bit 0 */
  2998. #define  NVIC_ICPR_CLRPEND_1                 ((uint32_t)0x00000002)        /*!< bit 1 */
  2999. #define  NVIC_ICPR_CLRPEND_2                 ((uint32_t)0x00000004)        /*!< bit 2 */
  3000. #define  NVIC_ICPR_CLRPEND_3                 ((uint32_t)0x00000008)        /*!< bit 3 */
  3001. #define  NVIC_ICPR_CLRPEND_4                 ((uint32_t)0x00000010)        /*!< bit 4 */
  3002. #define  NVIC_ICPR_CLRPEND_5                 ((uint32_t)0x00000020)        /*!< bit 5 */
  3003. #define  NVIC_ICPR_CLRPEND_6                 ((uint32_t)0x00000040)        /*!< bit 6 */
  3004. #define  NVIC_ICPR_CLRPEND_7                 ((uint32_t)0x00000080)        /*!< bit 7 */
  3005. #define  NVIC_ICPR_CLRPEND_8                 ((uint32_t)0x00000100)        /*!< bit 8 */
  3006. #define  NVIC_ICPR_CLRPEND_9                 ((uint32_t)0x00000200)        /*!< bit 9 */
  3007. #define  NVIC_ICPR_CLRPEND_10                ((uint32_t)0x00000400)        /*!< bit 10 */
  3008. #define  NVIC_ICPR_CLRPEND_11                ((uint32_t)0x00000800)        /*!< bit 11 */
  3009. #define  NVIC_ICPR_CLRPEND_12                ((uint32_t)0x00001000)        /*!< bit 12 */
  3010. #define  NVIC_ICPR_CLRPEND_13                ((uint32_t)0x00002000)        /*!< bit 13 */
  3011. #define  NVIC_ICPR_CLRPEND_14                ((uint32_t)0x00004000)        /*!< bit 14 */
  3012. #define  NVIC_ICPR_CLRPEND_15                ((uint32_t)0x00008000)        /*!< bit 15 */
  3013. #define  NVIC_ICPR_CLRPEND_16                ((uint32_t)0x00010000)        /*!< bit 16 */
  3014. #define  NVIC_ICPR_CLRPEND_17                ((uint32_t)0x00020000)        /*!< bit 17 */
  3015. #define  NVIC_ICPR_CLRPEND_18                ((uint32_t)0x00040000)        /*!< bit 18 */
  3016. #define  NVIC_ICPR_CLRPEND_19                ((uint32_t)0x00080000)        /*!< bit 19 */
  3017. #define  NVIC_ICPR_CLRPEND_20                ((uint32_t)0x00100000)        /*!< bit 20 */
  3018. #define  NVIC_ICPR_CLRPEND_21                ((uint32_t)0x00200000)        /*!< bit 21 */
  3019. #define  NVIC_ICPR_CLRPEND_22                ((uint32_t)0x00400000)        /*!< bit 22 */
  3020. #define  NVIC_ICPR_CLRPEND_23                ((uint32_t)0x00800000)        /*!< bit 23 */
  3021. #define  NVIC_ICPR_CLRPEND_24                ((uint32_t)0x01000000)        /*!< bit 24 */
  3022. #define  NVIC_ICPR_CLRPEND_25                ((uint32_t)0x02000000)        /*!< bit 25 */
  3023. #define  NVIC_ICPR_CLRPEND_26                ((uint32_t)0x04000000)        /*!< bit 26 */
  3024. #define  NVIC_ICPR_CLRPEND_27                ((uint32_t)0x08000000)        /*!< bit 27 */
  3025. #define  NVIC_ICPR_CLRPEND_28                ((uint32_t)0x10000000)        /*!< bit 28 */
  3026. #define  NVIC_ICPR_CLRPEND_29                ((uint32_t)0x20000000)        /*!< bit 29 */
  3027. #define  NVIC_ICPR_CLRPEND_30                ((uint32_t)0x40000000)        /*!< bit 30 */
  3028. #define  NVIC_ICPR_CLRPEND_31                ((uint32_t)0x80000000)        /*!< bit 31 */
  3029.  
  3030. /******************  Bit definition for NVIC_IABR register  *******************/
  3031. #define  NVIC_IABR_ACTIVE                    ((uint32_t)0xFFFFFFFF)        /*!< Interrupt active flags */
  3032. #define  NVIC_IABR_ACTIVE_0                  ((uint32_t)0x00000001)        /*!< bit 0 */
  3033. #define  NVIC_IABR_ACTIVE_1                  ((uint32_t)0x00000002)        /*!< bit 1 */
  3034. #define  NVIC_IABR_ACTIVE_2                  ((uint32_t)0x00000004)        /*!< bit 2 */
  3035. #define  NVIC_IABR_ACTIVE_3                  ((uint32_t)0x00000008)        /*!< bit 3 */
  3036. #define  NVIC_IABR_ACTIVE_4                  ((uint32_t)0x00000010)        /*!< bit 4 */
  3037. #define  NVIC_IABR_ACTIVE_5                  ((uint32_t)0x00000020)        /*!< bit 5 */
  3038. #define  NVIC_IABR_ACTIVE_6                  ((uint32_t)0x00000040)        /*!< bit 6 */
  3039. #define  NVIC_IABR_ACTIVE_7                  ((uint32_t)0x00000080)        /*!< bit 7 */
  3040. #define  NVIC_IABR_ACTIVE_8                  ((uint32_t)0x00000100)        /*!< bit 8 */
  3041. #define  NVIC_IABR_ACTIVE_9                  ((uint32_t)0x00000200)        /*!< bit 9 */
  3042. #define  NVIC_IABR_ACTIVE_10                 ((uint32_t)0x00000400)        /*!< bit 10 */
  3043. #define  NVIC_IABR_ACTIVE_11                 ((uint32_t)0x00000800)        /*!< bit 11 */
  3044. #define  NVIC_IABR_ACTIVE_12                 ((uint32_t)0x00001000)        /*!< bit 12 */
  3045. #define  NVIC_IABR_ACTIVE_13                 ((uint32_t)0x00002000)        /*!< bit 13 */
  3046. #define  NVIC_IABR_ACTIVE_14                 ((uint32_t)0x00004000)        /*!< bit 14 */
  3047. #define  NVIC_IABR_ACTIVE_15                 ((uint32_t)0x00008000)        /*!< bit 15 */
  3048. #define  NVIC_IABR_ACTIVE_16                 ((uint32_t)0x00010000)        /*!< bit 16 */
  3049. #define  NVIC_IABR_ACTIVE_17                 ((uint32_t)0x00020000)        /*!< bit 17 */
  3050. #define  NVIC_IABR_ACTIVE_18                 ((uint32_t)0x00040000)        /*!< bit 18 */
  3051. #define  NVIC_IABR_ACTIVE_19                 ((uint32_t)0x00080000)        /*!< bit 19 */
  3052. #define  NVIC_IABR_ACTIVE_20                 ((uint32_t)0x00100000)        /*!< bit 20 */
  3053. #define  NVIC_IABR_ACTIVE_21                 ((uint32_t)0x00200000)        /*!< bit 21 */
  3054. #define  NVIC_IABR_ACTIVE_22                 ((uint32_t)0x00400000)        /*!< bit 22 */
  3055. #define  NVIC_IABR_ACTIVE_23                 ((uint32_t)0x00800000)        /*!< bit 23 */
  3056. #define  NVIC_IABR_ACTIVE_24                 ((uint32_t)0x01000000)        /*!< bit 24 */
  3057. #define  NVIC_IABR_ACTIVE_25                 ((uint32_t)0x02000000)        /*!< bit 25 */
  3058. #define  NVIC_IABR_ACTIVE_26                 ((uint32_t)0x04000000)        /*!< bit 26 */
  3059. #define  NVIC_IABR_ACTIVE_27                 ((uint32_t)0x08000000)        /*!< bit 27 */
  3060. #define  NVIC_IABR_ACTIVE_28                 ((uint32_t)0x10000000)        /*!< bit 28 */
  3061. #define  NVIC_IABR_ACTIVE_29                 ((uint32_t)0x20000000)        /*!< bit 29 */
  3062. #define  NVIC_IABR_ACTIVE_30                 ((uint32_t)0x40000000)        /*!< bit 30 */
  3063. #define  NVIC_IABR_ACTIVE_31                 ((uint32_t)0x80000000)        /*!< bit 31 */
  3064.  
  3065. /******************  Bit definition for NVIC_PRI0 register  *******************/
  3066. #define  NVIC_IPR0_PRI_0                     ((uint32_t)0x000000FF)        /*!< Priority of interrupt 0 */
  3067. #define  NVIC_IPR0_PRI_1                     ((uint32_t)0x0000FF00)        /*!< Priority of interrupt 1 */
  3068. #define  NVIC_IPR0_PRI_2                     ((uint32_t)0x00FF0000)        /*!< Priority of interrupt 2 */
  3069. #define  NVIC_IPR0_PRI_3                     ((uint32_t)0xFF000000)        /*!< Priority of interrupt 3 */
  3070.  
  3071. /******************  Bit definition for NVIC_PRI1 register  *******************/
  3072. #define  NVIC_IPR1_PRI_4                     ((uint32_t)0x000000FF)        /*!< Priority of interrupt 4 */
  3073. #define  NVIC_IPR1_PRI_5                     ((uint32_t)0x0000FF00)        /*!< Priority of interrupt 5 */
  3074. #define  NVIC_IPR1_PRI_6                     ((uint32_t)0x00FF0000)        /*!< Priority of interrupt 6 */
  3075. #define  NVIC_IPR1_PRI_7                     ((uint32_t)0xFF000000)        /*!< Priority of interrupt 7 */
  3076.  
  3077. /******************  Bit definition for NVIC_PRI2 register  *******************/
  3078. #define  NVIC_IPR2_PRI_8                     ((uint32_t)0x000000FF)        /*!< Priority of interrupt 8 */
  3079. #define  NVIC_IPR2_PRI_9                     ((uint32_t)0x0000FF00)        /*!< Priority of interrupt 9 */
  3080. #define  NVIC_IPR2_PRI_10                    ((uint32_t)0x00FF0000)        /*!< Priority of interrupt 10 */
  3081. #define  NVIC_IPR2_PRI_11                    ((uint32_t)0xFF000000)        /*!< Priority of interrupt 11 */
  3082.  
  3083. /******************  Bit definition for NVIC_PRI3 register  *******************/
  3084. #define  NVIC_IPR3_PRI_12                    ((uint32_t)0x000000FF)        /*!< Priority of interrupt 12 */
  3085. #define  NVIC_IPR3_PRI_13                    ((uint32_t)0x0000FF00)        /*!< Priority of interrupt 13 */
  3086. #define  NVIC_IPR3_PRI_14                    ((uint32_t)0x00FF0000)        /*!< Priority of interrupt 14 */
  3087. #define  NVIC_IPR3_PRI_15                    ((uint32_t)0xFF000000)        /*!< Priority of interrupt 15 */
  3088.  
  3089. /******************  Bit definition for NVIC_PRI4 register  *******************/
  3090. #define  NVIC_IPR4_PRI_16                    ((uint32_t)0x000000FF)        /*!< Priority of interrupt 16 */
  3091. #define  NVIC_IPR4_PRI_17                    ((uint32_t)0x0000FF00)        /*!< Priority of interrupt 17 */
  3092. #define  NVIC_IPR4_PRI_18                    ((uint32_t)0x00FF0000)        /*!< Priority of interrupt 18 */
  3093. #define  NVIC_IPR4_PRI_19                    ((uint32_t)0xFF000000)        /*!< Priority of interrupt 19 */
  3094.  
  3095. /******************  Bit definition for NVIC_PRI5 register  *******************/
  3096. #define  NVIC_IPR5_PRI_20                    ((uint32_t)0x000000FF)        /*!< Priority of interrupt 20 */
  3097. #define  NVIC_IPR5_PRI_21                    ((uint32_t)0x0000FF00)        /*!< Priority of interrupt 21 */
  3098. #define  NVIC_IPR5_PRI_22                    ((uint32_t)0x00FF0000)        /*!< Priority of interrupt 22 */
  3099. #define  NVIC_IPR5_PRI_23                    ((uint32_t)0xFF000000)        /*!< Priority of interrupt 23 */
  3100.  
  3101. /******************  Bit definition for NVIC_PRI6 register  *******************/
  3102. #define  NVIC_IPR6_PRI_24                    ((uint32_t)0x000000FF)        /*!< Priority of interrupt 24 */
  3103. #define  NVIC_IPR6_PRI_25                    ((uint32_t)0x0000FF00)        /*!< Priority of interrupt 25 */
  3104. #define  NVIC_IPR6_PRI_26                    ((uint32_t)0x00FF0000)        /*!< Priority of interrupt 26 */
  3105. #define  NVIC_IPR6_PRI_27                    ((uint32_t)0xFF000000)        /*!< Priority of interrupt 27 */
  3106.  
  3107. /******************  Bit definition for NVIC_PRI7 register  *******************/
  3108. #define  NVIC_IPR7_PRI_28                    ((uint32_t)0x000000FF)        /*!< Priority of interrupt 28 */
  3109. #define  NVIC_IPR7_PRI_29                    ((uint32_t)0x0000FF00)        /*!< Priority of interrupt 29 */
  3110. #define  NVIC_IPR7_PRI_30                    ((uint32_t)0x00FF0000)        /*!< Priority of interrupt 30 */
  3111. #define  NVIC_IPR7_PRI_31                    ((uint32_t)0xFF000000)        /*!< Priority of interrupt 31 */
  3112.  
  3113. /******************  Bit definition for SCB_CPUID register  *******************/
  3114. #define  SCB_CPUID_REVISION                  ((uint32_t)0x0000000F)        /*!< Implementation defined revision number */
  3115. #define  SCB_CPUID_PARTNO                    ((uint32_t)0x0000FFF0)        /*!< Number of processor within family */
  3116. #define  SCB_CPUID_Constant                  ((uint32_t)0x000F0000)        /*!< Reads as 0x0F */
  3117. #define  SCB_CPUID_VARIANT                   ((uint32_t)0x00F00000)        /*!< Implementation defined variant number */
  3118. #define  SCB_CPUID_IMPLEMENTER               ((uint32_t)0xFF000000)        /*!< Implementer code. ARM is 0x41 */
  3119.  
  3120. /*******************  Bit definition for SCB_ICSR register  *******************/
  3121. #define  SCB_ICSR_VECTACTIVE                 ((uint32_t)0x000001FF)        /*!< Active ISR number field */
  3122. #define  SCB_ICSR_RETTOBASE                  ((uint32_t)0x00000800)        /*!< All active exceptions minus the IPSR_current_exception yields the empty set */
  3123. #define  SCB_ICSR_VECTPENDING                ((uint32_t)0x003FF000)        /*!< Pending ISR number field */
  3124. #define  SCB_ICSR_ISRPENDING                 ((uint32_t)0x00400000)        /*!< Interrupt pending flag */
  3125. #define  SCB_ICSR_ISRPREEMPT                 ((uint32_t)0x00800000)        /*!< It indicates that a pending interrupt becomes active in the next running cycle */
  3126. #define  SCB_ICSR_PENDSTCLR                  ((uint32_t)0x02000000)        /*!< Clear pending SysTick bit */
  3127. #define  SCB_ICSR_PENDSTSET                  ((uint32_t)0x04000000)        /*!< Set pending SysTick bit */
  3128. #define  SCB_ICSR_PENDSVCLR                  ((uint32_t)0x08000000)        /*!< Clear pending pendSV bit */
  3129. #define  SCB_ICSR_PENDSVSET                  ((uint32_t)0x10000000)        /*!< Set pending pendSV bit */
  3130. #define  SCB_ICSR_NMIPENDSET                 ((uint32_t)0x80000000)        /*!< Set pending NMI bit */
  3131.  
  3132. /*******************  Bit definition for SCB_VTOR register  *******************/
  3133. #define  SCB_VTOR_TBLOFF                     ((uint32_t)0x1FFFFF80)        /*!< Vector table base offset field */
  3134. #define  SCB_VTOR_TBLBASE                    ((uint32_t)0x20000000)        /*!< Table base in code(0) or RAM(1) */
  3135.  
  3136. /*!<*****************  Bit definition for SCB_AIRCR register  *******************/
  3137. #define  SCB_AIRCR_VECTRESET                 ((uint32_t)0x00000001)        /*!< System Reset bit */
  3138. #define  SCB_AIRCR_VECTCLRACTIVE             ((uint32_t)0x00000002)        /*!< Clear active vector bit */
  3139. #define  SCB_AIRCR_SYSRESETREQ               ((uint32_t)0x00000004)        /*!< Requests chip control logic to generate a reset */
  3140.  
  3141. #define  SCB_AIRCR_PRIGROUP                  ((uint32_t)0x00000700)        /*!< PRIGROUP[2:0] bits (Priority group) */
  3142. #define  SCB_AIRCR_PRIGROUP_0                ((uint32_t)0x00000100)        /*!< Bit 0 */
  3143. #define  SCB_AIRCR_PRIGROUP_1                ((uint32_t)0x00000200)        /*!< Bit 1 */
  3144. #define  SCB_AIRCR_PRIGROUP_2                ((uint32_t)0x00000400)        /*!< Bit 2  */
  3145.  
  3146. /* prority group configuration */
  3147. #define  SCB_AIRCR_PRIGROUP0                 ((uint32_t)0x00000000)        /*!< Priority group=0 (7 bits of pre-emption priority, 1 bit of subpriority) */
  3148. #define  SCB_AIRCR_PRIGROUP1                 ((uint32_t)0x00000100)        /*!< Priority group=1 (6 bits of pre-emption priority, 2 bits of subpriority) */
  3149. #define  SCB_AIRCR_PRIGROUP2                 ((uint32_t)0x00000200)        /*!< Priority group=2 (5 bits of pre-emption priority, 3 bits of subpriority) */
  3150. #define  SCB_AIRCR_PRIGROUP3                 ((uint32_t)0x00000300)        /*!< Priority group=3 (4 bits of pre-emption priority, 4 bits of subpriority) */
  3151. #define  SCB_AIRCR_PRIGROUP4                 ((uint32_t)0x00000400)        /*!< Priority group=4 (3 bits of pre-emption priority, 5 bits of subpriority) */
  3152. #define  SCB_AIRCR_PRIGROUP5                 ((uint32_t)0x00000500)        /*!< Priority group=5 (2 bits of pre-emption priority, 6 bits of subpriority) */
  3153. #define  SCB_AIRCR_PRIGROUP6                 ((uint32_t)0x00000600)        /*!< Priority group=6 (1 bit of pre-emption priority, 7 bits of subpriority) */
  3154. #define  SCB_AIRCR_PRIGROUP7                 ((uint32_t)0x00000700)        /*!< Priority group=7 (no pre-emption priority, 8 bits of subpriority) */
  3155.  
  3156. #define  SCB_AIRCR_ENDIANESS                 ((uint32_t)0x00008000)        /*!< Data endianness bit */
  3157. #define  SCB_AIRCR_VECTKEY                   ((uint32_t)0xFFFF0000)        /*!< Register key (VECTKEY) - Reads as 0xFA05 (VECTKEYSTAT) */
  3158.  
  3159. /*******************  Bit definition for SCB_SCR register  ********************/
  3160. #define  SCB_SCR_SLEEPONEXIT                 ((uint8_t)0x02)               /*!< Sleep on exit bit */
  3161. #define  SCB_SCR_SLEEPDEEP                   ((uint8_t)0x04)               /*!< Sleep deep bit */
  3162. #define  SCB_SCR_SEVONPEND                   ((uint8_t)0x10)               /*!< Wake up from WFE */
  3163.  
  3164. /********************  Bit definition for SCB_CCR register  *******************/
  3165. #define  SCB_CCR_NONBASETHRDENA              ((uint16_t)0x0001)            /*!< Thread mode can be entered from any level in Handler mode by controlled return value */
  3166. #define  SCB_CCR_USERSETMPEND                ((uint16_t)0x0002)            /*!< Enables user code to write the Software Trigger Interrupt register to trigger (pend) a Main exception */
  3167. #define  SCB_CCR_UNALIGN_TRP                 ((uint16_t)0x0008)            /*!< Trap for unaligned access */
  3168. #define  SCB_CCR_DIV_0_TRP                   ((uint16_t)0x0010)            /*!< Trap on Divide by 0 */
  3169. #define  SCB_CCR_BFHFNMIGN                   ((uint16_t)0x0100)            /*!< Handlers running at priority -1 and -2 */
  3170. #define  SCB_CCR_STKALIGN                    ((uint16_t)0x0200)            /*!< On exception entry, the SP used prior to the exception is adjusted to be 8-byte aligned */
  3171.  
  3172. /*******************  Bit definition for SCB_SHPR register ********************/
  3173. #define  SCB_SHPR_PRI_N                      ((uint32_t)0x000000FF)        /*!< Priority of system handler 4,8, and 12. Mem Manage, reserved and Debug Monitor */
  3174. #define  SCB_SHPR_PRI_N1                     ((uint32_t)0x0000FF00)        /*!< Priority of system handler 5,9, and 13. Bus Fault, reserved and reserved */
  3175. #define  SCB_SHPR_PRI_N2                     ((uint32_t)0x00FF0000)        /*!< Priority of system handler 6,10, and 14. Usage Fault, reserved and PendSV */
  3176. #define  SCB_SHPR_PRI_N3                     ((uint32_t)0xFF000000)        /*!< Priority of system handler 7,11, and 15. Reserved, SVCall and SysTick */
  3177.  
  3178. /******************  Bit definition for SCB_SHCSR register  *******************/
  3179. #define  SCB_SHCSR_MEMFAULTACT               ((uint32_t)0x00000001)        /*!< MemManage is active */
  3180. #define  SCB_SHCSR_BUSFAULTACT               ((uint32_t)0x00000002)        /*!< BusFault is active */
  3181. #define  SCB_SHCSR_USGFAULTACT               ((uint32_t)0x00000008)        /*!< UsageFault is active */
  3182. #define  SCB_SHCSR_SVCALLACT                 ((uint32_t)0x00000080)        /*!< SVCall is active */
  3183. #define  SCB_SHCSR_MONITORACT                ((uint32_t)0x00000100)        /*!< Monitor is active */
  3184. #define  SCB_SHCSR_PENDSVACT                 ((uint32_t)0x00000400)        /*!< PendSV is active */
  3185. #define  SCB_SHCSR_SYSTICKACT                ((uint32_t)0x00000800)        /*!< SysTick is active */
  3186. #define  SCB_SHCSR_USGFAULTPENDED            ((uint32_t)0x00001000)        /*!< Usage Fault is pended */
  3187. #define  SCB_SHCSR_MEMFAULTPENDED            ((uint32_t)0x00002000)        /*!< MemManage is pended */
  3188. #define  SCB_SHCSR_BUSFAULTPENDED            ((uint32_t)0x00004000)        /*!< Bus Fault is pended */
  3189. #define  SCB_SHCSR_SVCALLPENDED              ((uint32_t)0x00008000)        /*!< SVCall is pended */
  3190. #define  SCB_SHCSR_MEMFAULTENA               ((uint32_t)0x00010000)        /*!< MemManage enable */
  3191. #define  SCB_SHCSR_BUSFAULTENA               ((uint32_t)0x00020000)        /*!< Bus Fault enable */
  3192. #define  SCB_SHCSR_USGFAULTENA               ((uint32_t)0x00040000)        /*!< UsageFault enable */
  3193.  
  3194. /*******************  Bit definition for SCB_CFSR register  *******************/
  3195. /*!< MFSR */
  3196. #define  SCB_CFSR_IACCVIOL                   ((uint32_t)0x00000001)        /*!< Instruction access violation */
  3197. #define  SCB_CFSR_DACCVIOL                   ((uint32_t)0x00000002)        /*!< Data access violation */
  3198. #define  SCB_CFSR_MUNSTKERR                  ((uint32_t)0x00000008)        /*!< Unstacking error */
  3199. #define  SCB_CFSR_MSTKERR                    ((uint32_t)0x00000010)        /*!< Stacking error */
  3200. #define  SCB_CFSR_MMARVALID                  ((uint32_t)0x00000080)        /*!< Memory Manage Address Register address valid flag */
  3201. /*!< BFSR */
  3202. #define  SCB_CFSR_IBUSERR                    ((uint32_t)0x00000100)        /*!< Instruction bus error flag */
  3203. #define  SCB_CFSR_PRECISERR                  ((uint32_t)0x00000200)        /*!< Precise data bus error */
  3204. #define  SCB_CFSR_IMPRECISERR                ((uint32_t)0x00000400)        /*!< Imprecise data bus error */
  3205. #define  SCB_CFSR_UNSTKERR                   ((uint32_t)0x00000800)        /*!< Unstacking error */
  3206. #define  SCB_CFSR_STKERR                     ((uint32_t)0x00001000)        /*!< Stacking error */
  3207. #define  SCB_CFSR_BFARVALID                  ((uint32_t)0x00008000)        /*!< Bus Fault Address Register address valid flag */
  3208. /*!< UFSR */
  3209. #define  SCB_CFSR_UNDEFINSTR                 ((uint32_t)0x00010000)        /*!< The processor attempt to execute an undefined instruction */
  3210. #define  SCB_CFSR_INVSTATE                   ((uint32_t)0x00020000)        /*!< Invalid combination of EPSR and instruction */
  3211. #define  SCB_CFSR_INVPC                      ((uint32_t)0x00040000)        /*!< Attempt to load EXC_RETURN into pc illegally */
  3212. #define  SCB_CFSR_NOCP                       ((uint32_t)0x00080000)        /*!< Attempt to use a coprocessor instruction */
  3213. #define  SCB_CFSR_UNALIGNED                  ((uint32_t)0x01000000)        /*!< Fault occurs when there is an attempt to make an unaligned memory access */
  3214. #define  SCB_CFSR_DIVBYZERO                  ((uint32_t)0x02000000)        /*!< Fault occurs when SDIV or DIV instruction is used with a divisor of 0 */
  3215.  
  3216. /*******************  Bit definition for SCB_HFSR register  *******************/
  3217. #define  SCB_HFSR_VECTTBL                    ((uint32_t)0x00000002)        /*!< Fault occurs because of vector table read on exception processing */
  3218. #define  SCB_HFSR_FORCED                     ((uint32_t)0x40000000)        /*!< Hard Fault activated when a configurable Fault was received and cannot activate */
  3219. #define  SCB_HFSR_DEBUGEVT                   ((uint32_t)0x80000000)        /*!< Fault related to debug */
  3220.  
  3221. /*******************  Bit definition for SCB_DFSR register  *******************/
  3222. #define  SCB_DFSR_HALTED                     ((uint8_t)0x01)               /*!< Halt request flag */
  3223. #define  SCB_DFSR_BKPT                       ((uint8_t)0x02)               /*!< BKPT flag */
  3224. #define  SCB_DFSR_DWTTRAP                    ((uint8_t)0x04)               /*!< Data Watchpoint and Trace (DWT) flag */
  3225. #define  SCB_DFSR_VCATCH                     ((uint8_t)0x08)               /*!< Vector catch flag */
  3226. #define  SCB_DFSR_EXTERNAL                   ((uint8_t)0x10)               /*!< External debug request flag */
  3227.  
  3228. /*******************  Bit definition for SCB_MMFAR register  ******************/
  3229. #define  SCB_MMFAR_ADDRESS                   ((uint32_t)0xFFFFFFFF)        /*!< Mem Manage fault address field */
  3230.  
  3231. /*******************  Bit definition for SCB_BFAR register  *******************/
  3232. #define  SCB_BFAR_ADDRESS                    ((uint32_t)0xFFFFFFFF)        /*!< Bus fault address field */
  3233.  
  3234. /*******************  Bit definition for SCB_afsr register  *******************/
  3235. #define  SCB_AFSR_IMPDEF                     ((uint32_t)0xFFFFFFFF)        /*!< Implementation defined */
  3236.  
  3237. /******************************************************************************/
  3238. /*                                                                            */
  3239. /*                    External Interrupt/Event Controller                     */
  3240. /*                                                                            */
  3241. /******************************************************************************/
  3242.  
  3243. /*******************  Bit definition for EXTI_IMR register  *******************/
  3244. #define  EXTI_IMR_MR0                        ((uint32_t)0x00000001)        /*!< Interrupt Mask on line 0 */
  3245. #define  EXTI_IMR_MR1                        ((uint32_t)0x00000002)        /*!< Interrupt Mask on line 1 */
  3246. #define  EXTI_IMR_MR2                        ((uint32_t)0x00000004)        /*!< Interrupt Mask on line 2 */
  3247. #define  EXTI_IMR_MR3                        ((uint32_t)0x00000008)        /*!< Interrupt Mask on line 3 */
  3248. #define  EXTI_IMR_MR4                        ((uint32_t)0x00000010)        /*!< Interrupt Mask on line 4 */
  3249. #define  EXTI_IMR_MR5                        ((uint32_t)0x00000020)        /*!< Interrupt Mask on line 5 */
  3250. #define  EXTI_IMR_MR6                        ((uint32_t)0x00000040)        /*!< Interrupt Mask on line 6 */
  3251. #define  EXTI_IMR_MR7                        ((uint32_t)0x00000080)        /*!< Interrupt Mask on line 7 */
  3252. #define  EXTI_IMR_MR8                        ((uint32_t)0x00000100)        /*!< Interrupt Mask on line 8 */
  3253. #define  EXTI_IMR_MR9                        ((uint32_t)0x00000200)        /*!< Interrupt Mask on line 9 */
  3254. #define  EXTI_IMR_MR10                       ((uint32_t)0x00000400)        /*!< Interrupt Mask on line 10 */
  3255. #define  EXTI_IMR_MR11                       ((uint32_t)0x00000800)        /*!< Interrupt Mask on line 11 */
  3256. #define  EXTI_IMR_MR12                       ((uint32_t)0x00001000)        /*!< Interrupt Mask on line 12 */
  3257. #define  EXTI_IMR_MR13                       ((uint32_t)0x00002000)        /*!< Interrupt Mask on line 13 */
  3258. #define  EXTI_IMR_MR14                       ((uint32_t)0x00004000)        /*!< Interrupt Mask on line 14 */
  3259. #define  EXTI_IMR_MR15                       ((uint32_t)0x00008000)        /*!< Interrupt Mask on line 15 */
  3260. #define  EXTI_IMR_MR16                       ((uint32_t)0x00010000)        /*!< Interrupt Mask on line 16 */
  3261. #define  EXTI_IMR_MR17                       ((uint32_t)0x00020000)        /*!< Interrupt Mask on line 17 */
  3262. #define  EXTI_IMR_MR18                       ((uint32_t)0x00040000)        /*!< Interrupt Mask on line 18 */
  3263. #define  EXTI_IMR_MR19                       ((uint32_t)0x00080000)        /*!< Interrupt Mask on line 19 */
  3264.  
  3265. /*******************  Bit definition for EXTI_EMR register  *******************/
  3266. #define  EXTI_EMR_MR0                        ((uint32_t)0x00000001)        /*!< Event Mask on line 0 */
  3267. #define  EXTI_EMR_MR1                        ((uint32_t)0x00000002)        /*!< Event Mask on line 1 */
  3268. #define  EXTI_EMR_MR2                        ((uint32_t)0x00000004)        /*!< Event Mask on line 2 */
  3269. #define  EXTI_EMR_MR3                        ((uint32_t)0x00000008)        /*!< Event Mask on line 3 */
  3270. #define  EXTI_EMR_MR4                        ((uint32_t)0x00000010)        /*!< Event Mask on line 4 */
  3271. #define  EXTI_EMR_MR5                        ((uint32_t)0x00000020)        /*!< Event Mask on line 5 */
  3272. #define  EXTI_EMR_MR6                        ((uint32_t)0x00000040)        /*!< Event Mask on line 6 */
  3273. #define  EXTI_EMR_MR7                        ((uint32_t)0x00000080)        /*!< Event Mask on line 7 */
  3274. #define  EXTI_EMR_MR8                        ((uint32_t)0x00000100)        /*!< Event Mask on line 8 */
  3275. #define  EXTI_EMR_MR9                        ((uint32_t)0x00000200)        /*!< Event Mask on line 9 */
  3276. #define  EXTI_EMR_MR10                       ((uint32_t)0x00000400)        /*!< Event Mask on line 10 */
  3277. #define  EXTI_EMR_MR11                       ((uint32_t)0x00000800)        /*!< Event Mask on line 11 */
  3278. #define  EXTI_EMR_MR12                       ((uint32_t)0x00001000)        /*!< Event Mask on line 12 */
  3279. #define  EXTI_EMR_MR13                       ((uint32_t)0x00002000)        /*!< Event Mask on line 13 */
  3280. #define  EXTI_EMR_MR14                       ((uint32_t)0x00004000)        /*!< Event Mask on line 14 */
  3281. #define  EXTI_EMR_MR15                       ((uint32_t)0x00008000)        /*!< Event Mask on line 15 */
  3282. #define  EXTI_EMR_MR16                       ((uint32_t)0x00010000)        /*!< Event Mask on line 16 */
  3283. #define  EXTI_EMR_MR17                       ((uint32_t)0x00020000)        /*!< Event Mask on line 17 */
  3284. #define  EXTI_EMR_MR18                       ((uint32_t)0x00040000)        /*!< Event Mask on line 18 */
  3285. #define  EXTI_EMR_MR19                       ((uint32_t)0x00080000)        /*!< Event Mask on line 19 */
  3286.  
  3287. /******************  Bit definition for EXTI_RTSR register  *******************/
  3288. #define  EXTI_RTSR_TR0                       ((uint32_t)0x00000001)        /*!< Rising trigger event configuration bit of line 0 */
  3289. #define  EXTI_RTSR_TR1                       ((uint32_t)0x00000002)        /*!< Rising trigger event configuration bit of line 1 */
  3290. #define  EXTI_RTSR_TR2                       ((uint32_t)0x00000004)        /*!< Rising trigger event configuration bit of line 2 */
  3291. #define  EXTI_RTSR_TR3                       ((uint32_t)0x00000008)        /*!< Rising trigger event configuration bit of line 3 */
  3292. #define  EXTI_RTSR_TR4                       ((uint32_t)0x00000010)        /*!< Rising trigger event configuration bit of line 4 */
  3293. #define  EXTI_RTSR_TR5                       ((uint32_t)0x00000020)        /*!< Rising trigger event configuration bit of line 5 */
  3294. #define  EXTI_RTSR_TR6                       ((uint32_t)0x00000040)        /*!< Rising trigger event configuration bit of line 6 */
  3295. #define  EXTI_RTSR_TR7                       ((uint32_t)0x00000080)        /*!< Rising trigger event configuration bit of line 7 */
  3296. #define  EXTI_RTSR_TR8                       ((uint32_t)0x00000100)        /*!< Rising trigger event configuration bit of line 8 */
  3297. #define  EXTI_RTSR_TR9                       ((uint32_t)0x00000200)        /*!< Rising trigger event configuration bit of line 9 */
  3298. #define  EXTI_RTSR_TR10                      ((uint32_t)0x00000400)        /*!< Rising trigger event configuration bit of line 10 */
  3299. #define  EXTI_RTSR_TR11                      ((uint32_t)0x00000800)        /*!< Rising trigger event configuration bit of line 11 */
  3300. #define  EXTI_RTSR_TR12                      ((uint32_t)0x00001000)        /*!< Rising trigger event configuration bit of line 12 */
  3301. #define  EXTI_RTSR_TR13                      ((uint32_t)0x00002000)        /*!< Rising trigger event configuration bit of line 13 */
  3302. #define  EXTI_RTSR_TR14                      ((uint32_t)0x00004000)        /*!< Rising trigger event configuration bit of line 14 */
  3303. #define  EXTI_RTSR_TR15                      ((uint32_t)0x00008000)        /*!< Rising trigger event configuration bit of line 15 */
  3304. #define  EXTI_RTSR_TR16                      ((uint32_t)0x00010000)        /*!< Rising trigger event configuration bit of line 16 */
  3305. #define  EXTI_RTSR_TR17                      ((uint32_t)0x00020000)        /*!< Rising trigger event configuration bit of line 17 */
  3306. #define  EXTI_RTSR_TR18                      ((uint32_t)0x00040000)        /*!< Rising trigger event configuration bit of line 18 */
  3307. #define  EXTI_RTSR_TR19                      ((uint32_t)0x00080000)        /*!< Rising trigger event configuration bit of line 19 */
  3308.  
  3309. /******************  Bit definition for EXTI_FTSR register  *******************/
  3310. #define  EXTI_FTSR_TR0                       ((uint32_t)0x00000001)        /*!< Falling trigger event configuration bit of line 0 */
  3311. #define  EXTI_FTSR_TR1                       ((uint32_t)0x00000002)        /*!< Falling trigger event configuration bit of line 1 */
  3312. #define  EXTI_FTSR_TR2                       ((uint32_t)0x00000004)        /*!< Falling trigger event configuration bit of line 2 */
  3313. #define  EXTI_FTSR_TR3                       ((uint32_t)0x00000008)        /*!< Falling trigger event configuration bit of line 3 */
  3314. #define  EXTI_FTSR_TR4                       ((uint32_t)0x00000010)        /*!< Falling trigger event configuration bit of line 4 */
  3315. #define  EXTI_FTSR_TR5                       ((uint32_t)0x00000020)        /*!< Falling trigger event configuration bit of line 5 */
  3316. #define  EXTI_FTSR_TR6                       ((uint32_t)0x00000040)        /*!< Falling trigger event configuration bit of line 6 */
  3317. #define  EXTI_FTSR_TR7                       ((uint32_t)0x00000080)        /*!< Falling trigger event configuration bit of line 7 */
  3318. #define  EXTI_FTSR_TR8                       ((uint32_t)0x00000100)        /*!< Falling trigger event configuration bit of line 8 */
  3319. #define  EXTI_FTSR_TR9                       ((uint32_t)0x00000200)        /*!< Falling trigger event configuration bit of line 9 */
  3320. #define  EXTI_FTSR_TR10                      ((uint32_t)0x00000400)        /*!< Falling trigger event configuration bit of line 10 */
  3321. #define  EXTI_FTSR_TR11                      ((uint32_t)0x00000800)        /*!< Falling trigger event configuration bit of line 11 */
  3322. #define  EXTI_FTSR_TR12                      ((uint32_t)0x00001000)        /*!< Falling trigger event configuration bit of line 12 */
  3323. #define  EXTI_FTSR_TR13                      ((uint32_t)0x00002000)        /*!< Falling trigger event configuration bit of line 13 */
  3324. #define  EXTI_FTSR_TR14                      ((uint32_t)0x00004000)        /*!< Falling trigger event configuration bit of line 14 */
  3325. #define  EXTI_FTSR_TR15                      ((uint32_t)0x00008000)        /*!< Falling trigger event configuration bit of line 15 */
  3326. #define  EXTI_FTSR_TR16                      ((uint32_t)0x00010000)        /*!< Falling trigger event configuration bit of line 16 */
  3327. #define  EXTI_FTSR_TR17                      ((uint32_t)0x00020000)        /*!< Falling trigger event configuration bit of line 17 */
  3328. #define  EXTI_FTSR_TR18                      ((uint32_t)0x00040000)        /*!< Falling trigger event configuration bit of line 18 */
  3329. #define  EXTI_FTSR_TR19                      ((uint32_t)0x00080000)        /*!< Falling trigger event configuration bit of line 19 */
  3330.  
  3331. /******************  Bit definition for EXTI_SWIER register  ******************/
  3332. #define  EXTI_SWIER_SWIER0                   ((uint32_t)0x00000001)        /*!< Software Interrupt on line 0 */
  3333. #define  EXTI_SWIER_SWIER1                   ((uint32_t)0x00000002)        /*!< Software Interrupt on line 1 */
  3334. #define  EXTI_SWIER_SWIER2                   ((uint32_t)0x00000004)        /*!< Software Interrupt on line 2 */
  3335. #define  EXTI_SWIER_SWIER3                   ((uint32_t)0x00000008)        /*!< Software Interrupt on line 3 */
  3336. #define  EXTI_SWIER_SWIER4                   ((uint32_t)0x00000010)        /*!< Software Interrupt on line 4 */
  3337. #define  EXTI_SWIER_SWIER5                   ((uint32_t)0x00000020)        /*!< Software Interrupt on line 5 */
  3338. #define  EXTI_SWIER_SWIER6                   ((uint32_t)0x00000040)        /*!< Software Interrupt on line 6 */
  3339. #define  EXTI_SWIER_SWIER7                   ((uint32_t)0x00000080)        /*!< Software Interrupt on line 7 */
  3340. #define  EXTI_SWIER_SWIER8                   ((uint32_t)0x00000100)        /*!< Software Interrupt on line 8 */
  3341. #define  EXTI_SWIER_SWIER9                   ((uint32_t)0x00000200)        /*!< Software Interrupt on line 9 */
  3342. #define  EXTI_SWIER_SWIER10                  ((uint32_t)0x00000400)        /*!< Software Interrupt on line 10 */
  3343. #define  EXTI_SWIER_SWIER11                  ((uint32_t)0x00000800)        /*!< Software Interrupt on line 11 */
  3344. #define  EXTI_SWIER_SWIER12                  ((uint32_t)0x00001000)        /*!< Software Interrupt on line 12 */
  3345. #define  EXTI_SWIER_SWIER13                  ((uint32_t)0x00002000)        /*!< Software Interrupt on line 13 */
  3346. #define  EXTI_SWIER_SWIER14                  ((uint32_t)0x00004000)        /*!< Software Interrupt on line 14 */
  3347. #define  EXTI_SWIER_SWIER15                  ((uint32_t)0x00008000)        /*!< Software Interrupt on line 15 */
  3348. #define  EXTI_SWIER_SWIER16                  ((uint32_t)0x00010000)        /*!< Software Interrupt on line 16 */
  3349. #define  EXTI_SWIER_SWIER17                  ((uint32_t)0x00020000)        /*!< Software Interrupt on line 17 */
  3350. #define  EXTI_SWIER_SWIER18                  ((uint32_t)0x00040000)        /*!< Software Interrupt on line 18 */
  3351. #define  EXTI_SWIER_SWIER19                  ((uint32_t)0x00080000)        /*!< Software Interrupt on line 19 */
  3352.  
  3353. /*******************  Bit definition for EXTI_PR register  ********************/
  3354. #define  EXTI_PR_PR0                         ((uint32_t)0x00000001)        /*!< Pending bit for line 0 */
  3355. #define  EXTI_PR_PR1                         ((uint32_t)0x00000002)        /*!< Pending bit for line 1 */
  3356. #define  EXTI_PR_PR2                         ((uint32_t)0x00000004)        /*!< Pending bit for line 2 */
  3357. #define  EXTI_PR_PR3                         ((uint32_t)0x00000008)        /*!< Pending bit for line 3 */
  3358. #define  EXTI_PR_PR4                         ((uint32_t)0x00000010)        /*!< Pending bit for line 4 */
  3359. #define  EXTI_PR_PR5                         ((uint32_t)0x00000020)        /*!< Pending bit for line 5 */
  3360. #define  EXTI_PR_PR6                         ((uint32_t)0x00000040)        /*!< Pending bit for line 6 */
  3361. #define  EXTI_PR_PR7                         ((uint32_t)0x00000080)        /*!< Pending bit for line 7 */
  3362. #define  EXTI_PR_PR8                         ((uint32_t)0x00000100)        /*!< Pending bit for line 8 */
  3363. #define  EXTI_PR_PR9                         ((uint32_t)0x00000200)        /*!< Pending bit for line 9 */
  3364. #define  EXTI_PR_PR10                        ((uint32_t)0x00000400)        /*!< Pending bit for line 10 */
  3365. #define  EXTI_PR_PR11                        ((uint32_t)0x00000800)        /*!< Pending bit for line 11 */
  3366. #define  EXTI_PR_PR12                        ((uint32_t)0x00001000)        /*!< Pending bit for line 12 */
  3367. #define  EXTI_PR_PR13                        ((uint32_t)0x00002000)        /*!< Pending bit for line 13 */
  3368. #define  EXTI_PR_PR14                        ((uint32_t)0x00004000)        /*!< Pending bit for line 14 */
  3369. #define  EXTI_PR_PR15                        ((uint32_t)0x00008000)        /*!< Pending bit for line 15 */
  3370. #define  EXTI_PR_PR16                        ((uint32_t)0x00010000)        /*!< Pending bit for line 16 */
  3371. #define  EXTI_PR_PR17                        ((uint32_t)0x00020000)        /*!< Pending bit for line 17 */
  3372. #define  EXTI_PR_PR18                        ((uint32_t)0x00040000)        /*!< Pending bit for line 18 */
  3373. #define  EXTI_PR_PR19                        ((uint32_t)0x00080000)        /*!< Pending bit for line 19 */
  3374.  
  3375. /******************************************************************************/
  3376. /*                                                                            */
  3377. /*                             DMA Controller                                 */
  3378. /*                                                                            */
  3379. /******************************************************************************/
  3380.  
  3381. /*******************  Bit definition for DMA_ISR register  ********************/
  3382. #define  DMA_ISR_GIF1                        ((uint32_t)0x00000001)        /*!< Channel 1 Global interrupt flag */
  3383. #define  DMA_ISR_TCIF1                       ((uint32_t)0x00000002)        /*!< Channel 1 Transfer Complete flag */
  3384. #define  DMA_ISR_HTIF1                       ((uint32_t)0x00000004)        /*!< Channel 1 Half Transfer flag */
  3385. #define  DMA_ISR_TEIF1                       ((uint32_t)0x00000008)        /*!< Channel 1 Transfer Error flag */
  3386. #define  DMA_ISR_GIF2                        ((uint32_t)0x00000010)        /*!< Channel 2 Global interrupt flag */
  3387. #define  DMA_ISR_TCIF2                       ((uint32_t)0x00000020)        /*!< Channel 2 Transfer Complete flag */
  3388. #define  DMA_ISR_HTIF2                       ((uint32_t)0x00000040)        /*!< Channel 2 Half Transfer flag */
  3389. #define  DMA_ISR_TEIF2                       ((uint32_t)0x00000080)        /*!< Channel 2 Transfer Error flag */
  3390. #define  DMA_ISR_GIF3                        ((uint32_t)0x00000100)        /*!< Channel 3 Global interrupt flag */
  3391. #define  DMA_ISR_TCIF3                       ((uint32_t)0x00000200)        /*!< Channel 3 Transfer Complete flag */
  3392. #define  DMA_ISR_HTIF3                       ((uint32_t)0x00000400)        /*!< Channel 3 Half Transfer flag */
  3393. #define  DMA_ISR_TEIF3                       ((uint32_t)0x00000800)        /*!< Channel 3 Transfer Error flag */
  3394. #define  DMA_ISR_GIF4                        ((uint32_t)0x00001000)        /*!< Channel 4 Global interrupt flag */
  3395. #define  DMA_ISR_TCIF4                       ((uint32_t)0x00002000)        /*!< Channel 4 Transfer Complete flag */
  3396. #define  DMA_ISR_HTIF4                       ((uint32_t)0x00004000)        /*!< Channel 4 Half Transfer flag */
  3397. #define  DMA_ISR_TEIF4                       ((uint32_t)0x00008000)        /*!< Channel 4 Transfer Error flag */
  3398. #define  DMA_ISR_GIF5                        ((uint32_t)0x00010000)        /*!< Channel 5 Global interrupt flag */
  3399. #define  DMA_ISR_TCIF5                       ((uint32_t)0x00020000)        /*!< Channel 5 Transfer Complete flag */
  3400. #define  DMA_ISR_HTIF5                       ((uint32_t)0x00040000)        /*!< Channel 5 Half Transfer flag */
  3401. #define  DMA_ISR_TEIF5                       ((uint32_t)0x00080000)        /*!< Channel 5 Transfer Error flag */
  3402. #define  DMA_ISR_GIF6                        ((uint32_t)0x00100000)        /*!< Channel 6 Global interrupt flag */
  3403. #define  DMA_ISR_TCIF6                       ((uint32_t)0x00200000)        /*!< Channel 6 Transfer Complete flag */
  3404. #define  DMA_ISR_HTIF6                       ((uint32_t)0x00400000)        /*!< Channel 6 Half Transfer flag */
  3405. #define  DMA_ISR_TEIF6                       ((uint32_t)0x00800000)        /*!< Channel 6 Transfer Error flag */
  3406. #define  DMA_ISR_GIF7                        ((uint32_t)0x01000000)        /*!< Channel 7 Global interrupt flag */
  3407. #define  DMA_ISR_TCIF7                       ((uint32_t)0x02000000)        /*!< Channel 7 Transfer Complete flag */
  3408. #define  DMA_ISR_HTIF7                       ((uint32_t)0x04000000)        /*!< Channel 7 Half Transfer flag */
  3409. #define  DMA_ISR_TEIF7                       ((uint32_t)0x08000000)        /*!< Channel 7 Transfer Error flag */
  3410.  
  3411. /*******************  Bit definition for DMA_IFCR register  *******************/
  3412. #define  DMA_IFCR_CGIF1                      ((uint32_t)0x00000001)        /*!< Channel 1 Global interrupt clear */
  3413. #define  DMA_IFCR_CTCIF1                     ((uint32_t)0x00000002)        /*!< Channel 1 Transfer Complete clear */
  3414. #define  DMA_IFCR_CHTIF1                     ((uint32_t)0x00000004)        /*!< Channel 1 Half Transfer clear */
  3415. #define  DMA_IFCR_CTEIF1                     ((uint32_t)0x00000008)        /*!< Channel 1 Transfer Error clear */
  3416. #define  DMA_IFCR_CGIF2                      ((uint32_t)0x00000010)        /*!< Channel 2 Global interrupt clear */
  3417. #define  DMA_IFCR_CTCIF2                     ((uint32_t)0x00000020)        /*!< Channel 2 Transfer Complete clear */
  3418. #define  DMA_IFCR_CHTIF2                     ((uint32_t)0x00000040)        /*!< Channel 2 Half Transfer clear */
  3419. #define  DMA_IFCR_CTEIF2                     ((uint32_t)0x00000080)        /*!< Channel 2 Transfer Error clear */
  3420. #define  DMA_IFCR_CGIF3                      ((uint32_t)0x00000100)        /*!< Channel 3 Global interrupt clear */
  3421. #define  DMA_IFCR_CTCIF3                     ((uint32_t)0x00000200)        /*!< Channel 3 Transfer Complete clear */
  3422. #define  DMA_IFCR_CHTIF3                     ((uint32_t)0x00000400)        /*!< Channel 3 Half Transfer clear */
  3423. #define  DMA_IFCR_CTEIF3                     ((uint32_t)0x00000800)        /*!< Channel 3 Transfer Error clear */
  3424. #define  DMA_IFCR_CGIF4                      ((uint32_t)0x00001000)        /*!< Channel 4 Global interrupt clear */
  3425. #define  DMA_IFCR_CTCIF4                     ((uint32_t)0x00002000)        /*!< Channel 4 Transfer Complete clear */
  3426. #define  DMA_IFCR_CHTIF4                     ((uint32_t)0x00004000)        /*!< Channel 4 Half Transfer clear */
  3427. #define  DMA_IFCR_CTEIF4                     ((uint32_t)0x00008000)        /*!< Channel 4 Transfer Error clear */
  3428. #define  DMA_IFCR_CGIF5                      ((uint32_t)0x00010000)        /*!< Channel 5 Global interrupt clear */
  3429. #define  DMA_IFCR_CTCIF5                     ((uint32_t)0x00020000)        /*!< Channel 5 Transfer Complete clear */
  3430. #define  DMA_IFCR_CHTIF5                     ((uint32_t)0x00040000)        /*!< Channel 5 Half Transfer clear */
  3431. #define  DMA_IFCR_CTEIF5                     ((uint32_t)0x00080000)        /*!< Channel 5 Transfer Error clear */
  3432. #define  DMA_IFCR_CGIF6                      ((uint32_t)0x00100000)        /*!< Channel 6 Global interrupt clear */
  3433. #define  DMA_IFCR_CTCIF6                     ((uint32_t)0x00200000)        /*!< Channel 6 Transfer Complete clear */
  3434. #define  DMA_IFCR_CHTIF6                     ((uint32_t)0x00400000)        /*!< Channel 6 Half Transfer clear */
  3435. #define  DMA_IFCR_CTEIF6                     ((uint32_t)0x00800000)        /*!< Channel 6 Transfer Error clear */
  3436. #define  DMA_IFCR_CGIF7                      ((uint32_t)0x01000000)        /*!< Channel 7 Global interrupt clear */
  3437. #define  DMA_IFCR_CTCIF7                     ((uint32_t)0x02000000)        /*!< Channel 7 Transfer Complete clear */
  3438. #define  DMA_IFCR_CHTIF7                     ((uint32_t)0x04000000)        /*!< Channel 7 Half Transfer clear */
  3439. #define  DMA_IFCR_CTEIF7                     ((uint32_t)0x08000000)        /*!< Channel 7 Transfer Error clear */
  3440.  
  3441. /*******************  Bit definition for DMA_CCR1 register  *******************/
  3442. #define  DMA_CCR1_EN                         ((uint16_t)0x0001)            /*!< Channel enable*/
  3443. #define  DMA_CCR1_TCIE                       ((uint16_t)0x0002)            /*!< Transfer complete interrupt enable */
  3444. #define  DMA_CCR1_HTIE                       ((uint16_t)0x0004)            /*!< Half Transfer interrupt enable */
  3445. #define  DMA_CCR1_TEIE                       ((uint16_t)0x0008)            /*!< Transfer error interrupt enable */
  3446. #define  DMA_CCR1_DIR                        ((uint16_t)0x0010)            /*!< Data transfer direction */
  3447. #define  DMA_CCR1_CIRC                       ((uint16_t)0x0020)            /*!< Circular mode */
  3448. #define  DMA_CCR1_PINC                       ((uint16_t)0x0040)            /*!< Peripheral increment mode */
  3449. #define  DMA_CCR1_MINC                       ((uint16_t)0x0080)            /*!< Memory increment mode */
  3450.  
  3451. #define  DMA_CCR1_PSIZE                      ((uint16_t)0x0300)            /*!< PSIZE[1:0] bits (Peripheral size) */
  3452. #define  DMA_CCR1_PSIZE_0                    ((uint16_t)0x0100)            /*!< Bit 0 */
  3453. #define  DMA_CCR1_PSIZE_1                    ((uint16_t)0x0200)            /*!< Bit 1 */
  3454.  
  3455. #define  DMA_CCR1_MSIZE                      ((uint16_t)0x0C00)            /*!< MSIZE[1:0] bits (Memory size) */
  3456. #define  DMA_CCR1_MSIZE_0                    ((uint16_t)0x0400)            /*!< Bit 0 */
  3457. #define  DMA_CCR1_MSIZE_1                    ((uint16_t)0x0800)            /*!< Bit 1 */
  3458.  
  3459. #define  DMA_CCR1_PL                         ((uint16_t)0x3000)            /*!< PL[1:0] bits(Channel Priority level) */
  3460. #define  DMA_CCR1_PL_0                       ((uint16_t)0x1000)            /*!< Bit 0 */
  3461. #define  DMA_CCR1_PL_1                       ((uint16_t)0x2000)            /*!< Bit 1 */
  3462.  
  3463. #define  DMA_CCR1_MEM2MEM                    ((uint16_t)0x4000)            /*!< Memory to memory mode */
  3464.  
  3465. /*******************  Bit definition for DMA_CCR2 register  *******************/
  3466. #define  DMA_CCR2_EN                         ((uint16_t)0x0001)            /*!< Channel enable */
  3467. #define  DMA_CCR2_TCIE                       ((uint16_t)0x0002)            /*!< Transfer complete interrupt enable */
  3468. #define  DMA_CCR2_HTIE                       ((uint16_t)0x0004)            /*!< Half Transfer interrupt enable */
  3469. #define  DMA_CCR2_TEIE                       ((uint16_t)0x0008)            /*!< Transfer error interrupt enable */
  3470. #define  DMA_CCR2_DIR                        ((uint16_t)0x0010)            /*!< Data transfer direction */
  3471. #define  DMA_CCR2_CIRC                       ((uint16_t)0x0020)            /*!< Circular mode */
  3472. #define  DMA_CCR2_PINC                       ((uint16_t)0x0040)            /*!< Peripheral increment mode */
  3473. #define  DMA_CCR2_MINC                       ((uint16_t)0x0080)            /*!< Memory increment mode */
  3474.  
  3475. #define  DMA_CCR2_PSIZE                      ((uint16_t)0x0300)            /*!< PSIZE[1:0] bits (Peripheral size) */
  3476. #define  DMA_CCR2_PSIZE_0                    ((uint16_t)0x0100)            /*!< Bit 0 */
  3477. #define  DMA_CCR2_PSIZE_1                    ((uint16_t)0x0200)            /*!< Bit 1 */
  3478.  
  3479. #define  DMA_CCR2_MSIZE                      ((uint16_t)0x0C00)            /*!< MSIZE[1:0] bits (Memory size) */
  3480. #define  DMA_CCR2_MSIZE_0                    ((uint16_t)0x0400)            /*!< Bit 0 */
  3481. #define  DMA_CCR2_MSIZE_1                    ((uint16_t)0x0800)            /*!< Bit 1 */
  3482.  
  3483. #define  DMA_CCR2_PL                         ((uint16_t)0x3000)            /*!< PL[1:0] bits (Channel Priority level) */
  3484. #define  DMA_CCR2_PL_0                       ((uint16_t)0x1000)            /*!< Bit 0 */
  3485. #define  DMA_CCR2_PL_1                       ((uint16_t)0x2000)            /*!< Bit 1 */
  3486.  
  3487. #define  DMA_CCR2_MEM2MEM                    ((uint16_t)0x4000)            /*!< Memory to memory mode */
  3488.  
  3489. /*******************  Bit definition for DMA_CCR3 register  *******************/
  3490. #define  DMA_CCR3_EN                         ((uint16_t)0x0001)            /*!< Channel enable */
  3491. #define  DMA_CCR3_TCIE                       ((uint16_t)0x0002)            /*!< Transfer complete interrupt enable */
  3492. #define  DMA_CCR3_HTIE                       ((uint16_t)0x0004)            /*!< Half Transfer interrupt enable */
  3493. #define  DMA_CCR3_TEIE                       ((uint16_t)0x0008)            /*!< Transfer error interrupt enable */
  3494. #define  DMA_CCR3_DIR                        ((uint16_t)0x0010)            /*!< Data transfer direction */
  3495. #define  DMA_CCR3_CIRC                       ((uint16_t)0x0020)            /*!< Circular mode */
  3496. #define  DMA_CCR3_PINC                       ((uint16_t)0x0040)            /*!< Peripheral increment mode */
  3497. #define  DMA_CCR3_MINC                       ((uint16_t)0x0080)            /*!< Memory increment mode */
  3498.  
  3499. #define  DMA_CCR3_PSIZE                      ((uint16_t)0x0300)            /*!< PSIZE[1:0] bits (Peripheral size) */
  3500. #define  DMA_CCR3_PSIZE_0                    ((uint16_t)0x0100)            /*!< Bit 0 */
  3501. #define  DMA_CCR3_PSIZE_1                    ((uint16_t)0x0200)            /*!< Bit 1 */
  3502.  
  3503. #define  DMA_CCR3_MSIZE                      ((uint16_t)0x0C00)            /*!< MSIZE[1:0] bits (Memory size) */
  3504. #define  DMA_CCR3_MSIZE_0                    ((uint16_t)0x0400)            /*!< Bit 0 */
  3505. #define  DMA_CCR3_MSIZE_1                    ((uint16_t)0x0800)            /*!< Bit 1 */
  3506.  
  3507. #define  DMA_CCR3_PL                         ((uint16_t)0x3000)            /*!< PL[1:0] bits (Channel Priority level) */
  3508. #define  DMA_CCR3_PL_0                       ((uint16_t)0x1000)            /*!< Bit 0 */
  3509. #define  DMA_CCR3_PL_1                       ((uint16_t)0x2000)            /*!< Bit 1 */
  3510.  
  3511. #define  DMA_CCR3_MEM2MEM                    ((uint16_t)0x4000)            /*!< Memory to memory mode */
  3512.  
  3513. /*!<******************  Bit definition for DMA_CCR4 register  *******************/
  3514. #define  DMA_CCR4_EN                         ((uint16_t)0x0001)            /*!< Channel enable */
  3515. #define  DMA_CCR4_TCIE                       ((uint16_t)0x0002)            /*!< Transfer complete interrupt enable */
  3516. #define  DMA_CCR4_HTIE                       ((uint16_t)0x0004)            /*!< Half Transfer interrupt enable */
  3517. #define  DMA_CCR4_TEIE                       ((uint16_t)0x0008)            /*!< Transfer error interrupt enable */
  3518. #define  DMA_CCR4_DIR                        ((uint16_t)0x0010)            /*!< Data transfer direction */
  3519. #define  DMA_CCR4_CIRC                       ((uint16_t)0x0020)            /*!< Circular mode */
  3520. #define  DMA_CCR4_PINC                       ((uint16_t)0x0040)            /*!< Peripheral increment mode */
  3521. #define  DMA_CCR4_MINC                       ((uint16_t)0x0080)            /*!< Memory increment mode */
  3522.  
  3523. #define  DMA_CCR4_PSIZE                      ((uint16_t)0x0300)            /*!< PSIZE[1:0] bits (Peripheral size) */
  3524. #define  DMA_CCR4_PSIZE_0                    ((uint16_t)0x0100)            /*!< Bit 0 */
  3525. #define  DMA_CCR4_PSIZE_1                    ((uint16_t)0x0200)            /*!< Bit 1 */
  3526.  
  3527. #define  DMA_CCR4_MSIZE                      ((uint16_t)0x0C00)            /*!< MSIZE[1:0] bits (Memory size) */
  3528. #define  DMA_CCR4_MSIZE_0                    ((uint16_t)0x0400)            /*!< Bit 0 */
  3529. #define  DMA_CCR4_MSIZE_1                    ((uint16_t)0x0800)            /*!< Bit 1 */
  3530.  
  3531. #define  DMA_CCR4_PL                         ((uint16_t)0x3000)            /*!< PL[1:0] bits (Channel Priority level) */
  3532. #define  DMA_CCR4_PL_0                       ((uint16_t)0x1000)            /*!< Bit 0 */
  3533. #define  DMA_CCR4_PL_1                       ((uint16_t)0x2000)            /*!< Bit 1 */
  3534.  
  3535. #define  DMA_CCR4_MEM2MEM                    ((uint16_t)0x4000)            /*!< Memory to memory mode */
  3536.  
  3537. /******************  Bit definition for DMA_CCR5 register  *******************/
  3538. #define  DMA_CCR5_EN                         ((uint16_t)0x0001)            /*!< Channel enable */
  3539. #define  DMA_CCR5_TCIE                       ((uint16_t)0x0002)            /*!< Transfer complete interrupt enable */
  3540. #define  DMA_CCR5_HTIE                       ((uint16_t)0x0004)            /*!< Half Transfer interrupt enable */
  3541. #define  DMA_CCR5_TEIE                       ((uint16_t)0x0008)            /*!< Transfer error interrupt enable */
  3542. #define  DMA_CCR5_DIR                        ((uint16_t)0x0010)            /*!< Data transfer direction */
  3543. #define  DMA_CCR5_CIRC                       ((uint16_t)0x0020)            /*!< Circular mode */
  3544. #define  DMA_CCR5_PINC                       ((uint16_t)0x0040)            /*!< Peripheral increment mode */
  3545. #define  DMA_CCR5_MINC                       ((uint16_t)0x0080)            /*!< Memory increment mode */
  3546.  
  3547. #define  DMA_CCR5_PSIZE                      ((uint16_t)0x0300)            /*!< PSIZE[1:0] bits (Peripheral size) */
  3548. #define  DMA_CCR5_PSIZE_0                    ((uint16_t)0x0100)            /*!< Bit 0 */
  3549. #define  DMA_CCR5_PSIZE_1                    ((uint16_t)0x0200)            /*!< Bit 1 */
  3550.  
  3551. #define  DMA_CCR5_MSIZE                      ((uint16_t)0x0C00)            /*!< MSIZE[1:0] bits (Memory size) */
  3552. #define  DMA_CCR5_MSIZE_0                    ((uint16_t)0x0400)            /*!< Bit 0 */
  3553. #define  DMA_CCR5_MSIZE_1                    ((uint16_t)0x0800)            /*!< Bit 1 */
  3554.  
  3555. #define  DMA_CCR5_PL                         ((uint16_t)0x3000)            /*!< PL[1:0] bits (Channel Priority level) */
  3556. #define  DMA_CCR5_PL_0                       ((uint16_t)0x1000)            /*!< Bit 0 */
  3557. #define  DMA_CCR5_PL_1                       ((uint16_t)0x2000)            /*!< Bit 1 */
  3558.  
  3559. #define  DMA_CCR5_MEM2MEM                    ((uint16_t)0x4000)            /*!< Memory to memory mode enable */
  3560.  
  3561. /*******************  Bit definition for DMA_CCR6 register  *******************/
  3562. #define  DMA_CCR6_EN                         ((uint16_t)0x0001)            /*!< Channel enable */
  3563. #define  DMA_CCR6_TCIE                       ((uint16_t)0x0002)            /*!< Transfer complete interrupt enable */
  3564. #define  DMA_CCR6_HTIE                       ((uint16_t)0x0004)            /*!< Half Transfer interrupt enable */
  3565. #define  DMA_CCR6_TEIE                       ((uint16_t)0x0008)            /*!< Transfer error interrupt enable */
  3566. #define  DMA_CCR6_DIR                        ((uint16_t)0x0010)            /*!< Data transfer direction */
  3567. #define  DMA_CCR6_CIRC                       ((uint16_t)0x0020)            /*!< Circular mode */
  3568. #define  DMA_CCR6_PINC                       ((uint16_t)0x0040)            /*!< Peripheral increment mode */
  3569. #define  DMA_CCR6_MINC                       ((uint16_t)0x0080)            /*!< Memory increment mode */
  3570.  
  3571. #define  DMA_CCR6_PSIZE                      ((uint16_t)0x0300)            /*!< PSIZE[1:0] bits (Peripheral size) */
  3572. #define  DMA_CCR6_PSIZE_0                    ((uint16_t)0x0100)            /*!< Bit 0 */
  3573. #define  DMA_CCR6_PSIZE_1                    ((uint16_t)0x0200)            /*!< Bit 1 */
  3574.  
  3575. #define  DMA_CCR6_MSIZE                      ((uint16_t)0x0C00)            /*!< MSIZE[1:0] bits (Memory size) */
  3576. #define  DMA_CCR6_MSIZE_0                    ((uint16_t)0x0400)            /*!< Bit 0 */
  3577. #define  DMA_CCR6_MSIZE_1                    ((uint16_t)0x0800)            /*!< Bit 1 */
  3578.  
  3579. #define  DMA_CCR6_PL                         ((uint16_t)0x3000)            /*!< PL[1:0] bits (Channel Priority level) */
  3580. #define  DMA_CCR6_PL_0                       ((uint16_t)0x1000)            /*!< Bit 0 */
  3581. #define  DMA_CCR6_PL_1                       ((uint16_t)0x2000)            /*!< Bit 1 */
  3582.  
  3583. #define  DMA_CCR6_MEM2MEM                    ((uint16_t)0x4000)            /*!< Memory to memory mode */
  3584.  
  3585. /*******************  Bit definition for DMA_CCR7 register  *******************/
  3586. #define  DMA_CCR7_EN                         ((uint16_t)0x0001)            /*!< Channel enable */
  3587. #define  DMA_CCR7_TCIE                       ((uint16_t)0x0002)            /*!< Transfer complete interrupt enable */
  3588. #define  DMA_CCR7_HTIE                       ((uint16_t)0x0004)            /*!< Half Transfer interrupt enable */
  3589. #define  DMA_CCR7_TEIE                       ((uint16_t)0x0008)            /*!< Transfer error interrupt enable */
  3590. #define  DMA_CCR7_DIR                        ((uint16_t)0x0010)            /*!< Data transfer direction */
  3591. #define  DMA_CCR7_CIRC                       ((uint16_t)0x0020)            /*!< Circular mode */
  3592. #define  DMA_CCR7_PINC                       ((uint16_t)0x0040)            /*!< Peripheral increment mode */
  3593. #define  DMA_CCR7_MINC                       ((uint16_t)0x0080)            /*!< Memory increment mode */
  3594.  
  3595. #define  DMA_CCR7_PSIZE            ,         ((uint16_t)0x0300)            /*!< PSIZE[1:0] bits (Peripheral size) */
  3596. #define  DMA_CCR7_PSIZE_0                    ((uint16_t)0x0100)            /*!< Bit 0 */
  3597. #define  DMA_CCR7_PSIZE_1                    ((uint16_t)0x0200)            /*!< Bit 1 */
  3598.  
  3599. #define  DMA_CCR7_MSIZE                      ((uint16_t)0x0C00)            /*!< MSIZE[1:0] bits (Memory size) */
  3600. #define  DMA_CCR7_MSIZE_0                    ((uint16_t)0x0400)            /*!< Bit 0 */
  3601. #define  DMA_CCR7_MSIZE_1                    ((uint16_t)0x0800)            /*!< Bit 1 */
  3602.  
  3603. #define  DMA_CCR7_PL                         ((uint16_t)0x3000)            /*!< PL[1:0] bits (Channel Priority level) */
  3604. #define  DMA_CCR7_PL_0                       ((uint16_t)0x1000)            /*!< Bit 0 */
  3605. #define  DMA_CCR7_PL_1                       ((uint16_t)0x2000)            /*!< Bit 1 */
  3606.  
  3607. #define  DMA_CCR7_MEM2MEM                    ((uint16_t)0x4000)            /*!< Memory to memory mode enable */
  3608.  
  3609. /******************  Bit definition for DMA_CNDTR1 register  ******************/
  3610. #define  DMA_CNDTR1_NDT                      ((uint16_t)0xFFFF)            /*!< Number of data to Transfer */
  3611.  
  3612. /******************  Bit definition for DMA_CNDTR2 register  ******************/
  3613. #define  DMA_CNDTR2_NDT                      ((uint16_t)0xFFFF)            /*!< Number of data to Transfer */
  3614.  
  3615. /******************  Bit definition for DMA_CNDTR3 register  ******************/
  3616. #define  DMA_CNDTR3_NDT                      ((uint16_t)0xFFFF)            /*!< Number of data to Transfer */
  3617.  
  3618. /******************  Bit definition for DMA_CNDTR4 register  ******************/
  3619. #define  DMA_CNDTR4_NDT                      ((uint16_t)0xFFFF)            /*!< Number of data to Transfer */
  3620.  
  3621. /******************  Bit definition for DMA_CNDTR5 register  ******************/
  3622. #define  DMA_CNDTR5_NDT                      ((uint16_t)0xFFFF)            /*!< Number of data to Transfer */
  3623.  
  3624. /******************  Bit definition for DMA_CNDTR6 register  ******************/
  3625. #define  DMA_CNDTR6_NDT                      ((uint16_t)0xFFFF)            /*!< Number of data to Transfer */
  3626.  
  3627. /******************  Bit definition for DMA_CNDTR7 register  ******************/
  3628. #define  DMA_CNDTR7_NDT                      ((uint16_t)0xFFFF)            /*!< Number of data to Transfer */
  3629.  
  3630. /******************  Bit definition for DMA_CPAR1 register  *******************/
  3631. #define  DMA_CPAR1_PA                        ((uint32_t)0xFFFFFFFF)        /*!< Peripheral Address */
  3632.  
  3633. /******************  Bit definition for DMA_CPAR2 register  *******************/
  3634. #define  DMA_CPAR2_PA                        ((uint32_t)0xFFFFFFFF)        /*!< Peripheral Address */
  3635.  
  3636. /******************  Bit definition for DMA_CPAR3 register  *******************/
  3637. #define  DMA_CPAR3_PA                        ((uint32_t)0xFFFFFFFF)        /*!< Peripheral Address */
  3638.  
  3639.  
  3640. /******************  Bit definition for DMA_CPAR4 register  *******************/
  3641. #define  DMA_CPAR4_PA                        ((uint32_t)0xFFFFFFFF)        /*!< Peripheral Address */
  3642.  
  3643. /******************  Bit definition for DMA_CPAR5 register  *******************/
  3644. #define  DMA_CPAR5_PA                        ((uint32_t)0xFFFFFFFF)        /*!< Peripheral Address */
  3645.  
  3646. /******************  Bit definition for DMA_CPAR6 register  *******************/
  3647. #define  DMA_CPAR6_PA                        ((uint32_t)0xFFFFFFFF)        /*!< Peripheral Address */
  3648.  
  3649.  
  3650. /******************  Bit definition for DMA_CPAR7 register  *******************/
  3651. #define  DMA_CPAR7_PA                        ((uint32_t)0xFFFFFFFF)        /*!< Peripheral Address */
  3652.  
  3653. /******************  Bit definition for DMA_CMAR1 register  *******************/
  3654. #define  DMA_CMAR1_MA                        ((uint32_t)0xFFFFFFFF)        /*!< Memory Address */
  3655.  
  3656. /******************  Bit definition for DMA_CMAR2 register  *******************/
  3657. #define  DMA_CMAR2_MA                        ((uint32_t)0xFFFFFFFF)        /*!< Memory Address */
  3658.  
  3659. /******************  Bit definition for DMA_CMAR3 register  *******************/
  3660. #define  DMA_CMAR3_MA                        ((uint32_t)0xFFFFFFFF)        /*!< Memory Address */
  3661.  
  3662.  
  3663. /******************  Bit definition for DMA_CMAR4 register  *******************/
  3664. #define  DMA_CMAR4_MA                        ((uint32_t)0xFFFFFFFF)        /*!< Memory Address */
  3665.  
  3666. /******************  Bit definition for DMA_CMAR5 register  *******************/
  3667. #define  DMA_CMAR5_MA                        ((uint32_t)0xFFFFFFFF)        /*!< Memory Address */
  3668.  
  3669. /******************  Bit definition for DMA_CMAR6 register  *******************/
  3670. #define  DMA_CMAR6_MA                        ((uint32_t)0xFFFFFFFF)        /*!< Memory Address */
  3671.  
  3672. /******************  Bit definition for DMA_CMAR7 register  *******************/
  3673. #define  DMA_CMAR7_MA                        ((uint32_t)0xFFFFFFFF)        /*!< Memory Address */
  3674.  
  3675. /******************************************************************************/
  3676. /*                                                                            */
  3677. /*                        Analog to Digital Converter                         */
  3678. /*                                                                            */
  3679. /******************************************************************************/
  3680.  
  3681. /********************  Bit definition for ADC_SR register  ********************/
  3682. #define  ADC_SR_AWD                          ((uint8_t)0x01)               /*!< Analog watchdog flag */
  3683. #define  ADC_SR_EOC                          ((uint8_t)0x02)               /*!< End of conversion */
  3684. #define  ADC_SR_JEOC                         ((uint8_t)0x04)               /*!< Injected channel end of conversion */
  3685. #define  ADC_SR_JSTRT                        ((uint8_t)0x08)               /*!< Injected channel Start flag */
  3686. #define  ADC_SR_STRT                         ((uint8_t)0x10)               /*!< Regular channel Start flag */
  3687.  
  3688. /*******************  Bit definition for ADC_CR1 register  ********************/
  3689. #define  ADC_CR1_AWDCH                       ((uint32_t)0x0000001F)        /*!< AWDCH[4:0] bits (Analog watchdog channel select bits) */
  3690. #define  ADC_CR1_AWDCH_0                     ((uint32_t)0x00000001)        /*!< Bit 0 */
  3691. #define  ADC_CR1_AWDCH_1                     ((uint32_t)0x00000002)        /*!< Bit 1 */
  3692. #define  ADC_CR1_AWDCH_2                     ((uint32_t)0x00000004)        /*!< Bit 2 */
  3693. #define  ADC_CR1_AWDCH_3                     ((uint32_t)0x00000008)        /*!< Bit 3 */
  3694. #define  ADC_CR1_AWDCH_4                     ((uint32_t)0x00000010)        /*!< Bit 4 */
  3695.  
  3696. #define  ADC_CR1_EOCIE                       ((uint32_t)0x00000020)        /*!< Interrupt enable for EOC */
  3697. #define  ADC_CR1_AWDIE                       ((uint32_t)0x00000040)        /*!< Analog Watchdog interrupt enable */
  3698. #define  ADC_CR1_JEOCIE                      ((uint32_t)0x00000080)        /*!< Interrupt enable for injected channels */
  3699. #define  ADC_CR1_SCAN                        ((uint32_t)0x00000100)        /*!< Scan mode */
  3700. #define  ADC_CR1_AWDSGL                      ((uint32_t)0x00000200)        /*!< Enable the watchdog on a single channel in scan mode */
  3701. #define  ADC_CR1_JAUTO                       ((uint32_t)0x00000400)        /*!< Automatic injected group conversion */
  3702. #define  ADC_CR1_DISCEN                      ((uint32_t)0x00000800)        /*!< Discontinuous mode on regular channels */
  3703. #define  ADC_CR1_JDISCEN                     ((uint32_t)0x00001000)        /*!< Discontinuous mode on injected channels */
  3704.  
  3705. #define  ADC_CR1_DISCNUM                     ((uint32_t)0x0000E000)        /*!< DISCNUM[2:0] bits (Discontinuous mode channel count) */
  3706. #define  ADC_CR1_DISCNUM_0                   ((uint32_t)0x00002000)        /*!< Bit 0 */
  3707. #define  ADC_CR1_DISCNUM_1                   ((uint32_t)0x00004000)        /*!< Bit 1 */
  3708. #define  ADC_CR1_DISCNUM_2                   ((uint32_t)0x00008000)        /*!< Bit 2 */
  3709.  
  3710. #define  ADC_CR1_DUALMOD                     ((uint32_t)0x000F0000)        /*!< DUALMOD[3:0] bits (Dual mode selection) */
  3711. #define  ADC_CR1_DUALMOD_0                   ((uint32_t)0x00010000)        /*!< Bit 0 */
  3712. #define  ADC_CR1_DUALMOD_1                   ((uint32_t)0x00020000)        /*!< Bit 1 */
  3713. #define  ADC_CR1_DUALMOD_2                   ((uint32_t)0x00040000)        /*!< Bit 2 */
  3714. #define  ADC_CR1_DUALMOD_3                   ((uint32_t)0x00080000)        /*!< Bit 3 */
  3715.  
  3716. #define  ADC_CR1_JAWDEN                      ((uint32_t)0x00400000)        /*!< Analog watchdog enable on injected channels */
  3717. #define  ADC_CR1_AWDEN                       ((uint32_t)0x00800000)        /*!< Analog watchdog enable on regular channels */
  3718.  
  3719.  
  3720. /*******************  Bit definition for ADC_CR2 register  ********************/
  3721. #define  ADC_CR2_ADON                        ((uint32_t)0x00000001)        /*!< A/D Converter ON / OFF */
  3722. #define  ADC_CR2_CONT                        ((uint32_t)0x00000002)        /*!< Continuous Conversion */
  3723. #define  ADC_CR2_CAL                         ((uint32_t)0x00000004)        /*!< A/D Calibration */
  3724. #define  ADC_CR2_RSTCAL                      ((uint32_t)0x00000008)        /*!< Reset Calibration */
  3725. #define  ADC_CR2_DMA                         ((uint32_t)0x00000100)        /*!< Direct Memory access mode */
  3726. #define  ADC_CR2_ALIGN                       ((uint32_t)0x00000800)        /*!< Data Alignment */
  3727.  
  3728. #define  ADC_CR2_JEXTSEL                     ((uint32_t)0x00007000)        /*!< JEXTSEL[2:0] bits (External event select for injected group) */
  3729. #define  ADC_CR2_JEXTSEL_0                   ((uint32_t)0x00001000)        /*!< Bit 0 */
  3730. #define  ADC_CR2_JEXTSEL_1                   ((uint32_t)0x00002000)        /*!< Bit 1 */
  3731. #define  ADC_CR2_JEXTSEL_2                   ((uint32_t)0x00004000)        /*!< Bit 2 */
  3732.  
  3733. #define  ADC_CR2_JEXTTRIG                    ((uint32_t)0x00008000)        /*!< External Trigger Conversion mode for injected channels */
  3734.  
  3735. #define  ADC_CR2_EXTSEL                      ((uint32_t)0x000E0000)        /*!< EXTSEL[2:0] bits (External Event Select for regular group) */
  3736. #define  ADC_CR2_EXTSEL_0                    ((uint32_t)0x00020000)        /*!< Bit 0 */
  3737. #define  ADC_CR2_EXTSEL_1                    ((uint32_t)0x00040000)        /*!< Bit 1 */
  3738. #define  ADC_CR2_EXTSEL_2                    ((uint32_t)0x00080000)        /*!< Bit 2 */
  3739.  
  3740. #define  ADC_CR2_EXTTRIG                     ((uint32_t)0x00100000)        /*!< External Trigger Conversion mode for regular channels */
  3741. #define  ADC_CR2_JSWSTART                    ((uint32_t)0x00200000)        /*!< Start Conversion of injected channels */
  3742. #define  ADC_CR2_SWSTART                     ((uint32_t)0x00400000)        /*!< Start Conversion of regular channels */
  3743. #define  ADC_CR2_TSVREFE                     ((uint32_t)0x00800000)        /*!< Temperature Sensor and VREFINT Enable */
  3744.  
  3745. /******************  Bit definition for ADC_SMPR1 register  *******************/
  3746. #define  ADC_SMPR1_SMP10                     ((uint32_t)0x00000007)        /*!< SMP10[2:0] bits (Channel 10 Sample time selection) */
  3747. #define  ADC_SMPR1_SMP10_0                   ((uint32_t)0x00000001)        /*!< Bit 0 */
  3748. #define  ADC_SMPR1_SMP10_1                   ((uint32_t)0x00000002)        /*!< Bit 1 */
  3749. #define  ADC_SMPR1_SMP10_2                   ((uint32_t)0x00000004)        /*!< Bit 2 */
  3750.  
  3751. #define  ADC_SMPR1_SMP11                     ((uint32_t)0x00000038)        /*!< SMP11[2:0] bits (Channel 11 Sample time selection) */
  3752. #define  ADC_SMPR1_SMP11_0                   ((uint32_t)0x00000008)        /*!< Bit 0 */
  3753. #define  ADC_SMPR1_SMP11_1                   ((uint32_t)0x00000010)        /*!< Bit 1 */
  3754. #define  ADC_SMPR1_SMP11_2                   ((uint32_t)0x00000020)        /*!< Bit 2 */
  3755.  
  3756. #define  ADC_SMPR1_SMP12                     ((uint32_t)0x000001C0)        /*!< SMP12[2:0] bits (Channel 12 Sample time selection) */
  3757. #define  ADC_SMPR1_SMP12_0                   ((uint32_t)0x00000040)        /*!< Bit 0 */
  3758. #define  ADC_SMPR1_SMP12_1                   ((uint32_t)0x00000080)        /*!< Bit 1 */
  3759. #define  ADC_SMPR1_SMP12_2                   ((uint32_t)0x00000100)        /*!< Bit 2 */
  3760.  
  3761. #define  ADC_SMPR1_SMP13                     ((uint32_t)0x00000E00)        /*!< SMP13[2:0] bits (Channel 13 Sample time selection) */
  3762. #define  ADC_SMPR1_SMP13_0                   ((uint32_t)0x00000200)        /*!< Bit 0 */
  3763. #define  ADC_SMPR1_SMP13_1                   ((uint32_t)0x00000400)        /*!< Bit 1 */
  3764. #define  ADC_SMPR1_SMP13_2                   ((uint32_t)0x00000800)        /*!< Bit 2 */
  3765.  
  3766. #define  ADC_SMPR1_SMP14                     ((uint32_t)0x00007000)        /*!< SMP14[2:0] bits (Channel 14 Sample time selection) */
  3767. #define  ADC_SMPR1_SMP14_0                   ((uint32_t)0x00001000)        /*!< Bit 0 */
  3768. #define  ADC_SMPR1_SMP14_1                   ((uint32_t)0x00002000)        /*!< Bit 1 */
  3769. #define  ADC_SMPR1_SMP14_2                   ((uint32_t)0x00004000)        /*!< Bit 2 */
  3770.  
  3771. #define  ADC_SMPR1_SMP15                     ((uint32_t)0x00038000)        /*!< SMP15[2:0] bits (Channel 15 Sample time selection) */
  3772. #define  ADC_SMPR1_SMP15_0                   ((uint32_t)0x00008000)        /*!< Bit 0 */
  3773. #define  ADC_SMPR1_SMP15_1                   ((uint32_t)0x00010000)        /*!< Bit 1 */
  3774. #define  ADC_SMPR1_SMP15_2                   ((uint32_t)0x00020000)        /*!< Bit 2 */
  3775.  
  3776. #define  ADC_SMPR1_SMP16                     ((uint32_t)0x001C0000)        /*!< SMP16[2:0] bits (Channel 16 Sample time selection) */
  3777. #define  ADC_SMPR1_SMP16_0                   ((uint32_t)0x00040000)        /*!< Bit 0 */
  3778. #define  ADC_SMPR1_SMP16_1                   ((uint32_t)0x00080000)        /*!< Bit 1 */
  3779. #define  ADC_SMPR1_SMP16_2                   ((uint32_t)0x00100000)        /*!< Bit 2 */
  3780.  
  3781. #define  ADC_SMPR1_SMP17                     ((uint32_t)0x00E00000)        /*!< SMP17[2:0] bits (Channel 17 Sample time selection) */
  3782. #define  ADC_SMPR1_SMP17_0                   ((uint32_t)0x00200000)        /*!< Bit 0 */
  3783. #define  ADC_SMPR1_SMP17_1                   ((uint32_t)0x00400000)        /*!< Bit 1 */
  3784. #define  ADC_SMPR1_SMP17_2                   ((uint32_t)0x00800000)        /*!< Bit 2 */
  3785.  
  3786. /******************  Bit definition for ADC_SMPR2 register  *******************/
  3787. #define  ADC_SMPR2_SMP0                      ((uint32_t)0x00000007)        /*!< SMP0[2:0] bits (Channel 0 Sample time selection) */
  3788. #define  ADC_SMPR2_SMP0_0                    ((uint32_t)0x00000001)        /*!< Bit 0 */
  3789. #define  ADC_SMPR2_SMP0_1                    ((uint32_t)0x00000002)        /*!< Bit 1 */
  3790. #define  ADC_SMPR2_SMP0_2                    ((uint32_t)0x00000004)        /*!< Bit 2 */
  3791.  
  3792. #define  ADC_SMPR2_SMP1                      ((uint32_t)0x00000038)        /*!< SMP1[2:0] bits (Channel 1 Sample time selection) */
  3793. #define  ADC_SMPR2_SMP1_0                    ((uint32_t)0x00000008)        /*!< Bit 0 */
  3794. #define  ADC_SMPR2_SMP1_1                    ((uint32_t)0x00000010)        /*!< Bit 1 */
  3795. #define  ADC_SMPR2_SMP1_2                    ((uint32_t)0x00000020)        /*!< Bit 2 */
  3796.  
  3797. #define  ADC_SMPR2_SMP2                      ((uint32_t)0x000001C0)        /*!< SMP2[2:0] bits (Channel 2 Sample time selection) */
  3798. #define  ADC_SMPR2_SMP2_0                    ((uint32_t)0x00000040)        /*!< Bit 0 */
  3799. #define  ADC_SMPR2_SMP2_1                    ((uint32_t)0x00000080)        /*!< Bit 1 */
  3800. #define  ADC_SMPR2_SMP2_2                    ((uint32_t)0x00000100)        /*!< Bit 2 */
  3801.  
  3802. #define  ADC_SMPR2_SMP3                      ((uint32_t)0x00000E00)        /*!< SMP3[2:0] bits (Channel 3 Sample time selection) */
  3803. #define  ADC_SMPR2_SMP3_0                    ((uint32_t)0x00000200)        /*!< Bit 0 */
  3804. #define  ADC_SMPR2_SMP3_1                    ((uint32_t)0x00000400)        /*!< Bit 1 */
  3805. #define  ADC_SMPR2_SMP3_2                    ((uint32_t)0x00000800)        /*!< Bit 2 */
  3806.  
  3807. #define  ADC_SMPR2_SMP4                      ((uint32_t)0x00007000)        /*!< SMP4[2:0] bits (Channel 4 Sample time selection) */
  3808. #define  ADC_SMPR2_SMP4_0                    ((uint32_t)0x00001000)        /*!< Bit 0 */
  3809. #define  ADC_SMPR2_SMP4_1                    ((uint32_t)0x00002000)        /*!< Bit 1 */
  3810. #define  ADC_SMPR2_SMP4_2                    ((uint32_t)0x00004000)        /*!< Bit 2 */
  3811.  
  3812. #define  ADC_SMPR2_SMP5                      ((uint32_t)0x00038000)        /*!< SMP5[2:0] bits (Channel 5 Sample time selection) */
  3813. #define  ADC_SMPR2_SMP5_0                    ((uint32_t)0x00008000)        /*!< Bit 0 */
  3814. #define  ADC_SMPR2_SMP5_1                    ((uint32_t)0x00010000)        /*!< Bit 1 */
  3815. #define  ADC_SMPR2_SMP5_2                    ((uint32_t)0x00020000)        /*!< Bit 2 */
  3816.  
  3817. #define  ADC_SMPR2_SMP6                      ((uint32_t)0x001C0000)        /*!< SMP6[2:0] bits (Channel 6 Sample time selection) */
  3818. #define  ADC_SMPR2_SMP6_0                    ((uint32_t)0x00040000)        /*!< Bit 0 */
  3819. #define  ADC_SMPR2_SMP6_1                    ((uint32_t)0x00080000)        /*!< Bit 1 */
  3820. #define  ADC_SMPR2_SMP6_2                    ((uint32_t)0x00100000)        /*!< Bit 2 */
  3821.  
  3822. #define  ADC_SMPR2_SMP7                      ((uint32_t)0x00E00000)        /*!< SMP7[2:0] bits (Channel 7 Sample time selection) */
  3823. #define  ADC_SMPR2_SMP7_0                    ((uint32_t)0x00200000)        /*!< Bit 0 */
  3824. #define  ADC_SMPR2_SMP7_1                    ((uint32_t)0x00400000)        /*!< Bit 1 */
  3825. #define  ADC_SMPR2_SMP7_2                    ((uint32_t)0x00800000)        /*!< Bit 2 */
  3826.  
  3827. #define  ADC_SMPR2_SMP8                      ((uint32_t)0x07000000)        /*!< SMP8[2:0] bits (Channel 8 Sample time selection) */
  3828. #define  ADC_SMPR2_SMP8_0                    ((uint32_t)0x01000000)        /*!< Bit 0 */
  3829. #define  ADC_SMPR2_SMP8_1                    ((uint32_t)0x02000000)        /*!< Bit 1 */
  3830. #define  ADC_SMPR2_SMP8_2                    ((uint32_t)0x04000000)        /*!< Bit 2 */
  3831.  
  3832. #define  ADC_SMPR2_SMP9                      ((uint32_t)0x38000000)        /*!< SMP9[2:0] bits (Channel 9 Sample time selection) */
  3833. #define  ADC_SMPR2_SMP9_0                    ((uint32_t)0x08000000)        /*!< Bit 0 */
  3834. #define  ADC_SMPR2_SMP9_1                    ((uint32_t)0x10000000)        /*!< Bit 1 */
  3835. #define  ADC_SMPR2_SMP9_2                    ((uint32_t)0x20000000)        /*!< Bit 2 */
  3836.  
  3837. /******************  Bit definition for ADC_JOFR1 register  *******************/
  3838. #define  ADC_JOFR1_JOFFSET1                  ((uint16_t)0x0FFF)            /*!< Data offset for injected channel 1 */
  3839.  
  3840. /******************  Bit definition for ADC_JOFR2 register  *******************/
  3841. #define  ADC_JOFR2_JOFFSET2                  ((uint16_t)0x0FFF)            /*!< Data offset for injected channel 2 */
  3842.  
  3843. /******************  Bit definition for ADC_JOFR3 register  *******************/
  3844. #define  ADC_JOFR3_JOFFSET3                  ((uint16_t)0x0FFF)            /*!< Data offset for injected channel 3 */
  3845.  
  3846. /******************  Bit definition for ADC_JOFR4 register  *******************/
  3847. #define  ADC_JOFR4_JOFFSET4                  ((uint16_t)0x0FFF)            /*!< Data offset for injected channel 4 */
  3848.  
  3849. /*******************  Bit definition for ADC_HTR register  ********************/
  3850. #define  ADC_HTR_HT                          ((uint16_t)0x0FFF)            /*!< Analog watchdog high threshold */
  3851.  
  3852. /*******************  Bit definition for ADC_LTR register  ********************/
  3853. #define  ADC_LTR_LT                          ((uint16_t)0x0FFF)            /*!< Analog watchdog low threshold */
  3854.  
  3855. /*******************  Bit definition for ADC_SQR1 register  *******************/
  3856. #define  ADC_SQR1_SQ13                       ((uint32_t)0x0000001F)        /*!< SQ13[4:0] bits (13th conversion in regular sequence) */
  3857. #define  ADC_SQR1_SQ13_0                     ((uint32_t)0x00000001)        /*!< Bit 0 */
  3858. #define  ADC_SQR1_SQ13_1                     ((uint32_t)0x00000002)        /*!< Bit 1 */
  3859. #define  ADC_SQR1_SQ13_2                     ((uint32_t)0x00000004)        /*!< Bit 2 */
  3860. #define  ADC_SQR1_SQ13_3                     ((uint32_t)0x00000008)        /*!< Bit 3 */
  3861. #define  ADC_SQR1_SQ13_4                     ((uint32_t)0x00000010)        /*!< Bit 4 */
  3862.  
  3863. #define  ADC_SQR1_SQ14                       ((uint32_t)0x000003E0)        /*!< SQ14[4:0] bits (14th conversion in regular sequence) */
  3864. #define  ADC_SQR1_SQ14_0                     ((uint32_t)0x00000020)        /*!< Bit 0 */
  3865. #define  ADC_SQR1_SQ14_1                     ((uint32_t)0x00000040)        /*!< Bit 1 */
  3866. #define  ADC_SQR1_SQ14_2                     ((uint32_t)0x00000080)        /*!< Bit 2 */
  3867. #define  ADC_SQR1_SQ14_3                     ((uint32_t)0x00000100)        /*!< Bit 3 */
  3868. #define  ADC_SQR1_SQ14_4                     ((uint32_t)0x00000200)        /*!< Bit 4 */
  3869.  
  3870. #define  ADC_SQR1_SQ15                       ((uint32_t)0x00007C00)        /*!< SQ15[4:0] bits (15th conversion in regular sequence) */
  3871. #define  ADC_SQR1_SQ15_0                     ((uint32_t)0x00000400)        /*!< Bit 0 */
  3872. #define  ADC_SQR1_SQ15_1                     ((uint32_t)0x00000800)        /*!< Bit 1 */
  3873. #define  ADC_SQR1_SQ15_2                     ((uint32_t)0x00001000)        /*!< Bit 2 */
  3874. #define  ADC_SQR1_SQ15_3                     ((uint32_t)0x00002000)        /*!< Bit 3 */
  3875. #define  ADC_SQR1_SQ15_4                     ((uint32_t)0x00004000)        /*!< Bit 4 */
  3876.  
  3877. #define  ADC_SQR1_SQ16                       ((uint32_t)0x000F8000)        /*!< SQ16[4:0] bits (16th conversion in regular sequence) */
  3878. #define  ADC_SQR1_SQ16_0                     ((uint32_t)0x00008000)        /*!< Bit 0 */
  3879. #define  ADC_SQR1_SQ16_1                     ((uint32_t)0x00010000)        /*!< Bit 1 */
  3880. #define  ADC_SQR1_SQ16_2                     ((uint32_t)0x00020000)        /*!< Bit 2 */
  3881. #define  ADC_SQR1_SQ16_3                     ((uint32_t)0x00040000)        /*!< Bit 3 */
  3882. #define  ADC_SQR1_SQ16_4                     ((uint32_t)0x00080000)        /*!< Bit 4 */
  3883.  
  3884. #define  ADC_SQR1_L                          ((uint32_t)0x00F00000)        /*!< L[3:0] bits (Regular channel sequence length) */
  3885. #define  ADC_SQR1_L_0                        ((uint32_t)0x00100000)        /*!< Bit 0 */
  3886. #define  ADC_SQR1_L_1                        ((uint32_t)0x00200000)        /*!< Bit 1 */
  3887. #define  ADC_SQR1_L_2                        ((uint32_t)0x00400000)        /*!< Bit 2 */
  3888. #define  ADC_SQR1_L_3                        ((uint32_t)0x00800000)        /*!< Bit 3 */
  3889.  
  3890. /*******************  Bit definition for ADC_SQR2 register  *******************/
  3891. #define  ADC_SQR2_SQ7                        ((uint32_t)0x0000001F)        /*!< SQ7[4:0] bits (7th conversion in regular sequence) */
  3892. #define  ADC_SQR2_SQ7_0                      ((uint32_t)0x00000001)        /*!< Bit 0 */
  3893. #define  ADC_SQR2_SQ7_1                      ((uint32_t)0x00000002)        /*!< Bit 1 */
  3894. #define  ADC_SQR2_SQ7_2                      ((uint32_t)0x00000004)        /*!< Bit 2 */
  3895. #define  ADC_SQR2_SQ7_3                      ((uint32_t)0x00000008)        /*!< Bit 3 */
  3896. #define  ADC_SQR2_SQ7_4                      ((uint32_t)0x00000010)        /*!< Bit 4 */
  3897.  
  3898. #define  ADC_SQR2_SQ8                        ((uint32_t)0x000003E0)        /*!< SQ8[4:0] bits (8th conversion in regular sequence) */
  3899. #define  ADC_SQR2_SQ8_0                      ((uint32_t)0x00000020)        /*!< Bit 0 */
  3900. #define  ADC_SQR2_SQ8_1                      ((uint32_t)0x00000040)        /*!< Bit 1 */
  3901. #define  ADC_SQR2_SQ8_2                      ((uint32_t)0x00000080)        /*!< Bit 2 */
  3902. #define  ADC_SQR2_SQ8_3                      ((uint32_t)0x00000100)        /*!< Bit 3 */
  3903. #define  ADC_SQR2_SQ8_4                      ((uint32_t)0x00000200)        /*!< Bit 4 */
  3904.  
  3905. #define  ADC_SQR2_SQ9                        ((uint32_t)0x00007C00)        /*!< SQ9[4:0] bits (9th conversion in regular sequence) */
  3906. #define  ADC_SQR2_SQ9_0                      ((uint32_t)0x00000400)        /*!< Bit 0 */
  3907. #define  ADC_SQR2_SQ9_1                      ((uint32_t)0x00000800)        /*!< Bit 1 */
  3908. #define  ADC_SQR2_SQ9_2                      ((uint32_t)0x00001000)        /*!< Bit 2 */
  3909. #define  ADC_SQR2_SQ9_3                      ((uint32_t)0x00002000)        /*!< Bit 3 */
  3910. #define  ADC_SQR2_SQ9_4                      ((uint32_t)0x00004000)        /*!< Bit 4 */
  3911.  
  3912. #define  ADC_SQR2_SQ10                       ((uint32_t)0x000F8000)        /*!< SQ10[4:0] bits (10th conversion in regular sequence) */
  3913. #define  ADC_SQR2_SQ10_0                     ((uint32_t)0x00008000)        /*!< Bit 0 */
  3914. #define  ADC_SQR2_SQ10_1                     ((uint32_t)0x00010000)        /*!< Bit 1 */
  3915. #define  ADC_SQR2_SQ10_2                     ((uint32_t)0x00020000)        /*!< Bit 2 */
  3916. #define  ADC_SQR2_SQ10_3                     ((uint32_t)0x00040000)        /*!< Bit 3 */
  3917. #define  ADC_SQR2_SQ10_4                     ((uint32_t)0x00080000)        /*!< Bit 4 */
  3918.  
  3919. #define  ADC_SQR2_SQ11                       ((uint32_t)0x01F00000)        /*!< SQ11[4:0] bits (11th conversion in regular sequence) */
  3920. #define  ADC_SQR2_SQ11_0                     ((uint32_t)0x00100000)        /*!< Bit 0 */
  3921. #define  ADC_SQR2_SQ11_1                     ((uint32_t)0x00200000)        /*!< Bit 1 */
  3922. #define  ADC_SQR2_SQ11_2                     ((uint32_t)0x00400000)        /*!< Bit 2 */
  3923. #define  ADC_SQR2_SQ11_3                     ((uint32_t)0x00800000)        /*!< Bit 3 */
  3924. #define  ADC_SQR2_SQ11_4                     ((uint32_t)0x01000000)        /*!< Bit 4 */
  3925.  
  3926. #define  ADC_SQR2_SQ12                       ((uint32_t)0x3E000000)        /*!< SQ12[4:0] bits (12th conversion in regular sequence) */
  3927. #define  ADC_SQR2_SQ12_0                     ((uint32_t)0x02000000)        /*!< Bit 0 */
  3928. #define  ADC_SQR2_SQ12_1                     ((uint32_t)0x04000000)        /*!< Bit 1 */
  3929. #define  ADC_SQR2_SQ12_2                     ((uint32_t)0x08000000)        /*!< Bit 2 */
  3930. #define  ADC_SQR2_SQ12_3                     ((uint32_t)0x10000000)        /*!< Bit 3 */
  3931. #define  ADC_SQR2_SQ12_4                     ((uint32_t)0x20000000)        /*!< Bit 4 */
  3932.  
  3933. /*******************  Bit definition for ADC_SQR3 register  *******************/
  3934. #define  ADC_SQR3_SQ1                        ((uint32_t)0x0000001F)        /*!< SQ1[4:0] bits (1st conversion in regular sequence) */
  3935. #define  ADC_SQR3_SQ1_0                      ((uint32_t)0x00000001)        /*!< Bit 0 */
  3936. #define  ADC_SQR3_SQ1_1                      ((uint32_t)0x00000002)        /*!< Bit 1 */
  3937. #define  ADC_SQR3_SQ1_2                      ((uint32_t)0x00000004)        /*!< Bit 2 */
  3938. #define  ADC_SQR3_SQ1_3                      ((uint32_t)0x00000008)        /*!< Bit 3 */
  3939. #define  ADC_SQR3_SQ1_4                      ((uint32_t)0x00000010)        /*!< Bit 4 */
  3940.  
  3941. #define  ADC_SQR3_SQ2                        ((uint32_t)0x000003E0)        /*!< SQ2[4:0] bits (2nd conversion in regular sequence) */
  3942. #define  ADC_SQR3_SQ2_0                      ((uint32_t)0x00000020)        /*!< Bit 0 */
  3943. #define  ADC_SQR3_SQ2_1                      ((uint32_t)0x00000040)        /*!< Bit 1 */
  3944. #define  ADC_SQR3_SQ2_2                      ((uint32_t)0x00000080)        /*!< Bit 2 */
  3945. #define  ADC_SQR3_SQ2_3                      ((uint32_t)0x00000100)        /*!< Bit 3 */
  3946. #define  ADC_SQR3_SQ2_4                      ((uint32_t)0x00000200)        /*!< Bit 4 */
  3947.  
  3948. #define  ADC_SQR3_SQ3                        ((uint32_t)0x00007C00)        /*!< SQ3[4:0] bits (3rd conversion in regular sequence) */
  3949. #define  ADC_SQR3_SQ3_0                      ((uint32_t)0x00000400)        /*!< Bit 0 */
  3950. #define  ADC_SQR3_SQ3_1                      ((uint32_t)0x00000800)        /*!< Bit 1 */
  3951. #define  ADC_SQR3_SQ3_2                      ((uint32_t)0x00001000)        /*!< Bit 2 */
  3952. #define  ADC_SQR3_SQ3_3                      ((uint32_t)0x00002000)        /*!< Bit 3 */
  3953. #define  ADC_SQR3_SQ3_4                      ((uint32_t)0x00004000)        /*!< Bit 4 */
  3954.  
  3955. #define  ADC_SQR3_SQ4                        ((uint32_t)0x000F8000)        /*!< SQ4[4:0] bits (4th conversion in regular sequence) */
  3956. #define  ADC_SQR3_SQ4_0                      ((uint32_t)0x00008000)        /*!< Bit 0 */
  3957. #define  ADC_SQR3_SQ4_1                      ((uint32_t)0x00010000)        /*!< Bit 1 */
  3958. #define  ADC_SQR3_SQ4_2                      ((uint32_t)0x00020000)        /*!< Bit 2 */
  3959. #define  ADC_SQR3_SQ4_3                      ((uint32_t)0x00040000)        /*!< Bit 3 */
  3960. #define  ADC_SQR3_SQ4_4                      ((uint32_t)0x00080000)        /*!< Bit 4 */
  3961.  
  3962. #define  ADC_SQR3_SQ5                        ((uint32_t)0x01F00000)        /*!< SQ5[4:0] bits (5th conversion in regular sequence) */
  3963. #define  ADC_SQR3_SQ5_0                      ((uint32_t)0x00100000)        /*!< Bit 0 */
  3964. #define  ADC_SQR3_SQ5_1                      ((uint32_t)0x00200000)        /*!< Bit 1 */
  3965. #define  ADC_SQR3_SQ5_2                      ((uint32_t)0x00400000)        /*!< Bit 2 */
  3966. #define  ADC_SQR3_SQ5_3                      ((uint32_t)0x00800000)        /*!< Bit 3 */
  3967. #define  ADC_SQR3_SQ5_4                      ((uint32_t)0x01000000)        /*!< Bit 4 */
  3968.  
  3969. #define  ADC_SQR3_SQ6                        ((uint32_t)0x3E000000)        /*!< SQ6[4:0] bits (6th conversion in regular sequence) */
  3970. #define  ADC_SQR3_SQ6_0                      ((uint32_t)0x02000000)        /*!< Bit 0 */
  3971. #define  ADC_SQR3_SQ6_1                      ((uint32_t)0x04000000)        /*!< Bit 1 */
  3972. #define  ADC_SQR3_SQ6_2                      ((uint32_t)0x08000000)        /*!< Bit 2 */
  3973. #define  ADC_SQR3_SQ6_3                      ((uint32_t)0x10000000)        /*!< Bit 3 */
  3974. #define  ADC_SQR3_SQ6_4                      ((uint32_t)0x20000000)        /*!< Bit 4 */
  3975.  
  3976. /*******************  Bit definition for ADC_JSQR register  *******************/
  3977. #define  ADC_JSQR_JSQ1                       ((uint32_t)0x0000001F)        /*!< JSQ1[4:0] bits (1st conversion in injected sequence) */  
  3978. #define  ADC_JSQR_JSQ1_0                     ((uint32_t)0x00000001)        /*!< Bit 0 */
  3979. #define  ADC_JSQR_JSQ1_1                     ((uint32_t)0x00000002)        /*!< Bit 1 */
  3980. #define  ADC_JSQR_JSQ1_2                     ((uint32_t)0x00000004)        /*!< Bit 2 */
  3981. #define  ADC_JSQR_JSQ1_3                     ((uint32_t)0x00000008)        /*!< Bit 3 */
  3982. #define  ADC_JSQR_JSQ1_4                     ((uint32_t)0x00000010)        /*!< Bit 4 */
  3983.  
  3984. #define  ADC_JSQR_JSQ2                       ((uint32_t)0x000003E0)        /*!< JSQ2[4:0] bits (2nd conversion in injected sequence) */
  3985. #define  ADC_JSQR_JSQ2_0                     ((uint32_t)0x00000020)        /*!< Bit 0 */
  3986. #define  ADC_JSQR_JSQ2_1                     ((uint32_t)0x00000040)        /*!< Bit 1 */
  3987. #define  ADC_JSQR_JSQ2_2                     ((uint32_t)0x00000080)        /*!< Bit 2 */
  3988. #define  ADC_JSQR_JSQ2_3                     ((uint32_t)0x00000100)        /*!< Bit 3 */
  3989. #define  ADC_JSQR_JSQ2_4                     ((uint32_t)0x00000200)        /*!< Bit 4 */
  3990.  
  3991. #define  ADC_JSQR_JSQ3                       ((uint32_t)0x00007C00)        /*!< JSQ3[4:0] bits (3rd conversion in injected sequence) */
  3992. #define  ADC_JSQR_JSQ3_0                     ((uint32_t)0x00000400)        /*!< Bit 0 */
  3993. #define  ADC_JSQR_JSQ3_1                     ((uint32_t)0x00000800)        /*!< Bit 1 */
  3994. #define  ADC_JSQR_JSQ3_2                     ((uint32_t)0x00001000)        /*!< Bit 2 */
  3995. #define  ADC_JSQR_JSQ3_3                     ((uint32_t)0x00002000)        /*!< Bit 3 */
  3996. #define  ADC_JSQR_JSQ3_4                     ((uint32_t)0x00004000)        /*!< Bit 4 */
  3997.  
  3998. #define  ADC_JSQR_JSQ4                       ((uint32_t)0x000F8000)        /*!< JSQ4[4:0] bits (4th conversion in injected sequence) */
  3999. #define  ADC_JSQR_JSQ4_0                     ((uint32_t)0x00008000)        /*!< Bit 0 */
  4000. #define  ADC_JSQR_JSQ4_1                     ((uint32_t)0x00010000)        /*!< Bit 1 */
  4001. #define  ADC_JSQR_JSQ4_2                     ((uint32_t)0x00020000)        /*!< Bit 2 */
  4002. #define  ADC_JSQR_JSQ4_3                     ((uint32_t)0x00040000)        /*!< Bit 3 */
  4003. #define  ADC_JSQR_JSQ4_4                     ((uint32_t)0x00080000)        /*!< Bit 4 */
  4004.  
  4005. #define  ADC_JSQR_JL                         ((uint32_t)0x00300000)        /*!< JL[1:0] bits (Injected Sequence length) */
  4006. #define  ADC_JSQR_JL_0                       ((uint32_t)0x00100000)        /*!< Bit 0 */
  4007. #define  ADC_JSQR_JL_1                       ((uint32_t)0x00200000)        /*!< Bit 1 */
  4008.  
  4009. /*******************  Bit definition for ADC_JDR1 register  *******************/
  4010. #define  ADC_JDR1_JDATA                      ((uint16_t)0xFFFF)            /*!< Injected data */
  4011.  
  4012. /*******************  Bit definition for ADC_JDR2 register  *******************/
  4013. #define  ADC_JDR2_JDATA                      ((uint16_t)0xFFFF)            /*!< Injected data */
  4014.  
  4015. /*******************  Bit definition for ADC_JDR3 register  *******************/
  4016. #define  ADC_JDR3_JDATA                      ((uint16_t)0xFFFF)            /*!< Injected data */
  4017.  
  4018. /*******************  Bit definition for ADC_JDR4 register  *******************/
  4019. #define  ADC_JDR4_JDATA                      ((uint16_t)0xFFFF)            /*!< Injected data */
  4020.  
  4021. /********************  Bit definition for ADC_DR register  ********************/
  4022. #define  ADC_DR_DATA                         ((uint32_t)0x0000FFFF)        /*!< Regular data */
  4023. #define  ADC_DR_ADC2DATA                     ((uint32_t)0xFFFF0000)        /*!< ADC2 data */
  4024.  
  4025. /******************************************************************************/
  4026. /*                                                                            */
  4027. /*                      Digital to Analog Converter                           */
  4028. /*                                                                            */
  4029. /******************************************************************************/
  4030.  
  4031. /********************  Bit definition for DAC_CR register  ********************/
  4032. #define  DAC_CR_EN1                          ((uint32_t)0x00000001)        /*!< DAC channel1 enable */
  4033. #define  DAC_CR_BOFF1                        ((uint32_t)0x00000002)        /*!< DAC channel1 output buffer disable */
  4034. #define  DAC_CR_TEN1                         ((uint32_t)0x00000004)        /*!< DAC channel1 Trigger enable */
  4035.  
  4036. #define  DAC_CR_TSEL1                        ((uint32_t)0x00000038)        /*!< TSEL1[2:0] (DAC channel1 Trigger selection) */
  4037. #define  DAC_CR_TSEL1_0                      ((uint32_t)0x00000008)        /*!< Bit 0 */
  4038. #define  DAC_CR_TSEL1_1                      ((uint32_t)0x00000010)        /*!< Bit 1 */
  4039. #define  DAC_CR_TSEL1_2                      ((uint32_t)0x00000020)        /*!< Bit 2 */
  4040.  
  4041. #define  DAC_CR_WAVE1                        ((uint32_t)0x000000C0)        /*!< WAVE1[1:0] (DAC channel1 noise/triangle wave generation enable) */
  4042. #define  DAC_CR_WAVE1_0                      ((uint32_t)0x00000040)        /*!< Bit 0 */
  4043. #define  DAC_CR_WAVE1_1                      ((uint32_t)0x00000080)        /*!< Bit 1 */
  4044.  
  4045. #define  DAC_CR_MAMP1                        ((uint32_t)0x00000F00)        /*!< MAMP1[3:0] (DAC channel1 Mask/Amplitude selector) */
  4046. #define  DAC_CR_MAMP1_0                      ((uint32_t)0x00000100)        /*!< Bit 0 */
  4047. #define  DAC_CR_MAMP1_1                      ((uint32_t)0x00000200)        /*!< Bit 1 */
  4048. #define  DAC_CR_MAMP1_2                      ((uint32_t)0x00000400)        /*!< Bit 2 */
  4049. #define  DAC_CR_MAMP1_3                      ((uint32_t)0x00000800)        /*!< Bit 3 */
  4050.  
  4051. #define  DAC_CR_DMAEN1                       ((uint32_t)0x00001000)        /*!< DAC channel1 DMA enable */
  4052. #define  DAC_CR_EN2                          ((uint32_t)0x00010000)        /*!< DAC channel2 enable */
  4053. #define  DAC_CR_BOFF2                        ((uint32_t)0x00020000)        /*!< DAC channel2 output buffer disable */
  4054. #define  DAC_CR_TEN2                         ((uint32_t)0x00040000)        /*!< DAC channel2 Trigger enable */
  4055.  
  4056. #define  DAC_CR_TSEL2                        ((uint32_t)0x00380000)        /*!< TSEL2[2:0] (DAC channel2 Trigger selection) */
  4057. #define  DAC_CR_TSEL2_0                      ((uint32_t)0x00080000)        /*!< Bit 0 */
  4058. #define  DAC_CR_TSEL2_1                      ((uint32_t)0x00100000)        /*!< Bit 1 */
  4059. #define  DAC_CR_TSEL2_2                      ((uint32_t)0x00200000)        /*!< Bit 2 */
  4060.  
  4061. #define  DAC_CR_WAVE2                        ((uint32_t)0x00C00000)        /*!< WAVE2[1:0] (DAC channel2 noise/triangle wave generation enable) */
  4062. #define  DAC_CR_WAVE2_0                      ((uint32_t)0x00400000)        /*!< Bit 0 */
  4063. #define  DAC_CR_WAVE2_1                      ((uint32_t)0x00800000)        /*!< Bit 1 */
  4064.  
  4065. #define  DAC_CR_MAMP2                        ((uint32_t)0x0F000000)        /*!< MAMP2[3:0] (DAC channel2 Mask/Amplitude selector) */
  4066. #define  DAC_CR_MAMP2_0                      ((uint32_t)0x01000000)        /*!< Bit 0 */
  4067. #define  DAC_CR_MAMP2_1                      ((uint32_t)0x02000000)        /*!< Bit 1 */
  4068. #define  DAC_CR_MAMP2_2                      ((uint32_t)0x04000000)        /*!< Bit 2 */
  4069. #define  DAC_CR_MAMP2_3                      ((uint32_t)0x08000000)        /*!< Bit 3 */
  4070.  
  4071. #define  DAC_CR_DMAEN2                       ((uint32_t)0x10000000)        /*!< DAC channel2 DMA enabled */
  4072.  
  4073. #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
  4074.  #define  DAC_CR_DMAUDRIE1                   ((uint32_t)0x00002000)        /*!< DAC channel1 DMA underrun interrupt enable */
  4075.  #define  DAC_CR_DMAUDRIE2                   ((uint32_t)0x20000000)        /*!< DAC channel2 DMA underrun interrupt enable */
  4076. #endif
  4077.  
  4078. /*****************  Bit definition for DAC_SWTRIGR register  ******************/
  4079. #define  DAC_SWTRIGR_SWTRIG1                 ((uint8_t)0x01)               /*!< DAC channel1 software trigger */
  4080. #define  DAC_SWTRIGR_SWTRIG2                 ((uint8_t)0x02)               /*!< DAC channel2 software trigger */
  4081.  
  4082. /*****************  Bit definition for DAC_DHR12R1 register  ******************/
  4083. #define  DAC_DHR12R1_DACC1DHR                ((uint16_t)0x0FFF)            /*!< DAC channel1 12-bit Right aligned data */
  4084.  
  4085. /*****************  Bit definition for DAC_DHR12L1 register  ******************/
  4086. #define  DAC_DHR12L1_DACC1DHR                ((uint16_t)0xFFF0)            /*!< DAC channel1 12-bit Left aligned data */
  4087.  
  4088. /******************  Bit definition for DAC_DHR8R1 register  ******************/
  4089. #define  DAC_DHR8R1_DACC1DHR                 ((uint8_t)0xFF)               /*!< DAC channel1 8-bit Right aligned data */
  4090.  
  4091. /*****************  Bit definition for DAC_DHR12R2 register  ******************/
  4092. #define  DAC_DHR12R2_DACC2DHR                ((uint16_t)0x0FFF)            /*!< DAC channel2 12-bit Right aligned data */
  4093.  
  4094. /*****************  Bit definition for DAC_DHR12L2 register  ******************/
  4095. #define  DAC_DHR12L2_DACC2DHR                ((uint16_t)0xFFF0)            /*!< DAC channel2 12-bit Left aligned data */
  4096.  
  4097. /******************  Bit definition for DAC_DHR8R2 register  ******************/
  4098. #define  DAC_DHR8R2_DACC2DHR                 ((uint8_t)0xFF)               /*!< DAC channel2 8-bit Right aligned data */
  4099.  
  4100. /*****************  Bit definition for DAC_DHR12RD register  ******************/
  4101. #define  DAC_DHR12RD_DACC1DHR                ((uint32_t)0x00000FFF)        /*!< DAC channel1 12-bit Right aligned data */
  4102. #define  DAC_DHR12RD_DACC2DHR                ((uint32_t)0x0FFF0000)        /*!< DAC channel2 12-bit Right aligned data */
  4103.  
  4104. /*****************  Bit definition for DAC_DHR12LD register  ******************/
  4105. #define  DAC_DHR12LD_DACC1DHR                ((uint32_t)0x0000FFF0)        /*!< DAC channel1 12-bit Left aligned data */
  4106. #define  DAC_DHR12LD_DACC2DHR                ((uint32_t)0xFFF00000)        /*!< DAC channel2 12-bit Left aligned data */
  4107.  
  4108. /******************  Bit definition for DAC_DHR8RD register  ******************/
  4109. #define  DAC_DHR8RD_DACC1DHR                 ((uint16_t)0x00FF)            /*!< DAC channel1 8-bit Right aligned data */
  4110. #define  DAC_DHR8RD_DACC2DHR                 ((uint16_t)0xFF00)            /*!< DAC channel2 8-bit Right aligned data */
  4111.  
  4112. /*******************  Bit definition for DAC_DOR1 register  *******************/
  4113. #define  DAC_DOR1_DACC1DOR                   ((uint16_t)0x0FFF)            /*!< DAC channel1 data output */
  4114.  
  4115. /*******************  Bit definition for DAC_DOR2 register  *******************/
  4116. #define  DAC_DOR2_DACC2DOR                   ((uint16_t)0x0FFF)            /*!< DAC channel2 data output */
  4117.  
  4118. /********************  Bit definition for DAC_SR register  ********************/
  4119. #define  DAC_SR_DMAUDR1                      ((uint32_t)0x00002000)        /*!< DAC channel1 DMA underrun flag */
  4120. #define  DAC_SR_DMAUDR2                      ((uint32_t)0x20000000)        /*!< DAC channel2 DMA underrun flag */
  4121.  
  4122. /******************************************************************************/
  4123. /*                                                                            */
  4124. /*                                    CEC                                     */
  4125. /*                                                                            */
  4126. /******************************************************************************/
  4127. /********************  Bit definition for CEC_CFGR register  ******************/
  4128. #define  CEC_CFGR_PE              ((uint16_t)0x0001)     /*!<  Peripheral Enable */
  4129. #define  CEC_CFGR_IE              ((uint16_t)0x0002)     /*!<  Interrupt Enable */
  4130. #define  CEC_CFGR_BTEM            ((uint16_t)0x0004)     /*!<  Bit Timing Error Mode */
  4131. #define  CEC_CFGR_BPEM            ((uint16_t)0x0008)     /*!<  Bit Period Error Mode */
  4132.  
  4133. /********************  Bit definition for CEC_OAR register  ******************/
  4134. #define  CEC_OAR_OA               ((uint16_t)0x000F)     /*!<  OA[3:0]: Own Address */
  4135. #define  CEC_OAR_OA_0             ((uint16_t)0x0001)     /*!<  Bit 0 */
  4136. #define  CEC_OAR_OA_1             ((uint16_t)0x0002)     /*!<  Bit 1 */
  4137. #define  CEC_OAR_OA_2             ((uint16_t)0x0004)     /*!<  Bit 2 */
  4138. #define  CEC_OAR_OA_3             ((uint16_t)0x0008)     /*!<  Bit 3 */
  4139.  
  4140. /********************  Bit definition for CEC_PRES register  ******************/
  4141. #define  CEC_PRES_PRES            ((uint16_t)0x3FFF)   /*!<  Prescaler Counter Value */
  4142.  
  4143. /********************  Bit definition for CEC_ESR register  ******************/
  4144. #define  CEC_ESR_BTE              ((uint16_t)0x0001)     /*!<  Bit Timing Error */
  4145. #define  CEC_ESR_BPE              ((uint16_t)0x0002)     /*!<  Bit Period Error */
  4146. #define  CEC_ESR_RBTFE            ((uint16_t)0x0004)     /*!<  Rx Block Transfer Finished Error */
  4147. #define  CEC_ESR_SBE              ((uint16_t)0x0008)     /*!<  Start Bit Error */
  4148. #define  CEC_ESR_ACKE             ((uint16_t)0x0010)     /*!<  Block Acknowledge Error */
  4149. #define  CEC_ESR_LINE             ((uint16_t)0x0020)     /*!<  Line Error */
  4150. #define  CEC_ESR_TBTFE            ((uint16_t)0x0040)     /*!<  Tx Block Transfer Finished Error */
  4151.  
  4152. /********************  Bit definition for CEC_CSR register  ******************/
  4153. #define  CEC_CSR_TSOM             ((uint16_t)0x0001)     /*!<  Tx Start Of Message */
  4154. #define  CEC_CSR_TEOM             ((uint16_t)0x0002)     /*!<  Tx End Of Message */
  4155. #define  CEC_CSR_TERR             ((uint16_t)0x0004)     /*!<  Tx Error */
  4156. #define  CEC_CSR_TBTRF            ((uint16_t)0x0008)     /*!<  Tx Byte Transfer Request or Block Transfer Finished */
  4157. #define  CEC_CSR_RSOM             ((uint16_t)0x0010)     /*!<  Rx Start Of Message */
  4158. #define  CEC_CSR_REOM             ((uint16_t)0x0020)     /*!<  Rx End Of Message */
  4159. #define  CEC_CSR_RERR             ((uint16_t)0x0040)     /*!<  Rx Error */
  4160. #define  CEC_CSR_RBTF             ((uint16_t)0x0080)     /*!<  Rx Block Transfer Finished */
  4161.  
  4162. /********************  Bit definition for CEC_TXD register  ******************/
  4163. #define  CEC_TXD_TXD              ((uint16_t)0x00FF)     /*!<  Tx Data register */
  4164.  
  4165. /********************  Bit definition for CEC_RXD register  ******************/
  4166. #define  CEC_RXD_RXD              ((uint16_t)0x00FF)     /*!<  Rx Data register */
  4167.  
  4168. /******************************************************************************/
  4169. /*                                                                            */
  4170. /*                                    TIM                                     */
  4171. /*                                                                            */
  4172. /******************************************************************************/
  4173.  
  4174. /*******************  Bit definition for TIM_CR1 register  ********************/
  4175. #define  TIM_CR1_CEN                         ((uint16_t)0x0001)            /*!< Counter enable */
  4176. #define  TIM_CR1_UDIS                        ((uint16_t)0x0002)            /*!< Update disable */
  4177. #define  TIM_CR1_URS                         ((uint16_t)0x0004)            /*!< Update request source */
  4178. #define  TIM_CR1_OPM                         ((uint16_t)0x0008)            /*!< One pulse mode */
  4179. #define  TIM_CR1_DIR                         ((uint16_t)0x0010)            /*!< Direction */
  4180.  
  4181. #define  TIM_CR1_CMS                         ((uint16_t)0x0060)            /*!< CMS[1:0] bits (Center-aligned mode selection) */
  4182. #define  TIM_CR1_CMS_0                       ((uint16_t)0x0020)            /*!< Bit 0 */
  4183. #define  TIM_CR1_CMS_1                       ((uint16_t)0x0040)            /*!< Bit 1 */
  4184.  
  4185. #define  TIM_CR1_ARPE                        ((uint16_t)0x0080)            /*!< Auto-reload preload enable */
  4186.  
  4187. #define  TIM_CR1_CKD                         ((uint16_t)0x0300)            /*!< CKD[1:0] bits (clock division) */
  4188. #define  TIM_CR1_CKD_0                       ((uint16_t)0x0100)            /*!< Bit 0 */
  4189. #define  TIM_CR1_CKD_1                       ((uint16_t)0x0200)            /*!< Bit 1 */
  4190.  
  4191. /*******************  Bit definition for TIM_CR2 register  ********************/
  4192. #define  TIM_CR2_CCPC                        ((uint16_t)0x0001)            /*!< Capture/Compare Preloaded Control */
  4193. #define  TIM_CR2_CCUS                        ((uint16_t)0x0004)            /*!< Capture/Compare Control Update Selection */
  4194. #define  TIM_CR2_CCDS                        ((uint16_t)0x0008)            /*!< Capture/Compare DMA Selection */
  4195.  
  4196. #define  TIM_CR2_MMS                         ((uint16_t)0x0070)            /*!< MMS[2:0] bits (Master Mode Selection) */
  4197. #define  TIM_CR2_MMS_0                       ((uint16_t)0x0010)            /*!< Bit 0 */
  4198. #define  TIM_CR2_MMS_1                       ((uint16_t)0x0020)            /*!< Bit 1 */
  4199. #define  TIM_CR2_MMS_2                       ((uint16_t)0x0040)            /*!< Bit 2 */
  4200.  
  4201. #define  TIM_CR2_TI1S                        ((uint16_t)0x0080)            /*!< TI1 Selection */
  4202. #define  TIM_CR2_OIS1                        ((uint16_t)0x0100)            /*!< Output Idle state 1 (OC1 output) */
  4203. #define  TIM_CR2_OIS1N                       ((uint16_t)0x0200)            /*!< Output Idle state 1 (OC1N output) */
  4204. #define  TIM_CR2_OIS2                        ((uint16_t)0x0400)            /*!< Output Idle state 2 (OC2 output) */
  4205. #define  TIM_CR2_OIS2N                       ((uint16_t)0x0800)            /*!< Output Idle state 2 (OC2N output) */
  4206. #define  TIM_CR2_OIS3                        ((uint16_t)0x1000)            /*!< Output Idle state 3 (OC3 output) */
  4207. #define  TIM_CR2_OIS3N                       ((uint16_t)0x2000)            /*!< Output Idle state 3 (OC3N output) */
  4208. #define  TIM_CR2_OIS4                        ((uint16_t)0x4000)            /*!< Output Idle state 4 (OC4 output) */
  4209.  
  4210. /*******************  Bit definition for TIM_SMCR register  *******************/
  4211. #define  TIM_SMCR_SMS                        ((uint16_t)0x0007)            /*!< SMS[2:0] bits (Slave mode selection) */
  4212. #define  TIM_SMCR_SMS_0                      ((uint16_t)0x0001)            /*!< Bit 0 */
  4213. #define  TIM_SMCR_SMS_1                      ((uint16_t)0x0002)            /*!< Bit 1 */
  4214. #define  TIM_SMCR_SMS_2                      ((uint16_t)0x0004)            /*!< Bit 2 */
  4215.  
  4216. #define  TIM_SMCR_TS                         ((uint16_t)0x0070)            /*!< TS[2:0] bits (Trigger selection) */
  4217. #define  TIM_SMCR_TS_0                       ((uint16_t)0x0010)            /*!< Bit 0 */
  4218. #define  TIM_SMCR_TS_1                       ((uint16_t)0x0020)            /*!< Bit 1 */
  4219. #define  TIM_SMCR_TS_2                       ((uint16_t)0x0040)            /*!< Bit 2 */
  4220.  
  4221. #define  TIM_SMCR_MSM                        ((uint16_t)0x0080)            /*!< Master/slave mode */
  4222.  
  4223. #define  TIM_SMCR_ETF                        ((uint16_t)0x0F00)            /*!< ETF[3:0] bits (External trigger filter) */
  4224. #define  TIM_SMCR_ETF_0                      ((uint16_t)0x0100)            /*!< Bit 0 */
  4225. #define  TIM_SMCR_ETF_1                      ((uint16_t)0x0200)            /*!< Bit 1 */
  4226. #define  TIM_SMCR_ETF_2                      ((uint16_t)0x0400)            /*!< Bit 2 */
  4227. #define  TIM_SMCR_ETF_3                      ((uint16_t)0x0800)            /*!< Bit 3 */
  4228.  
  4229. #define  TIM_SMCR_ETPS                       ((uint16_t)0x3000)            /*!< ETPS[1:0] bits (External trigger prescaler) */
  4230. #define  TIM_SMCR_ETPS_0                     ((uint16_t)0x1000)            /*!< Bit 0 */
  4231. #define  TIM_SMCR_ETPS_1                     ((uint16_t)0x2000)            /*!< Bit 1 */
  4232.  
  4233. #define  TIM_SMCR_ECE                        ((uint16_t)0x4000)            /*!< External clock enable */
  4234. #define  TIM_SMCR_ETP                        ((uint16_t)0x8000)            /*!< External trigger polarity */
  4235.  
  4236. /*******************  Bit definition for TIM_DIER register  *******************/
  4237. #define  TIM_DIER_UIE                        ((uint16_t)0x0001)            /*!< Update interrupt enable */
  4238. #define  TIM_DIER_CC1IE                      ((uint16_t)0x0002)            /*!< Capture/Compare 1 interrupt enable */
  4239. #define  TIM_DIER_CC2IE                      ((uint16_t)0x0004)            /*!< Capture/Compare 2 interrupt enable */
  4240. #define  TIM_DIER_CC3IE                      ((uint16_t)0x0008)            /*!< Capture/Compare 3 interrupt enable */
  4241. #define  TIM_DIER_CC4IE                      ((uint16_t)0x0010)            /*!< Capture/Compare 4 interrupt enable */
  4242. #define  TIM_DIER_COMIE                      ((uint16_t)0x0020)            /*!< COM interrupt enable */
  4243. #define  TIM_DIER_TIE                        ((uint16_t)0x0040)            /*!< Trigger interrupt enable */
  4244. #define  TIM_DIER_BIE                        ((uint16_t)0x0080)            /*!< Break interrupt enable */
  4245. #define  TIM_DIER_UDE                        ((uint16_t)0x0100)            /*!< Update DMA request enable */
  4246. #define  TIM_DIER_CC1DE                      ((uint16_t)0x0200)            /*!< Capture/Compare 1 DMA request enable */
  4247. #define  TIM_DIER_CC2DE                      ((uint16_t)0x0400)            /*!< Capture/Compare 2 DMA request enable */
  4248. #define  TIM_DIER_CC3DE                      ((uint16_t)0x0800)            /*!< Capture/Compare 3 DMA request enable */
  4249. #define  TIM_DIER_CC4DE                      ((uint16_t)0x1000)            /*!< Capture/Compare 4 DMA request enable */
  4250. #define  TIM_DIER_COMDE                      ((uint16_t)0x2000)            /*!< COM DMA request enable */
  4251. #define  TIM_DIER_TDE                        ((uint16_t)0x4000)            /*!< Trigger DMA request enable */
  4252.  
  4253. /********************  Bit definition for TIM_SR register  ********************/
  4254. #define  TIM_SR_UIF                          ((uint16_t)0x0001)            /*!< Update interrupt Flag */
  4255. #define  TIM_SR_CC1IF                        ((uint16_t)0x0002)            /*!< Capture/Compare 1 interrupt Flag */
  4256. #define  TIM_SR_CC2IF                        ((uint16_t)0x0004)            /*!< Capture/Compare 2 interrupt Flag */
  4257. #define  TIM_SR_CC3IF                        ((uint16_t)0x0008)            /*!< Capture/Compare 3 interrupt Flag */
  4258. #define  TIM_SR_CC4IF                        ((uint16_t)0x0010)            /*!< Capture/Compare 4 interrupt Flag */
  4259. #define  TIM_SR_COMIF                        ((uint16_t)0x0020)            /*!< COM interrupt Flag */
  4260. #define  TIM_SR_TIF                          ((uint16_t)0x0040)            /*!< Trigger interrupt Flag */
  4261. #define  TIM_SR_BIF                          ((uint16_t)0x0080)            /*!< Break interrupt Flag */
  4262. #define  TIM_SR_CC1OF                        ((uint16_t)0x0200)            /*!< Capture/Compare 1 Overcapture Flag */
  4263. #define  TIM_SR_CC2OF                        ((uint16_t)0x0400)            /*!< Capture/Compare 2 Overcapture Flag */
  4264. #define  TIM_SR_CC3OF                        ((uint16_t)0x0800)            /*!< Capture/Compare 3 Overcapture Flag */
  4265. #define  TIM_SR_CC4OF                        ((uint16_t)0x1000)            /*!< Capture/Compare 4 Overcapture Flag */
  4266.  
  4267. /*******************  Bit definition for TIM_EGR register  ********************/
  4268. #define  TIM_EGR_UG                          ((uint8_t)0x01)               /*!< Update Generation */
  4269. #define  TIM_EGR_CC1G                        ((uint8_t)0x02)               /*!< Capture/Compare 1 Generation */
  4270. #define  TIM_EGR_CC2G                        ((uint8_t)0x04)               /*!< Capture/Compare 2 Generation */
  4271. #define  TIM_EGR_CC3G                        ((uint8_t)0x08)               /*!< Capture/Compare 3 Generation */
  4272. #define  TIM_EGR_CC4G                        ((uint8_t)0x10)               /*!< Capture/Compare 4 Generation */
  4273. #define  TIM_EGR_COMG                        ((uint8_t)0x20)               /*!< Capture/Compare Control Update Generation */
  4274. #define  TIM_EGR_TG                          ((uint8_t)0x40)               /*!< Trigger Generation */
  4275. #define  TIM_EGR_BG                          ((uint8_t)0x80)               /*!< Break Generation */
  4276.  
  4277. /******************  Bit definition for TIM_CCMR1 register  *******************/
  4278. #define  TIM_CCMR1_CC1S                      ((uint16_t)0x0003)            /*!< CC1S[1:0] bits (Capture/Compare 1 Selection) */
  4279. #define  TIM_CCMR1_CC1S_0                    ((uint16_t)0x0001)            /*!< Bit 0 */
  4280. #define  TIM_CCMR1_CC1S_1                    ((uint16_t)0x0002)            /*!< Bit 1 */
  4281.  
  4282. #define  TIM_CCMR1_OC1FE                     ((uint16_t)0x0004)            /*!< Output Compare 1 Fast enable */
  4283. #define  TIM_CCMR1_OC1PE                     ((uint16_t)0x0008)            /*!< Output Compare 1 Preload enable */
  4284.  
  4285. #define  TIM_CCMR1_OC1M                      ((uint16_t)0x0070)            /*!< OC1M[2:0] bits (Output Compare 1 Mode) */
  4286. #define  TIM_CCMR1_OC1M_0                    ((uint16_t)0x0010)            /*!< Bit 0 */
  4287. #define  TIM_CCMR1_OC1M_1                    ((uint16_t)0x0020)            /*!< Bit 1 */
  4288. #define  TIM_CCMR1_OC1M_2                    ((uint16_t)0x0040)            /*!< Bit 2 */
  4289.  
  4290. #define  TIM_CCMR1_OC1CE                     ((uint16_t)0x0080)            /*!< Output Compare 1Clear Enable */
  4291.  
  4292. #define  TIM_CCMR1_CC2S                      ((uint16_t)0x0300)            /*!< CC2S[1:0] bits (Capture/Compare 2 Selection) */
  4293. #define  TIM_CCMR1_CC2S_0                    ((uint16_t)0x0100)            /*!< Bit 0 */
  4294. #define  TIM_CCMR1_CC2S_1                    ((uint16_t)0x0200)            /*!< Bit 1 */
  4295.  
  4296. #define  TIM_CCMR1_OC2FE                     ((uint16_t)0x0400)            /*!< Output Compare 2 Fast enable */
  4297. #define  TIM_CCMR1_OC2PE                     ((uint16_t)0x0800)            /*!< Output Compare 2 Preload enable */
  4298.  
  4299. #define  TIM_CCMR1_OC2M                      ((uint16_t)0x7000)            /*!< OC2M[2:0] bits (Output Compare 2 Mode) */
  4300. #define  TIM_CCMR1_OC2M_0                    ((uint16_t)0x1000)            /*!< Bit 0 */
  4301. #define  TIM_CCMR1_OC2M_1                    ((uint16_t)0x2000)            /*!< Bit 1 */
  4302. #define  TIM_CCMR1_OC2M_2                    ((uint16_t)0x4000)            /*!< Bit 2 */
  4303.  
  4304. #define  TIM_CCMR1_OC2CE                     ((uint16_t)0x8000)            /*!< Output Compare 2 Clear Enable */
  4305.  
  4306. /*----------------------------------------------------------------------------*/
  4307.  
  4308. #define  TIM_CCMR1_IC1PSC                    ((uint16_t)0x000C)            /*!< IC1PSC[1:0] bits (Input Capture 1 Prescaler) */
  4309. #define  TIM_CCMR1_IC1PSC_0                  ((uint16_t)0x0004)            /*!< Bit 0 */
  4310. #define  TIM_CCMR1_IC1PSC_1                  ((uint16_t)0x0008)            /*!< Bit 1 */
  4311.  
  4312. #define  TIM_CCMR1_IC1F                      ((uint16_t)0x00F0)            /*!< IC1F[3:0] bits (Input Capture 1 Filter) */
  4313. #define  TIM_CCMR1_IC1F_0                    ((uint16_t)0x0010)            /*!< Bit 0 */
  4314. #define  TIM_CCMR1_IC1F_1                    ((uint16_t)0x0020)            /*!< Bit 1 */
  4315. #define  TIM_CCMR1_IC1F_2                    ((uint16_t)0x0040)            /*!< Bit 2 */
  4316. #define  TIM_CCMR1_IC1F_3                    ((uint16_t)0x0080)            /*!< Bit 3 */
  4317.  
  4318. #define  TIM_CCMR1_IC2PSC                    ((uint16_t)0x0C00)            /*!< IC2PSC[1:0] bits (Input Capture 2 Prescaler) */
  4319. #define  TIM_CCMR1_IC2PSC_0                  ((uint16_t)0x0400)            /*!< Bit 0 */
  4320. #define  TIM_CCMR1_IC2PSC_1                  ((uint16_t)0x0800)            /*!< Bit 1 */
  4321.  
  4322. #define  TIM_CCMR1_IC2F                      ((uint16_t)0xF000)            /*!< IC2F[3:0] bits (Input Capture 2 Filter) */
  4323. #define  TIM_CCMR1_IC2F_0                    ((uint16_t)0x1000)            /*!< Bit 0 */
  4324. #define  TIM_CCMR1_IC2F_1                    ((uint16_t)0x2000)            /*!< Bit 1 */
  4325. #define  TIM_CCMR1_IC2F_2                    ((uint16_t)0x4000)            /*!< Bit 2 */
  4326. #define  TIM_CCMR1_IC2F_3                    ((uint16_t)0x8000)            /*!< Bit 3 */
  4327.  
  4328. /******************  Bit definition for TIM_CCMR2 register  *******************/
  4329. #define  TIM_CCMR2_CC3S                      ((uint16_t)0x0003)            /*!< CC3S[1:0] bits (Capture/Compare 3 Selection) */
  4330. #define  TIM_CCMR2_CC3S_0                    ((uint16_t)0x0001)            /*!< Bit 0 */
  4331. #define  TIM_CCMR2_CC3S_1                    ((uint16_t)0x0002)            /*!< Bit 1 */
  4332.  
  4333. #define  TIM_CCMR2_OC3FE                     ((uint16_t)0x0004)            /*!< Output Compare 3 Fast enable */
  4334. #define  TIM_CCMR2_OC3PE                     ((uint16_t)0x0008)            /*!< Output Compare 3 Preload enable */
  4335.  
  4336. #define  TIM_CCMR2_OC3M                      ((uint16_t)0x0070)            /*!< OC3M[2:0] bits (Output Compare 3 Mode) */
  4337. #define  TIM_CCMR2_OC3M_0                    ((uint16_t)0x0010)            /*!< Bit 0 */
  4338. #define  TIM_CCMR2_OC3M_1                    ((uint16_t)0x0020)            /*!< Bit 1 */
  4339. #define  TIM_CCMR2_OC3M_2                    ((uint16_t)0x0040)            /*!< Bit 2 */
  4340.  
  4341. #define  TIM_CCMR2_OC3CE                     ((uint16_t)0x0080)            /*!< Output Compare 3 Clear Enable */
  4342.  
  4343. #define  TIM_CCMR2_CC4S                      ((uint16_t)0x0300)            /*!< CC4S[1:0] bits (Capture/Compare 4 Selection) */
  4344. #define  TIM_CCMR2_CC4S_0                    ((uint16_t)0x0100)            /*!< Bit 0 */
  4345. #define  TIM_CCMR2_CC4S_1                    ((uint16_t)0x0200)            /*!< Bit 1 */
  4346.  
  4347. #define  TIM_CCMR2_OC4FE                     ((uint16_t)0x0400)            /*!< Output Compare 4 Fast enable */
  4348. #define  TIM_CCMR2_OC4PE                     ((uint16_t)0x0800)            /*!< Output Compare 4 Preload enable */
  4349.  
  4350. #define  TIM_CCMR2_OC4M                      ((uint16_t)0x7000)            /*!< OC4M[2:0] bits (Output Compare 4 Mode) */
  4351. #define  TIM_CCMR2_OC4M_0                    ((uint16_t)0x1000)            /*!< Bit 0 */
  4352. #define  TIM_CCMR2_OC4M_1                    ((uint16_t)0x2000)            /*!< Bit 1 */
  4353. #define  TIM_CCMR2_OC4M_2                    ((uint16_t)0x4000)            /*!< Bit 2 */
  4354.  
  4355. #define  TIM_CCMR2_OC4CE                     ((uint16_t)0x8000)            /*!< Output Compare 4 Clear Enable */
  4356.  
  4357. /*----------------------------------------------------------------------------*/
  4358.  
  4359. #define  TIM_CCMR2_IC3PSC                    ((uint16_t)0x000C)            /*!< IC3PSC[1:0] bits (Input Capture 3 Prescaler) */
  4360. #define  TIM_CCMR2_IC3PSC_0                  ((uint16_t)0x0004)            /*!< Bit 0 */
  4361. #define  TIM_CCMR2_IC3PSC_1                  ((uint16_t)0x0008)            /*!< Bit 1 */
  4362.  
  4363. #define  TIM_CCMR2_IC3F                      ((uint16_t)0x00F0)            /*!< IC3F[3:0] bits (Input Capture 3 Filter) */
  4364. #define  TIM_CCMR2_IC3F_0                    ((uint16_t)0x0010)            /*!< Bit 0 */
  4365. #define  TIM_CCMR2_IC3F_1                    ((uint16_t)0x0020)            /*!< Bit 1 */
  4366. #define  TIM_CCMR2_IC3F_2                    ((uint16_t)0x0040)            /*!< Bit 2 */
  4367. #define  TIM_CCMR2_IC3F_3                    ((uint16_t)0x0080)            /*!< Bit 3 */
  4368.  
  4369. #define  TIM_CCMR2_IC4PSC                    ((uint16_t)0x0C00)            /*!< IC4PSC[1:0] bits (Input Capture 4 Prescaler) */
  4370. #define  TIM_CCMR2_IC4PSC_0                  ((uint16_t)0x0400)            /*!< Bit 0 */
  4371. #define  TIM_CCMR2_IC4PSC_1                  ((uint16_t)0x0800)            /*!< Bit 1 */
  4372.  
  4373. #define  TIM_CCMR2_IC4F                      ((uint16_t)0xF000)            /*!< IC4F[3:0] bits (Input Capture 4 Filter) */
  4374. #define  TIM_CCMR2_IC4F_0                    ((uint16_t)0x1000)            /*!< Bit 0 */
  4375. #define  TIM_CCMR2_IC4F_1                    ((uint16_t)0x2000)            /*!< Bit 1 */
  4376. #define  TIM_CCMR2_IC4F_2                    ((uint16_t)0x4000)            /*!< Bit 2 */
  4377. #define  TIM_CCMR2_IC4F_3                    ((uint16_t)0x8000)            /*!< Bit 3 */
  4378.  
  4379. /*******************  Bit definition for TIM_CCER register  *******************/
  4380. #define  TIM_CCER_CC1E                       ((uint16_t)0x0001)            /*!< Capture/Compare 1 output enable */
  4381. #define  TIM_CCER_CC1P                       ((uint16_t)0x0002)            /*!< Capture/Compare 1 output Polarity */
  4382. #define  TIM_CCER_CC1NE                      ((uint16_t)0x0004)            /*!< Capture/Compare 1 Complementary output enable */
  4383. #define  TIM_CCER_CC1NP                      ((uint16_t)0x0008)            /*!< Capture/Compare 1 Complementary output Polarity */
  4384. #define  TIM_CCER_CC2E                       ((uint16_t)0x0010)            /*!< Capture/Compare 2 output enable */
  4385. #define  TIM_CCER_CC2P                       ((uint16_t)0x0020)            /*!< Capture/Compare 2 output Polarity */
  4386. #define  TIM_CCER_CC2NE                      ((uint16_t)0x0040)            /*!< Capture/Compare 2 Complementary output enable */
  4387. #define  TIM_CCER_CC2NP                      ((uint16_t)0x0080)            /*!< Capture/Compare 2 Complementary output Polarity */
  4388. #define  TIM_CCER_CC3E                       ((uint16_t)0x0100)            /*!< Capture/Compare 3 output enable */
  4389. #define  TIM_CCER_CC3P                       ((uint16_t)0x0200)            /*!< Capture/Compare 3 output Polarity */
  4390. #define  TIM_CCER_CC3NE                      ((uint16_t)0x0400)            /*!< Capture/Compare 3 Complementary output enable */
  4391. #define  TIM_CCER_CC3NP                      ((uint16_t)0x0800)            /*!< Capture/Compare 3 Complementary output Polarity */
  4392. #define  TIM_CCER_CC4E                       ((uint16_t)0x1000)            /*!< Capture/Compare 4 output enable */
  4393. #define  TIM_CCER_CC4P                       ((uint16_t)0x2000)            /*!< Capture/Compare 4 output Polarity */
  4394. #define  TIM_CCER_CC4NP                      ((uint16_t)0x8000)            /*!< Capture/Compare 4 Complementary output Polarity */
  4395.  
  4396. /*******************  Bit definition for TIM_CNT register  ********************/
  4397. #define  TIM_CNT_CNT                         ((uint16_t)0xFFFF)            /*!< Counter Value */
  4398.  
  4399. /*******************  Bit definition for TIM_PSC register  ********************/
  4400. #define  TIM_PSC_PSC                         ((uint16_t)0xFFFF)            /*!< Prescaler Value */
  4401.  
  4402. /*******************  Bit definition for TIM_ARR register  ********************/
  4403. #define  TIM_ARR_ARR                         ((uint16_t)0xFFFF)            /*!< actual auto-reload Value */
  4404.  
  4405. /*******************  Bit definition for TIM_RCR register  ********************/
  4406. #define  TIM_RCR_REP                         ((uint8_t)0xFF)               /*!< Repetition Counter Value */
  4407.  
  4408. /*******************  Bit definition for TIM_CCR1 register  *******************/
  4409. #define  TIM_CCR1_CCR1                       ((uint16_t)0xFFFF)            /*!< Capture/Compare 1 Value */
  4410.  
  4411. /*******************  Bit definition for TIM_CCR2 register  *******************/
  4412. #define  TIM_CCR2_CCR2                       ((uint16_t)0xFFFF)            /*!< Capture/Compare 2 Value */
  4413.  
  4414. /*******************  Bit definition for TIM_CCR3 register  *******************/
  4415. #define  TIM_CCR3_CCR3                       ((uint16_t)0xFFFF)            /*!< Capture/Compare 3 Value */
  4416.  
  4417. /*******************  Bit definition for TIM_CCR4 register  *******************/
  4418. #define  TIM_CCR4_CCR4                       ((uint16_t)0xFFFF)            /*!< Capture/Compare 4 Value */
  4419.  
  4420. /*******************  Bit definition for TIM_BDTR register  *******************/
  4421. #define  TIM_BDTR_DTG                        ((uint16_t)0x00FF)            /*!< DTG[0:7] bits (Dead-Time Generator set-up) */
  4422. #define  TIM_BDTR_DTG_0                      ((uint16_t)0x0001)            /*!< Bit 0 */
  4423. #define  TIM_BDTR_DTG_1                      ((uint16_t)0x0002)            /*!< Bit 1 */
  4424. #define  TIM_BDTR_DTG_2                      ((uint16_t)0x0004)            /*!< Bit 2 */
  4425. #define  TIM_BDTR_DTG_3                      ((uint16_t)0x0008)            /*!< Bit 3 */
  4426. #define  TIM_BDTR_DTG_4                      ((uint16_t)0x0010)            /*!< Bit 4 */
  4427. #define  TIM_BDTR_DTG_5                      ((uint16_t)0x0020)            /*!< Bit 5 */
  4428. #define  TIM_BDTR_DTG_6                      ((uint16_t)0x0040)            /*!< Bit 6 */
  4429. #define  TIM_BDTR_DTG_7                      ((uint16_t)0x0080)            /*!< Bit 7 */
  4430.  
  4431. #define  TIM_BDTR_LOCK                       ((uint16_t)0x0300)            /*!< LOCK[1:0] bits (Lock Configuration) */
  4432. #define  TIM_BDTR_LOCK_0                     ((uint16_t)0x0100)            /*!< Bit 0 */
  4433. #define  TIM_BDTR_LOCK_1                     ((uint16_t)0x0200)            /*!< Bit 1 */
  4434.  
  4435. #define  TIM_BDTR_OSSI                       ((uint16_t)0x0400)            /*!< Off-State Selection for Idle mode */
  4436. #define  TIM_BDTR_OSSR                       ((uint16_t)0x0800)            /*!< Off-State Selection for Run mode */
  4437. #define  TIM_BDTR_BKE                        ((uint16_t)0x1000)            /*!< Break enable */
  4438. #define  TIM_BDTR_BKP                        ((uint16_t)0x2000)            /*!< Break Polarity */
  4439. #define  TIM_BDTR_AOE                        ((uint16_t)0x4000)            /*!< Automatic Output enable */
  4440. #define  TIM_BDTR_MOE                        ((uint16_t)0x8000)            /*!< Main Output enable */
  4441.  
  4442. /*******************  Bit definition for TIM_DCR register  ********************/
  4443. #define  TIM_DCR_DBA                         ((uint16_t)0x001F)            /*!< DBA[4:0] bits (DMA Base Address) */
  4444. #define  TIM_DCR_DBA_0                       ((uint16_t)0x0001)            /*!< Bit 0 */
  4445. #define  TIM_DCR_DBA_1                       ((uint16_t)0x0002)            /*!< Bit 1 */
  4446. #define  TIM_DCR_DBA_2                       ((uint16_t)0x0004)            /*!< Bit 2 */
  4447. #define  TIM_DCR_DBA_3                       ((uint16_t)0x0008)            /*!< Bit 3 */
  4448. #define  TIM_DCR_DBA_4                       ((uint16_t)0x0010)            /*!< Bit 4 */
  4449.  
  4450. #define  TIM_DCR_DBL                         ((uint16_t)0x1F00)            /*!< DBL[4:0] bits (DMA Burst Length) */
  4451. #define  TIM_DCR_DBL_0                       ((uint16_t)0x0100)            /*!< Bit 0 */
  4452. #define  TIM_DCR_DBL_1                       ((uint16_t)0x0200)            /*!< Bit 1 */
  4453. #define  TIM_DCR_DBL_2                       ((uint16_t)0x0400)            /*!< Bit 2 */
  4454. #define  TIM_DCR_DBL_3                       ((uint16_t)0x0800)            /*!< Bit 3 */
  4455. #define  TIM_DCR_DBL_4                       ((uint16_t)0x1000)            /*!< Bit 4 */
  4456.  
  4457. /*******************  Bit definition for TIM_DMAR register  *******************/
  4458. #define  TIM_DMAR_DMAB                       ((uint16_t)0xFFFF)            /*!< DMA register for burst accesses */
  4459.  
  4460. /******************************************************************************/
  4461. /*                                                                            */
  4462. /*                             Real-Time Clock                                */
  4463. /*                                                                            */
  4464. /******************************************************************************/
  4465.  
  4466. /*******************  Bit definition for RTC_CRH register  ********************/
  4467. #define  RTC_CRH_SECIE                       ((uint8_t)0x01)               /*!< Second Interrupt Enable */
  4468. #define  RTC_CRH_ALRIE                       ((uint8_t)0x02)               /*!< Alarm Interrupt Enable */
  4469. #define  RTC_CRH_OWIE                        ((uint8_t)0x04)               /*!< OverfloW Interrupt Enable */
  4470.  
  4471. /*******************  Bit definition for RTC_CRL register  ********************/
  4472. #define  RTC_CRL_SECF                        ((uint8_t)0x01)               /*!< Second Flag */
  4473. #define  RTC_CRL_ALRF                        ((uint8_t)0x02)               /*!< Alarm Flag */
  4474. #define  RTC_CRL_OWF                         ((uint8_t)0x04)               /*!< OverfloW Flag */
  4475. #define  RTC_CRL_RSF                         ((uint8_t)0x08)               /*!< Registers Synchronized Flag */
  4476. #define  RTC_CRL_CNF                         ((uint8_t)0x10)               /*!< Configuration Flag */
  4477. #define  RTC_CRL_RTOFF                       ((uint8_t)0x20)               /*!< RTC operation OFF */
  4478.  
  4479. /*******************  Bit definition for RTC_PRLH register  *******************/
  4480. #define  RTC_PRLH_PRL                        ((uint16_t)0x000F)            /*!< RTC Prescaler Reload Value High */
  4481.  
  4482. /*******************  Bit definition for RTC_PRLL register  *******************/
  4483. #define  RTC_PRLL_PRL                        ((uint16_t)0xFFFF)            /*!< RTC Prescaler Reload Value Low */
  4484.  
  4485. /*******************  Bit definition for RTC_DIVH register  *******************/
  4486. #define  RTC_DIVH_RTC_DIV                    ((uint16_t)0x000F)            /*!< RTC Clock Divider High */
  4487.  
  4488. /*******************  Bit definition for RTC_DIVL register  *******************/
  4489. #define  RTC_DIVL_RTC_DIV                    ((uint16_t)0xFFFF)            /*!< RTC Clock Divider Low */
  4490.  
  4491. /*******************  Bit definition for RTC_CNTH register  *******************/
  4492. #define  RTC_CNTH_RTC_CNT                    ((uint16_t)0xFFFF)            /*!< RTC Counter High */
  4493.  
  4494. /*******************  Bit definition for RTC_CNTL register  *******************/
  4495. #define  RTC_CNTL_RTC_CNT                    ((uint16_t)0xFFFF)            /*!< RTC Counter Low */
  4496.  
  4497. /*******************  Bit definition for RTC_ALRH register  *******************/
  4498. #define  RTC_ALRH_RTC_ALR                    ((uint16_t)0xFFFF)            /*!< RTC Alarm High */
  4499.  
  4500. /*******************  Bit definition for RTC_ALRL register  *******************/
  4501. #define  RTC_ALRL_RTC_ALR                    ((uint16_t)0xFFFF)            /*!< RTC Alarm Low */
  4502.  
  4503. /******************************************************************************/
  4504. /*                                                                            */
  4505. /*                           Independent WATCHDOG                             */
  4506. /*                                                                            */
  4507. /******************************************************************************/
  4508.  
  4509. /*******************  Bit definition for IWDG_KR register  ********************/
  4510. #define  IWDG_KR_KEY                         ((uint16_t)0xFFFF)            /*!< Key value (write only, read 0000h) */
  4511.  
  4512. /*******************  Bit definition for IWDG_PR register  ********************/
  4513. #define  IWDG_PR_PR                          ((uint8_t)0x07)               /*!< PR[2:0] (Prescaler divider) */
  4514. #define  IWDG_PR_PR_0                        ((uint8_t)0x01)               /*!< Bit 0 */
  4515. #define  IWDG_PR_PR_1                        ((uint8_t)0x02)               /*!< Bit 1 */
  4516. #define  IWDG_PR_PR_2                        ((uint8_t)0x04)               /*!< Bit 2 */
  4517.  
  4518. /*******************  Bit definition for IWDG_RLR register  *******************/
  4519. #define  IWDG_RLR_RL                         ((uint16_t)0x0FFF)            /*!< Watchdog counter reload value */
  4520.  
  4521. /*******************  Bit definition for IWDG_SR register  ********************/
  4522. #define  IWDG_SR_PVU                         ((uint8_t)0x01)               /*!< Watchdog prescaler value update */
  4523. #define  IWDG_SR_RVU                         ((uint8_t)0x02)               /*!< Watchdog counter reload value update */
  4524.  
  4525. /******************************************************************************/
  4526. /*                                                                            */
  4527. /*                            Window WATCHDOG                                 */
  4528. /*                                                                            */
  4529. /******************************************************************************/
  4530.  
  4531. /*******************  Bit definition for WWDG_CR register  ********************/
  4532. #define  WWDG_CR_T                           ((uint8_t)0x7F)               /*!< T[6:0] bits (7-Bit counter (MSB to LSB)) */
  4533. #define  WWDG_CR_T0                          ((uint8_t)0x01)               /*!< Bit 0 */
  4534. #define  WWDG_CR_T1                          ((uint8_t)0x02)               /*!< Bit 1 */
  4535. #define  WWDG_CR_T2                          ((uint8_t)0x04)               /*!< Bit 2 */
  4536. #define  WWDG_CR_T3                          ((uint8_t)0x08)               /*!< Bit 3 */
  4537. #define  WWDG_CR_T4                          ((uint8_t)0x10)               /*!< Bit 4 */
  4538. #define  WWDG_CR_T5                          ((uint8_t)0x20)               /*!< Bit 5 */
  4539. #define  WWDG_CR_T6                          ((uint8_t)0x40)               /*!< Bit 6 */
  4540.  
  4541. #define  WWDG_CR_WDGA                        ((uint8_t)0x80)               /*!< Activation bit */
  4542.  
  4543. /*******************  Bit definition for WWDG_CFR register  *******************/
  4544. #define  WWDG_CFR_W                          ((uint16_t)0x007F)            /*!< W[6:0] bits (7-bit window value) */
  4545. #define  WWDG_CFR_W0                         ((uint16_t)0x0001)            /*!< Bit 0 */
  4546. #define  WWDG_CFR_W1                         ((uint16_t)0x0002)            /*!< Bit 1 */
  4547. #define  WWDG_CFR_W2                         ((uint16_t)0x0004)            /*!< Bit 2 */
  4548. #define  WWDG_CFR_W3                         ((uint16_t)0x0008)            /*!< Bit 3 */
  4549. #define  WWDG_CFR_W4                         ((uint16_t)0x0010)            /*!< Bit 4 */
  4550. #define  WWDG_CFR_W5                         ((uint16_t)0x0020)            /*!< Bit 5 */
  4551. #define  WWDG_CFR_W6                         ((uint16_t)0x0040)            /*!< Bit 6 */
  4552.  
  4553. #define  WWDG_CFR_WDGTB                      ((uint16_t)0x0180)            /*!< WDGTB[1:0] bits (Timer Base) */
  4554. #define  WWDG_CFR_WDGTB0                     ((uint16_t)0x0080)            /*!< Bit 0 */
  4555. #define  WWDG_CFR_WDGTB1                     ((uint16_t)0x0100)            /*!< Bit 1 */
  4556.  
  4557. #define  WWDG_CFR_EWI                        ((uint16_t)0x0200)            /*!< Early Wakeup Interrupt */
  4558.  
  4559. /*******************  Bit definition for WWDG_SR register  ********************/
  4560. #define  WWDG_SR_EWIF                        ((uint8_t)0x01)               /*!< Early Wakeup Interrupt Flag */
  4561.  
  4562. /******************************************************************************/
  4563. /*                                                                            */
  4564. /*                       Flexible Static Memory Controller                    */
  4565. /*                                                                            */
  4566. /******************************************************************************/
  4567.  
  4568. /******************  Bit definition for FSMC_BCR1 register  *******************/
  4569. #define  FSMC_BCR1_MBKEN                     ((uint32_t)0x00000001)        /*!< Memory bank enable bit */
  4570. #define  FSMC_BCR1_MUXEN                     ((uint32_t)0x00000002)        /*!< Address/data multiplexing enable bit */
  4571.  
  4572. #define  FSMC_BCR1_MTYP                      ((uint32_t)0x0000000C)        /*!< MTYP[1:0] bits (Memory type) */
  4573. #define  FSMC_BCR1_MTYP_0                    ((uint32_t)0x00000004)        /*!< Bit 0 */
  4574. #define  FSMC_BCR1_MTYP_1                    ((uint32_t)0x00000008)        /*!< Bit 1 */
  4575.  
  4576. #define  FSMC_BCR1_MWID                      ((uint32_t)0x00000030)        /*!< MWID[1:0] bits (Memory data bus width) */
  4577. #define  FSMC_BCR1_MWID_0                    ((uint32_t)0x00000010)        /*!< Bit 0 */
  4578. #define  FSMC_BCR1_MWID_1                    ((uint32_t)0x00000020)        /*!< Bit 1 */
  4579.  
  4580. #define  FSMC_BCR1_FACCEN                    ((uint32_t)0x00000040)        /*!< Flash access enable */
  4581. #define  FSMC_BCR1_BURSTEN                   ((uint32_t)0x00000100)        /*!< Burst enable bit */
  4582. #define  FSMC_BCR1_WAITPOL                   ((uint32_t)0x00000200)        /*!< Wait signal polarity bit */
  4583. #define  FSMC_BCR1_WRAPMOD                   ((uint32_t)0x00000400)        /*!< Wrapped burst mode support */
  4584. #define  FSMC_BCR1_WAITCFG                   ((uint32_t)0x00000800)        /*!< Wait timing configuration */
  4585. #define  FSMC_BCR1_WREN                      ((uint32_t)0x00001000)        /*!< Write enable bit */
  4586. #define  FSMC_BCR1_WAITEN                    ((uint32_t)0x00002000)        /*!< Wait enable bit */
  4587. #define  FSMC_BCR1_EXTMOD                    ((uint32_t)0x00004000)        /*!< Extended mode enable */
  4588. #define  FSMC_BCR1_ASYNCWAIT                 ((uint32_t)0x00008000)       /*!< Asynchronous wait */
  4589. #define  FSMC_BCR1_CBURSTRW                  ((uint32_t)0x00080000)        /*!< Write burst enable */
  4590.  
  4591. /******************  Bit definition for FSMC_BCR2 register  *******************/
  4592. #define  FSMC_BCR2_MBKEN                     ((uint32_t)0x00000001)        /*!< Memory bank enable bit */
  4593. #define  FSMC_BCR2_MUXEN                     ((uint32_t)0x00000002)        /*!< Address/data multiplexing enable bit */
  4594.  
  4595. #define  FSMC_BCR2_MTYP                      ((uint32_t)0x0000000C)        /*!< MTYP[1:0] bits (Memory type) */
  4596. #define  FSMC_BCR2_MTYP_0                    ((uint32_t)0x00000004)        /*!< Bit 0 */
  4597. #define  FSMC_BCR2_MTYP_1                    ((uint32_t)0x00000008)        /*!< Bit 1 */
  4598.  
  4599. #define  FSMC_BCR2_MWID                      ((uint32_t)0x00000030)        /*!< MWID[1:0] bits (Memory data bus width) */
  4600. #define  FSMC_BCR2_MWID_0                    ((uint32_t)0x00000010)        /*!< Bit 0 */
  4601. #define  FSMC_BCR2_MWID_1                    ((uint32_t)0x00000020)        /*!< Bit 1 */
  4602.  
  4603. #define  FSMC_BCR2_FACCEN                    ((uint32_t)0x00000040)        /*!< Flash access enable */
  4604. #define  FSMC_BCR2_BURSTEN                   ((uint32_t)0x00000100)        /*!< Burst enable bit */
  4605. #define  FSMC_BCR2_WAITPOL                   ((uint32_t)0x00000200)        /*!< Wait signal polarity bit */
  4606. #define  FSMC_BCR2_WRAPMOD                   ((uint32_t)0x00000400)        /*!< Wrapped burst mode support */
  4607. #define  FSMC_BCR2_WAITCFG                   ((uint32_t)0x00000800)        /*!< Wait timing configuration */
  4608. #define  FSMC_BCR2_WREN                      ((uint32_t)0x00001000)        /*!< Write enable bit */
  4609. #define  FSMC_BCR2_WAITEN                    ((uint32_t)0x00002000)        /*!< Wait enable bit */
  4610. #define  FSMC_BCR2_EXTMOD                    ((uint32_t)0x00004000)        /*!< Extended mode enable */
  4611. #define  FSMC_BCR2_ASYNCWAIT                 ((uint32_t)0x00008000)       /*!< Asynchronous wait */
  4612. #define  FSMC_BCR2_CBURSTRW                  ((uint32_t)0x00080000)        /*!< Write burst enable */
  4613.  
  4614. /******************  Bit definition for FSMC_BCR3 register  *******************/
  4615. #define  FSMC_BCR3_MBKEN                     ((uint32_t)0x00000001)        /*!< Memory bank enable bit */
  4616. #define  FSMC_BCR3_MUXEN                     ((uint32_t)0x00000002)        /*!< Address/data multiplexing enable bit */
  4617.  
  4618. #define  FSMC_BCR3_MTYP                      ((uint32_t)0x0000000C)        /*!< MTYP[1:0] bits (Memory type) */
  4619. #define  FSMC_BCR3_MTYP_0                    ((uint32_t)0x00000004)        /*!< Bit 0 */
  4620. #define  FSMC_BCR3_MTYP_1                    ((uint32_t)0x00000008)        /*!< Bit 1 */
  4621.  
  4622. #define  FSMC_BCR3_MWID                      ((uint32_t)0x00000030)        /*!< MWID[1:0] bits (Memory data bus width) */
  4623. #define  FSMC_BCR3_MWID_0                    ((uint32_t)0x00000010)        /*!< Bit 0 */
  4624. #define  FSMC_BCR3_MWID_1                    ((uint32_t)0x00000020)        /*!< Bit 1 */
  4625.  
  4626. #define  FSMC_BCR3_FACCEN                    ((uint32_t)0x00000040)        /*!< Flash access enable */
  4627. #define  FSMC_BCR3_BURSTEN                   ((uint32_t)0x00000100)        /*!< Burst enable bit */
  4628. #define  FSMC_BCR3_WAITPOL                   ((uint32_t)0x00000200)        /*!< Wait signal polarity bit. */
  4629. #define  FSMC_BCR3_WRAPMOD                   ((uint32_t)0x00000400)        /*!< Wrapped burst mode support */
  4630. #define  FSMC_BCR3_WAITCFG                   ((uint32_t)0x00000800)        /*!< Wait timing configuration */
  4631. #define  FSMC_BCR3_WREN                      ((uint32_t)0x00001000)        /*!< Write enable bit */
  4632. #define  FSMC_BCR3_WAITEN                    ((uint32_t)0x00002000)        /*!< Wait enable bit */
  4633. #define  FSMC_BCR3_EXTMOD                    ((uint32_t)0x00004000)        /*!< Extended mode enable */
  4634. #define  FSMC_BCR3_ASYNCWAIT                 ((uint32_t)0x00008000)       /*!< Asynchronous wait */
  4635. #define  FSMC_BCR3_CBURSTRW                  ((uint32_t)0x00080000)        /*!< Write burst enable */
  4636.  
  4637. /******************  Bit definition for FSMC_BCR4 register  *******************/
  4638. #define  FSMC_BCR4_MBKEN                     ((uint32_t)0x00000001)        /*!< Memory bank enable bit */
  4639. #define  FSMC_BCR4_MUXEN                     ((uint32_t)0x00000002)        /*!< Address/data multiplexing enable bit */
  4640.  
  4641. #define  FSMC_BCR4_MTYP                      ((uint32_t)0x0000000C)        /*!< MTYP[1:0] bits (Memory type) */
  4642. #define  FSMC_BCR4_MTYP_0                    ((uint32_t)0x00000004)        /*!< Bit 0 */
  4643. #define  FSMC_BCR4_MTYP_1                    ((uint32_t)0x00000008)        /*!< Bit 1 */
  4644.  
  4645. #define  FSMC_BCR4_MWID                      ((uint32_t)0x00000030)        /*!< MWID[1:0] bits (Memory data bus width) */
  4646. #define  FSMC_BCR4_MWID_0                    ((uint32_t)0x00000010)        /*!< Bit 0 */
  4647. #define  FSMC_BCR4_MWID_1                    ((uint32_t)0x00000020)        /*!< Bit 1 */
  4648.  
  4649. #define  FSMC_BCR4_FACCEN                    ((uint32_t)0x00000040)        /*!< Flash access enable */
  4650. #define  FSMC_BCR4_BURSTEN                   ((uint32_t)0x00000100)        /*!< Burst enable bit */
  4651. #define  FSMC_BCR4_WAITPOL                   ((uint32_t)0x00000200)        /*!< Wait signal polarity bit */
  4652. #define  FSMC_BCR4_WRAPMOD                   ((uint32_t)0x00000400)        /*!< Wrapped burst mode support */
  4653. #define  FSMC_BCR4_WAITCFG                   ((uint32_t)0x00000800)        /*!< Wait timing configuration */
  4654. #define  FSMC_BCR4_WREN                      ((uint32_t)0x00001000)        /*!< Write enable bit */
  4655. #define  FSMC_BCR4_WAITEN                    ((uint32_t)0x00002000)        /*!< Wait enable bit */
  4656. #define  FSMC_BCR4_EXTMOD                    ((uint32_t)0x00004000)        /*!< Extended mode enable */
  4657. #define  FSMC_BCR4_ASYNCWAIT                 ((uint32_t)0x00008000)       /*!< Asynchronous wait */
  4658. #define  FSMC_BCR4_CBURSTRW                  ((uint32_t)0x00080000)        /*!< Write burst enable */
  4659.  
  4660. /******************  Bit definition for FSMC_BTR1 register  ******************/
  4661. #define  FSMC_BTR1_ADDSET                    ((uint32_t)0x0000000F)        /*!< ADDSET[3:0] bits (Address setup phase duration) */
  4662. #define  FSMC_BTR1_ADDSET_0                  ((uint32_t)0x00000001)        /*!< Bit 0 */
  4663. #define  FSMC_BTR1_ADDSET_1                  ((uint32_t)0x00000002)        /*!< Bit 1 */
  4664. #define  FSMC_BTR1_ADDSET_2                  ((uint32_t)0x00000004)        /*!< Bit 2 */
  4665. #define  FSMC_BTR1_ADDSET_3                  ((uint32_t)0x00000008)        /*!< Bit 3 */
  4666.  
  4667. #define  FSMC_BTR1_ADDHLD                    ((uint32_t)0x000000F0)        /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
  4668. #define  FSMC_BTR1_ADDHLD_0                  ((uint32_t)0x00000010)        /*!< Bit 0 */
  4669. #define  FSMC_BTR1_ADDHLD_1                  ((uint32_t)0x00000020)        /*!< Bit 1 */
  4670. #define  FSMC_BTR1_ADDHLD_2                  ((uint32_t)0x00000040)        /*!< Bit 2 */
  4671. #define  FSMC_BTR1_ADDHLD_3                  ((uint32_t)0x00000080)        /*!< Bit 3 */
  4672.  
  4673. #define  FSMC_BTR1_DATAST                    ((uint32_t)0x0000FF00)        /*!< DATAST [3:0] bits (Data-phase duration) */
  4674. #define  FSMC_BTR1_DATAST_0                  ((uint32_t)0x00000100)        /*!< Bit 0 */
  4675. #define  FSMC_BTR1_DATAST_1                  ((uint32_t)0x00000200)        /*!< Bit 1 */
  4676. #define  FSMC_BTR1_DATAST_2                  ((uint32_t)0x00000400)        /*!< Bit 2 */
  4677. #define  FSMC_BTR1_DATAST_3                  ((uint32_t)0x00000800)        /*!< Bit 3 */
  4678. #define  FSMC_BTR1_DATAST_4                  ((uint32_t)0x00001000)        /*!< Bit 4 */
  4679. #define  FSMC_BTR1_DATAST_5                  ((uint32_t)0x00002000)        /*!< Bit 5 */
  4680. #define  FSMC_BTR1_DATAST_6                  ((uint32_t)0x00004000)        /*!< Bit 6 */
  4681. #define  FSMC_BTR1_DATAST_7                  ((uint32_t)0x00008000)        /*!< Bit 7 */
  4682.  
  4683. #define  FSMC_BTR1_BUSTURN                   ((uint32_t)0x000F0000)        /*!< BUSTURN[3:0] bits (Bus turnaround phase duration) */
  4684. #define  FSMC_BTR1_BUSTURN_0                 ((uint32_t)0x00010000)        /*!< Bit 0 */
  4685. #define  FSMC_BTR1_BUSTURN_1                 ((uint32_t)0x00020000)        /*!< Bit 1 */
  4686. #define  FSMC_BTR1_BUSTURN_2                 ((uint32_t)0x00040000)        /*!< Bit 2 */
  4687. #define  FSMC_BTR1_BUSTURN_3                 ((uint32_t)0x00080000)        /*!< Bit 3 */
  4688.  
  4689. #define  FSMC_BTR1_CLKDIV                    ((uint32_t)0x00F00000)        /*!< CLKDIV[3:0] bits (Clock divide ratio) */
  4690. #define  FSMC_BTR1_CLKDIV_0                  ((uint32_t)0x00100000)        /*!< Bit 0 */
  4691. #define  FSMC_BTR1_CLKDIV_1                  ((uint32_t)0x00200000)        /*!< Bit 1 */
  4692. #define  FSMC_BTR1_CLKDIV_2                  ((uint32_t)0x00400000)        /*!< Bit 2 */
  4693. #define  FSMC_BTR1_CLKDIV_3                  ((uint32_t)0x00800000)        /*!< Bit 3 */
  4694.  
  4695. #define  FSMC_BTR1_DATLAT                    ((uint32_t)0x0F000000)        /*!< DATLA[3:0] bits (Data latency) */
  4696. #define  FSMC_BTR1_DATLAT_0                  ((uint32_t)0x01000000)        /*!< Bit 0 */
  4697. #define  FSMC_BTR1_DATLAT_1                  ((uint32_t)0x02000000)        /*!< Bit 1 */
  4698. #define  FSMC_BTR1_DATLAT_2                  ((uint32_t)0x04000000)        /*!< Bit 2 */
  4699. #define  FSMC_BTR1_DATLAT_3                  ((uint32_t)0x08000000)        /*!< Bit 3 */
  4700.  
  4701. #define  FSMC_BTR1_ACCMOD                    ((uint32_t)0x30000000)        /*!< ACCMOD[1:0] bits (Access mode) */
  4702. #define  FSMC_BTR1_ACCMOD_0                  ((uint32_t)0x10000000)        /*!< Bit 0 */
  4703. #define  FSMC_BTR1_ACCMOD_1                  ((uint32_t)0x20000000)        /*!< Bit 1 */
  4704.  
  4705. /******************  Bit definition for FSMC_BTR2 register  *******************/
  4706. #define  FSMC_BTR2_ADDSET                    ((uint32_t)0x0000000F)        /*!< ADDSET[3:0] bits (Address setup phase duration) */
  4707. #define  FSMC_BTR2_ADDSET_0                  ((uint32_t)0x00000001)        /*!< Bit 0 */
  4708. #define  FSMC_BTR2_ADDSET_1                  ((uint32_t)0x00000002)        /*!< Bit 1 */
  4709. #define  FSMC_BTR2_ADDSET_2                  ((uint32_t)0x00000004)        /*!< Bit 2 */
  4710. #define  FSMC_BTR2_ADDSET_3                  ((uint32_t)0x00000008)        /*!< Bit 3 */
  4711.  
  4712. #define  FSMC_BTR2_ADDHLD                    ((uint32_t)0x000000F0)        /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
  4713. #define  FSMC_BTR2_ADDHLD_0                  ((uint32_t)0x00000010)        /*!< Bit 0 */
  4714. #define  FSMC_BTR2_ADDHLD_1                  ((uint32_t)0x00000020)        /*!< Bit 1 */
  4715. #define  FSMC_BTR2_ADDHLD_2                  ((uint32_t)0x00000040)        /*!< Bit 2 */
  4716. #define  FSMC_BTR2_ADDHLD_3                  ((uint32_t)0x00000080)        /*!< Bit 3 */
  4717.  
  4718. #define  FSMC_BTR2_DATAST                    ((uint32_t)0x0000FF00)        /*!< DATAST [3:0] bits (Data-phase duration) */
  4719. #define  FSMC_BTR2_DATAST_0                  ((uint32_t)0x00000100)        /*!< Bit 0 */
  4720. #define  FSMC_BTR2_DATAST_1                  ((uint32_t)0x00000200)        /*!< Bit 1 */
  4721. #define  FSMC_BTR2_DATAST_2                  ((uint32_t)0x00000400)        /*!< Bit 2 */
  4722. #define  FSMC_BTR2_DATAST_3                  ((uint32_t)0x00000800)        /*!< Bit 3 */
  4723. #define  FSMC_BTR2_DATAST_4                  ((uint32_t)0x00001000)        /*!< Bit 4 */
  4724. #define  FSMC_BTR2_DATAST_5                  ((uint32_t)0x00002000)        /*!< Bit 5 */
  4725. #define  FSMC_BTR2_DATAST_6                  ((uint32_t)0x00004000)        /*!< Bit 6 */
  4726. #define  FSMC_BTR2_DATAST_7                  ((uint32_t)0x00008000)        /*!< Bit 7 */
  4727.  
  4728. #define  FSMC_BTR2_BUSTURN                   ((uint32_t)0x000F0000)        /*!< BUSTURN[3:0] bits (Bus turnaround phase duration) */
  4729. #define  FSMC_BTR2_BUSTURN_0                 ((uint32_t)0x00010000)        /*!< Bit 0 */
  4730. #define  FSMC_BTR2_BUSTURN_1                 ((uint32_t)0x00020000)        /*!< Bit 1 */
  4731. #define  FSMC_BTR2_BUSTURN_2                 ((uint32_t)0x00040000)        /*!< Bit 2 */
  4732. #define  FSMC_BTR2_BUSTURN_3                 ((uint32_t)0x00080000)        /*!< Bit 3 */
  4733.  
  4734. #define  FSMC_BTR2_CLKDIV                    ((uint32_t)0x00F00000)        /*!< CLKDIV[3:0] bits (Clock divide ratio) */
  4735. #define  FSMC_BTR2_CLKDIV_0                  ((uint32_t)0x00100000)        /*!< Bit 0 */
  4736. #define  FSMC_BTR2_CLKDIV_1                  ((uint32_t)0x00200000)        /*!< Bit 1 */
  4737. #define  FSMC_BTR2_CLKDIV_2                  ((uint32_t)0x00400000)        /*!< Bit 2 */
  4738. #define  FSMC_BTR2_CLKDIV_3                  ((uint32_t)0x00800000)        /*!< Bit 3 */
  4739.  
  4740. #define  FSMC_BTR2_DATLAT                    ((uint32_t)0x0F000000)        /*!< DATLA[3:0] bits (Data latency) */
  4741. #define  FSMC_BTR2_DATLAT_0                  ((uint32_t)0x01000000)        /*!< Bit 0 */
  4742. #define  FSMC_BTR2_DATLAT_1                  ((uint32_t)0x02000000)        /*!< Bit 1 */
  4743. #define  FSMC_BTR2_DATLAT_2                  ((uint32_t)0x04000000)        /*!< Bit 2 */
  4744. #define  FSMC_BTR2_DATLAT_3                  ((uint32_t)0x08000000)        /*!< Bit 3 */
  4745.  
  4746. #define  FSMC_BTR2_ACCMOD                    ((uint32_t)0x30000000)        /*!< ACCMOD[1:0] bits (Access mode) */
  4747. #define  FSMC_BTR2_ACCMOD_0                  ((uint32_t)0x10000000)        /*!< Bit 0 */
  4748. #define  FSMC_BTR2_ACCMOD_1                  ((uint32_t)0x20000000)        /*!< Bit 1 */
  4749.  
  4750. /*******************  Bit definition for FSMC_BTR3 register  *******************/
  4751. #define  FSMC_BTR3_ADDSET                    ((uint32_t)0x0000000F)        /*!< ADDSET[3:0] bits (Address setup phase duration) */
  4752. #define  FSMC_BTR3_ADDSET_0                  ((uint32_t)0x00000001)        /*!< Bit 0 */
  4753. #define  FSMC_BTR3_ADDSET_1                  ((uint32_t)0x00000002)        /*!< Bit 1 */
  4754. #define  FSMC_BTR3_ADDSET_2                  ((uint32_t)0x00000004)        /*!< Bit 2 */
  4755. #define  FSMC_BTR3_ADDSET_3                  ((uint32_t)0x00000008)        /*!< Bit 3 */
  4756.  
  4757. #define  FSMC_BTR3_ADDHLD                    ((uint32_t)0x000000F0)        /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
  4758. #define  FSMC_BTR3_ADDHLD_0                  ((uint32_t)0x00000010)        /*!< Bit 0 */
  4759. #define  FSMC_BTR3_ADDHLD_1                  ((uint32_t)0x00000020)        /*!< Bit 1 */
  4760. #define  FSMC_BTR3_ADDHLD_2                  ((uint32_t)0x00000040)        /*!< Bit 2 */
  4761. #define  FSMC_BTR3_ADDHLD_3                  ((uint32_t)0x00000080)        /*!< Bit 3 */
  4762.  
  4763. #define  FSMC_BTR3_DATAST                    ((uint32_t)0x0000FF00)        /*!< DATAST [3:0] bits (Data-phase duration) */
  4764. #define  FSMC_BTR3_DATAST_0                  ((uint32_t)0x00000100)        /*!< Bit 0 */
  4765. #define  FSMC_BTR3_DATAST_1                  ((uint32_t)0x00000200)        /*!< Bit 1 */
  4766. #define  FSMC_BTR3_DATAST_2                  ((uint32_t)0x00000400)        /*!< Bit 2 */
  4767. #define  FSMC_BTR3_DATAST_3                  ((uint32_t)0x00000800)        /*!< Bit 3 */
  4768. #define  FSMC_BTR3_DATAST_4                  ((uint32_t)0x00001000)        /*!< Bit 4 */
  4769. #define  FSMC_BTR3_DATAST_5                  ((uint32_t)0x00002000)        /*!< Bit 5 */
  4770. #define  FSMC_BTR3_DATAST_6                  ((uint32_t)0x00004000)        /*!< Bit 6 */
  4771. #define  FSMC_BTR3_DATAST_7                  ((uint32_t)0x00008000)        /*!< Bit 7 */
  4772.  
  4773. #define  FSMC_BTR3_BUSTURN                   ((uint32_t)0x000F0000)        /*!< BUSTURN[3:0] bits (Bus turnaround phase duration) */
  4774. #define  FSMC_BTR3_BUSTURN_0                 ((uint32_t)0x00010000)        /*!< Bit 0 */
  4775. #define  FSMC_BTR3_BUSTURN_1                 ((uint32_t)0x00020000)        /*!< Bit 1 */
  4776. #define  FSMC_BTR3_BUSTURN_2                 ((uint32_t)0x00040000)        /*!< Bit 2 */
  4777. #define  FSMC_BTR3_BUSTURN_3                 ((uint32_t)0x00080000)        /*!< Bit 3 */
  4778.  
  4779. #define  FSMC_BTR3_CLKDIV                    ((uint32_t)0x00F00000)        /*!< CLKDIV[3:0] bits (Clock divide ratio) */
  4780. #define  FSMC_BTR3_CLKDIV_0                  ((uint32_t)0x00100000)        /*!< Bit 0 */
  4781. #define  FSMC_BTR3_CLKDIV_1                  ((uint32_t)0x00200000)        /*!< Bit 1 */
  4782. #define  FSMC_BTR3_CLKDIV_2                  ((uint32_t)0x00400000)        /*!< Bit 2 */
  4783. #define  FSMC_BTR3_CLKDIV_3                  ((uint32_t)0x00800000)        /*!< Bit 3 */
  4784.  
  4785. #define  FSMC_BTR3_DATLAT                    ((uint32_t)0x0F000000)        /*!< DATLA[3:0] bits (Data latency) */
  4786. #define  FSMC_BTR3_DATLAT_0                  ((uint32_t)0x01000000)        /*!< Bit 0 */
  4787. #define  FSMC_BTR3_DATLAT_1                  ((uint32_t)0x02000000)        /*!< Bit 1 */
  4788. #define  FSMC_BTR3_DATLAT_2                  ((uint32_t)0x04000000)        /*!< Bit 2 */
  4789. #define  FSMC_BTR3_DATLAT_3                  ((uint32_t)0x08000000)        /*!< Bit 3 */
  4790.  
  4791. #define  FSMC_BTR3_ACCMOD                    ((uint32_t)0x30000000)        /*!< ACCMOD[1:0] bits (Access mode) */
  4792. #define  FSMC_BTR3_ACCMOD_0                  ((uint32_t)0x10000000)        /*!< Bit 0 */
  4793. #define  FSMC_BTR3_ACCMOD_1                  ((uint32_t)0x20000000)        /*!< Bit 1 */
  4794.  
  4795. /******************  Bit definition for FSMC_BTR4 register  *******************/
  4796. #define  FSMC_BTR4_ADDSET                    ((uint32_t)0x0000000F)        /*!< ADDSET[3:0] bits (Address setup phase duration) */
  4797. #define  FSMC_BTR4_ADDSET_0                  ((uint32_t)0x00000001)        /*!< Bit 0 */
  4798. #define  FSMC_BTR4_ADDSET_1                  ((uint32_t)0x00000002)        /*!< Bit 1 */
  4799. #define  FSMC_BTR4_ADDSET_2                  ((uint32_t)0x00000004)        /*!< Bit 2 */
  4800. #define  FSMC_BTR4_ADDSET_3                  ((uint32_t)0x00000008)        /*!< Bit 3 */
  4801.  
  4802. #define  FSMC_BTR4_ADDHLD                    ((uint32_t)0x000000F0)        /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
  4803. #define  FSMC_BTR4_ADDHLD_0                  ((uint32_t)0x00000010)        /*!< Bit 0 */
  4804. #define  FSMC_BTR4_ADDHLD_1                  ((uint32_t)0x00000020)        /*!< Bit 1 */
  4805. #define  FSMC_BTR4_ADDHLD_2                  ((uint32_t)0x00000040)        /*!< Bit 2 */
  4806. #define  FSMC_BTR4_ADDHLD_3                  ((uint32_t)0x00000080)        /*!< Bit 3 */
  4807.  
  4808. #define  FSMC_BTR4_DATAST                    ((uint32_t)0x0000FF00)        /*!< DATAST [3:0] bits (Data-phase duration) */
  4809. #define  FSMC_BTR4_DATAST_0                  ((uint32_t)0x00000100)        /*!< Bit 0 */
  4810. #define  FSMC_BTR4_DATAST_1                  ((uint32_t)0x00000200)        /*!< Bit 1 */
  4811. #define  FSMC_BTR4_DATAST_2                  ((uint32_t)0x00000400)        /*!< Bit 2 */
  4812. #define  FSMC_BTR4_DATAST_3                  ((uint32_t)0x00000800)        /*!< Bit 3 */
  4813. #define  FSMC_BTR4_DATAST_4                  ((uint32_t)0x00001000)        /*!< Bit 4 */
  4814. #define  FSMC_BTR4_DATAST_5                  ((uint32_t)0x00002000)        /*!< Bit 5 */
  4815. #define  FSMC_BTR4_DATAST_6                  ((uint32_t)0x00004000)        /*!< Bit 6 */
  4816. #define  FSMC_BTR4_DATAST_7                  ((uint32_t)0x00008000)        /*!< Bit 7 */
  4817.  
  4818. #define  FSMC_BTR4_BUSTURN                   ((uint32_t)0x000F0000)        /*!< BUSTURN[3:0] bits (Bus turnaround phase duration) */
  4819. #define  FSMC_BTR4_BUSTURN_0                 ((uint32_t)0x00010000)        /*!< Bit 0 */
  4820. #define  FSMC_BTR4_BUSTURN_1                 ((uint32_t)0x00020000)        /*!< Bit 1 */
  4821. #define  FSMC_BTR4_BUSTURN_2                 ((uint32_t)0x00040000)        /*!< Bit 2 */
  4822. #define  FSMC_BTR4_BUSTURN_3                 ((uint32_t)0x00080000)        /*!< Bit 3 */
  4823.  
  4824. #define  FSMC_BTR4_CLKDIV                    ((uint32_t)0x00F00000)        /*!< CLKDIV[3:0] bits (Clock divide ratio) */
  4825. #define  FSMC_BTR4_CLKDIV_0                  ((uint32_t)0x00100000)        /*!< Bit 0 */
  4826. #define  FSMC_BTR4_CLKDIV_1                  ((uint32_t)0x00200000)        /*!< Bit 1 */
  4827. #define  FSMC_BTR4_CLKDIV_2                  ((uint32_t)0x00400000)        /*!< Bit 2 */
  4828. #define  FSMC_BTR4_CLKDIV_3                  ((uint32_t)0x00800000)        /*!< Bit 3 */
  4829.  
  4830. #define  FSMC_BTR4_DATLAT                    ((uint32_t)0x0F000000)        /*!< DATLA[3:0] bits (Data latency) */
  4831. #define  FSMC_BTR4_DATLAT_0                  ((uint32_t)0x01000000)        /*!< Bit 0 */
  4832. #define  FSMC_BTR4_DATLAT_1                  ((uint32_t)0x02000000)        /*!< Bit 1 */
  4833. #define  FSMC_BTR4_DATLAT_2                  ((uint32_t)0x04000000)        /*!< Bit 2 */
  4834. #define  FSMC_BTR4_DATLAT_3                  ((uint32_t)0x08000000)        /*!< Bit 3 */
  4835.  
  4836. #define  FSMC_BTR4_ACCMOD                    ((uint32_t)0x30000000)        /*!< ACCMOD[1:0] bits (Access mode) */
  4837. #define  FSMC_BTR4_ACCMOD_0                  ((uint32_t)0x10000000)        /*!< Bit 0 */
  4838. #define  FSMC_BTR4_ACCMOD_1                  ((uint32_t)0x20000000)        /*!< Bit 1 */
  4839.  
  4840. /******************  Bit definition for FSMC_BWTR1 register  ******************/
  4841. #define  FSMC_BWTR1_ADDSET                   ((uint32_t)0x0000000F)        /*!< ADDSET[3:0] bits (Address setup phase duration) */
  4842. #define  FSMC_BWTR1_ADDSET_0                 ((uint32_t)0x00000001)        /*!< Bit 0 */
  4843. #define  FSMC_BWTR1_ADDSET_1                 ((uint32_t)0x00000002)        /*!< Bit 1 */
  4844. #define  FSMC_BWTR1_ADDSET_2                 ((uint32_t)0x00000004)        /*!< Bit 2 */
  4845. #define  FSMC_BWTR1_ADDSET_3                 ((uint32_t)0x00000008)        /*!< Bit 3 */
  4846.  
  4847. #define  FSMC_BWTR1_ADDHLD                   ((uint32_t)0x000000F0)        /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
  4848. #define  FSMC_BWTR1_ADDHLD_0                 ((uint32_t)0x00000010)        /*!< Bit 0 */
  4849. #define  FSMC_BWTR1_ADDHLD_1                 ((uint32_t)0x00000020)        /*!< Bit 1 */
  4850. #define  FSMC_BWTR1_ADDHLD_2                 ((uint32_t)0x00000040)        /*!< Bit 2 */
  4851. #define  FSMC_BWTR1_ADDHLD_3                 ((uint32_t)0x00000080)        /*!< Bit 3 */
  4852.  
  4853. #define  FSMC_BWTR1_DATAST                   ((uint32_t)0x0000FF00)        /*!< DATAST [3:0] bits (Data-phase duration) */
  4854. #define  FSMC_BWTR1_DATAST_0                 ((uint32_t)0x00000100)        /*!< Bit 0 */
  4855. #define  FSMC_BWTR1_DATAST_1                 ((uint32_t)0x00000200)        /*!< Bit 1 */
  4856. #define  FSMC_BWTR1_DATAST_2                 ((uint32_t)0x00000400)        /*!< Bit 2 */
  4857. #define  FSMC_BWTR1_DATAST_3                 ((uint32_t)0x00000800)        /*!< Bit 3 */
  4858. #define  FSMC_BWTR1_DATAST_4                 ((uint32_t)0x00001000)        /*!< Bit 4 */
  4859. #define  FSMC_BWTR1_DATAST_5                 ((uint32_t)0x00002000)        /*!< Bit 5 */
  4860. #define  FSMC_BWTR1_DATAST_6                 ((uint32_t)0x00004000)        /*!< Bit 6 */
  4861. #define  FSMC_BWTR1_DATAST_7                 ((uint32_t)0x00008000)        /*!< Bit 7 */
  4862.  
  4863. #define  FSMC_BWTR1_CLKDIV                   ((uint32_t)0x00F00000)        /*!< CLKDIV[3:0] bits (Clock divide ratio) */
  4864. #define  FSMC_BWTR1_CLKDIV_0                 ((uint32_t)0x00100000)        /*!< Bit 0 */
  4865. #define  FSMC_BWTR1_CLKDIV_1                 ((uint32_t)0x00200000)        /*!< Bit 1 */
  4866. #define  FSMC_BWTR1_CLKDIV_2                 ((uint32_t)0x00400000)        /*!< Bit 2 */
  4867. #define  FSMC_BWTR1_CLKDIV_3                 ((uint32_t)0x00800000)        /*!< Bit 3 */
  4868.  
  4869. #define  FSMC_BWTR1_DATLAT                   ((uint32_t)0x0F000000)        /*!< DATLA[3:0] bits (Data latency) */
  4870. #define  FSMC_BWTR1_DATLAT_0                 ((uint32_t)0x01000000)        /*!< Bit 0 */
  4871. #define  FSMC_BWTR1_DATLAT_1                 ((uint32_t)0x02000000)        /*!< Bit 1 */
  4872. #define  FSMC_BWTR1_DATLAT_2                 ((uint32_t)0x04000000)        /*!< Bit 2 */
  4873. #define  FSMC_BWTR1_DATLAT_3                 ((uint32_t)0x08000000)        /*!< Bit 3 */
  4874.  
  4875. #define  FSMC_BWTR1_ACCMOD                   ((uint32_t)0x30000000)        /*!< ACCMOD[1:0] bits (Access mode) */
  4876. #define  FSMC_BWTR1_ACCMOD_0                 ((uint32_t)0x10000000)        /*!< Bit 0 */
  4877. #define  FSMC_BWTR1_ACCMOD_1                 ((uint32_t)0x20000000)        /*!< Bit 1 */
  4878.  
  4879. /******************  Bit definition for FSMC_BWTR2 register  ******************/
  4880. #define  FSMC_BWTR2_ADDSET                   ((uint32_t)0x0000000F)        /*!< ADDSET[3:0] bits (Address setup phase duration) */
  4881. #define  FSMC_BWTR2_ADDSET_0                 ((uint32_t)0x00000001)        /*!< Bit 0 */
  4882. #define  FSMC_BWTR2_ADDSET_1                 ((uint32_t)0x00000002)        /*!< Bit 1 */
  4883. #define  FSMC_BWTR2_ADDSET_2                 ((uint32_t)0x00000004)        /*!< Bit 2 */
  4884. #define  FSMC_BWTR2_ADDSET_3                 ((uint32_t)0x00000008)        /*!< Bit 3 */
  4885.  
  4886. #define  FSMC_BWTR2_ADDHLD                   ((uint32_t)0x000000F0)        /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
  4887. #define  FSMC_BWTR2_ADDHLD_0                 ((uint32_t)0x00000010)        /*!< Bit 0 */
  4888. #define  FSMC_BWTR2_ADDHLD_1                 ((uint32_t)0x00000020)        /*!< Bit 1 */
  4889. #define  FSMC_BWTR2_ADDHLD_2                 ((uint32_t)0x00000040)        /*!< Bit 2 */
  4890. #define  FSMC_BWTR2_ADDHLD_3                 ((uint32_t)0x00000080)        /*!< Bit 3 */
  4891.  
  4892. #define  FSMC_BWTR2_DATAST                   ((uint32_t)0x0000FF00)        /*!< DATAST [3:0] bits (Data-phase duration) */
  4893. #define  FSMC_BWTR2_DATAST_0                 ((uint32_t)0x00000100)        /*!< Bit 0 */
  4894. #define  FSMC_BWTR2_DATAST_1                 ((uint32_t)0x00000200)        /*!< Bit 1 */
  4895. #define  FSMC_BWTR2_DATAST_2                 ((uint32_t)0x00000400)        /*!< Bit 2 */
  4896. #define  FSMC_BWTR2_DATAST_3                 ((uint32_t)0x00000800)        /*!< Bit 3 */
  4897. #define  FSMC_BWTR2_DATAST_4                 ((uint32_t)0x00001000)        /*!< Bit 4 */
  4898. #define  FSMC_BWTR2_DATAST_5                 ((uint32_t)0x00002000)        /*!< Bit 5 */
  4899. #define  FSMC_BWTR2_DATAST_6                 ((uint32_t)0x00004000)        /*!< Bit 6 */
  4900. #define  FSMC_BWTR2_DATAST_7                 ((uint32_t)0x00008000)        /*!< Bit 7 */
  4901.  
  4902. #define  FSMC_BWTR2_CLKDIV                   ((uint32_t)0x00F00000)        /*!< CLKDIV[3:0] bits (Clock divide ratio) */
  4903. #define  FSMC_BWTR2_CLKDIV_0                 ((uint32_t)0x00100000)        /*!< Bit 0 */
  4904. #define  FSMC_BWTR2_CLKDIV_1                 ((uint32_t)0x00200000)        /*!< Bit 1*/
  4905. #define  FSMC_BWTR2_CLKDIV_2                 ((uint32_t)0x00400000)        /*!< Bit 2 */
  4906. #define  FSMC_BWTR2_CLKDIV_3                 ((uint32_t)0x00800000)        /*!< Bit 3 */
  4907.  
  4908. #define  FSMC_BWTR2_DATLAT                   ((uint32_t)0x0F000000)        /*!< DATLA[3:0] bits (Data latency) */
  4909. #define  FSMC_BWTR2_DATLAT_0                 ((uint32_t)0x01000000)        /*!< Bit 0 */
  4910. #define  FSMC_BWTR2_DATLAT_1                 ((uint32_t)0x02000000)        /*!< Bit 1 */
  4911. #define  FSMC_BWTR2_DATLAT_2                 ((uint32_t)0x04000000)        /*!< Bit 2 */
  4912. #define  FSMC_BWTR2_DATLAT_3                 ((uint32_t)0x08000000)        /*!< Bit 3 */
  4913.  
  4914. #define  FSMC_BWTR2_ACCMOD                   ((uint32_t)0x30000000)        /*!< ACCMOD[1:0] bits (Access mode) */
  4915. #define  FSMC_BWTR2_ACCMOD_0                 ((uint32_t)0x10000000)        /*!< Bit 0 */
  4916. #define  FSMC_BWTR2_ACCMOD_1                 ((uint32_t)0x20000000)        /*!< Bit 1 */
  4917.  
  4918. /******************  Bit definition for FSMC_BWTR3 register  ******************/
  4919. #define  FSMC_BWTR3_ADDSET                   ((uint32_t)0x0000000F)        /*!< ADDSET[3:0] bits (Address setup phase duration) */
  4920. #define  FSMC_BWTR3_ADDSET_0                 ((uint32_t)0x00000001)        /*!< Bit 0 */
  4921. #define  FSMC_BWTR3_ADDSET_1                 ((uint32_t)0x00000002)        /*!< Bit 1 */
  4922. #define  FSMC_BWTR3_ADDSET_2                 ((uint32_t)0x00000004)        /*!< Bit 2 */
  4923. #define  FSMC_BWTR3_ADDSET_3                 ((uint32_t)0x00000008)        /*!< Bit 3 */
  4924.  
  4925. #define  FSMC_BWTR3_ADDHLD                   ((uint32_t)0x000000F0)        /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
  4926. #define  FSMC_BWTR3_ADDHLD_0                 ((uint32_t)0x00000010)        /*!< Bit 0 */
  4927. #define  FSMC_BWTR3_ADDHLD_1                 ((uint32_t)0x00000020)        /*!< Bit 1 */
  4928. #define  FSMC_BWTR3_ADDHLD_2                 ((uint32_t)0x00000040)        /*!< Bit 2 */
  4929. #define  FSMC_BWTR3_ADDHLD_3                 ((uint32_t)0x00000080)        /*!< Bit 3 */
  4930.  
  4931. #define  FSMC_BWTR3_DATAST                   ((uint32_t)0x0000FF00)        /*!< DATAST [3:0] bits (Data-phase duration) */
  4932. #define  FSMC_BWTR3_DATAST_0                 ((uint32_t)0x00000100)        /*!< Bit 0 */
  4933. #define  FSMC_BWTR3_DATAST_1                 ((uint32_t)0x00000200)        /*!< Bit 1 */
  4934. #define  FSMC_BWTR3_DATAST_2                 ((uint32_t)0x00000400)        /*!< Bit 2 */
  4935. #define  FSMC_BWTR3_DATAST_3                 ((uint32_t)0x00000800)        /*!< Bit 3 */
  4936. #define  FSMC_BWTR3_DATAST_4                 ((uint32_t)0x00001000)        /*!< Bit 4 */
  4937. #define  FSMC_BWTR3_DATAST_5                 ((uint32_t)0x00002000)        /*!< Bit 5 */
  4938. #define  FSMC_BWTR3_DATAST_6                 ((uint32_t)0x00004000)        /*!< Bit 6 */
  4939. #define  FSMC_BWTR3_DATAST_7                 ((uint32_t)0x00008000)        /*!< Bit 7 */
  4940.  
  4941. #define  FSMC_BWTR3_CLKDIV                   ((uint32_t)0x00F00000)        /*!< CLKDIV[3:0] bits (Clock divide ratio) */
  4942. #define  FSMC_BWTR3_CLKDIV_0                 ((uint32_t)0x00100000)        /*!< Bit 0 */
  4943. #define  FSMC_BWTR3_CLKDIV_1                 ((uint32_t)0x00200000)        /*!< Bit 1 */
  4944. #define  FSMC_BWTR3_CLKDIV_2                 ((uint32_t)0x00400000)        /*!< Bit 2 */
  4945. #define  FSMC_BWTR3_CLKDIV_3                 ((uint32_t)0x00800000)        /*!< Bit 3 */
  4946.  
  4947. #define  FSMC_BWTR3_DATLAT                   ((uint32_t)0x0F000000)        /*!< DATLA[3:0] bits (Data latency) */
  4948. #define  FSMC_BWTR3_DATLAT_0                 ((uint32_t)0x01000000)        /*!< Bit 0 */
  4949. #define  FSMC_BWTR3_DATLAT_1                 ((uint32_t)0x02000000)        /*!< Bit 1 */
  4950. #define  FSMC_BWTR3_DATLAT_2                 ((uint32_t)0x04000000)        /*!< Bit 2 */
  4951. #define  FSMC_BWTR3_DATLAT_3                 ((uint32_t)0x08000000)        /*!< Bit 3 */
  4952.  
  4953. #define  FSMC_BWTR3_ACCMOD                   ((uint32_t)0x30000000)        /*!< ACCMOD[1:0] bits (Access mode) */
  4954. #define  FSMC_BWTR3_ACCMOD_0                 ((uint32_t)0x10000000)        /*!< Bit 0 */
  4955. #define  FSMC_BWTR3_ACCMOD_1                 ((uint32_t)0x20000000)        /*!< Bit 1 */
  4956.  
  4957. /******************  Bit definition for FSMC_BWTR4 register  ******************/
  4958. #define  FSMC_BWTR4_ADDSET                   ((uint32_t)0x0000000F)        /*!< ADDSET[3:0] bits (Address setup phase duration) */
  4959. #define  FSMC_BWTR4_ADDSET_0                 ((uint32_t)0x00000001)        /*!< Bit 0 */
  4960. #define  FSMC_BWTR4_ADDSET_1                 ((uint32_t)0x00000002)        /*!< Bit 1 */
  4961. #define  FSMC_BWTR4_ADDSET_2                 ((uint32_t)0x00000004)        /*!< Bit 2 */
  4962. #define  FSMC_BWTR4_ADDSET_3                 ((uint32_t)0x00000008)        /*!< Bit 3 */
  4963.  
  4964. #define  FSMC_BWTR4_ADDHLD                   ((uint32_t)0x000000F0)        /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
  4965. #define  FSMC_BWTR4_ADDHLD_0                 ((uint32_t)0x00000010)        /*!< Bit 0 */
  4966. #define  FSMC_BWTR4_ADDHLD_1                 ((uint32_t)0x00000020)        /*!< Bit 1 */
  4967. #define  FSMC_BWTR4_ADDHLD_2                 ((uint32_t)0x00000040)        /*!< Bit 2 */
  4968. #define  FSMC_BWTR4_ADDHLD_3                 ((uint32_t)0x00000080)        /*!< Bit 3 */
  4969.  
  4970. #define  FSMC_BWTR4_DATAST                   ((uint32_t)0x0000FF00)        /*!< DATAST [3:0] bits (Data-phase duration) */
  4971. #define  FSMC_BWTR4_DATAST_0                 ((uint32_t)0x00000100)        /*!< Bit 0 */
  4972. #define  FSMC_BWTR4_DATAST_1                 ((uint32_t)0x00000200)        /*!< Bit 1 */
  4973. #define  FSMC_BWTR4_DATAST_2                 ((uint32_t)0x00000400)        /*!< Bit 2 */
  4974. #define  FSMC_BWTR4_DATAST_3                 ((uint32_t)0x00000800)        /*!< Bit 3 */
  4975. #define  FSMC_BWTR4_DATAST_4                 ((uint32_t)0x00001000)        /*!< Bit 4 */
  4976. #define  FSMC_BWTR4_DATAST_5                 ((uint32_t)0x00002000)        /*!< Bit 5 */
  4977. #define  FSMC_BWTR4_DATAST_6                 ((uint32_t)0x00004000)        /*!< Bit 6 */
  4978. #define  FSMC_BWTR4_DATAST_7                 ((uint32_t)0x00008000)        /*!< Bit 7 */
  4979.  
  4980. #define  FSMC_BWTR4_CLKDIV                   ((uint32_t)0x00F00000)        /*!< CLKDIV[3:0] bits (Clock divide ratio) */
  4981. #define  FSMC_BWTR4_CLKDIV_0                 ((uint32_t)0x00100000)        /*!< Bit 0 */
  4982. #define  FSMC_BWTR4_CLKDIV_1                 ((uint32_t)0x00200000)        /*!< Bit 1 */
  4983. #define  FSMC_BWTR4_CLKDIV_2                 ((uint32_t)0x00400000)        /*!< Bit 2 */
  4984. #define  FSMC_BWTR4_CLKDIV_3                 ((uint32_t)0x00800000)        /*!< Bit 3 */
  4985.  
  4986. #define  FSMC_BWTR4_DATLAT                   ((uint32_t)0x0F000000)        /*!< DATLA[3:0] bits (Data latency) */
  4987. #define  FSMC_BWTR4_DATLAT_0                 ((uint32_t)0x01000000)        /*!< Bit 0 */
  4988. #define  FSMC_BWTR4_DATLAT_1                 ((uint32_t)0x02000000)        /*!< Bit 1 */
  4989. #define  FSMC_BWTR4_DATLAT_2                 ((uint32_t)0x04000000)        /*!< Bit 2 */
  4990. #define  FSMC_BWTR4_DATLAT_3                 ((uint32_t)0x08000000)        /*!< Bit 3 */
  4991.  
  4992. #define  FSMC_BWTR4_ACCMOD                   ((uint32_t)0x30000000)        /*!< ACCMOD[1:0] bits (Access mode) */
  4993. #define  FSMC_BWTR4_ACCMOD_0                 ((uint32_t)0x10000000)        /*!< Bit 0 */
  4994. #define  FSMC_BWTR4_ACCMOD_1                 ((uint32_t)0x20000000)        /*!< Bit 1 */
  4995.  
  4996. /******************  Bit definition for FSMC_PCR2 register  *******************/
  4997. #define  FSMC_PCR2_PWAITEN                   ((uint32_t)0x00000002)        /*!< Wait feature enable bit */
  4998. #define  FSMC_PCR2_PBKEN                     ((uint32_t)0x00000004)        /*!< PC Card/NAND Flash memory bank enable bit */
  4999. #define  FSMC_PCR2_PTYP                      ((uint32_t)0x00000008)        /*!< Memory type */
  5000.  
  5001. #define  FSMC_PCR2_PWID                      ((uint32_t)0x00000030)        /*!< PWID[1:0] bits (NAND Flash databus width) */
  5002. #define  FSMC_PCR2_PWID_0                    ((uint32_t)0x00000010)        /*!< Bit 0 */
  5003. #define  FSMC_PCR2_PWID_1                    ((uint32_t)0x00000020)        /*!< Bit 1 */
  5004.  
  5005. #define  FSMC_PCR2_ECCEN                     ((uint32_t)0x00000040)        /*!< ECC computation logic enable bit */
  5006.  
  5007. #define  FSMC_PCR2_TCLR                      ((uint32_t)0x00001E00)        /*!< TCLR[3:0] bits (CLE to RE delay) */
  5008. #define  FSMC_PCR2_TCLR_0                    ((uint32_t)0x00000200)        /*!< Bit 0 */
  5009. #define  FSMC_PCR2_TCLR_1                    ((uint32_t)0x00000400)        /*!< Bit 1 */
  5010. #define  FSMC_PCR2_TCLR_2                    ((uint32_t)0x00000800)        /*!< Bit 2 */
  5011. #define  FSMC_PCR2_TCLR_3                    ((uint32_t)0x00001000)        /*!< Bit 3 */
  5012.  
  5013. #define  FSMC_PCR2_TAR                       ((uint32_t)0x0001E000)        /*!< TAR[3:0] bits (ALE to RE delay) */
  5014. #define  FSMC_PCR2_TAR_0                     ((uint32_t)0x00002000)        /*!< Bit 0 */
  5015. #define  FSMC_PCR2_TAR_1                     ((uint32_t)0x00004000)        /*!< Bit 1 */
  5016. #define  FSMC_PCR2_TAR_2                     ((uint32_t)0x00008000)        /*!< Bit 2 */
  5017. #define  FSMC_PCR2_TAR_3                     ((uint32_t)0x00010000)        /*!< Bit 3 */
  5018.  
  5019. #define  FSMC_PCR2_ECCPS                     ((uint32_t)0x000E0000)        /*!< ECCPS[1:0] bits (ECC page size) */
  5020. #define  FSMC_PCR2_ECCPS_0                   ((uint32_t)0x00020000)        /*!< Bit 0 */
  5021. #define  FSMC_PCR2_ECCPS_1                   ((uint32_t)0x00040000)        /*!< Bit 1 */
  5022. #define  FSMC_PCR2_ECCPS_2                   ((uint32_t)0x00080000)        /*!< Bit 2 */
  5023.  
  5024. /******************  Bit definition for FSMC_PCR3 register  *******************/
  5025. #define  FSMC_PCR3_PWAITEN                   ((uint32_t)0x00000002)        /*!< Wait feature enable bit */
  5026. #define  FSMC_PCR3_PBKEN                     ((uint32_t)0x00000004)        /*!< PC Card/NAND Flash memory bank enable bit */
  5027. #define  FSMC_PCR3_PTYP                      ((uint32_t)0x00000008)        /*!< Memory type */
  5028.  
  5029. #define  FSMC_PCR3_PWID                      ((uint32_t)0x00000030)        /*!< PWID[1:0] bits (NAND Flash databus width) */
  5030. #define  FSMC_PCR3_PWID_0                    ((uint32_t)0x00000010)        /*!< Bit 0 */
  5031. #define  FSMC_PCR3_PWID_1                    ((uint32_t)0x00000020)        /*!< Bit 1 */
  5032.  
  5033. #define  FSMC_PCR3_ECCEN                     ((uint32_t)0x00000040)        /*!< ECC computation logic enable bit */
  5034.  
  5035. #define  FSMC_PCR3_TCLR                      ((uint32_t)0x00001E00)        /*!< TCLR[3:0] bits (CLE to RE delay) */
  5036. #define  FSMC_PCR3_TCLR_0                    ((uint32_t)0x00000200)        /*!< Bit 0 */
  5037. #define  FSMC_PCR3_TCLR_1                    ((uint32_t)0x00000400)        /*!< Bit 1 */
  5038. #define  FSMC_PCR3_TCLR_2                    ((uint32_t)0x00000800)        /*!< Bit 2 */
  5039. #define  FSMC_PCR3_TCLR_3                    ((uint32_t)0x00001000)        /*!< Bit 3 */
  5040.  
  5041. #define  FSMC_PCR3_TAR                       ((uint32_t)0x0001E000)        /*!< TAR[3:0] bits (ALE to RE delay) */
  5042. #define  FSMC_PCR3_TAR_0                     ((uint32_t)0x00002000)        /*!< Bit 0 */
  5043. #define  FSMC_PCR3_TAR_1                     ((uint32_t)0x00004000)        /*!< Bit 1 */
  5044. #define  FSMC_PCR3_TAR_2                     ((uint32_t)0x00008000)        /*!< Bit 2 */
  5045. #define  FSMC_PCR3_TAR_3                     ((uint32_t)0x00010000)        /*!< Bit 3 */
  5046.  
  5047. #define  FSMC_PCR3_ECCPS                     ((uint32_t)0x000E0000)        /*!< ECCPS[2:0] bits (ECC page size) */
  5048. #define  FSMC_PCR3_ECCPS_0                   ((uint32_t)0x00020000)        /*!< Bit 0 */
  5049. #define  FSMC_PCR3_ECCPS_1                   ((uint32_t)0x00040000)        /*!< Bit 1 */
  5050. #define  FSMC_PCR3_ECCPS_2                   ((uint32_t)0x00080000)        /*!< Bit 2 */
  5051.  
  5052. /******************  Bit definition for FSMC_PCR4 register  *******************/
  5053. #define  FSMC_PCR4_PWAITEN                   ((uint32_t)0x00000002)        /*!< Wait feature enable bit */
  5054. #define  FSMC_PCR4_PBKEN                     ((uint32_t)0x00000004)        /*!< PC Card/NAND Flash memory bank enable bit */
  5055. #define  FSMC_PCR4_PTYP                      ((uint32_t)0x00000008)        /*!< Memory type */
  5056.  
  5057. #define  FSMC_PCR4_PWID                      ((uint32_t)0x00000030)        /*!< PWID[1:0] bits (NAND Flash databus width) */
  5058. #define  FSMC_PCR4_PWID_0                    ((uint32_t)0x00000010)        /*!< Bit 0 */
  5059. #define  FSMC_PCR4_PWID_1                    ((uint32_t)0x00000020)        /*!< Bit 1 */
  5060.  
  5061. #define  FSMC_PCR4_ECCEN                     ((uint32_t)0x00000040)        /*!< ECC computation logic enable bit */
  5062.  
  5063. #define  FSMC_PCR4_TCLR                      ((uint32_t)0x00001E00)        /*!< TCLR[3:0] bits (CLE to RE delay) */
  5064. #define  FSMC_PCR4_TCLR_0                    ((uint32_t)0x00000200)        /*!< Bit 0 */
  5065. #define  FSMC_PCR4_TCLR_1                    ((uint32_t)0x00000400)        /*!< Bit 1 */
  5066. #define  FSMC_PCR4_TCLR_2                    ((uint32_t)0x00000800)        /*!< Bit 2 */
  5067. #define  FSMC_PCR4_TCLR_3                    ((uint32_t)0x00001000)        /*!< Bit 3 */
  5068.  
  5069. #define  FSMC_PCR4_TAR                       ((uint32_t)0x0001E000)        /*!< TAR[3:0] bits (ALE to RE delay) */
  5070. #define  FSMC_PCR4_TAR_0                     ((uint32_t)0x00002000)        /*!< Bit 0 */
  5071. #define  FSMC_PCR4_TAR_1                     ((uint32_t)0x00004000)        /*!< Bit 1 */
  5072. #define  FSMC_PCR4_TAR_2                     ((uint32_t)0x00008000)        /*!< Bit 2 */
  5073. #define  FSMC_PCR4_TAR_3                     ((uint32_t)0x00010000)        /*!< Bit 3 */
  5074.  
  5075. #define  FSMC_PCR4_ECCPS                     ((uint32_t)0x000E0000)        /*!< ECCPS[2:0] bits (ECC page size) */
  5076. #define  FSMC_PCR4_ECCPS_0                   ((uint32_t)0x00020000)        /*!< Bit 0 */
  5077. #define  FSMC_PCR4_ECCPS_1                   ((uint32_t)0x00040000)        /*!< Bit 1 */
  5078. #define  FSMC_PCR4_ECCPS_2                   ((uint32_t)0x00080000)        /*!< Bit 2 */
  5079.  
  5080. /*******************  Bit definition for FSMC_SR2 register  *******************/
  5081. #define  FSMC_SR2_IRS                        ((uint8_t)0x01)               /*!< Interrupt Rising Edge status */
  5082. #define  FSMC_SR2_ILS                        ((uint8_t)0x02)               /*!< Interrupt Level status */
  5083. #define  FSMC_SR2_IFS                        ((uint8_t)0x04)               /*!< Interrupt Falling Edge status */
  5084. #define  FSMC_SR2_IREN                       ((uint8_t)0x08)               /*!< Interrupt Rising Edge detection Enable bit */
  5085. #define  FSMC_SR2_ILEN                       ((uint8_t)0x10)               /*!< Interrupt Level detection Enable bit */
  5086. #define  FSMC_SR2_IFEN                       ((uint8_t)0x20)               /*!< Interrupt Falling Edge detection Enable bit */
  5087. #define  FSMC_SR2_FEMPT                      ((uint8_t)0x40)               /*!< FIFO empty */
  5088.  
  5089. /*******************  Bit definition for FSMC_SR3 register  *******************/
  5090. #define  FSMC_SR3_IRS                        ((uint8_t)0x01)               /*!< Interrupt Rising Edge status */
  5091. #define  FSMC_SR3_ILS                        ((uint8_t)0x02)               /*!< Interrupt Level status */
  5092. #define  FSMC_SR3_IFS                        ((uint8_t)0x04)               /*!< Interrupt Falling Edge status */
  5093. #define  FSMC_SR3_IREN                       ((uint8_t)0x08)               /*!< Interrupt Rising Edge detection Enable bit */
  5094. #define  FSMC_SR3_ILEN                       ((uint8_t)0x10)               /*!< Interrupt Level detection Enable bit */
  5095. #define  FSMC_SR3_IFEN                       ((uint8_t)0x20)               /*!< Interrupt Falling Edge detection Enable bit */
  5096. #define  FSMC_SR3_FEMPT                      ((uint8_t)0x40)               /*!< FIFO empty */
  5097.  
  5098. /*******************  Bit definition for FSMC_SR4 register  *******************/
  5099. #define  FSMC_SR4_IRS                        ((uint8_t)0x01)               /*!< Interrupt Rising Edge status */
  5100. #define  FSMC_SR4_ILS                        ((uint8_t)0x02)               /*!< Interrupt Level status */
  5101. #define  FSMC_SR4_IFS                        ((uint8_t)0x04)               /*!< Interrupt Falling Edge status */
  5102. #define  FSMC_SR4_IREN                       ((uint8_t)0x08)               /*!< Interrupt Rising Edge detection Enable bit */
  5103. #define  FSMC_SR4_ILEN                       ((uint8_t)0x10)               /*!< Interrupt Level detection Enable bit */
  5104. #define  FSMC_SR4_IFEN                       ((uint8_t)0x20)               /*!< Interrupt Falling Edge detection Enable bit */
  5105. #define  FSMC_SR4_FEMPT                      ((uint8_t)0x40)               /*!< FIFO empty */
  5106.  
  5107. /******************  Bit definition for FSMC_PMEM2 register  ******************/
  5108. #define  FSMC_PMEM2_MEMSET2                  ((uint32_t)0x000000FF)        /*!< MEMSET2[7:0] bits (Common memory 2 setup time) */
  5109. #define  FSMC_PMEM2_MEMSET2_0                ((uint32_t)0x00000001)        /*!< Bit 0 */
  5110. #define  FSMC_PMEM2_MEMSET2_1                ((uint32_t)0x00000002)        /*!< Bit 1 */
  5111. #define  FSMC_PMEM2_MEMSET2_2                ((uint32_t)0x00000004)        /*!< Bit 2 */
  5112. #define  FSMC_PMEM2_MEMSET2_3                ((uint32_t)0x00000008)        /*!< Bit 3 */
  5113. #define  FSMC_PMEM2_MEMSET2_4                ((uint32_t)0x00000010)        /*!< Bit 4 */
  5114. #define  FSMC_PMEM2_MEMSET2_5                ((uint32_t)0x00000020)        /*!< Bit 5 */
  5115. #define  FSMC_PMEM2_MEMSET2_6                ((uint32_t)0x00000040)        /*!< Bit 6 */
  5116. #define  FSMC_PMEM2_MEMSET2_7                ((uint32_t)0x00000080)        /*!< Bit 7 */
  5117.  
  5118. #define  FSMC_PMEM2_MEMWAIT2                 ((uint32_t)0x0000FF00)        /*!< MEMWAIT2[7:0] bits (Common memory 2 wait time) */
  5119. #define  FSMC_PMEM2_MEMWAIT2_0               ((uint32_t)0x00000100)        /*!< Bit 0 */
  5120. #define  FSMC_PMEM2_MEMWAIT2_1               ((uint32_t)0x00000200)        /*!< Bit 1 */
  5121. #define  FSMC_PMEM2_MEMWAIT2_2               ((uint32_t)0x00000400)        /*!< Bit 2 */
  5122. #define  FSMC_PMEM2_MEMWAIT2_3               ((uint32_t)0x00000800)        /*!< Bit 3 */
  5123. #define  FSMC_PMEM2_MEMWAIT2_4               ((uint32_t)0x00001000)        /*!< Bit 4 */
  5124. #define  FSMC_PMEM2_MEMWAIT2_5               ((uint32_t)0x00002000)        /*!< Bit 5 */
  5125. #define  FSMC_PMEM2_MEMWAIT2_6               ((uint32_t)0x00004000)        /*!< Bit 6 */
  5126. #define  FSMC_PMEM2_MEMWAIT2_7               ((uint32_t)0x00008000)        /*!< Bit 7 */
  5127.  
  5128. #define  FSMC_PMEM2_MEMHOLD2                 ((uint32_t)0x00FF0000)        /*!< MEMHOLD2[7:0] bits (Common memory 2 hold time) */
  5129. #define  FSMC_PMEM2_MEMHOLD2_0               ((uint32_t)0x00010000)        /*!< Bit 0 */
  5130. #define  FSMC_PMEM2_MEMHOLD2_1               ((uint32_t)0x00020000)        /*!< Bit 1 */
  5131. #define  FSMC_PMEM2_MEMHOLD2_2               ((uint32_t)0x00040000)        /*!< Bit 2 */
  5132. #define  FSMC_PMEM2_MEMHOLD2_3               ((uint32_t)0x00080000)        /*!< Bit 3 */
  5133. #define  FSMC_PMEM2_MEMHOLD2_4               ((uint32_t)0x00100000)        /*!< Bit 4 */
  5134. #define  FSMC_PMEM2_MEMHOLD2_5               ((uint32_t)0x00200000)        /*!< Bit 5 */
  5135. #define  FSMC_PMEM2_MEMHOLD2_6               ((uint32_t)0x00400000)        /*!< Bit 6 */
  5136. #define  FSMC_PMEM2_MEMHOLD2_7               ((uint32_t)0x00800000)        /*!< Bit 7 */
  5137.  
  5138. #define  FSMC_PMEM2_MEMHIZ2                  ((uint32_t)0xFF000000)        /*!< MEMHIZ2[7:0] bits (Common memory 2 databus HiZ time) */
  5139. #define  FSMC_PMEM2_MEMHIZ2_0                ((uint32_t)0x01000000)        /*!< Bit 0 */
  5140. #define  FSMC_PMEM2_MEMHIZ2_1                ((uint32_t)0x02000000)        /*!< Bit 1 */
  5141. #define  FSMC_PMEM2_MEMHIZ2_2                ((uint32_t)0x04000000)        /*!< Bit 2 */
  5142. #define  FSMC_PMEM2_MEMHIZ2_3                ((uint32_t)0x08000000)        /*!< Bit 3 */
  5143. #define  FSMC_PMEM2_MEMHIZ2_4                ((uint32_t)0x10000000)        /*!< Bit 4 */
  5144. #define  FSMC_PMEM2_MEMHIZ2_5                ((uint32_t)0x20000000)        /*!< Bit 5 */
  5145. #define  FSMC_PMEM2_MEMHIZ2_6                ((uint32_t)0x40000000)        /*!< Bit 6 */
  5146. #define  FSMC_PMEM2_MEMHIZ2_7                ((uint32_t)0x80000000)        /*!< Bit 7 */
  5147.  
  5148. /******************  Bit definition for FSMC_PMEM3 register  ******************/
  5149. #define  FSMC_PMEM3_MEMSET3                  ((uint32_t)0x000000FF)        /*!< MEMSET3[7:0] bits (Common memory 3 setup time) */
  5150. #define  FSMC_PMEM3_MEMSET3_0                ((uint32_t)0x00000001)        /*!< Bit 0 */
  5151. #define  FSMC_PMEM3_MEMSET3_1                ((uint32_t)0x00000002)        /*!< Bit 1 */
  5152. #define  FSMC_PMEM3_MEMSET3_2                ((uint32_t)0x00000004)        /*!< Bit 2 */
  5153. #define  FSMC_PMEM3_MEMSET3_3                ((uint32_t)0x00000008)        /*!< Bit 3 */
  5154. #define  FSMC_PMEM3_MEMSET3_4                ((uint32_t)0x00000010)        /*!< Bit 4 */
  5155. #define  FSMC_PMEM3_MEMSET3_5                ((uint32_t)0x00000020)        /*!< Bit 5 */
  5156. #define  FSMC_PMEM3_MEMSET3_6                ((uint32_t)0x00000040)        /*!< Bit 6 */
  5157. #define  FSMC_PMEM3_MEMSET3_7                ((uint32_t)0x00000080)        /*!< Bit 7 */
  5158.  
  5159. #define  FSMC_PMEM3_MEMWAIT3                 ((uint32_t)0x0000FF00)        /*!< MEMWAIT3[7:0] bits (Common memory 3 wait time) */
  5160. #define  FSMC_PMEM3_MEMWAIT3_0               ((uint32_t)0x00000100)        /*!< Bit 0 */
  5161. #define  FSMC_PMEM3_MEMWAIT3_1               ((uint32_t)0x00000200)        /*!< Bit 1 */
  5162. #define  FSMC_PMEM3_MEMWAIT3_2               ((uint32_t)0x00000400)        /*!< Bit 2 */
  5163. #define  FSMC_PMEM3_MEMWAIT3_3               ((uint32_t)0x00000800)        /*!< Bit 3 */
  5164. #define  FSMC_PMEM3_MEMWAIT3_4               ((uint32_t)0x00001000)        /*!< Bit 4 */
  5165. #define  FSMC_PMEM3_MEMWAIT3_5               ((uint32_t)0x00002000)        /*!< Bit 5 */
  5166. #define  FSMC_PMEM3_MEMWAIT3_6               ((uint32_t)0x00004000)        /*!< Bit 6 */
  5167. #define  FSMC_PMEM3_MEMWAIT3_7               ((uint32_t)0x00008000)        /*!< Bit 7 */
  5168.  
  5169. #define  FSMC_PMEM3_MEMHOLD3                 ((uint32_t)0x00FF0000)        /*!< MEMHOLD3[7:0] bits (Common memory 3 hold time) */
  5170. #define  FSMC_PMEM3_MEMHOLD3_0               ((uint32_t)0x00010000)        /*!< Bit 0 */
  5171. #define  FSMC_PMEM3_MEMHOLD3_1               ((uint32_t)0x00020000)        /*!< Bit 1 */
  5172. #define  FSMC_PMEM3_MEMHOLD3_2               ((uint32_t)0x00040000)        /*!< Bit 2 */
  5173. #define  FSMC_PMEM3_MEMHOLD3_3               ((uint32_t)0x00080000)        /*!< Bit 3 */
  5174. #define  FSMC_PMEM3_MEMHOLD3_4               ((uint32_t)0x00100000)        /*!< Bit 4 */
  5175. #define  FSMC_PMEM3_MEMHOLD3_5               ((uint32_t)0x00200000)        /*!< Bit 5 */
  5176. #define  FSMC_PMEM3_MEMHOLD3_6               ((uint32_t)0x00400000)        /*!< Bit 6 */
  5177. #define  FSMC_PMEM3_MEMHOLD3_7               ((uint32_t)0x00800000)        /*!< Bit 7 */
  5178.  
  5179. #define  FSMC_PMEM3_MEMHIZ3                  ((uint32_t)0xFF000000)        /*!< MEMHIZ3[7:0] bits (Common memory 3 databus HiZ time) */
  5180. #define  FSMC_PMEM3_MEMHIZ3_0                ((uint32_t)0x01000000)        /*!< Bit 0 */
  5181. #define  FSMC_PMEM3_MEMHIZ3_1                ((uint32_t)0x02000000)        /*!< Bit 1 */
  5182. #define  FSMC_PMEM3_MEMHIZ3_2                ((uint32_t)0x04000000)        /*!< Bit 2 */
  5183. #define  FSMC_PMEM3_MEMHIZ3_3                ((uint32_t)0x08000000)        /*!< Bit 3 */
  5184. #define  FSMC_PMEM3_MEMHIZ3_4                ((uint32_t)0x10000000)        /*!< Bit 4 */
  5185. #define  FSMC_PMEM3_MEMHIZ3_5                ((uint32_t)0x20000000)        /*!< Bit 5 */
  5186. #define  FSMC_PMEM3_MEMHIZ3_6                ((uint32_t)0x40000000)        /*!< Bit 6 */
  5187. #define  FSMC_PMEM3_MEMHIZ3_7                ((uint32_t)0x80000000)        /*!< Bit 7 */
  5188.  
  5189. /******************  Bit definition for FSMC_PMEM4 register  ******************/
  5190. #define  FSMC_PMEM4_MEMSET4                  ((uint32_t)0x000000FF)        /*!< MEMSET4[7:0] bits (Common memory 4 setup time) */
  5191. #define  FSMC_PMEM4_MEMSET4_0                ((uint32_t)0x00000001)        /*!< Bit 0 */
  5192. #define  FSMC_PMEM4_MEMSET4_1                ((uint32_t)0x00000002)        /*!< Bit 1 */
  5193. #define  FSMC_PMEM4_MEMSET4_2                ((uint32_t)0x00000004)        /*!< Bit 2 */
  5194. #define  FSMC_PMEM4_MEMSET4_3                ((uint32_t)0x00000008)        /*!< Bit 3 */
  5195. #define  FSMC_PMEM4_MEMSET4_4                ((uint32_t)0x00000010)        /*!< Bit 4 */
  5196. #define  FSMC_PMEM4_MEMSET4_5                ((uint32_t)0x00000020)        /*!< Bit 5 */
  5197. #define  FSMC_PMEM4_MEMSET4_6                ((uint32_t)0x00000040)        /*!< Bit 6 */
  5198. #define  FSMC_PMEM4_MEMSET4_7                ((uint32_t)0x00000080)        /*!< Bit 7 */
  5199.  
  5200. #define  FSMC_PMEM4_MEMWAIT4                 ((uint32_t)0x0000FF00)        /*!< MEMWAIT4[7:0] bits (Common memory 4 wait time) */
  5201. #define  FSMC_PMEM4_MEMWAIT4_0               ((uint32_t)0x00000100)        /*!< Bit 0 */
  5202. #define  FSMC_PMEM4_MEMWAIT4_1               ((uint32_t)0x00000200)        /*!< Bit 1 */
  5203. #define  FSMC_PMEM4_MEMWAIT4_2               ((uint32_t)0x00000400)        /*!< Bit 2 */
  5204. #define  FSMC_PMEM4_MEMWAIT4_3               ((uint32_t)0x00000800)        /*!< Bit 3 */
  5205. #define  FSMC_PMEM4_MEMWAIT4_4               ((uint32_t)0x00001000)        /*!< Bit 4 */
  5206. #define  FSMC_PMEM4_MEMWAIT4_5               ((uint32_t)0x00002000)        /*!< Bit 5 */
  5207. #define  FSMC_PMEM4_MEMWAIT4_6               ((uint32_t)0x00004000)        /*!< Bit 6 */
  5208. #define  FSMC_PMEM4_MEMWAIT4_7               ((uint32_t)0x00008000)        /*!< Bit 7 */
  5209.  
  5210. #define  FSMC_PMEM4_MEMHOLD4                 ((uint32_t)0x00FF0000)        /*!< MEMHOLD4[7:0] bits (Common memory 4 hold time) */
  5211. #define  FSMC_PMEM4_MEMHOLD4_0               ((uint32_t)0x00010000)        /*!< Bit 0 */
  5212. #define  FSMC_PMEM4_MEMHOLD4_1               ((uint32_t)0x00020000)        /*!< Bit 1 */
  5213. #define  FSMC_PMEM4_MEMHOLD4_2               ((uint32_t)0x00040000)        /*!< Bit 2 */
  5214. #define  FSMC_PMEM4_MEMHOLD4_3               ((uint32_t)0x00080000)        /*!< Bit 3 */
  5215. #define  FSMC_PMEM4_MEMHOLD4_4               ((uint32_t)0x00100000)        /*!< Bit 4 */
  5216. #define  FSMC_PMEM4_MEMHOLD4_5               ((uint32_t)0x00200000)        /*!< Bit 5 */
  5217. #define  FSMC_PMEM4_MEMHOLD4_6               ((uint32_t)0x00400000)        /*!< Bit 6 */
  5218. #define  FSMC_PMEM4_MEMHOLD4_7               ((uint32_t)0x00800000)        /*!< Bit 7 */
  5219.  
  5220. #define  FSMC_PMEM4_MEMHIZ4                  ((uint32_t)0xFF000000)        /*!< MEMHIZ4[7:0] bits (Common memory 4 databus HiZ time) */
  5221. #define  FSMC_PMEM4_MEMHIZ4_0                ((uint32_t)0x01000000)        /*!< Bit 0 */
  5222. #define  FSMC_PMEM4_MEMHIZ4_1                ((uint32_t)0x02000000)        /*!< Bit 1 */
  5223. #define  FSMC_PMEM4_MEMHIZ4_2                ((uint32_t)0x04000000)        /*!< Bit 2 */
  5224. #define  FSMC_PMEM4_MEMHIZ4_3                ((uint32_t)0x08000000)        /*!< Bit 3 */
  5225. #define  FSMC_PMEM4_MEMHIZ4_4                ((uint32_t)0x10000000)        /*!< Bit 4 */
  5226. #define  FSMC_PMEM4_MEMHIZ4_5                ((uint32_t)0x20000000)        /*!< Bit 5 */
  5227. #define  FSMC_PMEM4_MEMHIZ4_6                ((uint32_t)0x40000000)        /*!< Bit 6 */
  5228. #define  FSMC_PMEM4_MEMHIZ4_7                ((uint32_t)0x80000000)        /*!< Bit 7 */
  5229.  
  5230. /******************  Bit definition for FSMC_PATT2 register  ******************/
  5231. #define  FSMC_PATT2_ATTSET2                  ((uint32_t)0x000000FF)        /*!< ATTSET2[7:0] bits (Attribute memory 2 setup time) */
  5232. #define  FSMC_PATT2_ATTSET2_0                ((uint32_t)0x00000001)        /*!< Bit 0 */
  5233. #define  FSMC_PATT2_ATTSET2_1                ((uint32_t)0x00000002)        /*!< Bit 1 */
  5234. #define  FSMC_PATT2_ATTSET2_2                ((uint32_t)0x00000004)        /*!< Bit 2 */
  5235. #define  FSMC_PATT2_ATTSET2_3                ((uint32_t)0x00000008)        /*!< Bit 3 */
  5236. #define  FSMC_PATT2_ATTSET2_4                ((uint32_t)0x00000010)        /*!< Bit 4 */
  5237. #define  FSMC_PATT2_ATTSET2_5                ((uint32_t)0x00000020)        /*!< Bit 5 */
  5238. #define  FSMC_PATT2_ATTSET2_6                ((uint32_t)0x00000040)        /*!< Bit 6 */
  5239. #define  FSMC_PATT2_ATTSET2_7                ((uint32_t)0x00000080)        /*!< Bit 7 */
  5240.  
  5241. #define  FSMC_PATT2_ATTWAIT2                 ((uint32_t)0x0000FF00)        /*!< ATTWAIT2[7:0] bits (Attribute memory 2 wait time) */
  5242. #define  FSMC_PATT2_ATTWAIT2_0               ((uint32_t)0x00000100)        /*!< Bit 0 */
  5243. #define  FSMC_PATT2_ATTWAIT2_1               ((uint32_t)0x00000200)        /*!< Bit 1 */
  5244. #define  FSMC_PATT2_ATTWAIT2_2               ((uint32_t)0x00000400)        /*!< Bit 2 */
  5245. #define  FSMC_PATT2_ATTWAIT2_3               ((uint32_t)0x00000800)        /*!< Bit 3 */
  5246. #define  FSMC_PATT2_ATTWAIT2_4               ((uint32_t)0x00001000)        /*!< Bit 4 */
  5247. #define  FSMC_PATT2_ATTWAIT2_5               ((uint32_t)0x00002000)        /*!< Bit 5 */
  5248. #define  FSMC_PATT2_ATTWAIT2_6               ((uint32_t)0x00004000)        /*!< Bit 6 */
  5249. #define  FSMC_PATT2_ATTWAIT2_7               ((uint32_t)0x00008000)        /*!< Bit 7 */
  5250.  
  5251. #define  FSMC_PATT2_ATTHOLD2                 ((uint32_t)0x00FF0000)        /*!< ATTHOLD2[7:0] bits (Attribute memory 2 hold time) */
  5252. #define  FSMC_PATT2_ATTHOLD2_0               ((uint32_t)0x00010000)        /*!< Bit 0 */
  5253. #define  FSMC_PATT2_ATTHOLD2_1               ((uint32_t)0x00020000)        /*!< Bit 1 */
  5254. #define  FSMC_PATT2_ATTHOLD2_2               ((uint32_t)0x00040000)        /*!< Bit 2 */
  5255. #define  FSMC_PATT2_ATTHOLD2_3               ((uint32_t)0x00080000)        /*!< Bit 3 */
  5256. #define  FSMC_PATT2_ATTHOLD2_4               ((uint32_t)0x00100000)        /*!< Bit 4 */
  5257. #define  FSMC_PATT2_ATTHOLD2_5               ((uint32_t)0x00200000)        /*!< Bit 5 */
  5258. #define  FSMC_PATT2_ATTHOLD2_6               ((uint32_t)0x00400000)        /*!< Bit 6 */
  5259. #define  FSMC_PATT2_ATTHOLD2_7               ((uint32_t)0x00800000)        /*!< Bit 7 */
  5260.  
  5261. #define  FSMC_PATT2_ATTHIZ2                  ((uint32_t)0xFF000000)        /*!< ATTHIZ2[7:0] bits (Attribute memory 2 databus HiZ time) */
  5262. #define  FSMC_PATT2_ATTHIZ2_0                ((uint32_t)0x01000000)        /*!< Bit 0 */
  5263. #define  FSMC_PATT2_ATTHIZ2_1                ((uint32_t)0x02000000)        /*!< Bit 1 */
  5264. #define  FSMC_PATT2_ATTHIZ2_2                ((uint32_t)0x04000000)        /*!< Bit 2 */
  5265. #define  FSMC_PATT2_ATTHIZ2_3                ((uint32_t)0x08000000)        /*!< Bit 3 */
  5266. #define  FSMC_PATT2_ATTHIZ2_4                ((uint32_t)0x10000000)        /*!< Bit 4 */
  5267. #define  FSMC_PATT2_ATTHIZ2_5                ((uint32_t)0x20000000)        /*!< Bit 5 */
  5268. #define  FSMC_PATT2_ATTHIZ2_6                ((uint32_t)0x40000000)        /*!< Bit 6 */
  5269. #define  FSMC_PATT2_ATTHIZ2_7                ((uint32_t)0x80000000)        /*!< Bit 7 */
  5270.  
  5271. /******************  Bit definition for FSMC_PATT3 register  ******************/
  5272. #define  FSMC_PATT3_ATTSET3                  ((uint32_t)0x000000FF)        /*!< ATTSET3[7:0] bits (Attribute memory 3 setup time) */
  5273. #define  FSMC_PATT3_ATTSET3_0                ((uint32_t)0x00000001)        /*!< Bit 0 */
  5274. #define  FSMC_PATT3_ATTSET3_1                ((uint32_t)0x00000002)        /*!< Bit 1 */
  5275. #define  FSMC_PATT3_ATTSET3_2                ((uint32_t)0x00000004)        /*!< Bit 2 */
  5276. #define  FSMC_PATT3_ATTSET3_3                ((uint32_t)0x00000008)        /*!< Bit 3 */
  5277. #define  FSMC_PATT3_ATTSET3_4                ((uint32_t)0x00000010)        /*!< Bit 4 */
  5278. #define  FSMC_PATT3_ATTSET3_5                ((uint32_t)0x00000020)        /*!< Bit 5 */
  5279. #define  FSMC_PATT3_ATTSET3_6                ((uint32_t)0x00000040)        /*!< Bit 6 */
  5280. #define  FSMC_PATT3_ATTSET3_7                ((uint32_t)0x00000080)        /*!< Bit 7 */
  5281.  
  5282. #define  FSMC_PATT3_ATTWAIT3                 ((uint32_t)0x0000FF00)        /*!< ATTWAIT3[7:0] bits (Attribute memory 3 wait time) */
  5283. #define  FSMC_PATT3_ATTWAIT3_0               ((uint32_t)0x00000100)        /*!< Bit 0 */
  5284. #define  FSMC_PATT3_ATTWAIT3_1               ((uint32_t)0x00000200)        /*!< Bit 1 */
  5285. #define  FSMC_PATT3_ATTWAIT3_2               ((uint32_t)0x00000400)        /*!< Bit 2 */
  5286. #define  FSMC_PATT3_ATTWAIT3_3               ((uint32_t)0x00000800)        /*!< Bit 3 */
  5287. #define  FSMC_PATT3_ATTWAIT3_4               ((uint32_t)0x00001000)        /*!< Bit 4 */
  5288. #define  FSMC_PATT3_ATTWAIT3_5               ((uint32_t)0x00002000)        /*!< Bit 5 */
  5289. #define  FSMC_PATT3_ATTWAIT3_6               ((uint32_t)0x00004000)        /*!< Bit 6 */
  5290. #define  FSMC_PATT3_ATTWAIT3_7               ((uint32_t)0x00008000)        /*!< Bit 7 */
  5291.  
  5292. #define  FSMC_PATT3_ATTHOLD3                 ((uint32_t)0x00FF0000)        /*!< ATTHOLD3[7:0] bits (Attribute memory 3 hold time) */
  5293. #define  FSMC_PATT3_ATTHOLD3_0               ((uint32_t)0x00010000)        /*!< Bit 0 */
  5294. #define  FSMC_PATT3_ATTHOLD3_1               ((uint32_t)0x00020000)        /*!< Bit 1 */
  5295. #define  FSMC_PATT3_ATTHOLD3_2               ((uint32_t)0x00040000)        /*!< Bit 2 */
  5296. #define  FSMC_PATT3_ATTHOLD3_3               ((uint32_t)0x00080000)        /*!< Bit 3 */
  5297. #define  FSMC_PATT3_ATTHOLD3_4               ((uint32_t)0x00100000)        /*!< Bit 4 */
  5298. #define  FSMC_PATT3_ATTHOLD3_5               ((uint32_t)0x00200000)        /*!< Bit 5 */
  5299. #define  FSMC_PATT3_ATTHOLD3_6               ((uint32_t)0x00400000)        /*!< Bit 6 */
  5300. #define  FSMC_PATT3_ATTHOLD3_7               ((uint32_t)0x00800000)        /*!< Bit 7 */
  5301.  
  5302. #define  FSMC_PATT3_ATTHIZ3                  ((uint32_t)0xFF000000)        /*!< ATTHIZ3[7:0] bits (Attribute memory 3 databus HiZ time) */
  5303. #define  FSMC_PATT3_ATTHIZ3_0                ((uint32_t)0x01000000)        /*!< Bit 0 */
  5304. #define  FSMC_PATT3_ATTHIZ3_1                ((uint32_t)0x02000000)        /*!< Bit 1 */
  5305. #define  FSMC_PATT3_ATTHIZ3_2                ((uint32_t)0x04000000)        /*!< Bit 2 */
  5306. #define  FSMC_PATT3_ATTHIZ3_3                ((uint32_t)0x08000000)        /*!< Bit 3 */
  5307. #define  FSMC_PATT3_ATTHIZ3_4                ((uint32_t)0x10000000)        /*!< Bit 4 */
  5308. #define  FSMC_PATT3_ATTHIZ3_5                ((uint32_t)0x20000000)        /*!< Bit 5 */
  5309. #define  FSMC_PATT3_ATTHIZ3_6                ((uint32_t)0x40000000)        /*!< Bit 6 */
  5310. #define  FSMC_PATT3_ATTHIZ3_7                ((uint32_t)0x80000000)        /*!< Bit 7 */
  5311.  
  5312. /******************  Bit definition for FSMC_PATT4 register  ******************/
  5313. #define  FSMC_PATT4_ATTSET4                  ((uint32_t)0x000000FF)        /*!< ATTSET4[7:0] bits (Attribute memory 4 setup time) */
  5314. #define  FSMC_PATT4_ATTSET4_0                ((uint32_t)0x00000001)        /*!< Bit 0 */
  5315. #define  FSMC_PATT4_ATTSET4_1                ((uint32_t)0x00000002)        /*!< Bit 1 */
  5316. #define  FSMC_PATT4_ATTSET4_2                ((uint32_t)0x00000004)        /*!< Bit 2 */
  5317. #define  FSMC_PATT4_ATTSET4_3                ((uint32_t)0x00000008)        /*!< Bit 3 */
  5318. #define  FSMC_PATT4_ATTSET4_4                ((uint32_t)0x00000010)        /*!< Bit 4 */
  5319. #define  FSMC_PATT4_ATTSET4_5                ((uint32_t)0x00000020)        /*!< Bit 5 */
  5320. #define  FSMC_PATT4_ATTSET4_6                ((uint32_t)0x00000040)        /*!< Bit 6 */
  5321. #define  FSMC_PATT4_ATTSET4_7                ((uint32_t)0x00000080)        /*!< Bit 7 */
  5322.  
  5323. #define  FSMC_PATT4_ATTWAIT4                 ((uint32_t)0x0000FF00)        /*!< ATTWAIT4[7:0] bits (Attribute memory 4 wait time) */
  5324. #define  FSMC_PATT4_ATTWAIT4_0               ((uint32_t)0x00000100)        /*!< Bit 0 */
  5325. #define  FSMC_PATT4_ATTWAIT4_1               ((uint32_t)0x00000200)        /*!< Bit 1 */
  5326. #define  FSMC_PATT4_ATTWAIT4_2               ((uint32_t)0x00000400)        /*!< Bit 2 */
  5327. #define  FSMC_PATT4_ATTWAIT4_3               ((uint32_t)0x00000800)        /*!< Bit 3 */
  5328. #define  FSMC_PATT4_ATTWAIT4_4               ((uint32_t)0x00001000)        /*!< Bit 4 */
  5329. #define  FSMC_PATT4_ATTWAIT4_5               ((uint32_t)0x00002000)        /*!< Bit 5 */
  5330. #define  FSMC_PATT4_ATTWAIT4_6               ((uint32_t)0x00004000)        /*!< Bit 6 */
  5331. #define  FSMC_PATT4_ATTWAIT4_7               ((uint32_t)0x00008000)        /*!< Bit 7 */
  5332.  
  5333. #define  FSMC_PATT4_ATTHOLD4                 ((uint32_t)0x00FF0000)        /*!< ATTHOLD4[7:0] bits (Attribute memory 4 hold time) */
  5334. #define  FSMC_PATT4_ATTHOLD4_0               ((uint32_t)0x00010000)        /*!< Bit 0 */
  5335. #define  FSMC_PATT4_ATTHOLD4_1               ((uint32_t)0x00020000)        /*!< Bit 1 */
  5336. #define  FSMC_PATT4_ATTHOLD4_2               ((uint32_t)0x00040000)        /*!< Bit 2 */
  5337. #define  FSMC_PATT4_ATTHOLD4_3               ((uint32_t)0x00080000)        /*!< Bit 3 */
  5338. #define  FSMC_PATT4_ATTHOLD4_4               ((uint32_t)0x00100000)        /*!< Bit 4 */
  5339. #define  FSMC_PATT4_ATTHOLD4_5               ((uint32_t)0x00200000)        /*!< Bit 5 */
  5340. #define  FSMC_PATT4_ATTHOLD4_6               ((uint32_t)0x00400000)        /*!< Bit 6 */
  5341. #define  FSMC_PATT4_ATTHOLD4_7               ((uint32_t)0x00800000)        /*!< Bit 7 */
  5342.  
  5343. #define  FSMC_PATT4_ATTHIZ4                  ((uint32_t)0xFF000000)        /*!< ATTHIZ4[7:0] bits (Attribute memory 4 databus HiZ time) */
  5344. #define  FSMC_PATT4_ATTHIZ4_0                ((uint32_t)0x01000000)        /*!< Bit 0 */
  5345. #define  FSMC_PATT4_ATTHIZ4_1                ((uint32_t)0x02000000)        /*!< Bit 1 */
  5346. #define  FSMC_PATT4_ATTHIZ4_2                ((uint32_t)0x04000000)        /*!< Bit 2 */
  5347. #define  FSMC_PATT4_ATTHIZ4_3                ((uint32_t)0x08000000)        /*!< Bit 3 */
  5348. #define  FSMC_PATT4_ATTHIZ4_4                ((uint32_t)0x10000000)        /*!< Bit 4 */
  5349. #define  FSMC_PATT4_ATTHIZ4_5                ((uint32_t)0x20000000)        /*!< Bit 5 */
  5350. #define  FSMC_PATT4_ATTHIZ4_6                ((uint32_t)0x40000000)        /*!< Bit 6 */
  5351. #define  FSMC_PATT4_ATTHIZ4_7                ((uint32_t)0x80000000)        /*!< Bit 7 */
  5352.  
  5353. /******************  Bit definition for FSMC_PIO4 register  *******************/
  5354. #define  FSMC_PIO4_IOSET4                    ((uint32_t)0x000000FF)        /*!< IOSET4[7:0] bits (I/O 4 setup time) */
  5355. #define  FSMC_PIO4_IOSET4_0                  ((uint32_t)0x00000001)        /*!< Bit 0 */
  5356. #define  FSMC_PIO4_IOSET4_1                  ((uint32_t)0x00000002)        /*!< Bit 1 */
  5357. #define  FSMC_PIO4_IOSET4_2                  ((uint32_t)0x00000004)        /*!< Bit 2 */
  5358. #define  FSMC_PIO4_IOSET4_3                  ((uint32_t)0x00000008)        /*!< Bit 3 */
  5359. #define  FSMC_PIO4_IOSET4_4                  ((uint32_t)0x00000010)        /*!< Bit 4 */
  5360. #define  FSMC_PIO4_IOSET4_5                  ((uint32_t)0x00000020)        /*!< Bit 5 */
  5361. #define  FSMC_PIO4_IOSET4_6                  ((uint32_t)0x00000040)        /*!< Bit 6 */
  5362. #define  FSMC_PIO4_IOSET4_7                  ((uint32_t)0x00000080)        /*!< Bit 7 */
  5363.  
  5364. #define  FSMC_PIO4_IOWAIT4                   ((uint32_t)0x0000FF00)        /*!< IOWAIT4[7:0] bits (I/O 4 wait time) */
  5365. #define  FSMC_PIO4_IOWAIT4_0                 ((uint32_t)0x00000100)        /*!< Bit 0 */
  5366. #define  FSMC_PIO4_IOWAIT4_1                 ((uint32_t)0x00000200)        /*!< Bit 1 */
  5367. #define  FSMC_PIO4_IOWAIT4_2                 ((uint32_t)0x00000400)        /*!< Bit 2 */
  5368. #define  FSMC_PIO4_IOWAIT4_3                 ((uint32_t)0x00000800)        /*!< Bit 3 */
  5369. #define  FSMC_PIO4_IOWAIT4_4                 ((uint32_t)0x00001000)        /*!< Bit 4 */
  5370. #define  FSMC_PIO4_IOWAIT4_5                 ((uint32_t)0x00002000)        /*!< Bit 5 */
  5371. #define  FSMC_PIO4_IOWAIT4_6                 ((uint32_t)0x00004000)        /*!< Bit 6 */
  5372. #define  FSMC_PIO4_IOWAIT4_7                 ((uint32_t)0x00008000)        /*!< Bit 7 */
  5373.  
  5374. #define  FSMC_PIO4_IOHOLD4                   ((uint32_t)0x00FF0000)        /*!< IOHOLD4[7:0] bits (I/O 4 hold time) */
  5375. #define  FSMC_PIO4_IOHOLD4_0                 ((uint32_t)0x00010000)        /*!< Bit 0 */
  5376. #define  FSMC_PIO4_IOHOLD4_1                 ((uint32_t)0x00020000)        /*!< Bit 1 */
  5377. #define  FSMC_PIO4_IOHOLD4_2                 ((uint32_t)0x00040000)        /*!< Bit 2 */
  5378. #define  FSMC_PIO4_IOHOLD4_3                 ((uint32_t)0x00080000)        /*!< Bit 3 */
  5379. #define  FSMC_PIO4_IOHOLD4_4                 ((uint32_t)0x00100000)        /*!< Bit 4 */
  5380. #define  FSMC_PIO4_IOHOLD4_5                 ((uint32_t)0x00200000)        /*!< Bit 5 */
  5381. #define  FSMC_PIO4_IOHOLD4_6                 ((uint32_t)0x00400000)        /*!< Bit 6 */
  5382. #define  FSMC_PIO4_IOHOLD4_7                 ((uint32_t)0x00800000)        /*!< Bit 7 */
  5383.  
  5384. #define  FSMC_PIO4_IOHIZ4                    ((uint32_t)0xFF000000)        /*!< IOHIZ4[7:0] bits (I/O 4 databus HiZ time) */
  5385. #define  FSMC_PIO4_IOHIZ4_0                  ((uint32_t)0x01000000)        /*!< Bit 0 */
  5386. #define  FSMC_PIO4_IOHIZ4_1                  ((uint32_t)0x02000000)        /*!< Bit 1 */
  5387. #define  FSMC_PIO4_IOHIZ4_2                  ((uint32_t)0x04000000)        /*!< Bit 2 */
  5388. #define  FSMC_PIO4_IOHIZ4_3                  ((uint32_t)0x08000000)        /*!< Bit 3 */
  5389. #define  FSMC_PIO4_IOHIZ4_4                  ((uint32_t)0x10000000)        /*!< Bit 4 */
  5390. #define  FSMC_PIO4_IOHIZ4_5                  ((uint32_t)0x20000000)        /*!< Bit 5 */
  5391. #define  FSMC_PIO4_IOHIZ4_6                  ((uint32_t)0x40000000)        /*!< Bit 6 */
  5392. #define  FSMC_PIO4_IOHIZ4_7                  ((uint32_t)0x80000000)        /*!< Bit 7 */
  5393.  
  5394. /******************  Bit definition for FSMC_ECCR2 register  ******************/
  5395. #define  FSMC_ECCR2_ECC2                     ((uint32_t)0xFFFFFFFF)        /*!< ECC result */
  5396.  
  5397. /******************  Bit definition for FSMC_ECCR3 register  ******************/
  5398. #define  FSMC_ECCR3_ECC3                     ((uint32_t)0xFFFFFFFF)        /*!< ECC result */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement