/*---------------------------------------------------------------------------- * Name: STM32_Init.c * Purpose: STM32 peripherals initialisation * Version: V1.28 * Note(s): *---------------------------------------------------------------------------- * This file is part of the uVision/ARM development tools. * This software may only be used under the terms of a valid, current, * end user licence from KEIL for a compatible version of KEIL software * development tools. Nothing else gives you the right to use this software. * * This software is supplied "AS IS" without warranties of any kind. * * Copyright (c) 2005-2009 Keil Software. All rights reserved. *---------------------------------------------------------------------------- * History: * V1.28 error correction for TIM1 initialisation * V1.27 error correction for Nested Vectored Interrupt Controller Section * V1.26 added register GPIOF, GPIOG * added GPIOF, GPIOG to External interrupt/event Configuration * V1.25 error correction for USART section * V1.24 changed function definition to 'static inline' * V1.23 error correction for RTC configuration (LSI selected) * V1.22 added Nested Vectored Interrupt Controller Section * V1.21 error correction for timer settings * V1.20 added Alternate Function remap Configuration Section * error correction for timer settings * V1.10 added more Sections * V1.00 Initial Version *----------------------------------------------------------------------------*/ #ifndef __STM32_INIT_C #define __STM32_INIT_C //#include #include // STM32F10x Library Definitions #include "STM32_Reg.h" // missing bit definitions //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- // //=========================================================================== Clock Configuration // Clock Configuration // Clock Control Register Configuration (RCC_CR) // PLLON: PLL enable // Default: PLL Disabled // PLLMUL: PLL Multiplication Factor // Default: PLLSRC * 2 // <0=> PLLSRC * 2 // <1=> PLLSRC * 3 // <2=> PLLSRC * 4 // <3=> PLLSRC * 5 // <4=> PLLSRC * 6 // <5=> PLLSRC * 7 // <6=> PLLSRC * 8 // <7=> PLLSRC * 9 // <8=> PLLSRC * 10 // <9=> PLLSRC * 11 // <10=> PLLSRC * 12 // <11=> PLLSRC * 13 // <12=> PLLSRC * 14 // <13=> PLLSRC * 15 // <14=> PLLSRC * 16 // PLLXTPRE: HSE divider for PLL entry // Default: HSE // <0=> HSE // <1=> HSE / 2 // PLLSRC: PLL entry clock source // Default: HSI/2 // <0=> HSI / 2 // <1=> HSE (PLLXTPRE output) // // CSSON: Clock Security System enable // Default: Clock detector OFF // HSEBYP: External High Speed clock Bypass // Default: HSE oscillator not bypassed // HSEON: External High Speed clock enable // Default: HSE oscillator OFF // HSITRIM: Internal High Speed clock trimming <0-31> // Default: 0 // HSION: Internal High Speed clock enable // Default: internal 8MHz RC oscillator OFF // // Clock Configuration Register Configuration (RCC_CFGR) // MCO: Microcontroller Clock Output // Default: MCO = noClock // <0=> MCO = noClock // <4=> MCO = SYSCLK // <5=> MCO = HSI // <6=> MCO = HSE // <7=> MCO = PLLCLK / 2 // USBPRE: USB prescaler // Default: USBCLK = PLLCLK / 1.5 // <0=> USBCLK = PLLCLK / 1.5 // <1=> USBCLK = PLLCLK // ADCPRE: ADC prescaler // Default: ADCCLK=PCLK2 / 2 // <0=> ADCCLK = PCLK2 / 2 // <1=> ADCCLK = PCLK2 / 4 // <2=> ADCCLK = PCLK2 / 6 // <3=> ADCCLK = PCLK2 / 8 // PPRE2: APB High speed prescaler (APB2) // Default: PCLK2 = HCLK // <0=> PCLK2 = HCLK // <4=> PCLK2 = HCLK / 2 // <5=> PCLK2 = HCLK / 4 // <6=> PCLK2 = HCLK / 8 // <7=> PCLK2 = HCLK / 16 // PPRE1: APB Low speed prescaler (APB1) // Default: PCLK1 = HCLK // <0=> PCLK1 = HCLK // <4=> PCLK1 = HCLK / 2 // <5=> PCLK1 = HCLK / 4 // <6=> PCLK1 = HCLK / 8 // <7=> PCLK1 = HCLK / 16 // HPRE: AHB prescaler // Default: HCLK = SYSCLK // <0=> HCLK = SYSCLK // <8=> HCLK = SYSCLK / 2 // <9=> HCLK = SYSCLK / 4 // <10=> HCLK = SYSCLK / 8 // <11=> HCLK = SYSCLK / 16 // <12=> HCLK = SYSCLK / 64 // <13=> HCLK = SYSCLK / 128 // <14=> HCLK = SYSCLK / 256 // <15=> HCLK = SYSCLK / 512 // SW: System Clock Switch // Default: SYSCLK = HSE // <0=> SYSCLK = HSI // <1=> SYSCLK = HSE // <2=> SYSCLK = PLLCLK // // HSE: External High Speed Clock [Hz] <4000000-16000000> // clock value for the used External High Speed Clock (4MHz <= HSE <= 16MHz). // Default: 8000000 (8MHz) // End of Clock Configuration #define __CLOCK_SETUP 1 #define __RCC_CR_VAL 0x010C0003 #define __RCC_CFGR_VAL 0x0028C402 #define __HSE 8000000 //=========================================================================== Nested Vectored Interrupt Controller // Nested Vectored Interrupt Controller (NVIC) // Vector Table Offset Register // TBLBASE: Vector Table Base // Default: FLASH // <0=> FLASH // <1=> RAM // TBLOFF: Vector Table Offset <0x0-0x1FFFFFC0:0x80><#/0x80> // Default: 0x00000000 // // End of Clock Configuration #define __NVIC_SETUP 0 #define __NVIC_USED 0x00000001 #define __NVIC_VTOR_VAL 0x00000000 //=========================================================================== Independent Watchdog Configuration // Independent Watchdog Configuration // IWDG period [us] <125-32000000:125> // Set the timer period for Independent Watchdog. // Default: 1000000 (1s) // #define __IWDG_SETUP 0 #define __IWDG_PERIOD 0x001E8480 //=========================================================================== System Timer Configuration // System Timer Configuration // System Timer clock source selection // Default: SYSTICKCLK = HCLK/8 // <0=> SYSTICKCLK = HCLK/8 // <1=> SYSTICKCLK = HCLK // SYSTICK period [ms] <1-1000:10> // Set the timer period for System Timer. // Default: 1 (1ms) // System Timer interrupt enabled // #define __SYSTICK_SETUP 1 #define __SYSTICK_CTRL_VAL 0x00000002 #define __SYSTICK_PERIOD 0x00000001 //=========================================================================== Real Time Clock Configuration // Real Time Clock Configuration // RTC clock source selection // Default: No Clock // <0=> No Clock // <1=> RTCCLK = LSE (32,768kHz) // <2=> RTCCLK = LSI (32 kHz) // <3=> RTCCLK = HSE/128 // RTC period [ms] <10-1000:10> // Set the timer period for Real Time Clock. // Default: 1000 (1s) // RTC Time Value // Hour <0-23> // Minute <0-59> // Second <0-59> // // RTC Alarm Value // Hour <0-23> // Minute <0-59> // Second <0-59> // // RTC interrupts // RTC_CRH.SECIE: Second interrupt enabled // RTC_CRH.ALRIE: Alarm interrupt enabled // RTC_CRH.OWIE: Overflow interrupt enabled // // #define __RTC_SETUP 0 #define __RTC_CLKSRC_VAL 0x00000100 #define __RTC_PERIOD 0x000003E8 #define __RTC_TIME_H 0x00 #define __RTC_TIME_M 0x00 #define __RTC_TIME_S 0x00 #define __RTC_ALARM_H 0x00 #define __RTC_ALARM_M 0x01 #define __RTC_ALARM_S 0x00 #define __RTC_INTERRUPTS 0x00000001 #define __RTC_CRH 0x00000001 //=========================================================================== Timer Configuration // Timer Configuration //--------------------------------------------------------------------------- Timer 1 enabled // TIM1 : Timer 1 enabled // TIM1 period [us] <1-72000000:10> // Set the timer period for Timer 1. // Default: 1000 (1ms) // Ignored if detailed settings is selected // TIM1 repetition counter <0-255> // Set the repetition counter for Timer 1. // Default: 0 // Ignored if detailed settings is selected // TIM1 detailed settings //--------------------------------------------------------------------------- Timer 1 detailed settings // TIM1.PSC: Timer1 Prescaler <0-65535> // Set the prescaler for Timer 1. // TIM1.ARR: Timer1 Auto-reload <0-65535> // Set the Auto-reload for Timer 1. // TIM1.RCR: Timer1 Repetition Counter <0-255> // Set the Repetition Counter for Timer 1. // // Timer 1 Control Register 1 Configuration (TIM1_CR1) // TIM1_CR1.CKD: Clock division // Default: tDTS = tCK_INT // devision ratio between timer clock and dead time // <0=> tDTS = tCK_INT // <1=> tDTS = 2*tCK_INT // <2=> tDTS = 4*tCK_INT // TIM1_CR1.ARPE: Auto-reload preload enable // Default: Auto-reload preload disenabled // TIM1_CR1.CMS: Center aligned mode selection // Default: Edge-aligned // <0=> Edge-aligned // <1=> Center-aligned mode1 // <2=> Center-aligned mode2 // <3=> Center-aligned mode3 // TIM1_CR1.DIR: Direction // Default: DIR = Counter used as up-counter // read only if timer is configured as Center-aligned or Encoder mode // <0=> Counter used as up-counter // <1=> Counter used as down-counter // TIM1_CR1.OPM: One pulse mode enable // Default: One pulse mode disabled // TIM1_CR1.URS: Update request source // Default: URS = Counter over-/underflow, UG bit, Slave mode controller // <0=> Counter over-/underflow, UG bit, Slave mode controller // <1=> Counter over-/underflow // TIM1_CR1.UDIS: Update disable // Default: Update enabled // // // Timer 1 Control Register 2 Configuration (TIM1_CR2) // TIM1_CR2.OIS4: Output Idle state4 (OC4 output) <0-1> // TIM1_CR2.OIS3N: Output Idle state3 (OC3N output) <0-1> // TIM1_CR2.OIS3: Output Idle state3 (OC3 output) <0-1> // TIM1_CR2.OIS2N: Output Idle state2 (OC2N output) <0-1> // TIM1_CR2.OIS2: Output Idle state2 (OC2 output) <0-1> // TIM1_CR2.OIS1N: Output Idle state1 (OC1N output) // Default: OC1 = 0 // <0=> OC1N=0 when MOE=0 // <1=> OC1N=1 when MOE=0 // TIM1_CR2.OI1S: Output Idle state1 (OC1 output) // Default: OC1=0 // <0=> OC1=0 when MOE=0 // <1=> OC1=1 when MOE=0 // TIM1_CR2.TI1S: TI1 Selection // Default: TIM1CH1 connected to TI1 input // <0=> TIM1CH1 connected to TI1 input // <1=> TIM1CH1,CH2,CH3 connected to TI1 input // TIM1_CR2.MMS: Master Mode Selection // Default: Reset // Select information to be sent in master mode to slave timers for synchronisation // <0=> Reset // <1=> Enable // <2=> Update // <3=> Compare Pulse // <4=> Compare OC1REF iused as TRGO // <5=> Compare OC2REF iused as TRGO // <6=> Compare OC3REF iused as TRGO // <7=> Compare OC4REF iused as TRGO // TIM1_CR2.CCUS: Capture/Compare Control Update Selection // Default: setting COM bit // <0=> setting COM bit // <1=> setting COM bit or rising edge TRGI // TIM1_CR2.CCPC: Capture/Compare Preloaded Control // Default: CCxE,CCxNE,OCxM not preloaded // <0=> CCxE,CCxNE,OCxM not preloaded // <1=> CCxE,CCxNE,OCxM preloaded // // // Timer 1 Slave mode control register Configuration (TIM1_SMC) // TIM1_SMCR.ETP: External trigger polarity // Default: ETR is non-inverted // <0=> ETR is non-inverted // <1=> ETR is inverted // TIM1_SMCR.ECE: External clock mode 2 enabled // TIM1_SMCR.ETPS: External trigger prescaler // Default: Prescaler OFF // <0=> Prescaler OFF // <1=> fETPR/2 // <2=> fETPR/4 // <3=> fETPR/8 // TIM1_SMCR.ETF: External trigger filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM1_SMCR.MSM: Delay trigger input // TIM1_SMCR.TS: Trigger Selection // Default: Reserved // <0=> Reserved // <1=> TIM2 (ITR1) // <2=> TIM3 (ITR2) // <3=> TIM4 (ITR3) // <4=> TI1 Edge Detector (TI1F_ED) // <5=> Filtered Timer Input 1 (TI1FP1) // <6=> Filtered Timer Input 2 (TI1FP2) // <7=> External Trigger Input (ETRF) // TIM1_SMCR.SMS: Slave mode selection // Default: Slave mode disabled // <0=> Slave mode disabled // <1=> Encoder mode 1 // <2=> Encoder mode 2 // <3=> Encoder mode 3 // <4=> Reset mode // <5=> Gated mode // <6=> Trigger mode // <7=> External clock mode 1 // // //--------------------------------------------------------------------------- Timer 1 channel 1 // Channel 1 Configuration // Channel configured as output // TIM1_CCMR1.OC1CE: Output Compare 1 Clear enabled // TIM1_CCMR1.OC1M: Output Compare 1 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 1 to active level on match // <2=> Set channel 1 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM1_CCMR1.OC1PE: Output Compare 1 Preload enabled // TIM1_CCMR1.OC1FE: Output Compare 1 Fast enabled // TIM1_CCMR1.CC1S: Capture/compare 1 selection // Default: CC1 configured as output // <0=> CC1 configured as output // TIM1_CCER.CC1NP: Capture/compare 1 Complementary output Polarity set // Default: OC1N active high // <0=> OC1N active high // <1=> OC1N active low // TIM1_CCER.CC1NE: Capture/compare 1 Complementary output enabled // Default: OC1N not active // <0=> OC1N not active // <1=> OC1N is output on corresponding pin // TIM1_CCER.CC1P: Capture/compare 1 output Polarity set // Default: OC1 active high // <0=> OC1 active high // <1=> OC1 active low // TIM1_CCER.CC1E: Capture/compare 1 output enabled // Default: OC1 not active // <0=> OC1 not active // <1=> OC1 is output on corresponding pin // // Channel configured as input // TIM1_CCMR1.IC1F: Input Capture 1 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM1_CCMR1.IC1PSC: Input Capture 1 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM1_CCMR1.CC1S: Capture/compare 1 selection // Default: CC1 configured as output // <0=> CC1 configured as output // <1=> CC1 configured as input, IC1 mapped on TI1 // <2=> CC1 configured as input, IC1 mapped on TI2 // <3=> CC1 configured as input, IC1 mapped on TRGI // TIM1_CCER.CC1P: Capture/compare 1 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM1_CCER.CC1E: Capture/compare 1 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM1_CCR1: Capture/compare register 1 <0-65535> // Set the Compare register value for compare register 1. // Default: 0 // // //--------------------------------------------------------------------------- Timer 1 channel 2 // Channel 2 Configuration // Channel configured as output // TIM1_CCMR1.OC2CE: Output Compare 2 Clear enabled // TIM1_CCMR1.OC2M: Output Compare 2 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 2 to active level on match // <2=> Set channel 2 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM1_CCMR1.OC2PE: Output Compare 2 Preload enabled // TIM1_CCMR1.OC2FE: Output Compare 2 Fast enabled // TIM1_CCMR1.CC2S: Capture/compare 2 selection // Default: CC2 configured as output // <0=> CC2 configured as output // TIM1_CCER.CC2NP: Capture/compare 2 Complementary output Polarity set // Default: OC2N active high // <0=> OC2N active high // <1=> OC2N active low // TIM1_CCER.CC2NE: Capture/compare 2 Complementary output enabled // Default: OC2N not active // <0=> OC2N not active // <1=> OC2N is output on corresponding pin // TIM1_CCER.CC2P: Capture/compare 2 output Polarity set // Default: OC2 active high // <0=> OC2 active high // <1=> OC2 active low // TIM1_CCER.CC2E: Capture/compare 2 output enabled // Default: OC2 not active // <0=> OC2 not active // <1=> OC2 is output on corresponding pin // // Channel configured as input // TIM1_CCMR1.IC2F: Input Capture 2 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM1_CCMR1.IC2PSC: Input Capture 2 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM1_CCMR1.CC2S: Capture/compare 2 selection // Default: CC2 configured as output // <0=> CC2 configured as output // <1=> CC2 configured as input, IC2 mapped on TI2 // <2=> CC2 configured as input, IC2 mapped on TI1 // <3=> CC2 configured as input, IC2 mapped on TRGI // TIM1_CCER.CC2P: Capture/compare 2 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM1_CCER.CC2E: Capture/compare 2 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM1_CCR2: Capture/compare register 2 <0-65535> // Set the Compare register value for compare register 2. // Default: 0 // // //--------------------------------------------------------------------------- Timer 1 channel 3 // Channel 3 Configuration // Channel configured as output // TIM1_CCMR2.OC3CE: Output Compare 3 Clear enabled // TIM1_CCMR2.OC3M: Output Compare 3 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 3 to active level on match // <2=> Set channel 3 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM1_CCMR2.OC3PE: Output Compare 3 Preload enabled // TIM1_CCMR2.OC3FE: Output Compare 3 Fast enabled // TIM1_CCMR2.CC3S: Capture/compare 3 selection // Default: CC3 configured as output // <0=> CC3 configured as output // TIM1_CCER.CC3NP: Capture/compare 3 Complementary output Polarity set // Default: OC3N active high // <0=> OC3N active high // <1=> OC3N active low // TIM1_CCER.CC3NE: Capture/compare 3 Complementary output enabled // Default: OC3N not active // <0=> OC3N not active // <1=> OC3N is output on corresponding pin // TIM1_CCER.CC3P: Capture/compare 3 output Polarity set // Default: OC3 active high // <0=> OC3 active high // <1=> OC3 active low // TIM1_CCER.CC3E: Capture/compare 3 output enabled // Default: OC3 not active // <0=> OC3 not active // <1=> OC3 is output on corresponding pin // // Channel configured as input // TIM1_CCMR2.IC3F: Input Capture 3 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM1_CCMR2.IC3PSC: Input Capture 3 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM1_CCMR2.CC3S: Capture/compare 3 selection // Default: CC3 configured as output // <0=> CC3 configured as output // <1=> CC3 configured as input, IC3 mapped on TI3 // <2=> CC3 configured as input, IC3 mapped on TI4 // <3=> CC3 configured as input, IC3 mapped on TRGI // TIM1_CCER.CC3P: Capture/compare 3 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM1_CCER.CC3E: Capture/compare 3 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM1_CCR3: Capture/compare register 3 <0-65535> // Set the Compare register value for compare register 3. // Default: 0 // // //--------------------------------------------------------------------------- Timer 1 channel 4 // Channel 4 Configuration // Channel configured as output // TIM1_CCMR2.OC4CE: Output Compare 4 Clear enabled // TIM1_CCMR2.OC4M: Output Compare 4 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 4 to active level on match // <2=> Set channel 4 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM1_CCMR2.OC4PE: Output Compare 4 Preload enabled // TIM1_CCMR2.OC4FE: Output Compare 4 Fast enabled // TIM1_CCMR2.CC4S: Capture/compare 4 selection // Default: CC4 configured as output // <0=> CC4 configured as output // TIM1_CCER.CC4P: Capture/compare 4 output Polarity set // Default: OC4 active high // <0=> OC4 active high // <1=> OC4 active low // TIM1_CCER.CC4E: Capture/compare 4 output enabled // Default: OC4 not active // <0=> OC4 not active // <1=> OC4 is output on corresponding pin // // Channel configured as input // TIM1_CCMR2.IC4F: Input Capture 4 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM1_CCMR2.IC4PSC: Input Capture 4 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM1_CCMR2.CC4S: Capture/compare 4 selection // Default: CC4 configured as output // <0=> CC4 configured as output // <1=> CC4 configured as input, IC4 mapped on TI4 // <2=> CC4 configured as input, IC4 mapped on TI3 // <3=> CC4 configured as input, IC4 mapped on TRGI // TIM1_CCER.CC4P: Capture/compare 4 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM1_CCER.CC4E: Capture/compare 4 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM1_CCR4: Capture/compare register 4 <0-65535> // Set the Compare register value for compare register 4. // Default: 0 // // // Timer1 Break and dead-time register Configuration (TIM1_BDTR) // TIM1_BDTR.MOE: Main Output enabled // TIM1_BDTR.AOE: Automatic Output enabled // TIM1_BDTR.BKP: Break Polarity active high // TIM1_BDTR.BKE: Break Inputs enabled // TIM1_BDTR.OSSR: Off-State Selection for Run mode // Default: OC/OCN output signal=0 // <0=> OC/OCN output signal=0 // <1=> OC/OCN output signal=1 // TIM1_BDTR.OSSI: Off-State Selection for Idle mode // Default: OC/OCN output signal=0 // <0=> OC/OCN output signal=0 // <1=> OC/OCN output signal=1 // TIM1_BDTR.LOCK: Lock Level <0-3> // Default: 0 (LOCK OFF) // TIM1_BDTR.DTG: Dead-Time Generator set-up <0x00-0xFF> // // // // TIM1 interrupts // TIM1_DIER.TDE: Trigger DMA request enabled // TIM1_DIER.CC4DE: Capture/Compare 4 DMA request enabled // TIM1_DIER.CC3DE: Capture/Compare 3 DMA request enabled // TIM1_DIER.CC2DE: Capture/Compare 2 DMA request enabled // TIM1_DIER.CC1DE: Capture/Compare 1 DMA request enabled // TIM1_DIER.UDE: Update DMA request enabled // TIM1_DIER.BIE: Break interrupt enabled // TIM1_DIER.TIE: Trigger interrupt enabled // TIM1_DIER.COMIE: COM interrupt enabled // TIM1_DIER.CC4IE: Capture/Compare 4 interrupt enabled // TIM1_DIER.CC3IE: Capture/Compare 3 interrupt enabled // TIM1_DIER.CC2IE: Capture/Compare 2 interrupt enabled // TIM1_DIER.CC1IE: Capture/Compare 1 interrupt enabled // TIM1_DIER.UIE: Update interrupt enabled // // //--------------------------------------------------------------------------- Timer 2 enabled // TIM2 : Timer 2 enabled // TIM2 period [us] <1-72000000:10> // Set the timer period for Timer 2. // Default: 1000 (1ms) // Ignored if Detailed settings is selected // TIM2 detailed settings //--------------------------------------------------------------------------- Timer 2 detailed settings // TIM2.PSC: Timer 2 Prescaler <0-65535> // Set the prescaler for Timer 2. // TIM2.ARR: Timer 2 Auto-reload <0-65535> // Set the Auto-reload for Timer 2. // Timer 2 Control Register 1 Configuration (TIM2_CR1) // TIM2_CR1.CKD: Clock division // Default: tDTS = tCK_INT // devision ratio between timer clock and dead time // <0=> tDTS = tCK_INT // <1=> tDTS = 2*tCK_INT // <2=> tDTS = 4*tCK_INT // TIM2_CR1.ARPE: Auto-reload preload enable // Default: Auto-reload preload disenabled // TIM2_CR1.CMS: Center aligned mode selection // Default: Edge-aligned // <0=> Edge-aligned // <1=> Center-aligned mode1 // <2=> Center-aligned mode2 // <3=> Center-aligned mode3 // TIM2_CR1.DIR: Direction // Default: DIR = Counter used as up-counter // read only if timer is configured as Center-aligned or Encoder mode // <0=> Counter used as up-counter // <1=> Counter used as down-counter // TIM2_CR1.OPM: One pulse mode enable // Default: One pulse mode disabled // TIM2_CR1.URS: Update request source // Default: URS = Counter over-/underflow, UG bit, Slave mode controller // <0=> Counter over-/underflow, UG bit, Slave mode controller // <1=> Counter over-/underflow // TIM2_CR1.UDIS: Update disable // Default: Update enabled // // // Timer 2 Control Register 2 Configuration (TIM2_CR2) // TIM2_CR2.TI1S: TI1 Selection // Default: TIM2CH1 connected to TI1 input // <0=> TIM2CH1 connected to TI1 input // <1=> TIM2CH1,CH2,CH3 connected to TI1 input // TIM2_CR2.MMS: Master Mode Selection // Default: Reset // Select information to be sent in master mode to slave timers for synchronisation // <0=> Reset // <1=> Enable // <2=> Update // <3=> Compare Pulse // <4=> Compare OC1REF iused as TRGO // <5=> Compare OC2REF iused as TRGO // <6=> Compare OC3REF iused as TRGO // <7=> Compare OC4REF iused as TRGO // TIM2_CR2.CCDS: Capture/Compare DMA Selection // Default: CC4 DMA request on CC4 event // <0=> CC4 DMA request on CC4 event // <1=> CC4 DMA request on update event // // // Timer 2 Slave mode control register Configuration (TIM2_SMC) // TIM2_SMCR.ETP: External trigger polarity // Default: ETR is non-inverted // <0=> ETR is non-inverted // <1=> ETR is inverted // TIM2_SMCR.ECE: External clock mode 2 enabled // TIM2_SMCR.ETPS: External trigger prescaler // Default: Prescaler OFF // <0=> Prescaler OFF // <1=> fETPR/2 // <2=> fETPR/4 // <3=> fETPR/8 // TIM2_SMCR.ETF: External trigger filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM2_SMCR.MSM: Delay trigger input // TIM2_SMCR.TS: Trigger Selection // Default: TIM1 (ITR0) // <0=> TIM1 (ITR0) // <1=> TIM2 (ITR1) // <2=> TIM3 (ITR2) // <3=> TIM4 (ITR3) // <4=> TI1 Edge Detector (TI1F_ED) // <5=> Filtered Timer Input 1 (TI1FP1) // <6=> Filtered Timer Input 2 (TI1FP2) // <7=> External Trigger Input (ETRF) // TIM2_SMCR.SMS: Slave mode selection // Default: Slave mode disabled // <0=> Slave mode disabled // <1=> Encoder mode 1 // <2=> Encoder mode 2 // <3=> Encoder mode 3 // <4=> Reset mode // <5=> Gated mode // <6=> Trigger mode // <7=> External clock mode 1 // // // //--------------------------------------------------------------------------- Timer 2 channel 1 // Channel 1 Configuration // Channel configured as output // TIM2_CCMR1.OC1CE: Output Compare 1 Clear enabled // TIM2_CCMR1.OC1M: Output Compare 1 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 1 to active level on match // <2=> Set channel 1 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM2_CCMR1.OC1PE: Output Compare 1 Preload enabled // TIM2_CCMR1.OC1FE: Output Compare 1 Fast enabled // TIM2_CCMR1.CC1S: Capture/compare 1 selection // Default: CC1 configured as output // <0=> CC1 configured as output // TIM2_CCER.CC1P: Capture/compare 1 output Polarity set // Default: OC1 active high // <0=> OC1 active high // <1=> OC1 active low // TIM1_CCER.CC1E: Capture/compare 1 output enabled // Default: OC1 not active // <0=> OC1 not active // <1=> OC1 is output on corresponding pin // // Channel configured as input // TIM2_CCMR1.IC1F: Input Capture 1 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM2_CCMR1.IC1PSC: Input Capture 1 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM2_CCMR1.CC1S: Capture/compare 1 selection // Default: CC1 configured as output // <0=> CC1 configured as output // <1=> CC1 configured as input, IC1 mapped on TI1 // <2=> CC1 configured as input, IC1 mapped on TI2 // <3=> CC1 configured as input, IC1 mapped on TRGI // TIM2_CCER.CC1P: Capture/compare 1 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM2_CCER.CC1E: Capture/compare 1 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM2_CCR1: Capture/compare register 1 <0-65535> // Set the Compare register value for compare register 1. // Default: 0 // // //--------------------------------------------------------------------------- Timer 2 channel 2 // Channel 2 Configuration // Channel configured as output // TIM2_CCMR1.OC2CE: Output Compare 2 Clear enabled // TIM2_CCMR1.OC2M: Output Compare 2 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 2 to active level on match // <2=> Set channel 2 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM2_CCMR1.OC2PE: Output Compare 2 Preload enabled // TIM2_CCMR1.OC2FE: Output Compare 2 Fast enabled // TIM2_CCMR1.CC2S: Capture/compare 2 selection // Default: CC2 configured as output // <0=> CC2 configured as output // TIM2_CCER.CC2P: Capture/compare 2 output Polarity set // Default: OC2 active high // <0=> OC2 active high // <1=> OC2 active low // TIM2_CCER.CC2E: Capture/compare 2 output enabled // Default: OC2 not active // <0=> OC2 not active // <1=> OC2 is output on corresponding pin // // Channel configured as input // TIM2_CCMR1.IC2F: Input Capture 2 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM2_CCMR1.IC2PSC: Input Capture 2 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM2_CCMR1.CC2S: Capture/compare 2 selection // Default: CC2 configured as output // <0=> CC2 configured as output // <1=> CC2 configured as input, IC2 mapped on TI2 // <2=> CC2 configured as input, IC2 mapped on TI1 // <3=> CC2 configured as input, IC2 mapped on TRGI // TIM2_CCER.CC2P: Capture/compare 2 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM2_CCER.CC2E: Capture/compare 2 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM2_CCR2: Capture/compare register 2 <0-65535> // Set the Compare register value for compare register 2. // Default: 0 // // //--------------------------------------------------------------------------- Timer 2 channel 3 // Channel 3 Configuration // Channel configured as output // TIM2_CCMR2.OC3CE: Output Compare 3 Clear enabled // TIM2_CCMR2.OC3M: Output Compare 3 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 3 to active level on match // <2=> Set channel 3 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM2_CCMR2.OC3PE: Output Compare 3 Preload enabled // TIM2_CCMR2.OC3FE: Output Compare 3 Fast enabled // TIM2_CCMR2.CC3S: Capture/compare 3 selection // Default: CC3 configured as output // <0=> CC3 configured as output // TIM2_CCER.CC3P: Capture/compare 3 output Polarity set // Default: OC3 active high // <0=> OC3 active high // <1=> OC3 active low // TIM2_CCER.CC3E: Capture/compare 3 output enabled // Default: OC3 not active // <0=> OC3 not active // <1=> OC3 is output on corresponding pin // // Channel configured as input // TIM2_CCMR2.IC3F: Input Capture 3 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM2_CCMR2.IC3PSC: Input Capture 3 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM2_CCMR2.CC3S: Capture/compare 3 selection // Default: CC3 configured as output // <0=> CC3 configured as output // <1=> CC3 configured as input, IC3 mapped on TI3 // <2=> CC3 configured as input, IC3 mapped on TI4 // <3=> CC3 configured as input, IC3 mapped on TRGI // TIM2_CCER.CC3P: Capture/compare 3 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM2_CCER.CC3E: Capture/compare 3 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM2_CCR3: Capture/compare register 3 <0-65535> // Set the Compare register value for compare register 3. // Default: 0 // // //--------------------------------------------------------------------------- Timer 2 channel 4 // Channel 4 Configuration // Channel configured as output // TIM2_CCMR2.OC4CE: Output Compare 4 Clear enabled // TIM2_CCMR2.OC4M: Output Compare 4 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 4 to active level on match // <2=> Set channel 4 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM2_CCMR2.OC4PE: Output Compare 4 Preload enabled // TIM2_CCMR2.OC4FE: Output Compare 4 Fast enabled // TIM2_CCMR2.CC4S: Capture/compare 4 selection // Default: CC4 configured as output // <0=> CC4 configured as output // TIM2_CCER.CC4P: Capture/compare 4 output Polarity set // Default: OC4 active high // <0=> OC4 active high // <1=> OC4 active low // TIM2_CCER.CC4E: Capture/compare 4 output enabled // Default: OC4 not active // <0=> OC4 not active // <1=> OC4 is output on corresponding pin // // Channel configured as input // TIM2_CCMR2.IC4F: Input Capture 4 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM2_CCMR2.IC4PSC: Input Capture 4 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM2_CCMR2.CC4S: Capture/compare 4 selection // Default: CC4 configured as output // <0=> CC4 configured as output // <1=> CC4 configured as input, IC4 mapped on TI4 // <2=> CC4 configured as input, IC4 mapped on TI3 // <3=> CC4 configured as input, IC4 mapped on TRGI // TIM2_CCER.CC4P: Capture/compare 4 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM2_CCER.CC4E: Capture/compare 4 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM2_CCR4: Capture/compare register 4 <0-65535> // Set the Compare register value for compare register 4. // Default: 0 // // // // TIM2 interrupts // TIM2_DIER.TDE: Trigger DMA request enabled // TIM2_DIER.CC4DE: Capture/Compare 4 DMA request enabled // TIM2_DIER.CC3DE: Capture/Compare 3 DMA request enabled // TIM2_DIER.CC2DE: Capture/Compare 2 DMA request enabled // TIM2_DIER.CC1DE: Capture/Compare 1 DMA request enabled // TIM2_DIER.UDE: Update DMA request enabled // TIM2_DIER.TIE: Trigger interrupt enabled // TIM2_DIER.CC4IE: Capture/Compare 4 interrupt enabled // TIM2_DIER.CC3IE: Capture/Compare 3 interrupt enabled // TIM2_DIER.CC2IE: Capture/Compare 2 interrupt enabled // TIM2_DIER.CC1IE: Capture/Compare 1 interrupt enabled // TIM2_DIER.UIE: Update interrupt enabled // // //--------------------------------------------------------------------------- Timer 3 enabled // TIM3 : Timer 3 enabled // TIM3 period [us] <1-72000000:10> // Set the timer period for Timer 3. // Default: 1000 (1ms) // Ignored if Detailed settings is selected //--------------------------------------------------------------------------- Timer 3 detailed settings // TIM3 detailed settings // TIM3.PSC: Timer 3 Prescaler <0-65535> // Set the prescaler for Timer 3. // TIM3.ARR: Timer 3 Auto-reload <0-65535> // Set the Auto-reload for Timer 3. // Timer 3 Control Register 1 Configuration (TIM3_CR1) // TIM3_CR1.CKD: Clock division // Default: tDTS = tCK_INT // devision ratio between timer clock and dead time // <0=> tDTS = tCK_INT // <1=> tDTS = 2*tCK_INT // <2=> tDTS = 4*tCK_INT // TIM3_CR1.ARPE: Auto-reload preload enable // Default: Auto-reload preload disenabled // TIM3_CR1.CMS: Center aligned mode selection // Default: Edge-aligned // <0=> Edge-aligned // <1=> Center-aligned mode1 // <2=> Center-aligned mode2 // <3=> Center-aligned mode3 // TIM3_CR1.DIR: Direction // Default: DIR = Counter used as up-counter // read only if timer is configured as Center-aligned or Encoder mode // <0=> Counter used as up-counter // <1=> Counter used as down-counter // TIM3_CR1.OPM: One pulse mode enable // Default: One pulse mode disabled // TIM3_CR1.URS: Update request source // Default: URS = Counter over-/underflow, UG bit, Slave mode controller // <0=> Counter over-/underflow, UG bit, Slave mode controller // <1=> Counter over-/underflow // TIM3_CR1.UDIS: Update disable // Default: Update enabled // // // Timer 3 Control Register 2 Configuration (TIM3_CR2) // TIM3_CR2.TI1S: TI1 Selection // Default: TIM3CH1 connected to TI1 input // <0=> TIM3CH1 connected to TI1 input // <1=> TIM3CH1,CH2,CH3 connected to TI1 input // TIM3_CR2.MMS: Master Mode Selection // Default: Reset // Select information to be sent in master mode to slave timers for synchronisation // <0=> Reset // <1=> Enable // <2=> Update // <3=> Compare Pulse // <4=> Compare OC1REF iused as TRGO // <5=> Compare OC2REF iused as TRGO // <6=> Compare OC3REF iused as TRGO // <7=> Compare OC4REF iused as TRGO // TIM3_CR2.CCDS: Capture/Compare DMA Selection // Default: CC4 DMA request on CC4 event // <0=> CC4 DMA request on CC4 event // <1=> CC4 DMA request on update event // // // Timer 3 Slave mode control register Configuration (TIM3_SMC) // TIM3_SMCR.ETP: External trigger polarity // Default: ETR is non-inverted // <0=> ETR is non-inverted // <1=> ETR is inverted // TIM3_SMCR.ECE: External clock mode 2 enabled // TIM3_SMCR.ETPS: External trigger prescaler // Default: Prescaler OFF // <0=> Prescaler OFF // <1=> fETPR/2 // <2=> fETPR/4 // <3=> fETPR/8 // TIM3_SMCR.ETF: External trigger filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM3_SMCR.MSM: Delay trigger input // TIM3_SMCR.TS: Trigger Selection // Default: TIM1 (ITR0) // <0=> TIM1 (ITR0) // <1=> TIM2 (ITR1) // <2=> TIM3 (ITR2) // <3=> TIM4 (ITR3) // <4=> TI1 Edge Detector (TI1F_ED) // <5=> Filtered Timer Input 1 (TI1FP1) // <6=> Filtered Timer Input 2 (TI1FP2) // <7=> External Trigger Input (ETRF) // TIM3_SMCR.SMS: Slave mode selection // Default: Slave mode disabled // <0=> Slave mode disabled // <1=> Encoder mode 1 // <2=> Encoder mode 2 // <3=> Encoder mode 3 // <4=> Reset mode // <5=> Gated mode // <6=> Trigger mode // <7=> External clock mode 1 // // //--------------------------------------------------------------------------- Timer 3 channel 1 // Channel 1 Configuration // Channel configured as output // TIM3_CCMR1.OC1CE: Output Compare 1 Clear enabled // TIM3_CCMR1.OC1M: Output Compare 1 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 1 to active level on match // <2=> Set channel 1 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM3_CCMR1.OC1PE: Output Compare 1 Preload enabled // TIM3_CCMR1.OC1FE: Output Compare 1 Fast enabled // TIM3_CCMR1.CC1S: Capture/compare 1 selection // Default: CC1 configured as output // <0=> CC1 configured as output // TIM3_CCER.CC1P: Capture/compare 1 output Polarity set // Default: OC1 active high // <0=> OC1 active high // <1=> OC1 active low // TIM1_CCER.CC1E: Capture/compare 1 output enabled // Default: OC1 not active // <0=> OC1 not active // <1=> OC1 is output on corresponding pin // // Channel configured as input // TIM3_CCMR1.IC1F: Input Capture 1 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM3_CCMR1.IC1PSC: Input Capture 1 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM3_CCMR1.CC1S: Capture/compare 1 selection // Default: CC1 configured as output // <0=> CC1 configured as output // <1=> CC1 configured as input, IC1 mapped on TI1 // <2=> CC1 configured as input, IC1 mapped on TI2 // <3=> CC1 configured as input, IC1 mapped on TRGI // TIM3_CCER.CC1P: Capture/compare 1 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM3_CCER.CC1E: Capture/compare 1 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM3_CCR1: Capture/compare register 1 <0-65535> // Set the Compare register value for compare register 1. // Default: 0 // // //--------------------------------------------------------------------------- Timer 3 channel 2 // Channel 2 Configuration // Channel configured as output // TIM3_CCMR1.OC2CE: Output Compare 2 Clear enabled // TIM3_CCMR1.OC2M: Output Compare 2 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 2 to active level on match // <2=> Set channel 2 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM3_CCMR1.OC2PE: Output Compare 2 Preload enabled // TIM3_CCMR1.OC2FE: Output Compare 2 Fast enabled // TIM3_CCMR1.CC2S: Capture/compare 2 selection // Default: CC2 configured as output // <0=> CC2 configured as output // TIM3_CCER.CC2P: Capture/compare 2 output Polarity set // Default: OC2 active high // <0=> OC2 active high // <1=> OC2 active low // TIM3_CCER.CC2E: Capture/compare 2 output enabled // Default: OC2 not active // <0=> OC2 not active // <1=> OC2 is output on corresponding pin // // Channel configured as input // TIM3_CCMR1.IC2F: Input Capture 2 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM3_CCMR1.IC2PSC: Input Capture 2 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM3_CCMR1.CC2S: Capture/compare 2 selection // Default: CC2 configured as output // <0=> CC2 configured as output // <1=> CC2 configured as input, IC2 mapped on TI2 // <2=> CC2 configured as input, IC2 mapped on TI1 // <3=> CC2 configured as input, IC2 mapped on TRGI // TIM3_CCER.CC2P: Capture/compare 2 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM3_CCER.CC2E: Capture/compare 2 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM3_CCR2: Capture/compare register 2 <0-65535> // Set the Compare register value for compare register 2. // Default: 0 // // //--------------------------------------------------------------------------- Timer 3 channel 3 // Channel 3 Configuration // Channel configured as output // TIM3_CCMR2.OC3CE: Output Compare 3 Clear enabled // TIM3_CCMR2.OC3M: Output Compare 3 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 3 to active level on match // <2=> Set channel 3 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM3_CCMR2.OC3PE: Output Compare 3 Preload enabled // TIM3_CCMR2.OC3FE: Output Compare 3 Fast enabled // TIM3_CCMR2.CC3S: Capture/compare 3 selection // Default: CC3 configured as output // <0=> CC3 configured as output // TIM3_CCER.CC3P: Capture/compare 3 output Polarity set // Default: OC3 active high // <0=> OC3 active high // <1=> OC3 active low // TIM3_CCER.CC3E: Capture/compare 3 output enabled // Default: OC3 not active // <0=> OC3 not active // <1=> OC3 is output on corresponding pin // // Channel configured as input // TIM3_CCMR2.IC3F: Input Capture 3 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM3_CCMR2.IC3PSC: Input Capture 3 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM3_CCMR2.CC3S: Capture/compare 3 selection // Default: CC3 configured as output // <0=> CC3 configured as output // <1=> CC3 configured as input, IC3 mapped on TI3 // <2=> CC3 configured as input, IC3 mapped on TI4 // <3=> CC3 configured as input, IC3 mapped on TRGI // TIM3_CCER.CC3P: Capture/compare 3 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM3_CCER.CC3E: Capture/compare 3 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM3_CCR3: Capture/compare register 3 <0-65535> // Set the Compare register value for compare register 3. // Default: 0 // // //--------------------------------------------------------------------------- Timer 3 channel 4 // Channel 4 Configuration // Channel configured as output // TIM3_CCMR2.OC4CE: Output Compare 4 Clear enabled // TIM3_CCMR2.OC4M: Output Compare 4 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 4 to active level on match // <2=> Set channel 4 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM3_CCMR2.OC4PE: Output Compare 4 Preload enabled // TIM3_CCMR2.OC4FE: Output Compare 4 Fast enabled // TIM3_CCMR2.CC4S: Capture/compare 4 selection // Default: CC4 configured as output // <0=> CC4 configured as output // TIM3_CCER.CC4P: Capture/compare 4 output Polarity set // Default: OC4 active high // <0=> OC4 active high // <1=> OC4 active low // TIM3_CCER.CC4E: Capture/compare 4 output enabled // Default: OC4 not active // <0=> OC4 not active // <1=> OC4 is output on corresponding pin // // Channel configured as input // TIM3_CCMR2.IC4F: Input Capture 4 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM3_CCMR2.IC4PSC: Input Capture 4 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM3_CCMR2.CC4S: Capture/compare 4 selection // Default: CC4 configured as output // <0=> CC4 configured as output // <1=> CC4 configured as input, IC4 mapped on TI4 // <2=> CC4 configured as input, IC4 mapped on TI3 // <3=> CC4 configured as input, IC4 mapped on TRGI // TIM3_CCER.CC4P: Capture/compare 4 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM3_CCER.CC4E: Capture/compare 4 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM3_CCR4: Capture/compare register 4 <0-65535> // Set the Compare register value for compare register 4. // Default: 0 // // // // TIM3 interrupts // TIM3_DIER.TDE: Trigger DMA request enabled // TIM3_DIER.CC4DE: Capture/Compare 4 DMA request enabled // TIM3_DIER.CC3DE: Capture/Compare 3 DMA request enabled // TIM3_DIER.CC2DE: Capture/Compare 2 DMA request enabled // TIM3_DIER.CC1DE: Capture/Compare 1 DMA request enabled // TIM3_DIER.UDE: Update DMA request enabled // TIM3_DIER.TIE: Trigger interrupt enabled // TIM3_DIER.CC4IE: Capture/Compare 4 interrupt enabled // TIM3_DIER.CC3IE: Capture/Compare 3 interrupt enabled // TIM3_DIER.CC2IE: Capture/Compare 2 interrupt enabled // TIM3_DIER.CC1IE: Capture/Compare 1 interrupt enabled // TIM3_DIER.UIE: Update interrupt enabled // // // //--------------------------------------------------------------------------- Timer 4 enabled // TIM4 : Timer 4 enabled // TIM4 period [us] <1-72000000:10> // Set the timer period for Timer 4. // Default: 1000 (1ms) // Ignored if detailed settings is selected //--------------------------------------------------------------------------- Timer 4 detailed settings // TIM4 detailed settings // TIM4.PSC: Timer 4 Prescaler <0-65535> // Set the prescaler for Timer 4. // TIM4.ARR: Timer 4 Auto-reload <0-65535> // Set the Auto-reload for Timer 4. // Timer 4 Control Register 1 Configuration (TIM4_CR1) // TIM4_CR1.CKD: Clock division // Default: tDTS = tCK_INT // devision ratio between timer clock and dead time // <0=> tDTS = tCK_INT // <1=> tDTS = 2*tCK_INT // <2=> tDTS = 4*tCK_INT // TIM4_CR1.ARPE: Auto-reload preload enable // Default: Auto-reload preload disenabled // TIM4_CR1.CMS: Center aligned mode selection // Default: Edge-aligned // <0=> Edge-aligned // <1=> Center-aligned mode1 // <2=> Center-aligned mode2 // <3=> Center-aligned mode3 // TIM4_CR1.DIR: Direction // Default: DIR = Counter used as up-counter // read only if timer is configured as Center-aligned or Encoder mode // <0=> Counter used as up-counter // <1=> Counter used as down-counter // TIM4_CR1.OPM: One pulse mode enable // Default: One pulse mode disabled // TIM4_CR1.URS: Update request source // Default: URS = Counter over-/underflow, UG bit, Slave mode controller // <0=> Counter over-/underflow, UG bit, Slave mode controller // <1=> Counter over-/underflow // TIM4_CR1.UDIS: Update disable // Default: Update enabled // // // Timer 4 Control Register 2 Configuration (TIM4_CR2) // TIM4_CR2.TI1S: TI1 Selection // Default: TIM4CH1 connected to TI1 input // <0=> TIM4CH1 connected to TI1 input // <1=> TIM4CH1,CH2,CH3 connected to TI1 input // TIM4_CR2.MMS: Master Mode Selection // Default: Reset // Select information to be sent in master mode to slave timers for synchronisation // <0=> Reset // <1=> Enable // <2=> Update // <3=> Compare Pulse // <4=> Compare OC1REF iused as TRGO // <5=> Compare OC2REF iused as TRGO // <6=> Compare OC3REF iused as TRGO // <7=> Compare OC4REF iused as TRGO // TIM4_CR2.CCDS: Capture/Compare DMA Selection // Default: CC4 DMA request on CC4 event // <0=> CC4 DMA request on CC4 event // <1=> CC4 DMA request on update event // // // Timer 4 Slave mode control register Configuration (TIM4_SMC) // TIM4_SMCR.ETP: External trigger polarity // Default: ETR is non-inverted // <0=> ETR is non-inverted // <1=> ETR is inverted // TIM4_SMCR.ECE: External clock mode 2 enabled // TIM4_SMCR.ETPS: External trigger prescaler // Default: Prescaler OFF // <0=> Prescaler OFF // <1=> fETPR/2 // <2=> fETPR/4 // <3=> fETPR/8 // TIM4_SMCR.ETF: External trigger filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM4_SMCR.MSM: Delay trigger input // TIM4_SMCR.TS: Trigger Selection // Default: TIM1 (ITR0) // <0=> TIM1 (ITR0) // <1=> TIM2 (ITR1) // <2=> TIM3 (ITR2) // <3=> TIM4 (ITR3) // <4=> TI1 Edge Detector (TI1F_ED) // <5=> Filtered Timer Input 1 (TI1FP1) // <6=> Filtered Timer Input 2 (TI1FP2) // <7=> External Trigger Input (ETRF) // TIM4_SMCR.SMS: Slave mode selection // Default: Slave mode disabled // <0=> Slave mode disabled // <1=> Encoder mode 1 // <2=> Encoder mode 2 // <3=> Encoder mode 3 // <4=> Reset mode // <5=> Gated mode // <6=> Trigger mode // <7=> External clock mode 1 // // // //--------------------------------------------------------------------------- Timer 4 channel 1 // Channel 1 Configuration // Channel configured as output // TIM4_CCMR1.OC1CE: Output Compare 1 Clear enabled // TIM4_CCMR1.OC1M: Output Compare 1 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 1 to active level on match // <2=> Set channel 1 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM4_CCMR1.OC1PE: Output Compare 1 Preload enabled // TIM4_CCMR1.OC1FE: Output Compare 1 Fast enabled // TIM4_CCMR1.CC1S: Capture/compare 1 selection // Default: CC1 configured as output // <0=> CC1 configured as output // TIM4_CCER.CC1P: Capture/compare 1 output Polarity set // Default: OC1 active high // <0=> OC1 active high // <1=> OC1 active low // TIM1_CCER.CC1E: Capture/compare 1 output enabled // Default: OC1 not active // <0=> OC1 not active // <1=> OC1 is output on corresponding pin // // Channel configured as input // TIM4_CCMR1.IC1F: Input Capture 1 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM4_CCMR1.IC1PSC: Input Capture 1 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM4_CCMR1.CC1S: Capture/compare 1 selection // Default: CC1 configured as output // <0=> CC1 configured as output // <1=> CC1 configured as input, IC1 mapped on TI1 // <2=> CC1 configured as input, IC1 mapped on TI2 // <3=> CC1 configured as input, IC1 mapped on TRGI // TIM4_CCER.CC1P: Capture/compare 1 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM4_CCER.CC1E: Capture/compare 1 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM4_CCR1: Capture/compare register 1 <0-65535> // Set the Compare register value for compare register 1. // Default: 0 // // //--------------------------------------------------------------------------- Timer 4 channel 2 // Channel 2 Configuration // Channel configured as output // TIM4_CCMR1.OC2CE: Output Compare 2 Clear enabled // TIM4_CCMR1.OC2M: Output Compare 2 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 2 to active level on match // <2=> Set channel 2 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM4_CCMR1.OC2PE: Output Compare 2 Preload enabled // TIM4_CCMR1.OC2FE: Output Compare 2 Fast enabled // TIM4_CCMR1.CC2S: Capture/compare 2 selection // Default: CC2 configured as output // <0=> CC2 configured as output // TIM4_CCER.CC2P: Capture/compare 2 output Polarity set // Default: OC2 active high // <0=> OC2 active high // <1=> OC2 active low // TIM4_CCER.CC2E: Capture/compare 2 output enabled // Default: OC2 not active // <0=> OC2 not active // <1=> OC2 is output on corresponding pin // // Channel configured as input // TIM4_CCMR1.IC2F: Input Capture 2 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM4_CCMR1.IC2PSC: Input Capture 2 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM4_CCMR1.CC2S: Capture/compare 2 selection // Default: CC2 configured as output // <0=> CC2 configured as output // <1=> CC2 configured as input, IC2 mapped on TI2 // <2=> CC2 configured as input, IC2 mapped on TI1 // <3=> CC2 configured as input, IC2 mapped on TRGI // TIM4_CCER.CC2P: Capture/compare 2 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM4_CCER.CC2E: Capture/compare 2 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM4_CCR2: Capture/compare register 2 <0-65535> // Set the Compare register value for compare register 2. // Default: 0 // // //--------------------------------------------------------------------------- Timer 4 channel 3 // Channel 3 Configuration // Channel configured as output // TIM4_CCMR2.OC3CE: Output Compare 3 Clear enabled // TIM4_CCMR2.OC3M: Output Compare 3 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 3 to active level on match // <2=> Set channel 3 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM4_CCMR2.OC3PE: Output Compare 3 Preload enabled // TIM4_CCMR2.OC3FE: Output Compare 3 Fast enabled // TIM4_CCMR2.CC3S: Capture/compare 3 selection // Default: CC3 configured as output // <0=> CC3 configured as output // TIM4_CCER.CC3P: Capture/compare 3 output Polarity set // Default: OC3 active high // <0=> OC3 active high // <1=> OC3 active low // TIM4_CCER.CC3E: Capture/compare 3 output enabled // Default: OC3 not active // <0=> OC3 not active // <1=> OC3 is output on corresponding pin // // Channel configured as input // TIM4_CCMR2.IC3F: Input Capture 3 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM4_CCMR2.IC3PSC: Input Capture 3 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM4_CCMR2.CC3S: Capture/compare 3 selection // Default: CC3 configured as output // <0=> CC3 configured as output // <1=> CC3 configured as input, IC3 mapped on TI3 // <2=> CC3 configured as input, IC3 mapped on TI4 // <3=> CC3 configured as input, IC3 mapped on TRGI // TIM4_CCER.CC3P: Capture/compare 3 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM4_CCER.CC3E: Capture/compare 3 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM4_CCR3: Capture/compare register 3 <0-65535> // Set the Compare register value for compare register 3. // Default: 0 // // //--------------------------------------------------------------------------- Timer 4 channel 4 // Channel 4 Configuration // Channel configured as output // TIM4_CCMR2.OC4CE: Output Compare 4 Clear enabled // TIM4_CCMR2.OC4M: Output Compare 4 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 4 to active level on match // <2=> Set channel 4 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM4_CCMR2.OC4PE: Output Compare 4 Preload enabled // TIM4_CCMR2.OC4FE: Output Compare 4 Fast enabled // TIM4_CCMR2.CC4S: Capture/compare 4 selection // Default: CC4 configured as output // <0=> CC4 configured as output // TIM4_CCER.CC4P: Capture/compare 4 output Polarity set // Default: OC4 active high // <0=> OC4 active high // <1=> OC4 active low // TIM4_CCER.CC4E: Capture/compare 4 output enabled // Default: OC4 not active // <0=> OC4 not active // <1=> OC4 is output on corresponding pin // // Channel configured as input // TIM4_CCMR2.IC4F: Input Capture 4 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM4_CCMR2.IC4PSC: Input Capture 4 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM4_CCMR2.CC4S: Capture/compare 4 selection // Default: CC4 configured as output // <0=> CC4 configured as output // <1=> CC4 configured as input, IC4 mapped on TI4 // <2=> CC4 configured as input, IC4 mapped on TI3 // <3=> CC4 configured as input, IC4 mapped on TRGI // TIM4_CCER.CC4P: Capture/compare 4 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM4_CCER.CC4E: Capture/compare 4 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM4_CCR4: Capture/compare register 4 <0-65535> // Set the Compare register value for compare register 4. // Default: 0 // // // // TIM4 interrupts // TIM4_DIER.TDE: Trigger DMA request enabled // TIM4_DIER.CC4DE: Capture/Compare 4 DMA request enabled // TIM4_DIER.CC3DE: Capture/Compare 3 DMA request enabled // TIM4_DIER.CC2DE: Capture/Compare 2 DMA request enabled // TIM4_DIER.CC1DE: Capture/Compare 1 DMA request enabled // TIM4_DIER.UDE: Update DMA request enabled // TIM4_DIER.TIE: Trigger interrupt enabled // TIM4_DIER.CC4IE: Capture/Compare 4 interrupt enabled // TIM4_DIER.CC3IE: Capture/Compare 3 interrupt enabled // TIM4_DIER.CC2IE: Capture/Compare 2 interrupt enabled // TIM4_DIER.CC1IE: Capture/Compare 1 interrupt enabled // TIM4_DIER.UIE: Update interrupt enabled // // // // //--------------------------------------------------------------------------- Timer 5 enabled // TIM5 : Timer 5 enabled // TIM5 period [us] <1-72000000:10> // Set the timer period for Timer 5. // Default: 1000 (1ms) // Ignored if detailed settings is selected //--------------------------------------------------------------------------- Timer 6 detailed settings // TIM5 detailed settings // TIM5.PSC: Timer 5 Prescaler <0-65535> // Set the prescaler for Timer 5. // TIM5.ARR: Timer 5 Auto-reload <0-65535> // Set the Auto-reload for Timer 5. // Timer 5 Control Register 1 Configuration (TIM5_CR1) // TIM5_CR1.CKD: Clock division // Default: tDTS = tCK_INT // devision ratio between timer clock and dead time // <0=> tDTS = tCK_INT // <1=> tDTS = 2*tCK_INT // <2=> tDTS = 4*tCK_INT // TIM5_CR1.ARPE: Auto-reload preload enable // Default: Auto-reload preload disenabled // TIM5_CR1.CMS: Center aligned mode selection // Default: Edge-aligned // <0=> Edge-aligned // <1=> Center-aligned mode1 // <2=> Center-aligned mode2 // <3=> Center-aligned mode3 // TIM5_CR1.DIR: Direction // Default: DIR = Counter used as up-counter // read only if timer is configured as Center-aligned or Encoder mode // <0=> Counter used as up-counter // <1=> Counter used as down-counter // TIM5_CR1.OPM: One pulse mode enable // Default: One pulse mode disabled // TIM5_CR1.URS: Update request source // Default: URS = Counter over-/underflow, UG bit, Slave mode controller // <0=> Counter over-/underflow, UG bit, Slave mode controller // <1=> Counter over-/underflow // TIM5_CR1.UDIS: Update disable // Default: Update enabled // // // Timer 5 Control Register 2 Configuration (TIM5_CR2) // TIM5_CR2.TI1S: TI1 Selection // Default: TIM5CH1 connected to TI1 input // <0=> TIM5CH1 connected to TI1 input // <1=> TIM5CH1,CH2,CH3 connected to TI1 input // TIM5_CR2.MMS: Master Mode Selection // Default: Reset // Select information to be sent in master mode to slave timers for synchronisation // <0=> Reset // <1=> Enable // <2=> Update // <3=> Compare Pulse // <4=> Compare OC1REF iused as TRGO // <5=> Compare OC2REF iused as TRGO // <6=> Compare OC3REF iused as TRGO // <7=> Compare OC4REF iused as TRGO // TIM5_CR2.CCDS: Capture/Compare DMA Selection // Default: CC4 DMA request on CC4 event // <0=> CC4 DMA request on CC4 event // <1=> CC4 DMA request on update event // // // Timer 5 Slave mode control register Configuration (TIM5_SMC) // TIM5_SMCR.ETP: External trigger polarity // Default: ETR is non-inverted // <0=> ETR is non-inverted // <1=> ETR is inverted // TIM5_SMCR.ECE: External clock mode 2 enabled // TIM5_SMCR.ETPS: External trigger prescaler // Default: Prescaler OFF // <0=> Prescaler OFF // <1=> fETPR/2 // <2=> fETPR/4 // <3=> fETPR/8 // TIM5_SMCR.ETF: External trigger filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM5_SMCR.MSM: Delay trigger input // TIM5_SMCR.TS: Trigger Selection // Default: TIM1 (ITR0) // <0=> TIM1 (ITR0) // <1=> TIM2 (ITR1) // <2=> TIM3 (ITR2) // <3=> TIM5 (ITR3) // <4=> TI1 Edge Detector (TI1F_ED) // <5=> Filtered Timer Input 1 (TI1FP1) // <6=> Filtered Timer Input 2 (TI1FP2) // <7=> External Trigger Input (ETRF) // TIM5_SMCR.SMS: Slave mode selection // Default: Slave mode disabled // <0=> Slave mode disabled // <1=> Encoder mode 1 // <2=> Encoder mode 2 // <3=> Encoder mode 3 // <4=> Reset mode // <5=> Gated mode // <6=> Trigger mode // <7=> External clock mode 1 // // // //--------------------------------------------------------------------------- Timer 5 channel 1 // Channel 1 Configuration // Channel configured as output // TIM5_CCMR1.OC1CE: Output Compare 1 Clear enabled // TIM5_CCMR1.OC1M: Output Compare 1 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 1 to active level on match // <2=> Set channel 1 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM5_CCMR1.OC1PE: Output Compare 1 Preload enabled // TIM5_CCMR1.OC1FE: Output Compare 1 Fast enabled // TIM5_CCMR1.CC1S: Capture/compare 1 selection // Default: CC1 configured as output // <0=> CC1 configured as output // TIM5_CCER.CC1P: Capture/compare 1 output Polarity set // Default: OC1 active high // <0=> OC1 active high // <1=> OC1 active low // TIM1_CCER.CC1E: Capture/compare 1 output enabled // Default: OC1 not active // <0=> OC1 not active // <1=> OC1 is output on corresponding pin // // Channel configured as input // TIM5_CCMR1.IC1F: Input Capture 1 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM5_CCMR1.IC1PSC: Input Capture 1 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM5_CCMR1.CC1S: Capture/compare 1 selection // Default: CC1 configured as output // <0=> CC1 configured as output // <1=> CC1 configured as input, IC1 mapped on TI1 // <2=> CC1 configured as input, IC1 mapped on TI2 // <3=> CC1 configured as input, IC1 mapped on TRGI // TIM5_CCER.CC1P: Capture/compare 1 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM5_CCER.CC1E: Capture/compare 1 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM5_CCR1: Capture/compare register 1 <0-65535> // Set the Compare register value for compare register 1. // Default: 0 // // //--------------------------------------------------------------------------- Timer 5 channel 2 // Channel 2 Configuration // Channel configured as output // TIM5_CCMR1.OC2CE: Output Compare 2 Clear enabled // TIM5_CCMR1.OC2M: Output Compare 2 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 2 to active level on match // <2=> Set channel 2 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM5_CCMR1.OC2PE: Output Compare 2 Preload enabled // TIM5_CCMR1.OC2FE: Output Compare 2 Fast enabled // TIM5_CCMR1.CC2S: Capture/compare 2 selection // Default: CC2 configured as output // <0=> CC2 configured as output // TIM5_CCER.CC2P: Capture/compare 2 output Polarity set // Default: OC2 active high // <0=> OC2 active high // <1=> OC2 active low // TIM5_CCER.CC2E: Capture/compare 2 output enabled // Default: OC2 not active // <0=> OC2 not active // <1=> OC2 is output on corresponding pin // // Channel configured as input // TIM5_CCMR1.IC2F: Input Capture 2 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM5_CCMR1.IC2PSC: Input Capture 2 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM5_CCMR1.CC2S: Capture/compare 2 selection // Default: CC2 configured as output // <0=> CC2 configured as output // <1=> CC2 configured as input, IC2 mapped on TI2 // <2=> CC2 configured as input, IC2 mapped on TI1 // <3=> CC2 configured as input, IC2 mapped on TRGI // TIM5_CCER.CC2P: Capture/compare 2 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM5_CCER.CC2E: Capture/compare 2 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM5_CCR2: Capture/compare register 2 <0-65535> // Set the Compare register value for compare register 2. // Default: 0 // // //--------------------------------------------------------------------------- Timer 5 channel 3 // Channel 3 Configuration // Channel configured as output // TIM5_CCMR2.OC3CE: Output Compare 3 Clear enabled // TIM5_CCMR2.OC3M: Output Compare 3 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 3 to active level on match // <2=> Set channel 3 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM5_CCMR2.OC3PE: Output Compare 3 Preload enabled // TIM5_CCMR2.OC3FE: Output Compare 3 Fast enabled // TIM5_CCMR2.CC3S: Capture/compare 3 selection // Default: CC3 configured as output // <0=> CC3 configured as output // TIM5_CCER.CC3P: Capture/compare 3 output Polarity set // Default: OC3 active high // <0=> OC3 active high // <1=> OC3 active low // TIM5_CCER.CC3E: Capture/compare 3 output enabled // Default: OC3 not active // <0=> OC3 not active // <1=> OC3 is output on corresponding pin // // Channel configured as input // TIM5_CCMR2.IC3F: Input Capture 3 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM5_CCMR2.IC3PSC: Input Capture 3 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM5_CCMR2.CC3S: Capture/compare 3 selection // Default: CC3 configured as output // <0=> CC3 configured as output // <1=> CC3 configured as input, IC3 mapped on TI3 // <2=> CC3 configured as input, IC3 mapped on TI4 // <3=> CC3 configured as input, IC3 mapped on TRGI // TIM5_CCER.CC3P: Capture/compare 3 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM5_CCER.CC3E: Capture/compare 3 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM5_CCR3: Capture/compare register 3 <0-65535> // Set the Compare register value for compare register 3. // Default: 0 // // //--------------------------------------------------------------------------- Timer 5 channel 4 // Channel 4 Configuration // Channel configured as output // TIM5_CCMR2.OC4CE: Output Compare 4 Clear enabled // TIM5_CCMR2.OC4M: Output Compare 4 Mode // Default: Frozen // <0=> Frozen // <1=> Set channel 4 to active level on match // <2=> Set channel 4 to inactive level on match // <3=> Toggle // <4=> Force inactive level // <5=> Force active level // <6=> PWM mode 1 // <7=> PWM mode 2 // TIM5_CCMR2.OC4PE: Output Compare 4 Preload enabled // TIM5_CCMR2.OC4FE: Output Compare 4 Fast enabled // TIM5_CCMR2.CC4S: Capture/compare 4 selection // Default: CC4 configured as output // <0=> CC4 configured as output // TIM5_CCER.CC4P: Capture/compare 4 output Polarity set // Default: OC4 active high // <0=> OC4 active high // <1=> OC4 active low // TIM5_CCER.CC4E: Capture/compare 4 output enabled // Default: OC4 not active // <0=> OC4 not active // <1=> OC4 is output on corresponding pin // // Channel configured as input // TIM5_CCMR2.IC4F: Input Capture 4 Filter // Default: No filter // <0=> No filter // <1=> fSampling=fCK_INT, N=2 // <2=> fSampling=fCK_INT, N=4 // <3=> fSampling=fCK_INT, N=8 // <4=> fSampling=fDTS/2, N=6 // <5=> fSampling=fDTS/2, N=8 // <6=> fSampling=fDTS/4, N=6 // <7=> fSampling=fDTS/4, N=8 // <8=> fSampling=fDTS/8, N=6 // <9=> fSampling=fDTS/8, N=8 // <10=> fSampling=fDTS/16, N=5 // <11=> fSampling=fDTS/16, N=6 // <12=> fSampling=fDTS/16, N=8 // <13=> fSampling=fDTS/32, N=5 // <14=> fSampling=fDTS/32, N=6 // <15=> fSampling=fDTS/32, N=8 // TIM5_CCMR2.IC4PSC: Input Capture 4 Prescaler // Default: No prescaler // <0=> No prescaler // <1=> capture every 2 events // <2=> capture every 4 events // <3=> capture every 8 events // TIM5_CCMR2.CC4S: Capture/compare 4 selection // Default: CC4 configured as output // <0=> CC4 configured as output // <1=> CC4 configured as input, IC4 mapped on TI4 // <2=> CC4 configured as input, IC4 mapped on TI3 // <3=> CC4 configured as input, IC4 mapped on TRGI // TIM5_CCER.CC4P: Capture/compare 4 output Polarity set // Default: non-inverted // <0=> non-inverted // <1=> inverted // TIM5_CCER.CC4E: Capture/compare 4 output enabled // Default: Capture disabled // <0=> Capture disabled // <1=> Capture enabled // // TIM5_CCR4: Capture/compare register 4 <0-65535> // Set the Compare register value for compare register 4. // Default: 0 // // // // TIM5 interrupts // TIM5_DIER.TDE: Trigger DMA request enabled // TIM5_DIER.CC4DE: Capture/Compare 4 DMA request enabled // TIM5_DIER.CC3DE: Capture/Compare 3 DMA request enabled // TIM5_DIER.CC2DE: Capture/Compare 2 DMA request enabled // TIM5_DIER.CC1DE: Capture/Compare 1 DMA request enabled // TIM5_DIER.UDE: Update DMA request enabled // TIM5_DIER.TIE: Trigger interrupt enabled // TIM5_DIER.CC4IE: Capture/Compare 4 interrupt enabled // TIM5_DIER.CC3IE: Capture/Compare 3 interrupt enabled // TIM5_DIER.CC2IE: Capture/Compare 2 interrupt enabled // TIM5_DIER.CC1IE: Capture/Compare 1 interrupt enabled // TIM5_DIER.UIE: Update interrupt enabled // // // // End of Timer Configuration #define __TIMER_SETUP 1 // 0 #define __TIMER_USED 0x000D // 1 #define __TIMER_DETAILS 0x000C // 2 #define __TIMER_INTERRUPTS 0x0013 // 3 #define __TIM1_PERIOD 0x001388 // 4 #define __TIM1_PSC 0x12C0 // 5 #define __TIM1_ARR 0x03E8 // 6 #define __TIM1_RCR 0x0000 // 7 #define __TIM1_CR1 0x0084 // 8 #define __TIM1_CR2 0x0015 // 9 #define __TIM1_SMCR 0x0000 // 10 #define __TIM1_CCMR1 0x0000 // 11 #define __TIM1_CCMR2 0x0008 // 12 #define __TIM1_CCER 0x0C00 // 13 #define __TIM1_CCR1 0x0000 // 14 #define __TIM1_CCR2 0x0000 // 15 #define __TIM1_CCR3 0x0000 // 16 #define __TIM1_CCR4 0x0000 // 17 #define __TIM1_BDTR 0x0000 // 18 #define __TIM1_DIER 0x0001 // 19 #define __TIM2_PERIOD 0x00003E8 // 20 #define __TIM2_PSC 0x0030 // 21 #define __TIM2_ARR 0x000A // 22 #define __TIM2_CR1 0x0084 // 23 #define __TIM2_CR2 0x0000 // 24 #define __TIM2_SMCR 0x0161 // 25 #define __TIM2_CCMR1 0x0101 // 26 #define __TIM2_CCMR2 0x0000 // 27 #define __TIM2_CCER 0x0010 // 28 #define __TIM2_CCR1 0x0000 // 29 #define __TIM2_CCR2 0x0000 // 30 #define __TIM2_CCR3 0x0000 // 31 #define __TIM2_CCR4 0x0000 // 32 #define __TIM2_DIER 0x0001 // 33 #define __TIM3_PERIOD 0x00001 // 34 #define __TIM3_PSC 0x01E0 // 35 #define __TIM3_ARR 0x0064 // 36 #define __TIM3_CR1 0x0080 // 37 #define __TIM3_CR2 0x0080 // 38 #define __TIM3_SMCR 0x0150 // 39 #define __TIM3_CCMR1 0x0068 // 40 #define __TIM3_CCMR2 0x0060 // 41 #define __TIM3_CCER 0x1101 // 42 #define __TIM3_CCR1 0x0032 // 43 #define __TIM3_CCR2 0x0014 // 44 #define __TIM3_CCR3 0x03E8 // 45 #define __TIM3_CCR4 0x01F4 // 46 #define __TIM3_DIER 0x0001 // 47 #define __TIM4_PERIOD 0x003E8 // 48 #define __TIM4_PSC 0x0018 // 49 #define __TIM4_ARR 0x03E7 // 50 #define __TIM4_CR1 0x0024 // 51 #define __TIM4_CR2 0x0000 // 52 #define __TIM4_SMCR 0x0050 // 53 #define __TIM4_CCMR1 0x6868 // 54 #define __TIM4_CCMR2 0x0800 // 55 #define __TIM4_CCER 0x0033 // 56 #define __TIM4_CCR1 0x0000 // 57 #define __TIM4_CCR2 0x0000 // 58 #define __TIM4_CCR3 0x0000 // 59 #define __TIM4_CCR4 0x0708 // 60 #define __TIM4_DIER 0x0001 // 61 #define __TIM5_PERIOD 0x00003E8 // 62 #define __TIM5_PSC 0xFFFF // 63 #define __TIM5_ARR 0xFFFF // 64 #define __TIM5_CR1 0x0001 // 65 #define __TIM5_CR2 0x0000 // 66 #define __TIM5_SMCR 0x0050 // 67 #define __TIM5_CCMR1 0xF1F0 // 68 #define __TIM5_CCMR2 0x6800 // 69 #define __TIM5_CCER 0x0000 // 70 #define __TIM5_CCR1 0x0384 // 71 #define __TIM5_CCR2 0x0000 // 72 #define __TIM5_CCR3 0x0000 // 73 #define __TIM5_CCR4 0x0708 // 74 #define __TIM5_DIER 0x0001 // 75 //=========================================================================== USART Configuration // USART Configuration //--------------------------------------------------------------------------- USART1 // USART1 : USART #1 enable // Baudrate // <9600=> 9600 Baud // <14400=> 14400 Baud // <19200=> 19200 Baud // <28800=> 28800 Baud // <38400=> 38400 Baud // <56000=> 56000 Baud // <57600=> 57600 Baud // <115200=> 115200 Baud // Data Bits // <0=> 8 Data Bits // <1=> 9 Data Bits // Stop Bits // <1=> 0.5 Stop Bit // <0=> 1 Stop Bit // <3=> 1.5 Stop Bits // <2=> 2 Stop Bits // Parity // <0=> No Parity // <2=> Even Parity // <3=> Odd Parity // Flow Control // <0=> None // <3=> Hardware // Pins used // <0=> TX = PA9, RX = PA10 // <1=> TX = PB6, RX = PB7 // USART1 interrupts // USART1_CR1.IDLEIE: IDLE Interrupt enable // USART1_CR1.RXNEIE: RXNE Interrupt enable // USART1_CR1.TCIE: Transmission Complete Interrupt enable // USART1_CR1.TXEIE: TXE Interrupt enable // USART1_CR1.PEIE: PE Interrupt enable // USART1_CR2.LBDIE: LIN Break Detection Interrupt enable // USART1_CR3.EIE: Error Interrupt enable // USART1_CR3.CTSIE: CTS Interrupt enable // // //--------------------------------------------------------------------------- USART2 // USART2 : USART #2 enable // Baudrate // <9600=> 9600 Baud // <14400=> 14400 Baud // <19200=> 19200 Baud // <28800=> 28800 Baud // <38400=> 38400 Baud // <56000=> 56000 Baud // <57600=> 57600 Baud // <115200=> 115200 Baud // Data Bits // <0=> 8 Data Bits // <1=> 9 Data Bits // Stop Bits // <1=> 0.5 Stop Bit // <0=> 1 Stop Bit // <3=> 1.5 Stop Bits // <2=> 2 Stop Bits // Parity // <0=> No Parity // <2=> Even Parity // <3=> Odd Parity // Flow Control // <0=> None // <3=> Hardware // Pins used // <0=> CTS = PA0, RTS = PA1, TX = PA2, RX = PA3 // <1=> CTS = PD3, RTS = PD4, TX = PD5, RX = PD6 // USART2 interrupts // USART1_CR2.IDLEIE: IDLE Interrupt enable // USART1_CR2.RXNEIE: RXNE Interrupt enable // USART1_CR2.TCIE: Transmission Complete Interrupt enable // USART1_CR2.TXEIE: TXE Interrupt enable // USART1_CR2.PEIE: PE Interrupt enable // USART1_CR2.LBDIE: LIN Break Detection Interrupt enable // USART1_CR2.EIE: Error Interrupt enable // USART1_CR2.CTSIE: CTS Interrupt enable // // //--------------------------------------------------------------------------- USART3 // USART3 : USART #3 enable // Baudrate // <9600=> 9600 Baud // <14400=> 14400 Baud // <19200=> 19200 Baud // <28800=> 28800 Baud // <38400=> 38400 Baud // <56000=> 56000 Baud // <57600=> 57600 Baud // <115200=> 115200 Baud // Data Bits // <0=> 8 Data Bits // <1=> 9 Data Bits // Stop Bits // <1=> 0.5 Stop Bit // <0=> 1 Stop Bit // <3=> 1.5 Stop Bits // <2=> 2 Stop Bits // Parity // <0=> No Parity // <2=> Even Parity // <3=> Odd Parity // Flow Control // <0=> None // <3=> Hardware // Pins used // <0=> TX = PB10, RX = PB11, CTS = PB13, RTS = PB14 // <1=> TX = PC10, RX = PC11, CTS = PB13, RTS = PB14 // <3=> TX = PD8, RX = PD9, CTS = PD11, RTS = PB12 // USART3 interrupts // USART3_CR1.IDLEIE: IDLE Interrupt enable // USART3_CR1.RXNEIE: RXNE Interrupt enable // USART3_CR1.TCIE: Transmission Complete Interrupt enable // USART3_CR1.TXEIE: TXE Interrupt enable // USART3_CR1.PEIE: PE Interrupt enable // USART3_CR2.LBDIE: LIN Break Detection Interrupt enable // USART3_CR3.EIE: Error Interrupt enable // USART3_CR3.CTSIE: CTS Interrupt enable // // // End of USART Configuration #define __USART_SETUP 0 // 0 #define __USART_USED 0x01 // 1 #define __USART_DETAILS 0x00 // 2 #define __USART_INTERRUPTS 0x07 // 3 #define __USART1_BAUDRATE 115200 // 4 #define __USART1_DATABITS 0x00000000 #define __USART1_STOPBITS 0x00000000 #define __USART1_PARITY 0x00000000 #define __USART1_FLOWCTRL 0x00000000 #define __USART1_REMAP 0x00000000 #define __USART1_CR1 0x00000020 #define __USART1_CR2 0x00000000 #define __USART1_CR3 0x00000000 #define __USART2_BAUDRATE 115200 // 13 #define __USART2_DATABITS 0x00000000 #define __USART2_STOPBITS 0x00000000 #define __USART2_PARITY 0x00000000 #define __USART2_FLOWCTRL 0x00000000 #define __USART2_REMAP 0x00000000 #define __USART2_CR1 0x00000000 #define __USART2_CR2 0x00000000 #define __USART2_CR3 0x00000000 #define __USART3_BAUDRATE 9600 // 22 #define __USART3_DATABITS 0x00000000 #define __USART3_STOPBITS 0x00000000 #define __USART3_PARITY 0x00000000 #define __USART3_FLOWCTRL 0x00000000 #define __USART3_REMAP 0x00000000 #define __USART3_CR1 0x00000000 #define __USART3_CR2 0x00000000 #define __USART3_CR3 0x00000000 //=========================================================================== Tamper Configuration // Tamper Configuration // Tamper Pin enable // Tamper pin active level // Default: active level = HIGH // <0=> active level = HIGH // <1=> active level = LOW // Tamper interrupt enable // End of Tamper Configuration #define __TAMPER_SETUP 1 // 0 #define __BKP_CR 0x00000000 // 1 #define __BKP_CSR 0x00000000 // 2 //=========================================================================== External interrupt/event Configuration // External interrupt/event Configuration //--------------------------------------------------------------------------- EXTI line 0 // EXTI0: EXTI line 0 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA0 // <0=> pin = PA0 // <1=> pin = PB0 // <2=> pin = PC0 // <3=> pin = PD0 // <4=> pin = PE0 // <5=> pin = PF0 // <6=> pin = PG0 // //--------------------------------------------------------------------------- EXTI line 1 // EXTI1: EXTI line 1 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA1 // <0=> pin = PA1 // <1=> pin = PB1 // <2=> pin = PC1 // <3=> pin = PD1 // <4=> pin = PE1 // <5=> pin = PF1 // <6=> pin = PG1 // //--------------------------------------------------------------------------- EXTI line 2 // EXTI2: EXTI line 2 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA2 // <0=> pin = PA2 // <1=> pin = PB2 // <2=> pin = PC2 // <3=> pin = PD2 // <4=> pin = PE2 // <5=> pin = PF2 // <6=> pin = PG2 // //--------------------------------------------------------------------------- EXTI line 3 // EXTI3: EXTI line 3 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA3 // <0=> pin = PA3 // <1=> pin = PB3 // <2=> pin = PC3 // <3=> pin = PD3 // <4=> pin = PE3 // <5=> pin = PF3 // <6=> pin = PG3 // //--------------------------------------------------------------------------- EXTI line 4 // EXTI4: EXTI line 4 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA4 // <0=> pin = PA4 // <1=> pin = PB4 // <2=> pin = PC4 // <3=> pin = PD4 // <4=> pin = PE4 // <5=> pin = PF4 // <6=> pin = PG4 // //--------------------------------------------------------------------------- EXTI line 5 // EXTI5: EXTI line 5 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA5 // <0=> pin = PA5 // <1=> pin = PB5 // <2=> pin = PC5 // <3=> pin = PD5 // <4=> pin = PE5 // <5=> pin = PF5 // <6=> pin = PG5 // //--------------------------------------------------------------------------- EXTI line 6 // EXTI6: EXTI line 6 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA6 // <0=> pin = PA6 // <1=> pin = PB6 // <2=> pin = PC6 // <3=> pin = PD6 // <4=> pin = PE6 // <5=> pin = PF6 // <6=> pin = PG6 // //--------------------------------------------------------------------------- EXTI line 7 // EXTI7: EXTI line 7 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA7 // <0=> pin = PA7 // <1=> pin = PB7 // <2=> pin = PC7 // <3=> pin = PD7 // <4=> pin = PE7 // <5=> pin = PF7 // <6=> pin = PG7 // //--------------------------------------------------------------------------- EXTI line 8 // EXTI8: EXTI line 8 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA8 // <0=> pin = PA8 // <1=> pin = PB8 // <2=> pin = PC8 // <3=> pin = PD8 // <4=> pin = PE8 // <5=> pin = PF8 // <6=> pin = PG8 // //--------------------------------------------------------------------------- EXTI line 9 // EXTI9: EXTI line 9 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA9 // <0=> pin = PA9 // <1=> pin = PB9 // <2=> pin = PC9 // <3=> pin = PD9 // <4=> pin = PE9 // <5=> pin = PF9 // <6=> pin = PG9 // //--------------------------------------------------------------------------- EXTI line 10 // EXTI10: EXTI line 10 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA10 // <0=> pin = PA10 // <1=> pin = PB10 // <2=> pin = PC10 // <3=> pin = PD10 // <4=> pin = PE10 // <5=> pin = PF10 // <6=> pin = PG10 // //--------------------------------------------------------------------------- EXTI line 11 // EXTI11: EXTI line 11 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA11 // <0=> pin = PA11 // <1=> pin = PB11 // <2=> pin = PC11 // <3=> pin = PD11 // <4=> pin = PE11 // <5=> pin = PF11 // <6=> pin = PG11 // //--------------------------------------------------------------------------- EXTI line 12 // EXTI12: EXTI line 12 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA12 // <0=> pin = PA12 // <1=> pin = PB12 // <2=> pin = PC12 // <3=> pin = PD12 // <4=> pin = PE12 // <5=> pin = PF12 // <6=> pin = PG12 // //--------------------------------------------------------------------------- EXTI line 13 // EXTI13: EXTI line 13 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA13 // <0=> pin = PA13 // <1=> pin = PB13 // <2=> pin = PC13 // <3=> pin = PD13 // <4=> pin = PE13 // <5=> pin = PF13 // <6=> pin = PG13 // //--------------------------------------------------------------------------- EXTI line 14 // EXTI14: EXTI line 14 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA14 // <0=> pin = PA14 // <1=> pin = PB14 // <2=> pin = PC14 // <3=> pin = PD14 // <4=> pin = PE14 // <5=> pin = PF14 // <6=> pin = PG14 // //--------------------------------------------------------------------------- EXTI line 15 // EXTI15: EXTI line 15 enable // interrupt enable // generate interrupt // generate event // use rising trigger for interrupt/event // use falling trigger for interrupt/event // use pin for for interrupt/event // Default: pin = PA15 // <0=> pin = PA15 // <1=> pin = PB15 // <2=> pin = PC15 // <3=> pin = PD15 // <4=> pin = PE15 // <5=> pin = PF15 // <6=> pin = PG15 // // End of External interrupt/event Configuration #define __EXTI_SETUP 0 // 0 #define __EXTI_USED 0x0000 // 1 #define __EXTI_INTERRUPTS 0x0000700E // 2 #define __EXTI_IMR 0x0000700E // 3 #define __EXTI_EMR 0x00000000 // 4 #define __EXTI_RTSR 0x00000008 // 5 #define __EXTI_FTSR 0x00007006 // 6 #define __AFIO_EXTICR1 0x00006660 // 7 #define __AFIO_EXTICR2 0x00000000 // 8 #define __AFIO_EXTICR3 0x00000000 // 9 #define __AFIO_EXTICR4 0x00000555 // 10 //=========================================================================== Alternate Function remap Configuration // Alternate Function remap Configuration //--------------------------------------------------------------------------- SPI1 remapping // SPI1 remapping // Default: No Remap (NSS/PA4, SCK/PA5, MISO/PA6, MOSI/PA7) // <0=> No Remap (NSS/PA4, SCK/PA5, MISO/PA6, MOSI/PA7) // <1=> Remap (NSS/PA15, SCK/PB3, MISO/PB4, MOSI/PB5) //--------------------------------------------------------------------------- I2C1 remapping // I2C1 remapping // Default: No Remap (SCL/PB6, SDA/PB7) // <0=> No Remap (SCL/PB6, SDA/PB7) // <1=> Remap (SCL/PB8, SDA/PB9) //--------------------------------------------------------------------------- USART1 remapping // USART1 remapping // Default: No Remap (TX/PA9, RX/PA10) // <0=> No Remap (TX/PA9, RX/PA10) // <1=> Remap (TX/PB6, RX/PB7) //--------------------------------------------------------------------------- USART2 remapping // USART2 remapping // Default: No Remap (CTS/PA0, RTS/PA1, TX/PA2, RX/PA3, CK/PA4) // <0=> No Remap (CTS/PA0, RTS/PA1, TX/PA2, RX/PA3, CK/PA4) // <1=> Remap (CTS/PD3, RTS/PD4, TX/PD5, RX/PD6, CK/PD7) //--------------------------------------------------------------------------- USART3 remapping // USART3 remapping // Default: No Remap (TX/PB10, RX/PB11, CK/PB12, CTS/PB13, RTS/PB14) // <0=> No Remap (TX/PB10, RX/PB11, CK/PB12, CTS/PB13, RTS/PB14) // <1=> Partial Remap (TX/PC10, RX/PC11, CK/PC12, CTS/PB13, RTS/PB14) // <3=> Full Remap (TX/PD8, RX/PD9, CK/PD10, CTS/PD11, RTS/PD12) //--------------------------------------------------------------------------- TIM1 remapping // TIM1 remapping // Default: No Remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PB12, CH1N/PB13, CH2N/PB14, CH3N/PB15) // <0=> No Remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PB12, CH1N/PB13, CH2N/PB14, CH3N/PB15) // <1=> Partial Remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PA6, CH1N/PA7, CH2N/PB0, CH3N/PB1) // <3=> Full Remap (ETR/PE7, CH1/PE9, CH2/PE11, CH3/PE13, CH4/PE14, BKIN/PE15, CH1N/PE8, CH2N/PE10, CH3N/PE12) //--------------------------------------------------------------------------- TIM2 remapping // TIM2 remapping // Default: No Remap (CH1/ETR/PA0, CH2/PA1, CH3/PA2, CH4/PA3) // <0=> No Remap (CH1/ETR/PA0, CH2/PA1, CH3/PA2, CH4/PA3) // <1=> Partial Remap (CH1/ETR/PA15, CH2/PB3, CH3/PA2, CH4/PA3) // <2=> Partial Remap (CH1/ETR/PA0, CH2/PA1, CH3/PB10, CH4/PB11) // <3=> Full Remap (CH1/ETR/PA15, CH2/PB3, CH3/PB10, CH4/PB11) //--------------------------------------------------------------------------- TIM3 remapping // TIM3 remapping // Default: No Remap (CH1/PA6, CH2/PA7, CH3/PB0, CH4/PB1) // <0=> No Remap (CH1/PA6, CH2/PA7, CH3/PB0, CH4/PB1) // <2=> Partial Remap (CH1/PB4, CH2/PB5, CH3/PB0, CH4/PB1) // <3=> Full Remap (CH1/PC6, CH2/PC7, CH3/PC8, CH4/PC9) //--------------------------------------------------------------------------- TIM4 remapping // TIM4 remapping // Default: No Remap (CH1/PB6, CH2/PB7, CH3/PB8, CH4/PB9) // <0=> No Remap (CH1/PB6, CH2/PB7, CH3/PB8, CH4/PB9) // <1=> Remap (CH1/PD12, CH2/PD13, CH3/PD14, CH4/PD15) //--------------------------------------------------------------------------- CAN remapping // CAN remapping // Default: No Remap (CANRX/PA11, CANTX/PA12) // <0=> No Remap (CANRX/PA11, CANTX/PA12) // <2=> Remap (CANRX/PB8, CANTX/PB9) // <3=> Remap (CANRX/PD0, CANTX/PPD1) //--------------------------------------------------------------------------- PD01 remapping // PD01 remapping // Default: No Remap // <0=> No Remap // <1=> Remap (PD0/OSCIN, PD1/OSC_OUT) //--------------------------------------------------------------------------- Disable JTAG // Disable JTAG and JDI // Default: JTAG Enabled // <0=> JTAG Enabled // <1=> JTAG Disabled // End of Alternate Function remap Configuration #define __AFREMAP_SETUP 1 // 0 #define __AFIO_MAPR 0x04000800 // 1 //=========================================================================== General purpose I/O Configuration // General purpose I/O Configuration //--------------------------------------------------------------------------- GPIO port A // GPIOA : GPIO port A used // Pin 0 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 1 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 2 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 3 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 4 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 5 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 6 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 7 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 8 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 9 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 10 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 11 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 12 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 13 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 14 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 15 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // //--------------------------------------------------------------------------- GPIO port B // GPIOB : GPIO port B used // Pin 0 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 1 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 2 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 3 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 4 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 5 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 6 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 7 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 8 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 9 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 10 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 11 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 12 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 13 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 14 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 15 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // //--------------------------------------------------------------------------- GPIO port C // GPIOC : GPIO port C used // Pin 0 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 1 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 2 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 3 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 4 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 5 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 6 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 7 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 8 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 9 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 10 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 11 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 12 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 13 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 14 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 15 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // //--------------------------------------------------------------------------- GPIO port D // GPIOD : GPIO port D used // Pin 0 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 1 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 2 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 3 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 4 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 5 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 6 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 7 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 8 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 9 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 10 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 11 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 12 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 13 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 14 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 15 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // //--------------------------------------------------------------------------- GPIO port E // GPIOE : GPIO port E used // Pin 0 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 1 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 2 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 3 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 4 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 5 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 6 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 7 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 8 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 9 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 10 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 11 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 12 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 13 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 14 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 15 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // //--------------------------------------------------------------------------- GPIO port F // GPIOF : GPIO port F used // Pin 0 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 1 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 2 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 3 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 4 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 5 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 6 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 7 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 8 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 9 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 10 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 11 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 12 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 13 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 14 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 15 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // //--------------------------------------------------------------------------- GPIO port G // GPIOG : GPIO port G used // Pin 0 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 1 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 2 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 3 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 4 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 5 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 6 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 7 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 8 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 9 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 10 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 11 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 12 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 13 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 14 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // Pin 15 used as // <0=>Analog Input // <4=>Floating Input // <8=>Input with pull-up / pull-down // <1=>General Purpose Output push-pull (max speed 10MHz) // <5=>General Purpose Output open-drain (max speed 10MHz) // <2=>General Purpose Output push-pull (max speed 2MHz) // <6=>General Purpose Output open-drain (max speed 2MHz) // <3=>General Purpose Output push-pull (max speed 50MHz) // <7=>General Purpose Output open-drain (max speed 50MHz) // <9=>Alternate Function push-pull (max speed 10MHz) // <13=>Alternate Function open-drain (max speed 10MHz) // <10=>Alternate Function push-pull (max speed 2MHz) // <14=>Alternate Function open-drain (max speed 2MHz) // <11=>Alternate Function push-pull (max speed 50MHz) // <15=>Alternate Function open-drain (max speed 50MHz) // // End of General purpose I/O Configuration #define __GPIO_SETUP 1 #define __GPIO_USED 0x0F #define __GPIOA_CRL 0x04000000 #define __GPIOA_CRH 0x81114000 #define __GPIOB_CRL 0x99190100 #define __GPIOB_CRH 0x11111111 #define __GPIOC_CRL 0x18000000 #define __GPIOC_CRH 0x00011114 #define __GPIOD_CRL 0x00000100 #define __GPIOD_CRH 0x00400000 #define __GPIOE_CRL 0x48444444 #define __GPIOE_CRH 0x33333343 #define __GPIOF_CRL 0x00000000 #define __GPIOF_CRH 0x88873330 #define __GPIOG_CRL 0x00008880 #define __GPIOG_CRH 0x00000000 //=========================================================================== Embedded Flash Configuration // Embedded Flash Configuration // Flash Access Control Configuration (FLASH_ACR) // LATENCY: Latency // Default: 2 wait states // <0=> 0 wait states // <1=> 1 wait states // <2=> 2 wait states // HLFCYA: Flash Half Cycle Access Enable // PRFTBE: Prefetch Buffer Enable // PRFTBS: Prefetch Buffer Status Enable // // #define __EFI_SETUP 0 #define __EFI_ACR_Val 0x00000012 /*---------------------------------------------------------------------------- DEFINES *----------------------------------------------------------------------------*/ #define CFGR_SWS_MASK 0x0000000C // Mask for used SYSCLK #define CFGR_SW_MASK 0x00000003 // Mask for used SYSCLK #define CFGR_PLLMULL_MASK 0x003C0000 // Mask for PLL multiplier #define CFGR_PLLXTPRE_MASK 0x00020000 // Mask for PLL HSE devider #define CFGR_PLLSRC_MASK 0x00010000 // Mask for PLL clock source #define CFGR_HPRE_MASK 0x000000F0 // Mask for AHB prescaler #define CFGR_PRE1_MASK 0x00000700 // Mask for APB1 prescaler #define CFGR_PRE2_MASK 0x00003800 // Mask for APB2 prescaler /*---------------------------------------------------------------------------- Define SYSCLK *----------------------------------------------------------------------------*/ #define __HSI 8000000UL //#define __HSE 8000000UL #define __PLLMULL (((__RCC_CFGR_VAL & CFGR_PLLMULL_MASK) >> 18) + 2) #if ((__RCC_CFGR_VAL & CFGR_SW_MASK) == 0x00) #define __SYSCLK __HSI // HSI is used as system clock #elif ((__RCC_CFGR_VAL & CFGR_SW_MASK) == 0x01) #define __SYSCLK __HSE // HSE is used as system clock #elif ((__RCC_CFGR_VAL & CFGR_SW_MASK) == 0x02) #if (__RCC_CFGR_VAL & CFGR_PLLSRC_MASK) // HSE is PLL clock source #if (__RCC_CFGR_VAL & CFGR_PLLXTPRE_MASK) // HSE/2 is used #define __SYSCLK ((__HSE >> 1) * __PLLMULL)// SYSCLK = HSE/2 * pllmull #else // HSE is used #define __SYSCLK ((__HSE >> 0) * __PLLMULL)// SYSCLK = HSE * pllmul #endif #else // HSI/2 is PLL clock source #define __SYSCLK ((__HSI >> 1) * __PLLMULL) // SYSCLK = HSI/2 * pllmul #endif #else #error "ask for help" #endif /*---------------------------------------------------------------------------- Define HCLK *----------------------------------------------------------------------------*/ #define __HCLKPRESC ((__RCC_CFGR_VAL & CFGR_HPRE_MASK) >> 4) #if (__HCLKPRESC & 0x08) #define __HCLK (__SYSCLK >> ((__HCLKPRESC & 0x07)+1)) #else #define __HCLK (__SYSCLK) #endif /*---------------------------------------------------------------------------- Define PCLK1 *----------------------------------------------------------------------------*/ #define __PCLK1PRESC ((__RCC_CFGR_VAL & CFGR_PRE1_MASK) >> 8) #if (__PCLK1PRESC & 0x04) #define __PCLK1 (__HCLK >> ((__PCLK1PRESC & 0x03)+1)) #else #define __PCLK1 (__HCLK) #endif /*---------------------------------------------------------------------------- Define PCLK2 *----------------------------------------------------------------------------*/ #define __PCLK2PRESC ((__RCC_CFGR_VAL & CFGR_PRE2_MASK) >> 11) #if (__PCLK2PRESC & 0x04) #define __PCLK2 (__HCLK >> ((__PCLK2PRESC & 0x03)+1)) #else #define __PCLK2 (__HCLK) #endif /*---------------------------------------------------------------------------- Define IWDG PR and RLR settings *----------------------------------------------------------------------------*/ #if (__IWDG_PERIOD > 16384000UL) #define __IWDG_PR (6) #define __IWDGCLOCK (32000UL/256) #elif (__IWDG_PERIOD > 8192000UL) #define __IWDG_PR (5) #define __IWDGCLOCK (32000UL/128) #elif (__IWDG_PERIOD > 4096000UL) #define __IWDG_PR (4) #define __IWDGCLOCK (32000UL/64) #elif (__IWDG_PERIOD > 2048000UL) #define __IWDG_PR (3) #define __IWDGCLOCK (32000UL/32) #elif (__IWDG_PERIOD > 1024000UL) #define __IWDG_PR (2) #define __IWDGCLOCK (32000UL/16) #elif (__IWDG_PERIOD > 512000UL) #define __IWDG_PR (1) #define __IWDGCLOCK (32000UL/8) #else #define __IWDG_PR (0) #define __IWDGCLOCK (32000UL/4) #endif #define __IWGDCLK (32000UL/(0x04<<__IWDG_PR)) #define __IWDG_RLR (__IWDG_PERIOD*__IWGDCLK/1000000UL-1) /*---------------------------------------------------------------------------- Define SYSTICKCLK *----------------------------------------------------------------------------*/ #if (__SYSTICK_CTRL_VAL & 0x04) #define __SYSTICKCLK (__HCLK) #else #define __SYSTICKCLK (__HCLK/8) #endif /*---------------------------------------------------------------------------- Define RTCCLK *----------------------------------------------------------------------------*/ #if ((__RTC_CLKSRC_VAL & 0x00000300) == 0x00000000) #define __RTCCLK (0) #elif ((__RTC_CLKSRC_VAL & 0x00000300) == 0x00000100) #define __RTCCLK (32768) #elif ((__RTC_CLKSRC_VAL & 0x00000300) == 0x00000200) #define __RTCCLK (32000) #elif ((__RTC_CLKSRC_VAL & 0x00000300) == 0x00000300) #define __RTCCLK (__HSE/128) #endif /*---------------------------------------------------------------------------- Define TIM1CLK *----------------------------------------------------------------------------*/ #if (__PCLK2PRESC & 0x04) #define __TIM1CLK (2*__PCLK2) #else #define __TIM1CLK (__PCLK2) #endif /*---------------------------------------------------------------------------- Define TIMXCLK *----------------------------------------------------------------------------*/ #if (__PCLK1PRESC & 0x04) #define __TIMXCLK (2*__PCLK1) #else #define __TIMXCLK (__PCLK1) #endif /*---------------------------------------------------------------------------- Define Real Time Clock CNT and ALR settings *----------------------------------------------------------------------------*/ #define __RTC_CNT_TICKS ((__RTC_TIME_H *3600UL)+(__RTC_TIME_M *60UL)+(__RTC_TIME_S) ) #define __RTC_ALR_TICKS ((__RTC_ALARM_H*3600UL)+(__RTC_ALARM_M*60UL)+(__RTC_ALARM_S)) #define __RTC_CNT (__RTC_CNT_TICKS*1000UL/__RTC_PERIOD) #define __RTC_ALR (__RTC_ALR_TICKS*1000UL/__RTC_PERIOD) /*---------------------------------------------------------------------------- Define Timer PSC and ARR settings *----------------------------------------------------------------------------*/ #define __VAL(__TIMCLK, __PERIOD) ((__TIMCLK/1000000UL)*__PERIOD) //#define __PSC(__TIMCLK, __PERIOD) ((__VAL(__TIMCLK, __PERIOD)-1)>>15) #define __PSC(__TIMCLK, __PERIOD) (((__VAL(__TIMCLK, __PERIOD)+49999UL)/50000UL) - 1) #define __ARR(__TIMCLK, __PERIOD) ((__VAL(__TIMCLK, __PERIOD)/(__PSC(__TIMCLK, __PERIOD)+1)) - 1) /*---------------------------------------------------------------------------- Define Baudrate setting (BRR) for USART1 *----------------------------------------------------------------------------*/ #define __DIV(__PCLK, __BAUD) ((__PCLK*25)/(4*__BAUD)) #define __DIVMANT(__PCLK, __BAUD) (__DIV(__PCLK, __BAUD)/100) #define __DIVFRAQ(__PCLK, __BAUD) (((__DIV(__PCLK, __BAUD) - (__DIVMANT(__PCLK, __BAUD) * 100)) * 16 + 50) / 100) #define __USART_BRR(__PCLK, __BAUD) ((__DIVMANT(__PCLK, __BAUD) << 4)|(__DIVFRAQ(__PCLK, __BAUD) & 0x0F)) #if __EFI_SETUP /*---------------------------------------------------------------------------- STM32 embedded Flash interface setup. initializes the ACR register *----------------------------------------------------------------------------*/ __inline static void stm32_EfiSetup (void) { FLASH->ACR = __EFI_ACR_Val; // set access control register } #endif #if __CLOCK_SETUP /*---------------------------------------------------------------------------- STM32 clock setup. initializes the RCC register *----------------------------------------------------------------------------*/ __inline static void stm32_ClockSetup (void) { /* Clock Configuration*/ // URUTAN INISIALISASI HARUS DIBUAT SEPERTI INI, APABILA TIDAK pll TIDAK BISA BEKERJA DIATAS 48MHZ RCC->CR = 0; if (__RCC_CR_VAL & RCC_CR_HSION) { // if HSI enabled RCC->CR |=RCC_CR_HSION; while ((RCC->CR & RCC_CR_HSIRDY) == 0); // Wait for HSIRDY = 1 (HSI is ready) } if (__RCC_CR_VAL & RCC_CR_HSEON) { // if HSE enabled RCC->CR |=RCC_CR_HSEON; while ((RCC->CR & RCC_CR_HSERDY) == 0); // Wait for HSERDY = 1 (HSE is ready) } RCC->CFGR = __RCC_CFGR_VAL; // set clock configuration register /* turn on the flash pre-fetch buffer and set its wait state to 2 */ FLASH_SetLatency(FLASH_Latency_2); /* Flash 2 wait state */ FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); RCC->CR = __RCC_CR_VAL; // set clock control register if (__RCC_CR_VAL & RCC_CR_PLLON) { // if PLL enabled while ((RCC->CR & RCC_CR_PLLRDY) == 0); // Wait for PLLRDY = 1 (PLL is ready) } /* Wait till SYSCLK is stabilized (depending on selected clock) */ while ((RCC->CFGR & RCC_CFGR_SWS) != ((__RCC_CFGR_VAL<<2) & RCC_CFGR_SWS)); } // end of stm32_ClockSetup #endif #if __NVIC_SETUP /*---------------------------------------------------------------------------- STM32 NVIC setup. initializes the NVIC register *----------------------------------------------------------------------------*/ __inline static void stm32_NvicSetup (void) { if (__NVIC_USED & (1 << 0)) { // Vector Table Offset Register SCB->VTOR = (__NVIC_VTOR_VAL & (u32)0x3FFFFF80); // set register } } // end of stm32_NvicSetup #endif #if __IWDG_SETUP /*---------------------------------------------------------------------------- STM32 Independent watchdog setup. initializes the IWDG register *----------------------------------------------------------------------------*/ __inline static void stm32_IwdgSetup (void) { // RCC->CSR |= (1<<0); // LSI enable, necessary for IWDG // while ((RCC->CSR & (1<<1)) == 0); // wait till LSI is ready IWDG->KR = 0x5555; // enable write to PR, RLR IWDG->PR = __IWDG_PR; // Init prescaler IWDG->RLR = __IWDG_RLR; // Init RLR IWDG->KR = 0xAAAA; // Reload the watchdog IWDG->KR = 0xCCCC; // Start the watchdog } // end of stm32_IwdgSetup #endif #if __SYSTICK_SETUP /*---------------------------------------------------------------------------- STM32 System Timer setup. initializes the SysTick register *----------------------------------------------------------------------------*/ __inline static void stm32_SysTickSetup (void) { #if ((__SYSTICK_PERIOD*(__SYSTICKCLK/1000)-1) > 0xFFFFFF) // reload value to large #error "Reload Value to large! Please use 'HCLK/8' as System Timer clock source or smaller period" #else SysTick->LOAD = __SYSTICK_PERIOD*(__SYSTICKCLK/1000)-1; // set reload register SysTick->CTRL = __SYSTICK_CTRL_VAL; // set clock source and Interrupt enable SysTick->VAL = 0; // clear the counter SysTick->CTRL |= SYSTICK_CSR_ENABLE; // enable the counter #endif } // end of stm32_SysTickSetup #endif #if __RTC_SETUP /*---------------------------------------------------------------------------- STM32 Real Time Clock setup. initializes the RTC Prescaler and RTC counter register *----------------------------------------------------------------------------*/ __inline static void stm32_RtcSetup (void) { RCC->APB1ENR |= RCC_APB1ENR_PWREN; // enable clock for Power interface PWR->CR |= PWR_CR_DBP; // enable access to RTC, BDC registers if ((__RTC_CLKSRC_VAL & RCC_BDCR_RTCSEL) == 0x00000100) { // LSE is RTC clock source RCC->BDCR |= RCC_BDCR_LSEON; // enable LSE while ((RCC->BDCR & RCC_BDCR_LSERDY) == 0); // Wait for LSERDY = 1 (LSE is ready) } if ((__RTC_CLKSRC_VAL & RCC_BDCR_RTCSEL) == 0x00000200) { // LSI is RTC clock source RCC->CSR |= RCC_CSR_LSION; // enable LSI while ((RCC->CSR & RCC_CSR_LSIRDY) == 0); // Wait for LSERDY = 1 (LSE is ready) } RCC->BDCR |= (__RTC_CLKSRC_VAL | RCC_BDCR_RTCEN); // set RTC clock source, enable RTC clock // RTC->CRL &= ~(1<<3); // reset Registers Synchronized Flag // while ((RTC->CRL & (1<<3)) == 0); // wait until registers are synchronized RTC->CRL |= RTC_CRL_CNF; // set configuration mode RTC->PRLH = ((__RTC_PERIOD*__RTCCLK/1000-1)>>16) & 0x00FF; // set prescaler load register high RTC->PRLL = ((__RTC_PERIOD*__RTCCLK/1000-1) ) & 0xFFFF; // set prescaler load register low RTC->CNTH = ((__RTC_CNT)>>16) & 0xFFFF; // set counter high RTC->CNTL = ((__RTC_CNT) ) & 0xFFFF; // set counter low RTC->ALRH = ((__RTC_ALR)>>16) & 0xFFFF; // set alarm high RTC->ALRL = ((__RTC_ALR) ) & 0xFFFF; // set alarm low if (__RTC_INTERRUPTS) { // RTC interrupts used RTC->CRH = __RTC_CRH; // enable RTC interrupts NVIC->ISER[0] |= (1 << (RTC_IRQChannel & 0x1F)); // enable interrupt } RTC->CRL &= ~RTC_CRL_CNF; // reset configuration mode while ((RTC->CRL & RTC_CRL_RTOFF) == 0); // wait until write is finished PWR->CR &= ~PWR_CR_DBP; // disable access to RTC registers } // end of stm32_RtcSetup #endif #if __TIMER_SETUP /*---------------------------------------------------------------------------- STM32 Timer setup. initializes the Timer register *----------------------------------------------------------------------------*/ __inline static void stm32_TimerSetup (void) { if (__TIMER_USED & 0x01) { // TIM1 used RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; // enable clock for TIM1 TIM1->PSC = __PSC(__TIM1CLK, __TIM1_PERIOD); // set prescaler TIM1->ARR = __ARR(__TIM1CLK, __TIM1_PERIOD); // set auto-reload TIM1->RCR = __TIM1_RCR; // set repetition counter TIM1->CR1 = 0; // reset command register 1 TIM1->CR2 = 0; // reset command register 2 if (__TIMER_DETAILS & 0x01) { // detailed settings used TIM1->PSC = __TIM1_PSC; // set prescaler TIM1->ARR = __TIM1_ARR; // set auto-reload TIM1->CCR1 = __TIM1_CCR1; // TIM1->CCR2 = __TIM1_CCR2; // TIM1->CCR3 = __TIM1_CCR3; // TIM1->CCR4 = __TIM1_CCR4; // TIM1->CCMR1 = __TIM1_CCMR1; // TIM1->CCMR2 = __TIM1_CCMR2; // TIM1->CCER = __TIM1_CCER; // set capture/compare enable register TIM1->SMCR = __TIM1_SMCR; // set slave mode control register TIM1->BDTR = __TIM1_BDTR; // set break and dead-time register TIM1->CR1 = __TIM1_CR1; // set command register 1 TIM1->CR2 = __TIM1_CR2; // set command register 2 } if (__TIMER_INTERRUPTS & 0x01) { // interrupts used TIM1->DIER = __TIM1_DIER; // enable interrupt NVIC->ISER[0] |= (1 << (TIM1_UP_IRQChannel & 0x1F)); // enable interrupt } TIM1->CR1 |= TIMX_CR1_CEN; // enable timer } // end TIM1 used if (__TIMER_USED & 0x02) { // TIM2 used RCC->APB1ENR |= RCC_APB1ENR_TIM2EN; // enable clock for TIM2 TIM2->PSC = __PSC(__TIMXCLK, __TIM2_PERIOD); // set prescaler TIM2->ARR = __ARR(__TIMXCLK, __TIM2_PERIOD); // set auto-reload TIM2->CR1 = 0; // reset command register 1 TIM2->CR2 = 0; // reset command register 2 if (__TIMER_DETAILS & 0x02) { // detailed settings used TIM2->PSC = __TIM2_PSC; // set prescaler TIM2->ARR = __TIM2_ARR; // set auto-reload TIM2->CCR1 = __TIM2_CCR1; // TIM2->CCR2 = __TIM2_CCR2; // TIM2->CCR3 = __TIM2_CCR3; // TIM2->CCR4 = __TIM2_CCR4; // TIM2->CCMR1 = __TIM2_CCMR1; // TIM2->CCMR2 = __TIM2_CCMR2; // TIM2->CCER = __TIM2_CCER; // set capture/compare enable register TIM2->SMCR = __TIM2_SMCR; // set slave mode control register TIM2->CR1 = __TIM2_CR1; // set command register 1 TIM2->CR2 = __TIM2_CR2; // set command register 2 } if (__TIMER_INTERRUPTS & 0x02) { // interrupts used TIM2->DIER = __TIM2_DIER; // enable interrupt NVIC->ISER[0] |= (1 << (TIM2_IRQChannel & 0x1F)); // enable interrupt } TIM2->CR1 |= TIMX_CR1_CEN; // enable timer } // end TIM2 used if (__TIMER_USED & 0x04) { // TIM3 used RCC->APB1ENR |= RCC_APB1ENR_TIM3EN; // enable clock for TIM3 TIM3->PSC = __PSC(__TIMXCLK, __TIM3_PERIOD); // set prescaler TIM3->ARR = __ARR(__TIMXCLK, __TIM3_PERIOD); // set auto-reload TIM3->CR1 = 0; // reset command register 1 TIM3->CR2 = 0; // reset command register 2 if (__TIMER_DETAILS & 0x04) { // detailed settings used TIM3->PSC = __TIM3_PSC; // set prescaler TIM3->ARR = __TIM3_ARR; // set auto-reload TIM3->CCR1 = __TIM3_CCR1; // TIM3->CCR2 = __TIM3_CCR2; // TIM3->CCR3 = __TIM3_CCR3; // TIM3->CCR4 = __TIM3_CCR4; // TIM3->CCMR1 = __TIM3_CCMR1; // TIM3->CCMR2 = __TIM3_CCMR2; // TIM3->CCER = __TIM3_CCER; // set capture/compare enable register TIM3->SMCR = __TIM3_SMCR; // set slave mode control register TIM3->CR1 = __TIM3_CR1; // set command register 1 TIM3->CR2 = __TIM3_CR2; // set command register 2 } if (__TIMER_INTERRUPTS & 0x04) { // interrupts used TIM3->DIER = __TIM3_DIER; // enable interrupt NVIC->ISER[0] |= (1 << (TIM3_IRQChannel & 0x1F)); // enable interrupt } TIM3->CR1 |= TIMX_CR1_CEN; // enable timer } // end TIM3 used if (__TIMER_USED & 0x08) { // TIM4 used RCC->APB1ENR |= RCC_APB1ENR_TIM4EN; // enable clock for TIM4 TIM4->PSC = __PSC(__TIMXCLK, __TIM4_PERIOD); // set prescaler TIM4->ARR = __ARR(__TIMXCLK, __TIM4_PERIOD); // set auto-reload TIM4->CR1 = 0; // reset command register 1 TIM4->CR2 = 0; // reset command register 2 if (__TIMER_DETAILS & 0x08) { // detailed settings used TIM4->PSC = __TIM4_PSC; // set prescaler TIM4->ARR = __TIM4_ARR; // set auto-reload TIM4->CCR1 = __TIM4_CCR1; // TIM4->CCR2 = __TIM4_CCR2; // TIM4->CCR3 = __TIM4_CCR3; // TIM4->CCR4 = __TIM4_CCR4; // TIM4->CCMR1 = __TIM4_CCMR1; // TIM4->CCMR2 = __TIM4_CCMR2; // TIM4->CCER = __TIM4_CCER; // set capture/compare enable register TIM4->SMCR = __TIM4_SMCR; // set slave mode control register TIM4->CR1 = __TIM4_CR1; // set command register 1 TIM4->CR2 = __TIM4_CR2; // set command register 2 } if (__TIMER_INTERRUPTS & 0x08) { // interrupts used TIM4->DIER = __TIM4_DIER; // enable interrupt NVIC->ISER[0] |= (1 << (TIM4_IRQChannel & 0x1F)); // enable interrupt } TIM4->CR1 |= TIMX_CR1_CEN; // enable timer } // end TIM4 used if (__TIMER_USED & 0x10) { // TIM5 used RCC->APB1ENR |= 8; //RCC_APB1ENR_TIM5EN; // enable clock for TIM5 TIM5->PSC = __PSC(__TIMXCLK, __TIM5_PERIOD); // set prescaler TIM5->ARR = __ARR(__TIMXCLK, __TIM5_PERIOD); // set auto-reload TIM5->CR1 = 0; // reset command register 1 TIM5->CR2 = 0; // reset command register 2 if (__TIMER_DETAILS & 0x10) { // detailed settings used TIM5->PSC = __TIM5_PSC; // set prescaler TIM5->ARR = __TIM5_ARR; // set auto-reload TIM5->CCR1 = __TIM5_CCR1; // TIM5->CCR2 = __TIM5_CCR2; // TIM5->CCR3 = __TIM5_CCR3; // TIM5->CCR4 = __TIM5_CCR4; // TIM5->CCMR1 = __TIM5_CCMR1; // TIM5->CCMR2 = __TIM5_CCMR2; // TIM5->CCER = __TIM5_CCER; // set capture/compare enable register TIM5->SMCR = __TIM5_SMCR; // set slave mode control register TIM5->CR1 = __TIM5_CR1; // set command register 1 TIM5->CR2 = __TIM5_CR2; // set command register 2 } if (__TIMER_INTERRUPTS & 0x10) { // interrupts used TIM5->DIER = __TIM5_DIER; // enable interrupt NVIC->ISER[0] |= (1 << (TIM5_IRQChannel & 0x1F)); // enable interrupt } TIM5->CR1 |= TIMX_CR1_CEN; // enable timer } // end TIM5 used } // end of stm32_TimSetup #endif #if __GPIO_SETUP /*---------------------------------------------------------------------------- STM32 GPIO setup. initializes the GPIOx_CRL and GPIOxCRH register *----------------------------------------------------------------------------*/ __inline static void stm32_GpioSetup (void) { if (__GPIO_USED & 0x01) { // GPIO Port A used RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; // enable clock for GPIOA GPIOA->CRL = __GPIOA_CRL; // set Port configuration register low GPIOA->CRH = __GPIOA_CRH; // set Port configuration register high } if (__GPIO_USED & 0x02) { // GPIO Port B used RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; // enable clock for GPIOB GPIOB->CRL = __GPIOB_CRL; // set Port configuration register low GPIOB->CRH = __GPIOB_CRH; // set Port configuration register high } if (__GPIO_USED & 0x04) { // GPIO Port C used RCC->APB2ENR |= RCC_APB2ENR_IOPCEN; // enable clock for GPIOC GPIOC->CRL = __GPIOC_CRL; // set Port configuration register low GPIOC->CRH = __GPIOC_CRH; // set Port configuration register high } if (__GPIO_USED & 0x08) { // GPIO Port D used RCC->APB2ENR |= RCC_APB2ENR_IOPDEN; // enable clock for GPIOD GPIOD->CRL = __GPIOD_CRL; // set Port configuration register low GPIOD->CRH = __GPIOD_CRH; // set Port configuration register high } if (__GPIO_USED & 0x10) { // GPIO Port E used RCC->APB2ENR |= RCC_APB2ENR_IOPEEN; // enable clock for GPIOE GPIOE->CRL = __GPIOE_CRL; // set Port configuration register low GPIOE->CRH = __GPIOE_CRH; // set Port configuration register high } if (__GPIO_USED & 0x20) { // GPIO Port F used RCC->APB2ENR |= RCC_APB2ENR_IOPFEN; // enable clock for GPIOF GPIOF->CRL = __GPIOF_CRL; // set Port configuration register low GPIOF->CRH = __GPIOF_CRH; // set Port configuration register high } if (__GPIO_USED & 0x40) { // GPIO Port G used RCC->APB2ENR |= RCC_APB2ENR_IOPGEN; // enable clock for GPIOG GPIOG->CRL = __GPIOG_CRL; // set Port configuration register low GPIOG->CRH = __GPIOG_CRH; // set Port configuration register high } } // end of stm32_GpioSetup #endif #if __USART_SETUP /*---------------------------------------------------------------------------- STM32 USART setup. initializes the USARTx register *----------------------------------------------------------------------------*/ __inline static void stm32_UsartSetup (void) { if (__USART_USED & 0x01) { // USART1 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(1 << 2); // clear USART1 remap if ((__USART1_REMAP & 0x04) == 0x00) { // USART1 no remap RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; // enable clock for GPIOA GPIOA->CRH &= ~(0xFFUL << 4); // Clear PA9, PA10 GPIOA->CRH |= (0x0BUL << 4); // USART1 Tx (PA9) alternate output push-pull GPIOA->CRH |= (0x04UL << 8); // USART1 Rx (PA10) input floating } else { // USART1 remap RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR |= __USART1_REMAP; // set USART1 remap RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; // enable clock for GPIOB GPIOB->CRL &= ~(0xFFUL << 24); // Clear PB6, PB7 GPIOB->CRL |= (0x0BUL << 24); // USART1 Tx (PB6) alternate output push-pull GPIOB->CRL |= (0x04UL << 28); // USART1 Rx (PB7) input floating } RCC->APB2ENR |= RCC_APB2ENR_USART1EN; // enable clock for USART1 USART1->BRR = __USART_BRR(__PCLK2, __USART1_BAUDRATE); // set baudrate USART1->CR1 = __USART1_DATABITS; // set Data bits USART1->CR2 = __USART1_STOPBITS; // set Stop bits USART1->CR1 |= __USART1_PARITY; // set Parity USART1->CR3 = __USART1_FLOWCTRL; // Set Flow Control USART1->CR1 |= (USART_CR1_RE | USART_CR1_TE); // RX, TX enable if (__USART_INTERRUPTS & 0x01) { // interrupts used USART1->CR1 |= __USART1_CR1; USART1->CR2 |= __USART1_CR2; USART1->CR3 |= __USART1_CR3; NVIC->ISER[1] |= (1 << (USART1_IRQChannel & 0x1F)); // enable interrupt } USART1->CR1 |= USART_CR1_UE; // USART enable } // end USART1 used if (__USART_USED & 0x02) { // USART2 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(1 << 3); // clear USART2 remap if ((__USART2_REMAP & 0x08) == 0x00) { // USART2 no remap RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; // enable clock for GPIOA GPIOA->CRL &= ~(0xFFUL << 8); // Clear PA2, PA3 GPIOA->CRL |= (0x0BUL << 8); // USART2 Tx (PA2) alternate output push-pull GPIOA->CRL |= (0x04UL << 12); // USART2 Rx (PA3) input floating if (__USART2_FLOWCTRL & 0x0300) { // HW flow control enabled GPIOA->CRL &= ~(0xFFUL << 0); // Clear PA0, PA1 GPIOA->CRL |= (0x04UL << 0); // USART2 CTS (PA0) input floating GPIOA->CRL |= (0x0BUL << 4); // USART2 RTS (PA1) alternate output push-pull } } else { // USART2 remap RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR |= __USART2_REMAP; // set USART2 remap RCC->APB2ENR |= RCC_APB2ENR_IOPDEN; // enable clock for GPIOD GPIOD->CRL &= ~(0xFFUL << 20); // Clear PD5, PD6 GPIOD->CRL |= (0x0BUL << 20); // USART2 Tx (PD5) alternate output push-pull GPIOD->CRL |= (0x04UL << 24); // USART2 Rx (PD6) input floating if (__USART2_FLOWCTRL & 0x0300) { // HW flow control enabled GPIOD->CRL &= ~(0xFFUL << 12); // Clear PD3, PD4 GPIOD->CRL |= (0x04UL << 12); // USART2 CTS (PD3) input floating GPIOD->CRL |= (0x0BUL << 16); // USART2 RTS (PD4) alternate output push-pull } } RCC->APB1ENR |= RCC_APB1ENR_USART2EN; // enable clock for USART2 USART2->BRR = __USART_BRR(__PCLK1, __USART2_BAUDRATE); // set baudrate USART2->CR1 = __USART2_DATABITS; // set Data bits USART2->CR2 = __USART2_STOPBITS; // set Stop bits USART2->CR1 |= __USART2_PARITY; // set Parity USART2->CR3 = __USART2_FLOWCTRL; // Set Flow Control USART2->CR1 |= (USART_CR1_RE | USART_CR1_TE); // RX, TX enable if (__USART_INTERRUPTS & 0x02) { // interrupts used USART2->CR1 |= __USART2_CR1; USART2->CR2 |= __USART2_CR2; USART2->CR3 |= __USART2_CR3; NVIC->ISER[1] |= (1 << (USART2_IRQChannel & 0x1F)); // enable interrupt } USART2->CR1 |= USART_CR1_UE; // USART enable } // end USART2 used if (__USART_USED & 0x04) { // USART3 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(3 << 4); // clear USART3 remap if ((__USART3_REMAP & 0x30) == 0x00) { // USART3 no remap RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; // enable clock for GPIOB GPIOB->CRH &= ~(0xFFUL << 8); // Clear PB10, PB11 GPIOB->CRH |= (0x0BUL << 8); // USART3 Tx (PB10) alternate output push-pull GPIOB->CRH |= (0x04UL << 12); // USART3 Rx (PB11) input floating if (__USART3_FLOWCTRL & 0x0300) { // HW flow control enabled GPIOB->CRH &= ~(0xFFUL << 20); // Clear PB13, PB14 GPIOB->CRH |= (0x04UL << 20); // USART3 CTS (PB13) input floating GPIOB->CRH |= (0x0BUL << 24); // USART3 RTS (PB14) alternate output push-pull } } else if ((__USART3_REMAP & 0x30) == 0x10) { // USART3 partial remap RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR |= __USART3_REMAP; // set USART3 remap RCC->APB2ENR |= RCC_APB2ENR_IOPCEN; // enable clock for GPIOC GPIOC->CRH &= ~(0xFFUL << 8); // Clear PC10, PC11 GPIOC->CRH |= (0x0BUL << 8); // USART3 Tx (PC10) alternate output push-pull GPIOC->CRH |= (0x04UL << 12); // USART3 Rx (PC11) input floating if (__USART3_FLOWCTRL & 0x0300) { // HW flow control enabled RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; // enable clock for GPIOB GPIOB->CRH &= ~(0xFFUL << 20); // Clear PB13, PB14 GPIOB->CRH |= (0x04UL << 20); // USART3 CTS (PB13) input floating GPIOB->CRH |= (0x0BUL << 24); // USART3 RTS (PB14) alternate output push-pull } } else { // USART3 full remap RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR |= __USART3_REMAP; // set USART3 remap RCC->APB2ENR |= RCC_APB2ENR_IOPDEN; // enable clock for GPIOD GPIOD->CRH &= ~(0xFFUL << 0); // Clear PD8, PD9 GPIOD->CRH |= (0x0BUL << 0); // USART3 Tx (PD8) alternate output push-pull GPIOD->CRH |= (0x04UL << 4); // USART3 Rx (PD9) input floating if (__USART3_FLOWCTRL & 0x0300) { // HW flow control enabled GPIOD->CRH &= ~(0xFFUL << 12); // Clear PD11, PD12 GPIOD->CRH |= (0x04UL << 12); // USART3 CTS (PD11) input floating GPIOD->CRH |= (0x0BUL << 16); // USART3 RTS (PD12) alternate output push-pull } } RCC->APB1ENR |= RCC_APB1ENR_USART3EN; // enable clock for USART3 USART3->BRR = __USART_BRR(__PCLK1, __USART3_BAUDRATE); // set baudrate USART3->CR1 = __USART3_DATABITS; // set Data bits USART3->CR2 = __USART3_STOPBITS; // set Stop bits USART3->CR1 |= __USART3_PARITY; // set Parity USART3->CR3 = __USART3_FLOWCTRL; // Set Flow Control USART3->CR1 |= (USART_CR1_RE | USART_CR1_TE); // RX, TX enable if (__USART_INTERRUPTS & 0x04) { // interrupts used USART3->CR1 |= __USART3_CR1; USART3->CR2 |= __USART3_CR2; USART3->CR3 |= __USART3_CR3; NVIC->ISER[1] |= (1 << (USART3_IRQChannel & 0x1F)); // enable interrupt } USART3->CR1 |= USART_CR1_UE; // USART enable } // end USART3 used } // end of stm32_UsartSetup #endif #if __EXTI_SETUP /*---------------------------------------------------------------------------- STM32 EXTI setup. initializes the EXTI register *----------------------------------------------------------------------------*/ __inline static void stm32_ExtiSetup (void) { if (__EXTI_USED & (1 << 0)) { // EXTI0 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[0] &= 0xFFF0; // clear used pin AFIO->EXTICR[0] |= (0x000F & __AFIO_EXTICR1); // set pin to use EXTI->IMR |= ((1 << 0) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 0) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 0) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 0) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 0)) { // interrupt used NVIC->ISER[0] |= (1 << (EXTI0_IRQChannel & 0x1F)); // enable interrupt EXTI 0 } } // end EXTI0 used if (__EXTI_USED & (1 << 1)) { // EXTI1 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[0] &= 0xFF0F; // clear used pin AFIO->EXTICR[0] |= (0x00F0 & __AFIO_EXTICR1); // set pin to use EXTI->IMR |= ((1 << 1) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 1) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 1) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 1) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 1)) { // interrupt used NVIC->ISER[0] |= (1 << (EXTI1_IRQChannel & 0x1F)); // enable interrupt EXTI 1 } } // end EXTI1 used if (__EXTI_USED & (1 << 2)) { // EXTI2 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[0] &= 0xF0FF; // clear used pin AFIO->EXTICR[0] |= (0x0F00 & __AFIO_EXTICR1); // set pin to use EXTI->IMR |= ((1 << 2) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 2) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 2) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 2) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 2)) { // interrupt used NVIC->ISER[0] |= (1 << (EXTI2_IRQChannel & 0x1F)); // enable interrupt EXTI 2 } } // end EXTI2 used if (__EXTI_USED & (1 << 3)) { // EXTI3 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[0] &= 0x0FFF; // clear used pin AFIO->EXTICR[0] |= (0xFF00 & __AFIO_EXTICR1); // set pin to use EXTI->IMR |= ((1 << 3) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 3) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 3) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 3) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 3)) { // interrupt used NVIC->ISER[0] |= (1 << (EXTI3_IRQChannel & 0x1F)); // enable interrupt EXTI 3 } } // end EXTI3 used if (__EXTI_USED & (1 << 4)) { // EXTI4 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[1] &= 0xFFF0; // clear used pin AFIO->EXTICR[1] |= (0x000F & __AFIO_EXTICR2); // set pin to use EXTI->IMR |= ((1 << 4) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 4) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 4) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 4) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 4)) { // interrupt used NVIC->ISER[0] |= (1 << (EXTI4_IRQChannel & 0x1F)); // enable interrupt EXTI 4 } } // end EXTI4 used if (__EXTI_USED & (1 << 5)) { // EXTI5 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[1] &= 0xFF0F; // clear used pin AFIO->EXTICR[1] |= (0x00F0 & __AFIO_EXTICR2); // set pin to use EXTI->IMR |= ((1 << 5) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 5) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 5) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 5) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 5)) { // interrupt used NVIC->ISER[0] |= (1 << (EXTI9_5_IRQChannel & 0x1F)); // enable interrupt EXTI 9..5 } } // end EXTI5 used if (__EXTI_USED & (1 << 6)) { // EXTI6 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[1] &= 0xF0FF; // clear used pin AFIO->EXTICR[1] |= (0x0F00 & __AFIO_EXTICR2); // set pin to use EXTI->IMR |= ((1 << 6) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 6) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 6) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 6) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 6)) { // interrupt used NVIC->ISER[0] |= (1 << (EXTI9_5_IRQChannel & 0x1F)); // enable interrupt EXTI 9..5 } } // end EXTI6 used if (__EXTI_USED & (1 << 7)) { // EXTI7 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[1] &= 0x0FFF; // clear used pin AFIO->EXTICR[1] |= (0xF000 & __AFIO_EXTICR2); // set pin to use EXTI->IMR |= ((1 << 7) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 7) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 7) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 7) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 7)) { // interrupt used NVIC->ISER[0] |= (1 << (EXTI9_5_IRQChannel & 0x1F)); // enable interrupt EXTI 9..5 } } // end EXTI7 used if (__EXTI_USED & (1 << 8)) { // EXTI8 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[2] &= 0xFFF0; // clear used pin AFIO->EXTICR[2] |= (0x000F & __AFIO_EXTICR3); // set pin to use EXTI->IMR |= ((1 << 8) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 8) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 8) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 8) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 8)) { // interrupt used NVIC->ISER[0] |= (1 << (EXTI9_5_IRQChannel & 0x1F)); // enable interrupt EXTI 9..5 } } // end EXTI8 used if (__EXTI_USED & (1 << 9)) { // EXTI9 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[2] &= 0xFF0F; // clear used pin AFIO->EXTICR[2] |= (0x00F0 & __AFIO_EXTICR3); // set pin to use EXTI->IMR |= ((1 << 9) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 9) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 9) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 9) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 9)) { // interrupt used NVIC->ISER[0] |= (1 << (EXTI9_5_IRQChannel & 0x1F)); // enable interrupt EXTI 9..5 } } // end EXTI9 used if (__EXTI_USED & (1 << 10)) { // EXTI10 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[2] &= 0xF0FF; // clear used pin AFIO->EXTICR[2] |= (0x0F00 & __AFIO_EXTICR3); // set pin to use EXTI->IMR |= ((1 << 10) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 10) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 10) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 10) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 10)) { // interrupt used NVIC->ISER[1] |= (1 << (EXTI15_10_IRQChannel & 0x1F));// enable interrupt EXTI 10..15 } } // end EXTI10 used if (__EXTI_USED & (1 << 11)) { // EXTI11 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[2] &= 0x0FFF; // clear used pin AFIO->EXTICR[2] |= (0xF000 & __AFIO_EXTICR3); // set pin to use EXTI->IMR |= ((1 << 11) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 11) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 11) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 11) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 11)) { // interrupt used NVIC->ISER[1] |= (1 << (EXTI15_10_IRQChannel & 0x1F));// enable interrupt EXTI 10..15 } } // end EXTI11 used if (__EXTI_USED & (1 << 12)) { // EXTI12 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[3] &= 0xFFF0; // clear used pin AFIO->EXTICR[3] |= (0x000F & __AFIO_EXTICR4); // set pin to use EXTI->IMR |= ((1 << 12) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 12) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 12) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 12) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 12)) { // interrupt used NVIC->ISER[1] |= (1 << (EXTI15_10_IRQChannel & 0x1F));// enable interrupt EXTI 10..15 } } // end EXTI12 used if (__EXTI_USED & (1 << 13)) { // EXTI13 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[3] &= 0xFF0F; // clear used pin AFIO->EXTICR[3] |= (0x00F0 & __AFIO_EXTICR4); // set pin to use EXTI->IMR |= ((1 << 13) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 13) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 13) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 13) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 13)) { // interrupt used NVIC->ISER[1] |= (1 << (EXTI15_10_IRQChannel & 0x1F));// enable interrupt EXTI 10..15 } } // end EXTI13 used if (__EXTI_USED & (1 << 14)) { // EXTI14 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[3] &= 0xF0FF; // clear used pin AFIO->EXTICR[3] |= (0x0F00 & __AFIO_EXTICR4); // set pin to use EXTI->IMR |= ((1 << 14) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 14) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 14) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 14) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 14)) { // interrupt used NVIC->ISER[1] |= (1 << (EXTI15_10_IRQChannel & 0x1F));// enable interrupt EXTI 10..15 } } // end EXTI14 used if (__EXTI_USED & (1 << 15)) { // EXTI15 used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->EXTICR[3] &= 0x0FFF; // clear used pin AFIO->EXTICR[3] |= (0xF000 & __AFIO_EXTICR4); // set pin to use EXTI->IMR |= ((1 << 15) & __EXTI_IMR); // unmask interrupt EXTI->EMR |= ((1 << 15) & __EXTI_EMR); // unmask event EXTI->RTSR |= ((1 << 15) & __EXTI_RTSR); // set rising edge EXTI->FTSR |= ((1 << 15) & __EXTI_FTSR); // set falling edge if (__EXTI_INTERRUPTS & (1 << 15)) { // interrupt used NVIC->ISER[1] |= (1 << (EXTI15_10_IRQChannel & 0x1F));// enable interrupt EXTI 10..15 } } // end EXTI15 used } // end of stm32_ExtiSetup #endif #if __AFREMAP_SETUP /*---------------------------------------------------------------------------- STM32 AF remap setup. initializes the AFIO_MAPR register *----------------------------------------------------------------------------*/ __inline static void stm32_AfRemapSetup (void) { if (__AFIO_MAPR & (1 << 0)) { // SPI1 remap used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(1 << 0); // clear used bit AFIO->MAPR |= ((1 << 0) & __AFIO_MAPR); // set used bits } // end SPI1 remap used if (__AFIO_MAPR & (1 << 1)) { // I2C1 remap used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(1 << 1); // clear used bit AFIO->MAPR |= ((1 << 1) & __AFIO_MAPR); // set used bits } // end I2C1 remap used if (__AFIO_MAPR & (1 << 2)) { // USART1 remap used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(1 << 2); // clear used bit AFIO->MAPR |= ((1 << 2) & __AFIO_MAPR); // set used bits } // end USART1 remap used if (__AFIO_MAPR & (1 << 3)) { // USART2 remap used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(1 << 3); // clear used bit AFIO->MAPR |= ((1 << 3) & __AFIO_MAPR); // set used bits } // end USART2 remap used if (__AFIO_MAPR & (3 << 4)) { // USART3 remap used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(3 << 4); // clear used bit AFIO->MAPR |= ((3 << 4) & __AFIO_MAPR); // set used bits } // end USART3 remap used if (__AFIO_MAPR & (3 << 6)) { // TIM1 remap used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(3 << 6); // clear used bit AFIO->MAPR |= ((3 << 6) & __AFIO_MAPR); // set used bits } // end TIM1 remap used if (__AFIO_MAPR & (3 << 8)) { // TIM2 remap used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(3 << 8); // clear used bit AFIO->MAPR |= ((3 << 8) & __AFIO_MAPR); // set used bits } // end TIM2 remap used if (__AFIO_MAPR & (3 << 10)) { // TIM3 remap used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(3 << 10); // clear used bit AFIO->MAPR |= ((3 << 10) & __AFIO_MAPR); // set used bits } // end TIM3 remap used if (__AFIO_MAPR & (1 << 12)) { // TIM4 remap used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(1 << 12); // clear used bit AFIO->MAPR |= ((1 << 12) & __AFIO_MAPR); // set used bits } // end TIM2 remap used if (__AFIO_MAPR & (3 << 13)) { // CAN remap used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(3 << 13); // clear used bit AFIO->MAPR |= ((3 << 13) & __AFIO_MAPR); // set used bits } // end TIM2 remap used if (__AFIO_MAPR & (1 << 15)) { // PD01 remap used RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(1 << 15); // clear used bit AFIO->MAPR |= ((1 << 15) & __AFIO_MAPR); // set used bits } // end TIM2 remap used if (__AFIO_MAPR & (1 << 26)) { // Disable JTAG function RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable clock for Alternate Function AFIO->MAPR &= ~(1 << 26); // clear used bit AFIO->MAPR |= ((1 << 26) & __AFIO_MAPR); // set used bits } // end disable JTAG pins } // end of stm32_AfRemapSetup #endif #if __TAMPER_SETUP /*---------------------------------------------------------------------------- STM32 Tamper setup. initializes the Tamper register *----------------------------------------------------------------------------*/ __inline static void stm32_TamperSetup (void) { RCC->APB1ENR |= RCC_APB1ENR_BKPEN; // enable clock for Backup interface RCC->APB1ENR |= RCC_APB1ENR_PWREN; // enable clock for Power interface PWR->CR |= PWR_CR_DBP; // enable access to RTC, BDC registers BKP->CR = __BKP_CR; // set BKP_CR register BKP->CSR = __BKP_CSR; // set BKP_CSR register BKP->CSR |= 0x0003; // clear CTI, CTE PWR->CR &= ~PWR_CR_DBP; // disable access to RTC, BDC registers if (BKP->CSR & (1<<2)) { // Tamper interrupt enable ? NVIC->ISER[0] |= (1 << (TAMPER_IRQChannel & 0x1F)); // enable interrupt } } // end of stm32_TamperSetup #endif /*---------------------------------------------------------------------------- STM32 initialization Call this function as first in main () *----------------------------------------------------------------------------*/ void stm32_Init () { #if __EFI_SETUP stm32_EfiSetup (); #endif #if __CLOCK_SETUP stm32_ClockSetup (); #endif #if __NVIC_SETUP stm32_NvicSetup (); #endif #if __SYSTICK_SETUP stm32_SysTickSetup (); #endif #if __RTC_SETUP stm32_RtcSetup (); #endif #if __TIMER_SETUP stm32_TimerSetup (); #endif #if __AFREMAP_SETUP stm32_AfRemapSetup (); #endif #if __GPIO_SETUP stm32_GpioSetup (); #endif #if __USART_SETUP stm32_UsartSetup(); #endif #if __EXTI_SETUP stm32_ExtiSetup(); #endif #if __TAMPER_SETUP stm32_TamperSetup(); #endif #if __IWDG_SETUP stm32_IwdgSetup(); // this should be the last function. watchdog is running afterwards #endif } // end of stm32_Init /*---------------------------------------------------------------------------- STM32 get PCLK1 deliver the PCLK1 *----------------------------------------------------------------------------*/ unsigned int stm32_GetPCLK1 (void) { return ((unsigned int)__PCLK1); } /*---------------------------------------------------------------------------- STM32 get PCLK2 deliver the PCLK2 *----------------------------------------------------------------------------*/ unsigned int stm32_GetPCLK2 (void) { return ((unsigned int)__PCLK2); } #endif