Table of Contents

Advertisement

Quick Links

Description of STM32F30xx/31xx Standard Peripheral Library
Introduction
The STM32F30xx and STM32F31xx Standard Peripheral Library covers 3 abstraction levels, and
includes:
A complete register address mapping with all bits, bitfields and registers declared in C. This avoids
a cumbersome task and more important, it brings the benefits of a bug free reference mapping file,
speeding up the early project phase.
A collection of routines and data structures covering all peripheral functions (drivers with common
API). It can directly be used as a reference framework, since it also includes macros for supporting
core-related intrinsic features, common constants, and definition of data types.
A set of examples covering all available peripherals with template projects for the most common
development tools. With the appropriate hardware evaluation board, this allows to get started with
a brand-new micro within few hours.

Each driver consists of a set of functions covering all peripheral features. The development of each
driver is driven by a common API (application programming interface) which standardizes the driver
structure, the functions and the parameter names.The driver source code is developed in „Strict ANSI-C‟
(relaxed ANSI-C for projects and example files). It is fully documented and is MISRA-C 2004 compliant.
Writing the whole library in „Strict ANSI-C‟ makes it independent from the development tools. Only the
start-up files depend on the development tools. Thanks to the Standard Peripheral Library, low-level
implementation details are transparent so that reusing code on a different MCU requires only to
reconfigure the compiler. As a result, developers can easily migrate designs across the STM32 series to
quickly bring product line extensions to market without any redesign. In addition, the library is built
around a modular architecture that makes it easy to tailor and run it on the same MCU using hardware
platforms different from ST evaluation boards.
The Standard Peripheral Library implements run-time failure detection by checking the input values for
all library functions. Such dynamic checking contributes towards enhancing the robustness of the
software. Run-time detection is suitable for user application development and debugging. It adds an
overhead which can be removed from the final application code to minimize code size and execution
speed. For more details refer to
Since the Standard Peripheral Library is generic and covers all peripheral features, the size and/or
execution speed of the application code may not be optimized. For many applications, the library may
be used as is. 

The firmware library user manual is structured as follows:
Document conventions, rules, architecture and overview of the Library package.
How to use and customize the Library (step by step).
Detailed description of each peripheral driver: configuration structure, functions and how to use the
provided API to build your application.

The STM32F30xx and STM32F31xx Standard Peripheral Library will be referred to as STM32F30xx
Library throughout the document, unless otherwise specified.
Type
Microcontrollers
October 2012
Section 1.1.5: "Run-time
Table 1: Applicable products
Part numbers
STM32F30xx and STM32F31xx
DocID023800 Rev 1
User manual
checking".

UM1581
1/584
www.st.com

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the STM32F31xx and is the answer not in the manual?

Questions and answers

Summary of Contents for ST STM32F31xx

  • Page 1 Detailed description of each peripheral driver: configuration structure, functions and how to use the provided API to build your application.
 The STM32F30xx and STM32F31xx Standard Peripheral Library will be referred to as STM32F30xx Library throughout the document, unless otherwise specified.
  • Page 2: Table Of Contents

    STM32F30xx Standard Peripheral Library UM1581 Contents STM32F30xx Standard Peripheral Library ...... 14 1.1 Coding rules and conventions ..........14 1.1.1 Acronyms ..................14 1.1.2 Naming conventions ..............14 1.1.3 Coding rules .................. 15 1.1.4 Bit-Banding ..................18 1.1.5 Run-time checking ................. 19 1.1.6 MISRA-C 2004 compliance ............
  • Page 3 STM32F30xx Standard Peripheral Library UM1581 3.1.3 ADC_InitTypeDef ................47 3.1.4 ADC_InjectedInitTypeDef .............. 48 3.1.5 ADC_TypeDef ................48 3.2 ADC Firmware driver API description ........51 3.2.1 How to use this driver ..............51 3.2.2 Initialization and Configuration functions ........51 3.2.3 Analog Watchdog configuration functions ........
  • Page 4 STM32F30xx Standard Peripheral Library UM1581 4.2.6 CAN Bus Error management functions ........113 4.2.7 Interrupts and flags management functions ........ 113 4.2.8 Initialization and Configuration functions ........115 4.2.9 CAN Frames Transmission functions .......... 118 4.2.10 CAN Frames Reception functions ..........119 4.2.11 CAN Operating mode functions ...........
  • Page 5 STM32F30xx Standard Peripheral Library UM1581 Digital-to-analog converter (DAC) ......... 160 7.1 DAC Firmware driver registers structures ......160 7.1.1 DAC_TypeDef ................160 7.1.2 DAC_InitTypeDef ................. 161 7.2 DAC Firmware driver API description ........ 161 7.2.1 DAC Peripheral features ............. 161 7.2.2 How to use this driver ..............
  • Page 6 STM32F30xx Standard Peripheral Library UM1581 9.2.7 Interrupts and flags management functions ........ 189 9.3 DMA Firmware driver defines ..........196 9.3.1 DMA ..................... 196 External interrupt/event controller (EXTI) ..... 207 10.1 EXTI Firmware driver registers structures ......207 10.1.1 EXTI_TypeDef ................207 10.1.2 EXTI_InitTypeDef ................
  • Page 7 STM32F30xx Standard Peripheral Library UM1581 12.2.1 How to use this driver ..............235 12.2.2 Initialization and Configuration ............ 236 12.2.3 GPIO Read and Write ..............236 12.2.4 GPIO Alternate functions configuration functions ....... 236 12.2.5 Initialization and Configuration ............ 237 12.2.6 GPIO Read and Write functions ..........
  • Page 8 STM32F30xx Standard Peripheral Library UM1581 14.2.3 Prescaler and Counter configuration functions ......279 14.2.4 IWDG activation function ............. 279 14.2.5 Flag management function ............279 14.2.6 Prescaler and counter configuration functions ......280 14.2.7 IWDG activation function ............. 282 14.2.8 Flag management function ............282 14.3 IWDG Firmware driver defines ..........
  • Page 9 STM32F30xx Standard Peripheral Library UM1581 17.2.6 Backup domain access function ..........304 17.2.7 PVD configuration function ............304 17.2.8 WakeUp pins configuration functions .......... 305 17.2.9 Low power mode configuration functions ........306 17.2.10 Flag management functions ............. 307 17.3 PWR Firmware driver defines ..........308 17.3.1 PWR ....................
  • Page 10 STM32F30xx Standard Peripheral Library UM1581 19.2.5 RTC and low power modes ............361 19.2.6 Selection of RTC_AF alternate functions ........361 19.2.7 Initialization and Configuration functions ........362 19.2.8 Backup Data Registers configuration functions ......362 19.2.9 Output Type Config configuration functions ........ 362 19.2.10 Shift control synchronisation functions ........
  • Page 11 STM32F30xx Standard Peripheral Library UM1581 20.2.3 Data transfers functions............... 408 20.2.4 Hardware CRC Calculation functions .......... 408 20.2.5 DMA transfers management functions ........409 20.2.6 Interrupts and flags management functions ........ 409 20.2.7 Initialization and configuration functions........411 20.2.8 Data transfer functions ..............418 20.2.9 Hardware CRC Calculation functions ..........
  • Page 12 STM32F30xx Standard Peripheral Library UM1581 22.2.10 Specific remapping management function ....... 458 22.2.11 TimeBase management functions ..........458 22.2.12 Output Compare management functions ......... 465 22.2.13 Input Capture management functions ........487 22.2.14 Advanced-control timers (TIM1, TIM8) specific features ..492 22.2.15 Interrupts DMA and flags management functions ....
  • Page 13 STM32F30xx Standard Peripheral Library UM1581 23.2.20 AutoBaudRate functions ............561 23.2.21 MultiProcessor Communication functions ........ 562 23.2.22 LIN mode functions ..............564 23.2.23 Halfduplex mode function ............565 23.2.24 Smartcard mode functions ............565 23.2.25 IrDA mode functions ..............567 23.3 USART Firmware driver defines ........
  • Page 14: Stm32F30Xx Standard Peripheral Library

    STM32F30xx Standard Peripheral Library UM1581 STM32F30xx Standard Peripheral Library Coding rules and conventions The conventions used in the present user manual and in the library are described in the sections below. 1.1.1 Acronyms The table below describes the acronyms used in this document. Table 2: List of abbreviations Acronym Peripheral / unit...
  • Page 15: Coding Rules

    UM1581  System and source/header file names are preceded by „stm32f30x_‟, for example stm32f30x_conf.h even if they are valid both for STM32F30xx and STM32F31xx microcontrollers.  Constants used in one file are defined within this file. A constant used in more than one file is defined in a header file.
  • Page 16 STM32F30xx Standard Peripheral Library UM1581 Variable types Specific variable types are already defined with a fixed type and size. These types are defined in the file stm32f30x.h typedef enum { RESET = 0, SET = !RESET FlagStatus, ITStatus; typedef enum { DISABLE = 0, ENABLE = !DISABLE FunctionalState;...
  • Page 17 STM32F30xx Standard Peripheral Library UM1581 __IO uint16_t TXCRCR; /*!< SPI TX CRC register (not used in I2S mode),Address offset: 0x18 */ uint16_t RESERVED6;/*!< Reserved, 0x1A __IO uint16_t I2SCFGR; /*!< SPI_I2S configuration register, Address offset: 0x1C */ uint16_t RESERVED7;/*!< Reserved, 0x1E __IO uint16_t I2SPR;...
  • Page 18: Bit-Banding

    STM32F30xx Standard Peripheral Library UM1581 Peripheral registers bits All the peripheral registers bits are defined as constants in the stm32f30x.h file. They are defined as acronyms written in upper-case into the form: PPP_<register_name>_<bit_name> Example: #define SPI_CR1_CPHA ((uint16_t)0x0001) /*!< Clock Phase */ #define SPI_CR1_CPOL ((uint16_t)0x0002) /*!<...
  • Page 19: Run-Time Checking

    STM32F30xx Standard Peripheral Library UM1581 /* ------------ RCC registers bit address in the alias region ----- ------ */ #define RCC_OFFSET (RCC_BASE - PERIPH_BASE) /* --- CR Register ---*/ /* Alias word address of PLLON bit */ #define CR_OFFSET (RCC_OFFSET + 0x00) #define PLLON_BitNumber 0x18 #define CR_PLLON_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) +...
  • Page 20 STM32F30xx Standard Peripheral Library UM1581 #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB)) If the expression passed to the assert_param macro is false, the assert_failed function is called and returns the name of the source file and the source line number of the call that failed.
  • Page 21: Misra-C 2004 Compliance

    STM32F30xx Standard Peripheral Library UM1581 However if you want to keep this functionality in your final application, reuse the assert_param macro defined within the library to test the parameter values before calling the library functions. 1.1.6 MISRA-C 2004 compliance The C programming language is growing in importance for embedded systems. However, when it comes to developing code for safety-critical applications, this language has many drawbacks.
  • Page 22 STM32F30xx Standard Peripheral Library UM1581 MISRA-C Required/Advisory Summary Reason 2004 rule number 10.1 Required The value of an expression of integer Complexity type shall not be implicitly converted to a different underlying type. 10.3 Required The value of a complex expression of Complexity integer type shall only be casted to a type that is not wider and of the same...
  • Page 23: Architecture

     STM32F30xx standard peripheral driver that provides drivers and header files for all the peripherals. It uses CMSIS layer to access STM32F30xx and STM32F31xx registers. BSP is a board specific package (BSP) that implements an abstraction layer to interact with the Human Interface resources;...
  • Page 24: Package Description

    STM32F30xx Standard Peripheral Library UM1581 Application layer The application layer consists of a set of examples covering all available peripherals with template projects for the most common development Tools. With the appropriate hardware evaluation board, this allows to get started with a brand new micro within few hours. Package description The Library is supplied in one single zip file.
  • Page 25 STM32F30xx Standard Peripheral Library UM1581 Figure 3: Library folder structure CMSIS subfolder This subfolder contains the STM32F30/31xx and Cortex-M4 CMSIS files:  Cortex-M CMSIS files containing name definitions, address definitions and helper functions to access Cortex-M4 core registers and peripherals. It defines also a device independent interface for RTOS kernels that includes debug channel definitions.
  • Page 26 This file is automatically generated by the clock configuration tool "STM32f30x_Clock_Configuration.xls". Using this tool, you can generate a configuration file customized for your application requirements. For more information, please refer to AN4152 available from ST web site. system_stm32f30x.h Header file for system_stm32f30x.c startup_stm32f30x.s Provides the Cortex-M4 startup code and interrupt vectors for all STM32F30/31xx device interrupt handlers.
...
  • Page 27: Project Folder

    STM32F30xx Standard Peripheral Library UM1581 File name Description  It branches to __main in the C library (which eventually calls main()).
 A file is provided for each compiler. Table 5: STM32f30xx_StdPeriph_Driver files description File name Description stm32f30x_ppp.c Driver source code file of PPP peripheral coded in Strict ANSI-C, and independent from the development Tools.
  • Page 28 "STM32f30x_Clock_Configuration.xls". Using this tool, you can generate a configuration file customized for your application requirements. For more information, please refer to AN4152 available from ST web site. stm32f30x_it.c Template source file containing the interrupt service routine (ISR) for Cortex- M4 exceptions.
  • Page 29: Utilities Folder

    STM32F30xx Standard Peripheral Library UM1581 1.3.3 Utilities folder This folder contains the abstraction layer allowing interacting with the human interface resources (buttons, LEDs, LCD and COM ports (USARTs)) available on STMicroelectronics evaluation boards. A common API is provided to manage these different resources.
  • Page 30 STM32F30xx Standard Peripheral Library UM1581 Table 7: Utilities/STM32_EVAL files description File name Description stm32303c_eval.c This file provides:  A set of firmware functions to manage LEDs, pushbuttons, and COM ports  Low level initialization functions for SDcard (on SPI) and serial EEPROM (sEE) 
 available on STM32303C_eval board.
  • Page 31: Supported Devices And Development Tools

    Supported devices and development tools 1.4.1 Supported devices The library supports the STM32F30xx and STM32F31xx microcontroller memory and peripherals. By using this library moving the application firmware from one STM32F30/31xx device to another becomes straightforward. The device part number is defined as follows in stm32f30x.h file:...
  • Page 32: How To Use And Customize The Library

    How to use and customize the library UM1581 How to use and customize the library The following sections explain all the steps required to configure, customize, run your first example, and develop your application based on the library. Library configuration parameters The configuration interface allows customizing the library for your application.
  • Page 33 How to use and customize the library UM1581 Parameter File Description /*!<Core revision r0p1>*/ #define __CM4_REV 0x0001 /*!<STM32F30/31x features an MPU>*/ #define __MPU_PRESENT /*!<STM32F30/31x features 4 bits for priority levels>*/ #define __NVIC_PRIO_BITS /*!<Set to 1 if different SysTick configuration is used >*/ #define __Vendor_SysTickConfig...
  • Page 34: Library Programming Model

    How to use and customize the library UM1581 Parameter File Description #include "stm32f30x_i2c.h" #include "stm32f30x_iwdg.h" #include "stm32f30x_pwr.h" #include "stm32f30x_opamp.h" #include "stm32f30x_rcc.h" #include "stm32f30x_rtc.h" #include "stm32f30x_spi.h" #include "stm32f30x_tim.h" #include "stm32f30x_usart.h" #include "stm32f30x_wwdg.h" #include "misc.h" USE_STM32303C_EVAL stm32303C_eval.h Default status: disabled This define statement is used to include the driver for STM32303C_EVAL board, when used.
  • Page 35: Peripheral Initialization And Configuration

    How to use and customize the library UM1581 Peripheral driver access In this model the application code uses the peripheral driver API to control the peripheral configuration and operation. It allows any device to be used in the user application without the need for in-depth study of each peripheral specification.
  • Page 36: How To Run Your First Example

    Latest release of documents and library. You can download the latest version of STM32F30/31xx related documents and library from STMicroelectronics web site: www.st.com/stm32 
 Hardware: to run the examples, you need an STM32303C-EVAL evaluation board from STMicroelectronics or any other compatible hardware. 
...
  • Page 37: Run Your First Example

    USB port of your PC. The STM32303C-EVAL features a build-in ST-Link/V2 debugger and programmer which makes the external hardware debuggers useless to load and debug your program. Simply select ST-Link/V2 as your debugger in your Development Tool configuration menu and connect the CN5 to your host PC through an USB cable.
  • Page 38: Run A Peripheral Example

    How to use and customize the library UM1581 Browse to TASKING workspace directory and select the STM32303C-EVAL project to configure the project for STM32F30/31xx devices Rebuild all project files by selecting the project in the "Project explorer" window and clicking on Project->build project menu Run the program by selecting the project in the "Project explorer"...
  • Page 39: Stm32F30/31Xx Programming Model Using The Library

    How to use and customize the library UM1581 Figure 7: How to run a peripheral example
 STM32F30/31xx programming model using the library This chapter contains useful general information for using the library to develop application based on STM32F30/31xx devices. It describes in details the sequence to use a peripheral, from the configuration of the system to the configuration of the peripheral registers.
  • Page 40 How to use and customize the library UM1581 Figure 8: STM32F30/31xx programming model using the library System clock configuration: the STM32F30/31xx devices can run at frequency up to 72 MHz and feature several prescalers to configure the AHB, APB1 and APB2 frequencies.
  • Page 41: How To Develop Your First Application

    How to use and customize the library UM1581 USB FS: in STM32F30/31xx devices, the USB FS requires a frequency equal to 48MHz to work correctly. 12-bit ADC: STM32F30/31xx12-bit ADC features two clock schemes:  Clock for the analog circuitry (ADCCLK). This clock is generated from the PLL output.
  • Page 42: Library Configuration Parameters

    How to use and customize the library UM1581  main.c: first move the template main.c file to another location (to backup the template for future use), then create a new empty C file and rename it to main.c. This file will be used to implement the program code as described in the section below.
  • Page 43: Main.c

    How to use and customize the library UM1581 2.6.4 main.c The main.c file calls the library driver functions to configure the EXTI, GPIO and NIVC peripherals. Include the library and STM32303C-EVAL-EVAL board resources: /* Includes -----------------------------------------------------*/ #include "stm32f30x.h" /* The Library entry point */ #include "stm32303C_eval"...
  • Page 44: Stm32F30X_It.c

    How to use and customize the library UM1581 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_Init(GPIOE, &GPIO_InitStructure); Configure the peripheral in the desired mode: /* Configure EXTI line 6 */ EXTI_InitStructure.EXTI_Line = EXTI_Line6; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Enable and set EXTI line 6 nterrupt to the lowest priority */ NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;...
  • Page 45 How to use and customize the library UM1581 /************************************************************** ************/ * @brief This function handles External line 6 * interrupt request. * @param None * @retval None void EXTI9_5_IRQHandler(void) if(EXTI_GetITStatus(EXTI_Line6) != RESET) /* Toggle LD1 */ STM_EVAL_LEDToggle(LED1); /* Clear the EXTI line 6 pending bit */ EXTI_ClearITPendingBit(EXTI_Line6);...
  • Page 46: Analog-To-Digital Converter (Adc)

    Analog-to-digital converter (ADC) UM1581 Analog-to-digital converter (ADC) ADC Firmware driver registers structures 3.1.1 ADC_Common_TypeDef ADC_Common_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t CSR  uint32_t RESERVED  __IO uint32_t CCR  __IO uint32_t CDR Field Documentation  __IO uint32_t ADC_Common_TypeDef::CSR ...
  • Page 47: Adc_Inittypedef

    Analog-to-digital converter (ADC) UM1581  Select the clock of the ADC. The clock is common for both master and slave ADCs. This parameter can be a value of ADC_Clock  uint32_t ADC_CommonInitTypeDef::ADC_DMAAccessMode  Configures the Direct memory access mode for multi ADC mode. This parameter can be a value of ADC_Direct_memory_access_mode_for_multi_mode ...
  • Page 48: Adc_Injectedinittypedef

    Analog-to-digital converter (ADC) UM1581  Enable/disable automatic injected group conversion after regular group conversion. This parameter can be set to ENABLE or DISABLE.  uint8_t ADC_InitTypeDef::ADC_NbrOfRegChannel  Specifies the number of ADC channels that will be converted using the sequencer for regular channel group. This parameter must range from 1 to 16. 3.1.4 ADC_InjectedInitTypeDef ADC_InjectedInitTypeDef is defined in the stm32f30x_adc.h...
  • Page 49 Analog-to-digital converter (ADC) UM1581  __IO uint32_t SMPR1  __IO uint32_t SMPR2  uint32_t RESERVED1  __IO uint32_t TR1  __IO uint32_t TR2  __IO uint32_t TR3  uint32_t RESERVED2  __IO uint32_t SQR1  __IO uint32_t SQR2  __IO uint32_t SQR3 ...
  • Page 50 Analog-to-digital converter (ADC) UM1581  __IO uint32_t ADC_TypeDef::TR1  ADC watchdog threshold register 1, Address offset: 0x20  __IO uint32_t ADC_TypeDef::TR2  ADC watchdog threshold register 2, Address offset: 0x24  __IO uint32_t ADC_TypeDef::TR3  ADC watchdog threshold register 3, Address offset: 0x28 ...
  • Page 51: Adc Firmware Driver Api Description

    Analog-to-digital converter (ADC) UM1581  uint32_t ADC_TypeDef::RESERVED9  Reserved, 0x0AC  __IO uint32_t ADC_TypeDef::DIFSEL  ADC Differential Mode Selection Register, Address offset: 0xB0  __IO uint32_t ADC_TypeDef::CALFACT  ADC Calibration Factors, Address offset: 0xB4 ADC Firmware driver API description The following section lists the various functions of the ADC library. 3.2.1 How to use this driver select the ADC clock using the function RCC_ADCCLKConfig()
  • Page 52: Analog Watchdog Configuration Functions

    Analog-to-digital converter (ADC) UM1581 Single ended or differential mode Enabling the queue of context and the auto delay mode The number of ADC conversions that will be done using the sequencer for regular channel group Enable or disable the ADC peripheral ...
  • Page 53: Temperature Sensor - Vrefint (Internal Reference Voltage) And Vbat Management Functions

    Analog-to-digital converter (ADC) UM1581 3.2.4 Temperature Sensor - Vrefint (Internal Reference Voltage) and VBAT management functions This section provides a function allowing to enable/ disable the internal connections between the ADC and the Vbat/2, Temperature Sensor and the Vrefint source. A typical configuration to get the Temperature sensor and Vrefint channels voltages is done following these steps : Enable the internal connection of Vbat/2, Temperature sensor and Vrefint sources...
  • Page 54: Regular Channels Dma Configuration Functions

    Analog-to-digital converter (ADC) UM1581 ADC_DiscModeChannelCountConfig() to configure the number of discontinuous channel to be converted. ADC_DiscModeCmd() to enable the discontinuous mode. To configure and enable/disable the Channel offset use the functions: (++) ADC_SetChannelOffset1() (++) ADC_SetChannelOffset2() (++) ADC_SetChannelOffset3() (++) ADC_SetChannelOffset4() (++) ADC_ChannelOffset1Cmd() (++) ADC_ChannelOffset2Cmd() (++) ADC_ChannelOffset3Cmd() (++) ADC_ChannelOffset4Cmd() ...
  • Page 55: Interrupts And Flags Management Functions

    Analog-to-digital converter (ADC) UM1581 Get the Specified Injected channel conversion data: This subsection provides an important function in the ADC peripheral since it returns the converted data of the specific injected channel. This section provide functions allowing to configure the ADC Injected channels, it is composed of 2 sub sections : (#) Configuration functions for Injected channels: This subsection provides functions allowing to configure the ADC injected channels : ...
  • Page 56 Analog-to-digital converter (ADC) UM1581 Flags for Master (+) ADC_FLAG_MSTRDY: ADC master Ready (ADRDY) flag (+) ADC_FLAG_MSTEOSMP: ADC master End of Sampling flag (+) ADC_FLAG_MSTEOC: ADC master End of Regular Conversion flag (+) ADC_FLAG_MSTEOS: ADC master End of Regular sequence of Conversions flag (+) ADC_FLAG_MSTOVR: ADC master overrun flag (+) ADC_FLAG_MSTJEOC: ADC master End of Injected Conversion flag (+) ADC_FLAG_MSTJEOS: ADC master End of Injected sequence of Conversions...
  • Page 57: Initialization And Configuration Functions

    Analog-to-digital converter (ADC) UM1581  ADC_FLAG_AWD2: ADC Analog watchdog 2 flag  ADC_FLAG_AWD3: ADC Analog watchdog 3 flag Flags  ADC_IT_AWD1: ADC Analog watchdog 1 interrupt source  ADC_IT_AWD2: ADC Analog watchdog 2 interrupt source  ADC_IT_AWD3: ADC Analog watchdog 3 interrupt source (#) Flags for ADC dual mode Flags for Master ...
  • Page 58 Analog-to-digital converter (ADC) UM1581 Function Name void ADC_DeInit ( ADC_TypeDef * ADCx) Function Description Deinitializes the ADCx peripheral registers to their default reset values.  Parameters ADCx : where x can be 1, 2,3 or 4 to select the ADC peripheral.
  • Page 59 Analog-to-digital converter (ADC) UM1581 3.2.9.4 ADC_InjectedInit Function Name void ADC_InjectedInit ( ADC_TypeDef * ADCx, ADC_InjectedInitTypeDef * ADC_InjectedInitStruct) Function Description Initializes the ADCx peripheral according to the specified parameters in the ADC_InitStruct.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 60 Analog-to-digital converter (ADC) UM1581 configuration information for All ADCs peripherals.  Return values None.  Notes None. 3.2.9.7 ADC_CommonStructInit Function Name void ADC_CommonStructInit ( ADC_CommonInitTypeDef * ADC_CommonInitStruct) Function Description Fills each ADC_CommonInitStruct member with its default value.  Parameters ADC_CommonInitStruct : pointer to an ADC_CommonInitTypeDef structure which will be initialized.
  • Page 61 Analog-to-digital converter (ADC) UM1581 3.2.9.9 ADC_StartCalibration Function Name void ADC_StartCalibration ( ADC_TypeDef * ADCx) Function Description Starts the selected ADC calibration process.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral. ...
  • Page 62 Analog-to-digital converter (ADC) UM1581 3.2.9.12 ADC_SelectCalibrationMode Function Name void ADC_SelectCalibrationMode ( ADC_TypeDef * ADCx, uint32_t ADC_CalibrationMode) Function Description Select the ADC calibration mode.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 63 Analog-to-digital converter (ADC) UM1581  Return values None.  Notes None. 3.2.9.15 ADC_GetDisableCmdStatus Function Name FlagStatus ADC_GetDisableCmdStatus ( ADC_TypeDef * ADCx) Function Description Gets the selected ADC disable command Status.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 64 Analog-to-digital converter (ADC) UM1581 uint8_t ADC_Channel, FunctionalState NewState) Function Description Selectes the differential mode for a specific channel.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.  ADC_Channel : the ADC channel to configure for the analog watchdog.
  • Page 65: Analog Watchdog Configuration Functions

    Analog-to-digital converter (ADC) UM1581 3.2.9.19 ADC_AutoDelayCmd Function Name void ADC_AutoDelayCmd ( ADC_TypeDef * ADCx, FunctionalState NewState) Function Description Selects the ADC Delayed Conversion Mode.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 66 Analog-to-digital converter (ADC) UM1581 3.2.10.2 ADC_AnalogWatchdog1ThresholdsConfig Function Name void ADC_AnalogWatchdog1ThresholdsConfig ( ADC_TypeDef * ADCx, uint16_t HighThreshold, uint16_t LowThreshold) Function Description Configures the high and low thresholds of the analog watchdog1.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 67 Analog-to-digital converter (ADC) UM1581 3.2.10.4 ADC_AnalogWatchdog3ThresholdsConfig Function Name void ADC_AnalogWatchdog3ThresholdsConfig ( ADC_TypeDef * ADCx, uint8_t HighThreshold, uint8_t LowThreshold) Function Description Configures the high and low thresholds of the analog watchdog3.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 68 Analog-to-digital converter (ADC) UM1581  ADC_Channel_18 : ADC Channel18 selected  Return values None.  Notes None. 3.2.10.6 ADC_AnalogWatchdog2SingleChannelConfig Function Name void ADC_AnalogWatchdog2SingleChannelConfig ( ADC_TypeDef * ADCx, uint8_t ADC_Channel) Function Description Configures the analog watchdog 2 guarded single channel.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 69: Temperature Sensor- Vrefint (Internal Reference Voltage) And Vbat Management Function

    Analog-to-digital converter (ADC) UM1581 3.2.10.7 ADC_AnalogWatchdog3SingleChannelConfig Function Name void ADC_AnalogWatchdog3SingleChannelConfig ( ADC_TypeDef * ADCx, uint8_t ADC_Channel) Function Description Configures the analog watchdog 3 guarded single channel.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 70 Analog-to-digital converter (ADC) UM1581 parameter can be: ENABLE or DISABLE.  Return values None.  Notes None. 3.2.11.2 ADC_VrefintCmd Function Name void ADC_VrefintCmd ( ADC_TypeDef * ADCx, FunctionalState NewState) Function Description Enables or disables the Vrefint channel.  Parameters ADCx : where x can be 1 or 4 to select the ADC peripheral. ...
  • Page 71: Regular Channels Configuration Functions

    Analog-to-digital converter (ADC) UM1581 3.2.12 Regular Channels Configuration functions 3.2.12.1 ADC_RegularChannelConfig Function Name void ADC_RegularChannelConfig ( ADC_TypeDef * ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime) Function Description Configures for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. ...
  • Page 72 Analog-to-digital converter (ADC) UM1581  ADC_SampleTime_181Cycles5 : Sample time equal to 181.5 cycles  ADC_SampleTime_601Cycles5 : Sample time equal to 601.5 cycles  Return values None.  Notes None. 3.2.12.2 ADC_RegularChannelSequencerLengthConfig Function Name void ADC_RegularChannelSequencerLengthConfig ( ADC_TypeDef * ADCx, uint8_t SequencerLength) Function Description Sets the ADC regular channel sequence lenght.
  • Page 73 Analog-to-digital converter (ADC) UM1581  ADC_ExternalTrigger_Event3 : External trigger event  ADC_ExternalTrigger_Event4 : External trigger event  ADC_ExternalTrigger_Event5 : External trigger event  ADC_ExternalTrigger_Event6 : External trigger event  ADC_ExternalTrigger_Event7 : External trigger event  ADC_ExternalTrigger_Event8 : External trigger event ...
  • Page 74 Analog-to-digital converter (ADC) UM1581  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.  Return values None.  Notes None. 3.2.12.5 ADC_GetStartConversionStatus Function Name FlagStatus ADC_GetStartConversionStatus ( ADC_TypeDef * ADCx) Function Description Gets the selected ADC start conversion Status.
  • Page 75 Analog-to-digital converter (ADC) UM1581 Function Description Configures the discontinuous mode for the selected ADC regular group channel.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.  Number : specifies the discontinuous mode regular channel count value.
  • Page 76 Analog-to-digital converter (ADC) UM1581 3.2.12.10 ADC_GetDualModeConversionValue Function Name uint32_t ADC_GetDualModeConversionValue ( ADC_TypeDef ADCx) Function Description Returns the last ADC1, ADC2, ADC3 and ADC4 regular conversions results data in the selected dual mode.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 77 Analog-to-digital converter (ADC) UM1581  ADC_Channel_17 : ADC Channel17 selected  ADC_Channel_18 : ADC Channel18 selected  Offset : the offset value for the selected ADC Channel This parameter must be a 12bit value.  Return values None.  Notes None.
  • Page 78 Analog-to-digital converter (ADC) UM1581 3.2.12.13 ADC_SetChannelOffset3 Function Name void ADC_SetChannelOffset3 ( ADC_TypeDef * ADCx, uint8_t ADC_Channel, uint16_t Offset) Function Description Set the ADC channels conversion value offset3.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 79 Analog-to-digital converter (ADC) UM1581  ADC_Channel_1 : ADC Channel1 selected  ADC_Channel_2 : ADC Channel2 selected  ADC_Channel_3 : ADC Channel3 selected  ADC_Channel_4 : ADC Channel4 selected  ADC_Channel_5 : ADC Channel5 selected  ADC_Channel_6 : ADC Channel6 selected ...
  • Page 80 Analog-to-digital converter (ADC) UM1581 3.2.12.16 ADC_ChannelOffset2Cmd Function Name void ADC_ChannelOffset2Cmd ( ADC_TypeDef * ADCx, FunctionalState NewState) Function Description Enables or disables the Offset2.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 81: Regular Channels Dma Configuration Functions

    Analog-to-digital converter (ADC) UM1581 can be: ENABLE or DISABLE.  Return values None.  Notes None. 3.2.13 Regular Channels DMA Configuration functions 3.2.13.1 ADC_DMACmd Function Name void ADC_DMACmd ( ADC_TypeDef * ADCx, FunctionalState NewState) Function Description Enables or disables the specified ADC DMA request. ...
  • Page 82: Injected Channels Configuration Functions

    Analog-to-digital converter (ADC) UM1581 3.2.14 Injected channels Configuration functions 3.2.14.1 ADC_StartInjectedConversion Function Name void ADC_StartInjectedConversion ( ADC_TypeDef * ADCx) Function Description Enables or disables the selected ADC start of the injected channels conversion.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 83 Analog-to-digital converter (ADC) UM1581 RESET).  Notes None. 3.2.14.4 ADC_AutoInjectedConvCmd Function Name void ADC_AutoInjectedConvCmd ( ADC_TypeDef * ADCx, FunctionalState NewState) Function Description Enables or disables the selected ADC automatic injected group conversion after regular one.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 84: Interrupts And Flags Management Functions

    Analog-to-digital converter (ADC) UM1581 3.2.14.6 ADC_GetInjectedConversionValue Function Name uint16_t ADC_GetInjectedConversionValue ( ADC_TypeDef * ADCx, uint8_t ADC_InjectedChannel) Function Description Returns the ADC injected channel conversion result.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 85 Analog-to-digital converter (ADC) UM1581  ADC_IT_AWD2 : ADC Analog watchdog 2 interrupt source  ADC_IT_AWD3 : ADC Analog watchdog 3 interrupt source  ADC_IT_JQOVF : ADC Injected Context Queue Overflow interrupt source  NewState : new state of the specified ADC interrupts. This parameter can be: ENABLE or DISABLE.
  • Page 86 Analog-to-digital converter (ADC) UM1581 3.2.15.3 ADC_ClearFlag Function Name void ADC_ClearFlag ( ADC_TypeDef * ADCx, uint32_t ADC_FLAG) Function Description Clears the ADCx's pending flags.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.
  • Page 87 Analog-to-digital converter (ADC) UM1581  ADC_FLAG_MSTEOC : ADC master End of Regular Conversion flag  ADC_FLAG_MSTEOS : ADC master End of Regular sequence of Conversions flag  ADC_FLAG_MSTOVR : ADC master overrun flag  ADC_FLAG_MSTJEOC : ADC master End of Injected Conversion flag ...
  • Page 88 Analog-to-digital converter (ADC) UM1581 Function Description Clears the ADCx's pending flags.  Parameters ADCx : where x can be 1, 2, 3 or 4 to select the ADC peripheral.  ADC_FLAG : specifies the master or slave flag to clear. This parameter can be one of the following values: ...
  • Page 89 Analog-to-digital converter (ADC) UM1581 3.2.15.6 ADC_GetITStatus Function Name ITStatus ADC_GetITStatus ( ADC_TypeDef * ADCx, uint32_t ADC_IT) Function Description Checks whether the specified ADC interrupt has occurred or not.  Parameters ADCx : where x can be 1, 2 or 3 to select the ADC peripheral.
  • Page 90: Adc Firmware Driver Defines

    Analog-to-digital converter (ADC) UM1581 This parameter can be any combination of the following values:  ADC_IT_RDY : ADC Ready (ADRDY) interrupt source  ADC_IT_EOSMP : ADC End of Sampling interrupt source  ADC_IT_EOC : ADC End of Regular Conversion interrupt source ...
  • Page 91 Analog-to-digital converter (ADC) UM1581  #define: ADC_AnalogWatchdog_AllInjecEnable ((uint32_t)0x01000000) ADC Analog watchdog all injected mode  #define: ADC_AnalogWatchdog_AllRegAllInjecEnable ((uint32_t)0x01800000) ADC Analog watchdog all regular and all injected mode  #define: ADC_AnalogWatchdog_None ((uint32_t)0x00000000) ADC Analog watchdog off ADC_AutoInjecMode  #define: ADC_AutoInjec_Enable ((uint32_t)0x02000000) ADC Auto injected Mode enable ...
  • Page 92 Analog-to-digital converter (ADC) UM1581  #define: ADC_Channel_5 ((uint8_t)0x05) ADC Channel 5  #define: ADC_Channel_6 ((uint8_t)0x06) ADC Channel 6  #define: ADC_Channel_7 ((uint8_t)0x07) ADC Channel 7  #define: ADC_Channel_8 ((uint8_t)0x08) ADC Channel 8  #define: ADC_Channel_9 ((uint8_t)0x09) ADC Channel 9  #define: ADC_Channel_10 ((uint8_t)0x0A) ADC Channel 10 ...
  • Page 93 Analog-to-digital converter (ADC) UM1581  #define: ADC_Channel_17 ((uint8_t)0x11) ADC Channel 17  #define: ADC_Channel_18 ((uint8_t)0x12) ADC Channel 18  #define: ADC_Channel_TempSensor ((uint8_t)ADC_Channel_16)  #define: ADC_Channel_Vrefint ((uint8_t)ADC_Channel_18)  #define: ADC_Channel_Vbat ((uint8_t)ADC_Channel_17) ADC_Clock  #define: ADC_Clock_AsynClkMode ((uint32_t)0x00000000) ADC Asynchronous clock mode  #define: ADC_Clock_SynClkModeDiv1 ((uint32_t)0x00010000) Synchronous clock mode divided by 1 ...
  • Page 94 Analog-to-digital converter (ADC) UM1581  #define: ADC_FLAG_MSTEOC ((uint32_t)0x00000004) ADC Master End of Regular Conversion flag  #define: ADC_FLAG_MSTEOS ((uint32_t)0x00000008) ADC Master End of Regular sequence of Conversions flag  #define: ADC_FLAG_MSTOVR ((uint32_t)0x00000010) ADC Master overrun flag  #define: ADC_FLAG_MSTJEOC ((uint32_t)0x00000020) ADC Master End of Injected Conversion flag ...
  • Page 95 Analog-to-digital converter (ADC) UM1581  #define: ADC_FLAG_SLVEOS ((uint32_t)0x00080000) ADC Slave End of Regular sequence of Conversions flag  #define: ADC_FLAG_SLVOVR ((uint32_t)0x00100000) ADC Slave overrun flag  #define: ADC_FLAG_SLVJEOC ((uint32_t)0x00200000) ADC Slave End of Injected Conversion flag  #define: ADC_FLAG_SLVJEOS ((uint32_t)0x00400000) ADC Slave End of Injected sequence of Conversions flag ...
  • Page 96 Analog-to-digital converter (ADC) UM1581 ADC Data alignment left ADC_Direct_memory_access_mode_for_multi_mode  #define: ADC_DMAAccessMode_Disabled ((uint32_t)0x00000000) DMA mode disabled  #define: ADC_DMAAccessMode_1 ((uint32_t)0x00008000) DMA mode enabled for 12 and 10-bit resolution (6 bit)  #define: ADC_DMAAccessMode_2 ((uint32_t)0x0000C000) DMA mode enabled for 8 and 6-bit resolution (8bit) ADC_DMA_Mode_definition ...
  • Page 97 Analog-to-digital converter (ADC) UM1581  #define: ADC_ExternalTrigEventEdge_RisingEdge ((uint16_t)0x0400) ADC external trigger rising edge for regular conversion  #define: ADC_ExternalTrigEventEdge_FallingEdge ((uint16_t)0x0800) ADC ADC external trigger falling edge for regular conversion  #define: ADC_ExternalTrigEventEdge_BothEdge ((uint16_t)0x0C00) ADC ADC external trigger both edges for regular conversion ADC_external_trigger_sources_for_Injected_channels_conversion ...
  • Page 98 Analog-to-digital converter (ADC) UM1581  #define: ADC_ExternalTrigInjecConvEvent_9 ((uint16_t)0x0024) ADC external trigger for injected conversion event 9  #define: ADC_ExternalTrigInjecConvEvent_10 ((uint16_t)0x0028) ADC external trigger for injected conversion event 10  #define: ADC_ExternalTrigInjecConvEvent_11 ((uint16_t)0x002C) ADC external trigger for injected conversion event 11 ...
  • Page 99 Analog-to-digital converter (ADC) UM1581 ADC external trigger event 4  #define: ADC_ExternalTrigConvEvent_5 ((uint16_t)0x0140) ADC external trigger event 5  #define: ADC_ExternalTrigConvEvent_6 ((uint16_t)0x0180) ADC external trigger event 6  #define: ADC_ExternalTrigConvEvent_7 ((uint16_t)0x01C0) ADC external trigger event 7  #define: ADC_ExternalTrigConvEvent_8 ((uint16_t)0x0200) ADC external trigger event 8 ...
  • Page 100 Analog-to-digital converter (ADC) UM1581  #define: ADC_FLAG_RDY ((uint16_t)0x0001) ADC Ready (ADRDY) flag  #define: ADC_FLAG_EOSMP ((uint16_t)0x0002) ADC End of Sampling flag  #define: ADC_FLAG_EOC ((uint16_t)0x0004) ADC End of Regular Conversion flag  #define: ADC_FLAG_EOS ((uint16_t)0x0008) ADC End of Regular sequence of Conversions flag ...
  • Page 101 Analog-to-digital converter (ADC) UM1581  #define: ADC_InjectedChannel_2 ADC_Channel_2 ADC Injected channel 2  #define: ADC_InjectedChannel_3 ADC_Channel_3 ADC Injected channel 3  #define: ADC_InjectedChannel_4 ADC_Channel_4 ADC Injected channel 4 ADC_interrupts_definition  #define: ADC_IT_RDY ((uint16_t)0x0001) ADC Ready (ADRDY) interrupt source  #define: ADC_IT_EOSMP ((uint16_t)0x0002) ADC End of Sampling interrupt source ...
  • Page 102 Analog-to-digital converter (ADC) UM1581 ADC Analog watchdog 2 interrupt source  #define: ADC_IT_AWD3 ((uint16_t)0x0200) ADC Analog watchdog 3 interrupt source  #define: ADC_IT_JQOVF ((uint16_t)0x0400) ADC Injected Context Queue Overflow interrupt source ADC_mode  #define: ADC_Mode_Independent ((uint32_t)0x00000000) ADC independent mode  #define: ADC_Mode_CombRegSimulInjSimul ((uint32_t)0x00000001) ADC multi ADC mode: Combined Regular simultaneous injected simultaneous mode ...
  • Page 103 Analog-to-digital converter (ADC) UM1581 ADC_resolution  #define: ADC_Resolution_12b ((uint32_t)0x00000000) ADC 12-bit resolution  #define: ADC_Resolution_10b ((uint32_t)0x00000008) ADC 10-bit resolution  #define: ADC_Resolution_8b ((uint32_t)0x00000010) ADC 8-bit resolution  #define: ADC_Resolution_6b ((uint32_t)0x00000018) ADC 6-bit resolution ADC_sampling_time  #define: ADC_SampleTime_1Cycles5 ((uint8_t)0x00) ADC sampling time 1.5 cycle ...
  • Page 104 Analog-to-digital converter (ADC) UM1581  #define: ADC_SampleTime_601Cycles5 ((uint8_t)0x07) ADC sampling time 601.5 cycles 104/584 DocID023800 Rev 1...
  • Page 105: Controller Area Network (Bxcan)

    Controller area network (bxCAN) UM1581 Controller area network (bxCAN) CAN Firmware driver registers structures 4.1.1 CAN_TypeDef CAN_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t MCR  __IO uint32_t MSR  __IO uint32_t TSR  __IO uint32_t RF0R ...
  • Page 106: Can_Fifomailbox_Typedef

    Controller area network (bxCAN) UM1581  __IO uint32_t CAN_TypeDef::BTR  CAN bit timing register, Address offset: 0x1C  uint32_t CAN_TypeDef::RESERVED0[88]  Reserved, 0x020 - 0x17F  CAN_TxMailBox_TypeDef CAN_TypeDef::sTxMailBox[3]  CAN Tx MailBox, Address offset: 0x180 - 0x1AC  CAN_FIFOMailBox_TypeDef CAN_TypeDef::sFIFOMailBox[2] ...
  • Page 107: Can_Txmailbox_Typedef

    Controller area network (bxCAN) UM1581  CAN receive FIFO mailbox data low register  __IO uint32_t CAN_FIFOMailBox_TypeDef::RDHR  CAN receive FIFO mailbox data high register 4.1.3 CAN_TxMailBox_TypeDef CAN_TxMailBox_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t TIR  __IO uint32_t TDTR ...
  • Page 108 Controller area network (bxCAN) UM1581 Data Fields  uint16_t CAN_Prescaler  uint8_t CAN_Mode  uint8_t CAN_SJW  uint8_t CAN_BS1  uint8_t CAN_BS2  FunctionalState CAN_TTCM  FunctionalState CAN_ABOM  FunctionalState CAN_AWUM  FunctionalState CAN_NART  FunctionalState CAN_RFLM  FunctionalState CAN_TXFP Field Documentation ...
  • Page 109: Can_Filterinittypedef

    Controller area network (bxCAN) UM1581 4.1.6 CAN_FilterInitTypeDef CAN_FilterInitTypeDef is defined in the stm32f30x_can.h Data Fields  uint16_t CAN_FilterIdHigh  uint16_t CAN_FilterIdLow  uint16_t CAN_FilterMaskIdHigh  uint16_t CAN_FilterMaskIdLow  uint16_t CAN_FilterFIFOAssignment  uint8_t CAN_FilterNumber  uint8_t CAN_FilterMode  uint8_t CAN_FilterScale  FunctionalState CAN_FilterActivation Field Documentation ...
  • Page 110: Canrxmsg

    Controller area network (bxCAN) UM1581 4.1.7 CanRxMsg CanRxMsg is defined in the stm32f30x_can.h Data Fields  uint32_t StdId  uint32_t ExtId  uint8_t IDE  uint8_t RTR  uint8_t DLC  uint8_t Data  uint8_t FMI Field Documentation  uint32_t CanRxMsg::StdId ...
  • Page 111: Can Firmware Driver Api Description

    Controller area network (bxCAN) UM1581 Field Documentation  uint32_t CanTxMsg::StdId  Specifies the standard identifier. This parameter can be a value between 0 to 0x7FF.  uint32_t CanTxMsg::ExtId  Specifies the extended identifier. This parameter can be a value between 0 to 0x1FFFFFFF.
  • Page 112: Initialization And Configuration Functions

    Controller area network (bxCAN) UM1581 CAN_ClearFlag() function. And after checking on an interrupt event you should clear it using CAN_ClearITPendingBit() function. 4.2.2 Initialization and Configuration functions This section provides functions allowing to:  Initialize the CAN peripherals : Prescaler, operating mode, the maximum number of time quanta to perform resynchronization, the number of time quanta in Bit Segment 1 and 2 and many other modes.
  • Page 113: Can Bus Error Management Functions

    Controller area network (bxCAN) UM1581  CAN_OperatingModeRequest()  CAN_Sleep()  CAN_WakeUp() 4.2.6 CAN Bus Error management functions This section provides functions allowing to  Return the CANx's last error code (LEC).  Return the CANx Receive Error Counter (REC).  Return the LSB of the 9-bit CANx Transmit Error Counter(TEC).
  • Page 114 Controller area network (bxCAN) UM1581  CAN_FLAG_FF1: FIFO 0 and 1 Full Flags; Set when three messages are stored in the selected FIFO.  CAN_FLAG_FOV0.  CAN_FLAG_FOV1: FIFO 0 and 1 Overrun Flags; Set when a new message has been received and passed the filter while the FIFO was full. ...
  • Page 115: Initialization And Configuration Functions

    Controller area network (bxCAN) UM1581  CAN_IT_BOF: Bus-off Interrupt; If enabled, this interrupt source is pending when CAN enters the bus-off state. The bus-off state is entered on TEC overflow, greater than 255. This Flag is cleared only by hardware. ...
  • Page 116 Controller area network (bxCAN) UM1581 parameters in the CAN_InitStruct.  Parameters CANx : where x can be 1 to select the CAN1 peripheral.  CAN_InitStruct : pointer to a CAN_InitTypeDef structure that contains the configuration information for the CAN peripheral. ...
  • Page 117 Controller area network (bxCAN) UM1581 4.2.8.5 CAN_SlaveStartBank Function Name void CAN_SlaveStartBank ( uint8_t CAN_BankNumber) Function Description Select the start bank filter for slave CAN.  Parameters CAN_BankNumber : Select the start slave bank filter from 1..27.  Return values None. ...
  • Page 118: Can Frames Transmission Functions

    Controller area network (bxCAN) UM1581 ENABLE or DISABLE. When enabled, Time stamp (TIME[15:0]) value is sent in the last two data bytes of the 8- byte message: TIME[7:0] in data byte 6 and TIME[15:8] in data byte 7.  Return values None.
  • Page 119: Can Frames Reception Functions

    Controller area network (bxCAN) UM1581 4.2.9.3 CAN_CancelTransmit Function Name void CAN_CancelTransmit ( CAN_TypeDef * CANx, uint8_t Mailbox) Function Description Cancels a transmit request.  Parameters CANx : where x can be 1 to select the CAN1 peripheral.  Mailbox : Mailbox number. ...
  • Page 120: Can Operating Mode Functions

    Controller area network (bxCAN) UM1581 FIFONumber) Function Description Releases the specified receive FIFO.  Parameters CANx : where x can be 1 to select the CAN1 peripheral.  FIFONumber : FIFO to release, CAN_FIFO0 or CAN_FIFO1.  Return values None. ...
  • Page 121: Can Bus Error Management Functions

    Controller area network (bxCAN) UM1581 4.2.11.2 CAN_Sleep Function Name uint8_t CAN_Sleep ( CAN_TypeDef * CANx) Function Description Enters the Sleep (low power) mode.  Parameters CANx : where x can be 1 to select the CAN1 peripheral.  Return values CAN_Sleep_Ok if sleep entered, CAN_Sleep_Failed otherwise.
  • Page 122 Controller area network (bxCAN) UM1581  CAN_ERRORCODE_StuffErr: Stuff Error  CAN_ERRORCODE_FormErr: Form Error  CAN_ERRORCODE_ACKErr : Acknowledgment Error  CAN_ERRORCODE_BitRecessiveErr: Bit Recessive Error  CAN_ERRORCODE_BitDominantErr: Bit Dominant Error  CAN_ERRORCODE_CRCErr: CRC Error  CAN_ERRORCODE_SoftwareSetErr: Software Set Error  Notes None. 4.2.12.2 CAN_GetReceiveErrorCounter Function Name...
  • Page 123: Interrupts And Flags Management Functions

    Controller area network (bxCAN) UM1581 4.2.13 Interrupts and flags management functions 4.2.13.1 CAN_ITConfig Function Name void CAN_ITConfig ( CAN_TypeDef * CANx, uint32_t CAN_IT, FunctionalState NewState) Function Description Enables or disables the specified CANx interrupts.  Parameters CANx : where x can be 1 or 2 to to select the CAN peripheral.
  • Page 124 Controller area network (bxCAN) UM1581  CAN_FLAG_RQCP0 : Request MailBox0 Flag  CAN_FLAG_RQCP1 : Request MailBox1 Flag  CAN_FLAG_RQCP2 : Request MailBox2 Flag  CAN_FLAG_FMP0 : FIFO 0 Message Pending Flag  CAN_FLAG_FF0 : FIFO 0 Full Flag  CAN_FLAG_FOV0 : FIFO 0 Overrun Flag ...
  • Page 125 Controller area network (bxCAN) UM1581 4.2.13.4 CAN_GetITStatus Function Name ITStatus CAN_GetITStatus ( CAN_TypeDef * CANx, uint32_t CAN_IT) Function Description Checks whether the specified CANx interrupt has occurred or not.  Parameters CANx : where x can be 1 or 2 to to select the CAN peripheral.
  • Page 126: Can Firmware Driver Defines

    Controller area network (bxCAN) UM1581  CAN_IT_SLK : Sleep acknowledge Interrupt  CAN_IT_EWG : Error warning Interrupt  CAN_IT_EPV : Error passive Interrupt  CAN_IT_BOF : Bus-off Interrupt  CAN_IT_LEC : Last error code Interrupt  CAN_IT_ERR : Error Interrupt ...
  • Page 127 Controller area network (bxCAN) UM1581 Software Set Error CAN_filter_FIFO  #define: CAN_Filter_FIFO0 ((uint8_t)0x00) Filter FIFO 0 assignment for filter x  #define: CAN_Filter_FIFO1 ((uint8_t)0x01) Filter FIFO 1 assignment for filter x  #define: CAN_FilterFIFO0 CAN_Filter_FIFO0  #define: CAN_FilterFIFO1 CAN_Filter_FIFO1 CAN_filter_mode ...
  • Page 128 Controller area network (bxCAN) UM1581  #define: CAN_FLAG_RQCP2 ((uint32_t)0x38010000) Request MailBox2 Flag  #define: CAN_FLAG_FMP0 ((uint32_t)0x12000003) FIFO 0 Message Pending Flag  #define: CAN_FLAG_FF0 ((uint32_t)0x32000008) FIFO 0 Full Flag  #define: CAN_FLAG_FOV0 ((uint32_t)0x32000010) FIFO 0 Overrun Flag  #define: CAN_FLAG_FMP1 ((uint32_t)0x14000003) FIFO 1 Message Pending Flag ...
  • Page 129 Controller area network (bxCAN) UM1581  #define: CAN_FLAG_LEC ((uint32_t)0x30F00070) Last error code Flag CAN_identifier_type  #define: CAN_Id_Standard ((uint32_t)0x00000000) Standard Id  #define: CAN_Id_Extended ((uint32_t)0x00000004) Extended Id  #define: CAN_ID_STD CAN_Id_Standard  #define: CAN_ID_EXT CAN_Id_Extended CAN_InitStatus  #define: CAN_InitStatus_Failed ((uint8_t)0x00) CAN initialization failed ...
  • Page 130 Controller area network (bxCAN) UM1581  #define: CAN_IT_FF0 ((uint32_t)0x00000004) FIFO 0 full Interrupt  #define: CAN_IT_FOV0 ((uint32_t)0x00000008) FIFO 0 overrun Interrupt  #define: CAN_IT_FMP1 ((uint32_t)0x00000010) FIFO 1 message pending Interrupt  #define: CAN_IT_FF1 ((uint32_t)0x00000020) FIFO 1 full Interrupt  #define: CAN_IT_FOV1 ((uint32_t)0x00000040) FIFO 1 overrun Interrupt ...
  • Page 131 Controller area network (bxCAN) UM1581  #define: CAN_IT_RQCP0 CAN_IT_TME  #define: CAN_IT_RQCP1 CAN_IT_TME  #define: CAN_IT_RQCP2 CAN_IT_TME CAN_operating_mode  #define: CAN_Mode_Normal ((uint8_t)0x00) normal mode  #define: CAN_Mode_LoopBack ((uint8_t)0x01) loopback mode  #define: CAN_Mode_Silent ((uint8_t)0x02) silent mode  #define: CAN_Mode_Silent_LoopBack ((uint8_t)0x03) loopback combined with silent mode ...
  • Page 132 Controller area network (bxCAN) UM1581 CAN entering the specific mode Succeed CAN_receive_FIFO_number_constants  #define: CAN_FIFO0 ((uint8_t)0x00) CAN FIFO 0 used to receive  #define: CAN_FIFO1 ((uint8_t)0x01) CAN FIFO 1 used to receive CAN_remote_transmission_request  #define: CAN_RTR_Data ((uint32_t)0x00000000) Data frame  #define: CAN_RTR_Remote ((uint32_t)0x00000002) Remote frame ...
  • Page 133 Controller area network (bxCAN) UM1581  #define: CAN_SJW_1tq ((uint8_t)0x00) 1 time quantum  #define: CAN_SJW_2tq ((uint8_t)0x01) 2 time quantum  #define: CAN_SJW_3tq ((uint8_t)0x02) 3 time quantum  #define: CAN_SJW_4tq ((uint8_t)0x03) 4 time quantum CAN_time_quantum_in_bit_segment_1  #define: CAN_BS1_1tq ((uint8_t)0x00) 1 time quantum ...
  • Page 134 Controller area network (bxCAN) UM1581  #define: CAN_BS1_9tq ((uint8_t)0x08) 9 time quantum  #define: CAN_BS1_10tq ((uint8_t)0x09) 10 time quantum  #define: CAN_BS1_11tq ((uint8_t)0x0A) 11 time quantum  #define: CAN_BS1_12tq ((uint8_t)0x0B) 12 time quantum  #define: CAN_BS1_13tq ((uint8_t)0x0C) 13 time quantum ...
  • Page 135 Controller area network (bxCAN) UM1581 4 time quantum  #define: CAN_BS2_5tq ((uint8_t)0x04) 5 time quantum  #define: CAN_BS2_6tq ((uint8_t)0x05) 6 time quantum  #define: CAN_BS2_7tq ((uint8_t)0x06) 7 time quantum  #define: CAN_BS2_8tq ((uint8_t)0x07) 8 time quantum CAN_transmit_constants  #define: CAN_TxStatus_Failed ((uint8_t)0x00) CAN transmission failed ...
  • Page 136 Controller area network (bxCAN) UM1581  #define: CAN_NO_MB CAN_TxStatus_NoMailBox CAN_wake_up_constants  #define: CAN_WakeUp_Failed ((uint8_t)0x00) CAN did not leave the sleep mode  #define: CAN_WakeUp_Ok ((uint8_t)0x01) CAN leaved the sleep mode  #define: CANWAKEUPFAILED CAN_WakeUp_Failed  #define: CANWAKEUPOK CAN_WakeUp_Ok 136/584 DocID023800 Rev 1...
  • Page 137: Comparators (Comp)

    Comparators (COMP) UM1581 Comparators (COMP) COMP Firmware driver registers structures 5.1.1 COMP_TypeDef COMP_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t CSR Field Documentation  __IO uint32_t COMP_TypeDef::CSR  Comparator control Status register, Address offset: 0x00 5.1.2 COMP_InitTypeDef COMP_InitTypeDef is defined in the stm32f30x_comp.h Data Fields ...
  • Page 138: Comp Firmware Driver Api Description

    Comparators (COMP) UM1581  Selects the output polarity of the comparator. This parameter can be a value of COMP_OutputPoloarity  uint32_t COMP_InitTypeDef::COMP_Hysteresis  Selects the hysteresis voltage of the comparator. This parameter can be a value COMP_Hysteresis  uint32_t COMP_InitTypeDef::COMP_Mode ...
  • Page 139 Comparators (COMP) UM1581 COMP1 COMP2 COMP3 COMP4 COMP5 COMP6 COMP7 PB14 PD12 PD11 Inverting Input PD14 PB13 PB11 Table 11: COMP Outputs COMP1 COMP2 COMP3 COMP4 COMP5 COMP6 COMP7 PA10 PA12 PA11 Table 12: COMP Outputs redirection to embedded timers COMP1 COMP2 COMP3...
  • Page 140: How To Use This Driver

    Comparators (COMP) UM1581 Table 13: COMP Outputs blanking sources COMP1 COMP2 COMP3 COMP4 COMP5 COMP6 COMP7 TIM1 OC5 TIM1 OC5 TIM1 OC5 TIM3 OC4 TIM3 OC3 TIM2 OC4 TIM1 OC5 TIM3 OC3 TIM3 OC3 TIM2 OC4 TIM15 OC1 TIM8 BKIN TIM15 OC2 TIM15 OC2 TIM2 OC3...
  • Page 141: Initialization And Configuration Functions

    Comparators (COMP) UM1581 5.2.5 Initialization and Configuration functions 5.2.5.1 COMP_DeInit Function Name void COMP_DeInit ( uint32_t COMP_Selection) Function Description Deinitializes COMP peripheral registers to their default reset values.  Parameters COMP_Selection.  Return values None.  Notes Deinitialization can't be performed if the COMP configuration is locked.
  • Page 142 Comparators (COMP) UM1581  COMP_Mode :  Return values None.  Notes If the selected comparator is locked, initialization can't be performed. To unlock the configuration, perform a system reset.  By default, PA1 is selected as COMP1 non inverting input. To use PA4 as COMP1 non inverting input call COMP_SwitchCmd() after COMP_Init() 5.2.5.3...
  • Page 143 Comparators (COMP) UM1581 performed. To unlock the configuration, perform a system reset. 5.2.5.5 COMP_SwitchCmd Function Name void COMP_SwitchCmd ( uint32_t COMP_Selection, FunctionalState NewState) Function Description Close or Open the SW1 switch.  Parameters NewState : New state of the analog switch. This parameter can be ENABLE so the SW1 is closed;...
  • Page 144: Write Mode Control Functions

    Comparators (COMP) UM1581 5.2.6 Write mode control functions 5.2.6.1 COMP_WindowCmd Function Name void COMP_WindowCmd ( uint32_t COMP_Selection, FunctionalState NewState) Function Description Enables or disables the window mode.  Parameters COMP_Selection : the selected comparator. This parameter can be COMP_Selection_COMPx where x can be 2, 4 or 6 to select the COMP peripheral.
  • Page 145: Comp Firmware Driver Defines

    Comparators (COMP) UM1581 COMP Firmware driver defines 5.3.1 COMP COMP COMP_BlankingSrce  #define: COMP_BlankingSrce_None ((uint32_t)0x00000000) No blanking source  #define: COMP_BlankingSrce_TIM1OC5 COMP_CSR_COMPxBLANKING_0 TIM1 OC5 selected as blanking source for compartor  #define: COMP_BlankingSrce_TIM2OC3 COMP_CSR_COMPxBLANKING_1 TIM2 OC5 selected as blanking source for compartor ...
  • Page 146 Comparators (COMP) UM1581 Hysteresis level low  #define: COMP_Hysteresis_Medium COMP_CSR_COMPxHYST_1 Hysteresis level medium  #define: COMP_Hysteresis_High COMP_CSR_COMPxHYST Hysteresis level high COMP_InvertingInput  #define: COMP_InvertingInput_1_4VREFINT ((uint32_t)0x00000000) 1/4 VREFINT connected to comparator inverting input  #define: COMP_InvertingInput_1_2VREFINT COMP_CSR_COMPxINSEL_0 1/2 VREFINT connected to comparator inverting input ...
  • Page 147 Comparators (COMP) UM1581 High Speed  #define: COMP_Mode_MediumSpeed COMP_CSR_COMPxMODE_0 Medium Speed  #define: COMP_Mode_LowPower COMP_CSR_COMPxMODE_1 Low power mode  #define: COMP_Mode_UltraLowPower COMP_CSR_COMPxMODE Ultra-low power mode COMP_NonInvertingInput  #define: COMP_NonInvertingInput_IO1 ((uint32_t)0x00000000) I/O1 (PA1 for COMP1, PA7 for COMP2, PB14 for COMP3, PB0 for COMP4, PD12 for COMP5, PD11 for COMP6, PA0 for COMP7) connected to comparator non inverting input ...
  • Page 148 Comparators (COMP) UM1581 COMP output connected to TIM1 Break Input 2 and TIM8 Break Input 2  #define: COMP_Output_TIM1OCREFCLR ((uint32_t)0x00001800) COMP output connected to TIM1 OCREF Clear  #define: COMP_Output_TIM1IC1 ((uint32_t)0x00001C00) COMP output connected to TIM1 Input Capture 1  #define: COMP_Output_TIM2IC4 ((uint32_t)0x00002000) COMP output connected to TIM2 Input Capture 4 ...
  • Page 149 Comparators (COMP) UM1581 COMP output connected to TIM8 OCREF Clear  #define: COMP_Output_TIM15IC2 ((uint32_t)0x00002000) COMP output connected to TIM15 Input Capture 2  #define: COMP_Output_TIM4IC2 ((uint32_t)0x00002400) COMP output connected to TIM4 Input Capture 2  #define: COMP_Output_TIM15OCREFCLR ((uint32_t)0x00002800) COMP output connected to TIM15 OCREF Clear ...
  • Page 150 Comparators (COMP) UM1581 COMP output connected to TIM4 Input Capture 4  #define: COMP_Output_TIM2IC3 ((uint32_t)0x00002000) COMP output connected to TIM2 Input Capture 3  #define: COMP_Output_TIM1IC2 ((uint32_t)0x00002400) COMP output connected to TIM1 Input Capture 2  #define: COMP_Output_TIM17OCREFCLR ((uint32_t)0x00002800) COMP output connected to TIM16 OCREF Clear ...
  • Page 151 Comparators (COMP) UM1581 COMP3 Selection  #define: COMP_Selection_COMP4 ((uint32_t)0x0000000C) COMP4 Selection  #define: COMP_Selection_COMP5 ((uint32_t)0x00000010) COMP5 Selection  #define: COMP_Selection_COMP6 ((uint32_t)0x00000014) COMP6 Selection  #define: COMP_Selection_COMP7 ((uint32_t)0x00000018) COMP7 Selection DocID023800 Rev 1 151/584...
  • Page 152: Crc Calculation Unit (Crc)

    CRC calculation unit (CRC) UM1581 CRC calculation unit (CRC) CRC Firmware driver registers structures 6.1.1 CRC_TypeDef CRC_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t DR  __IO uint8_t IDR  uint8_t RESERVED0  uint16_t RESERVED1  __IO uint32_t CR ...
  • Page 153: Crc Configuration Functions

    CRC calculation unit (CRC) UM1581 Enable CRC AHB clock using RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE) function. Select the polynomial size: 7-bit, 8-bit, 16-bit or 32-bit. Set the polynomial coefficients using CRC_SetPolynomial(); If required, select the reverse operation on input data using CRC_ReverseInputDataSelect(); If required, enable the reverse operation on output data using CRC_ReverseOutputDataCmd(Enable);...
  • Page 154 CRC calculation unit (CRC) UM1581 6.2.5.2 CRC_ResetDR Function Name void CRC_ResetDR ( void ) Function Description Resets the CRC calculation unit and sets INIT register content in DR register.  Parameters None.  Return values None.  Notes None. 6.2.5.3 CRC_PolynomialSizeSelect Function Name void CRC_PolynomialSizeSelect ( uint32_t CRC_PolSize)
  • Page 155 CRC calculation unit (CRC) UM1581  Parameters CRC_ReverseInputData : Specifies the reverse operation on input data. This parameter can be:  CRC_ReverseInputData_No : No reverse operation is performed  CRC_ReverseInputData_8bits : reverse operation performed on 8 bits  CRC_ReverseInputData_16bits : reverse operation performed on 16 bits ...
  • Page 156: Crc Computation Of One/Many 32-Bit Data Functions

    CRC calculation unit (CRC) UM1581 6.2.5.7 CRC_SetPolynomial Function Name void CRC_SetPolynomial ( uint32_t CRC_Pol) Function Description Initializes the polynomail coefficients.  Parameters CRC_Pol : Polynomial to be used for CRC calculation.  Return values None.  Notes None. 6.2.6 CRC computation of one/many 32-bit data functions 6.2.6.1 CRC_CalcCRC Function Name...
  • Page 157 CRC calculation unit (CRC) UM1581 6.2.6.3 CRC_CalcCRC8bits Function Name uint32_t CRC_CalcCRC8bits ( uint8_t CRC_Data) Function Description Computes the 8-bit CRC of a given 8-bit data.  Parameters CRC_Data : 8-bit data to compute its CRC  Return values 8-bit CRC ...
  • Page 158: Crc Independent Register (Idr) Access Functions

    CRC calculation unit (CRC) UM1581 6.2.7 CRC Independent Register (IDR) access functions 6.2.7.1 CRC_SetIDRegister Function Name void CRC_SetIDRegister ( uint8_t CRC_IDValue) Function Description Stores an 8-bit data in the Independent Data(ID) register.  Parameters CRC_IDValue : 8-bit value to be stored in the ID register ...
  • Page 159 CRC calculation unit (CRC) UM1581  #define: CRC_PolSize_32 ((uint32_t)0x00000000) 32-bit polynomial for CRC calculation CRC_ReverseInputData  #define: CRC_ReverseInputData_No ((uint32_t)0x00000000) No reverse operation of Input Data  #define: CRC_ReverseInputData_8bits CRC_CR_REV_IN_0 Reverse operation of Input Data on 8 bits  #define: CRC_ReverseInputData_16bits CRC_CR_REV_IN_1 Reverse operation of Input Data on 16 bits ...
  • Page 160: Digital-To-Analog Converter (Dac)

    Digital-to-analog converter (DAC) UM1581 Digital-to-analog converter (DAC) DAC Firmware driver registers structures 7.1.1 DAC_TypeDef DAC_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t CR  __IO uint32_t SWTRIGR  __IO uint32_t DHR12R1  __IO uint32_t DHR12L1  __IO uint32_t DHR8R1 ...
  • Page 161: Dac_Inittypedef

    Digital-to-analog converter (DAC) UM1581  __IO uint32_t DAC_TypeDef::DOR1  DAC channel1 data output register, Address offset: 0x2C  __IO uint32_t DAC_TypeDef::DOR2  DAC channel2 data output register, Address offset: 0x30  __IO uint32_t DAC_TypeDef::SR  DAC status register, Address offset: 0x34 7.1.2 DAC_InitTypeDef DAC_InitTypeDef is defined in the stm32f30x_dac.h...
  • Page 162: How To Use This Driver

    Digital-to-analog converter (DAC) UM1581 Digital to Analog conversion can be non-triggered using DAC_Trigger_None and DAC_OUT1/DAC_OUT2 is available once writing to DHRx register using DAC_SetChannel1Data()/DAC_SetChannel2Data. Digital to Analog conversion can be triggered by: External event: EXTI Line 9 (any GPIOx_Pin9) using DAC_Trigger_Ext_IT9. The used pin (GPIOx_Pin9) must be configured in input mode.
  • Page 163: Dac Channels Configuration: Trigger, Output Buffer, Data Format

    Digital-to-analog converter (DAC) UM1581  DAC APB clock must be enabled to get write access to DAC registers using RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);  Configure DAC_OUTx (DAC_OUT1: PA4, DAC_OUT2: PA5) in analog mode.  Configure the DAC channel using DAC_Init();  Enable the DAC channel using DAC_Cmd(); 7.2.3 DAC channels configuration: trigger, output buffer, data format ...
  • Page 164 Digital-to-analog converter (DAC) UM1581 7.2.6.2 DAC_Init Function Name void DAC_Init ( uint32_t DAC_Channel, DAC_InitTypeDef * DAC_InitStruct) Function Description Initializes the DAC peripheral according to the specified parameters in the DAC_InitStruct.  Parameters DAC_Channel : the selected DAC channel. This parameter can be: ...
  • Page 165 Digital-to-analog converter (DAC) UM1581  DAC_Channel_2 : DAC Channel2 selected  NewState : new state of the DAC channel. This parameter can be: ENABLE or DISABLE.  Return values None.  Notes When the DAC channel is enabled the trigger source can no more be modified.
  • Page 166 Digital-to-analog converter (DAC) UM1581 7.2.6.7 DAC_WaveGenerationCmd Function Name void DAC_WaveGenerationCmd ( uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState) Function Description Enables or disables the selected DAC channel wave generation.  Parameters DAC_Channel : The selected DAC channel. This parameter can be: ...
  • Page 167 Digital-to-analog converter (DAC) UM1581 7.2.6.9 DAC_SetChannel2Data Function Name void DAC_SetChannel2Data ( uint32_t DAC_Align, uint16_t Data) Function Description Sets the specified data holding register value for DAC channel2.  Parameters DAC_Align : Specifies the data alignment for DAC channel2. This parameter can be: ...
  • Page 168: Dac Management Functions

    Digital-to-analog converter (DAC) UM1581 7.2.6.11 DAC_GetDataOutputValue Function Name uint16_t DAC_GetDataOutputValue ( uint32_t DAC_Channel) Function Description Returns the last data output value of the selected DAC channel.  Parameters DAC_Channel : The selected DAC channel. This parameter can be:  DAC_Channel_1 : DAC Channel1 selected ...
  • Page 169: Interrupts And Flags Management Functions

    Digital-to-analog converter (DAC) UM1581 7.2.8 Interrupts and flags management functions 7.2.8.1 DAC_ITConfig Function Name void DAC_ITConfig ( uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState) Function Description Enables or disables the specified DAC interrupts.  Parameters DAC_Channel : The selected DAC channel. This parameter can be: ...
  • Page 170 Digital-to-analog converter (DAC) UM1581 7.2.8.3 DAC_ClearFlag Function Name void DAC_ClearFlag ( uint32_t DAC_Channel, uint32_t DAC_FLAG) Function Description Clears the DAC channel's pending flags.  Parameters DAC_Channel : The selected DAC channel. This parameter can be:  DAC_Channel_1 : DAC Channel1 selected ...
  • Page 171: Dac Firmware Driver Defines

    Digital-to-analog converter (DAC) UM1581 7.2.8.5 DAC_ClearITPendingBit Function Name void DAC_ClearITPendingBit ( uint32_t DAC_Channel, uint32_t DAC_IT) Function Description Clears the DAC channel's interrupt pending bits.  Parameters DAC_Channel : The selected DAC channel. This parameter can be:  DAC_Channel_1 : DAC Channel1 selected ...
  • Page 172 Digital-to-analog converter (DAC) UM1581 DAC_flags_definition  #define: DAC_FLAG_DMAUDR ((uint32_t)0x00002000) DAC_interrupts_definition  #define: DAC_IT_DMAUDR ((uint32_t)0x00002000) DAC_lfsrunmask_triangleamplitude  #define: DAC_LFSRUnmask_Bit0 ((uint32_t)0x00000000) Unmask DAC channel LFSR bit0 for noise wave generation  #define: DAC_LFSRUnmask_Bits1_0 ((uint32_t)0x00000100) Unmask DAC channel LFSR bit[1:0] for noise wave generation ...
  • Page 173 Digital-to-analog converter (DAC) UM1581  #define: DAC_LFSRUnmask_Bits9_0 ((uint32_t)0x00000900) Unmask DAC channel LFSR bit[9:0] for noise wave generation  #define: DAC_LFSRUnmask_Bits10_0 ((uint32_t)0x00000A00) Unmask DAC channel LFSR bit[10:0] for noise wave generation  #define: DAC_LFSRUnmask_Bits11_0 ((uint32_t)0x00000B00) Unmask DAC channel LFSR bit[11:0] for noise wave generation ...
  • Page 174 Digital-to-analog converter (DAC) UM1581  #define: DAC_TriangleAmplitude_1023 ((uint32_t)0x00000900) Select max triangle amplitude of 1023  #define: DAC_TriangleAmplitude_2047 ((uint32_t)0x00000A00) Select max triangle amplitude of 2047  #define: DAC_TriangleAmplitude_4095 ((uint32_t)0x00000B00) Select max triangle amplitude of 4095 DAC_output_buffer  #define: DAC_OutputBuffer_Enable ((uint32_t)0x00000000)  #define: DAC_OutputBuffer_Disable ((uint32_t)0x00000002) DAC_trigger_selection ...
  • Page 175 Digital-to-analog converter (DAC) UM1581 TIM8 TRGO selected as external conversion trigger for DAC channel  #define: DAC_Trigger_T15_TRGO ((uint32_t)0x0000001C) TIM15 TRGO selected as external conversion trigger for DAC channel  #define: DAC_Trigger_Ext_IT9 ((uint32_t)0x00000034) EXTI Line9 event selected as external conversion trigger for DAC channel ...
  • Page 176: Debug Support (Dbgmcu)

    Debug support (DBGMCU) UM1581 Debug support (DBGMCU) DBGMCU Firmware driver registers structures 8.1.1 DBGMCU_TypeDef DBGMCU_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t IDCODE  __IO uint32_t CR  __IO uint32_t APB1FZ  __IO uint32_t APB2FZ Field Documentation ...
  • Page 177: Device And Revision Id Management Functions

    Debug support (DBGMCU) UM1581 8.2.3 Device and Revision ID management functions 8.2.3.1 DBGMCU_GetREVID Function Name uint32_t DBGMCU_GetREVID ( void ) Function Description Returns the device revision identifier.  Parameters None.  Return values Device revision identifier  Notes None. 8.2.3.2 DBGMCU_GetDEVID Function Name uint32_t DBGMCU_GetDEVID ( void )
  • Page 178 Debug support (DBGMCU) UM1581 during STANDBY mode.  NewState : new state of the specified low power mode in Debug mode. This parameter can be: ENABLE or DISABLE.  Return values None.  Notes None. 8.2.4.2 DBGMCU_APB1PeriphConfig Function Name void DBGMCU_APB1PeriphConfig ( uint32_t DBGMCU_Periph, FunctionalState NewState)
  • Page 179: Dbgmcu Firmware Driver Defines

    Debug support (DBGMCU) UM1581 8.2.4.3 DBGMCU_APB2PeriphConfig Function Name void DBGMCU_APB2PeriphConfig ( uint32_t DBGMCU_Periph, FunctionalState NewState) Function Description Configures APB2 peripheral behavior when the MCU is in Debug mode.  Parameters DBGMCU_Periph : specifies the APB2 peripheral. This parameter can be any combination of the following values: ...
  • Page 180 Debug support (DBGMCU) UM1581  #define: DBGMCU_TIM3_STOP ((uint32_t)0x00000002)  #define: DBGMCU_TIM4_STOP ((uint32_t)0x00000004)  #define: DBGMCU_TIM6_STOP ((uint32_t)0x00000010)  #define: DBGMCU_TIM7_STOP ((uint32_t)0x00000020)  #define: DBGMCU_RTC_STOP ((uint32_t)0x00000400)  #define: DBGMCU_WWDG_STOP ((uint32_t)0x00000800)  #define: DBGMCU_IWDG_STOP ((uint32_t)0x00001000)  #define: DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00200000)  #define: DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00400000) ...
  • Page 181 Debug support (DBGMCU) UM1581  #define: DBGMCU_TIM15_STOP ((uint32_t)0x00000004)  #define: DBGMCU_TIM16_STOP ((uint32_t)0x00000008)  #define: DBGMCU_TIM17_STOP ((uint32_t)0x00000010) DocID023800 Rev 1 181/584...
  • Page 182: Dma Controller (Dma)

    DMA controller (DMA) UM1581 DMA controller (DMA) DMA Firmware driver registers structures 9.1.1 DMA_Channel_TypeDef DMA_Channel_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t CCR  __IO uint32_t CNDTR  __IO uint32_t CPAR  __IO uint32_t CMAR Field Documentation ...
  • Page 183 DMA controller (DMA) UM1581 Data Fields  uint32_t DMA_PeripheralBaseAddr  uint32_t DMA_MemoryBaseAddr  uint32_t DMA_DIR  uint16_t DMA_BufferSize  uint32_t DMA_PeripheralInc  uint32_t DMA_MemoryInc  uint32_t DMA_PeripheralDataSize  uint32_t DMA_MemoryDataSize  uint32_t DMA_Mode  uint32_t DMA_Priority  uint32_t DMA_M2M Field Documentation ...
  • Page 184: Dma Firmware Driver Api Description

    DMA controller (DMA) UM1581 DMA Firmware driver API description The following section lists the various functions of the DMA library. 9.2.1 How to use this driver Enable The DMA controller clock using RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE) function for DMA1 or using RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE) function for DMA2.
  • Page 185: Data Counter Functions

    DMA controller (DMA) UM1581 9.2.3 Data Counter functions This subsection provides function allowing to configure and read the buffer size (number of data to be transferred).The DMA data counter can be written only when the DMA channel is disabled (ie. after transfer complete event). The following function can be used to write the Channel data counter value: ...
  • Page 186: Initialization And Configuration Functions

    DMA controller (DMA) UM1581  void DMA_ClearFlag(uint32_t DMA_FLAG); Interrupt Mode Each DMA channel can be managed through 4 Interrupts:  Interrupt Source DMA_IT_TC: specifies the interrupt source for the Transfer Complete event. DMA_IT_HT: specifies the interrupt source for the Half-transfer Complete event. DMA_IT_TE: specifies the interrupt source for the transfer errors event.
  • Page 187 DMA controller (DMA) UM1581 parameters in the DMA_InitStruct.  Parameters DMAy_Channelx : where y can be 1 or 2 to select the DMA and x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
  • Page 188: Data Counter Functions

    DMA controller (DMA) UM1581 9.2.6 Data counter functions 9.2.6.1 DMA_SetCurrDataCounter Function Name void DMA_SetCurrDataCounter ( DMA_Channel_TypeDef * DMAy_Channelx, uint16_t DataNumber) Function Description Sets the number of data units in the current DMAy Channelx transfer.  Parameters DMAy_Channelx : where y can be 1 or 2 to select the DMA and x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
  • Page 189: Interrupts And Flags Management Functions

    DMA controller (DMA) UM1581 9.2.7 Interrupts and flags management functions 9.2.7.1 DMA_ITConfig Function Name void DMA_ITConfig ( DMA_Channel_TypeDef * DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState) Function Description Enables or disables the specified DMAy Channelx interrupts.  Parameters DMAy_Channelx : where y can be 1 or 2 to select the DMA and x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
  • Page 190 DMA controller (DMA) UM1581  DMA1_FLAG_HT3 : DMA1 Channel3 half transfer flag.  DMA1_FLAG_TE3 : DMA1 Channel3 transfer error flag.  DMA1_FLAG_GL4 : DMA1 Channel4 global flag.  DMA1_FLAG_TC4 : DMA1 Channel4 transfer complete flag.  DMA1_FLAG_HT4 : DMA1 Channel4 half transfer flag. ...
  • Page 191 DMA controller (DMA) UM1581 9.2.7.3 DMA_ClearFlag Function Name void DMA_ClearFlag ( uint32_t DMAy_FLAG) Function Description Clears the DMAy Channelx's pending flags.  Parameters DMAy_FLAG : specifies the flag to clear. This parameter can be any combination (for the same DMA) of the following values: ...
  • Page 192 DMA controller (DMA) UM1581  DMA2_FLAG_HT1 : DMA2 Channel1 half transfer flag.  DMA2_FLAG_TE1 : DMA2 Channel1 transfer error flag.  DMA2_FLAG_GL2 : DMA2 Channel2 global flag.  DMA2_FLAG_TC2 : DMA2 Channel2 transfer complete flag.  DMA2_FLAG_HT2 : DMA2 Channel2 half transfer flag. ...
  • Page 193 DMA controller (DMA) UM1581  DMA1_IT_HT2 : DMA1 Channel2 half transfer interrupt.  DMA1_IT_TE2 : DMA1 Channel2 transfer error interrupt.  DMA1_IT_GL3 : DMA1 Channel3 global interrupt.  DMA1_IT_TC3 : DMA1 Channel3 transfer complete interrupt.  DMA1_IT_HT3 : DMA1 Channel3 half transfer interrupt. ...
  • Page 194 DMA controller (DMA) UM1581 interrupt.  DMA2_IT_HT4 : DMA2 Channel4 half transfer interrupt.  DMA2_IT_TE4 : DMA2 Channel4 transfer error interrupt.  DMA2_IT_GL5 : DMA2 Channel5 global interrupt.  DMA2_IT_TC5 : DMA2 Channel5 transfer complete interrupt.  DMA2_IT_HT5 : DMA2 Channel5 half transfer interrupt. ...
  • Page 195 DMA controller (DMA) UM1581  DMA1_IT_TE4 : DMA1 Channel4 transfer error interrupt.  DMA1_IT_GL5 : DMA1 Channel5 global interrupt.  DMA1_IT_TC5 : DMA1 Channel5 transfer complete interrupt.  DMA1_IT_HT5 : DMA1 Channel5 half transfer interrupt.  DMA1_IT_TE5 : DMA1 Channel5 transfer error interrupt.
  • Page 196: Dma Firmware Driver Defines

    DMA controller (DMA) UM1581 clearing all other interrupts relative to the same channel (Transfer Complete, Half-transfer Complete and Transfer Error interrupts: DMAy_IT_TCx, DMAy_IT_HTx and DMAy_IT_TEx). DMA Firmware driver defines 9.3.1 DMA_circular_normal_mode  #define: DMA_Mode_Normal ((uint32_t)0x00000000)  #define: DMA_Mode_Circular DMA_CCR_CIRC DMA_data_transfer_direction ...
  • Page 197 DMA controller (DMA) UM1581  #define: DMA1_FLAG_GL2 ((uint32_t)0x00000010)  #define: DMA1_FLAG_TC2 ((uint32_t)0x00000020)  #define: DMA1_FLAG_HT2 ((uint32_t)0x00000040)  #define: DMA1_FLAG_TE2 ((uint32_t)0x00000080)  #define: DMA1_FLAG_GL3 ((uint32_t)0x00000100)  #define: DMA1_FLAG_TC3 ((uint32_t)0x00000200)  #define: DMA1_FLAG_HT3 ((uint32_t)0x00000400)  #define: DMA1_FLAG_TE3 ((uint32_t)0x00000800)  #define: DMA1_FLAG_GL4 ((uint32_t)0x00001000) ...
  • Page 198 DMA controller (DMA) UM1581  #define: DMA1_FLAG_GL5 ((uint32_t)0x00010000)  #define: DMA1_FLAG_TC5 ((uint32_t)0x00020000)  #define: DMA1_FLAG_HT5 ((uint32_t)0x00040000)  #define: DMA1_FLAG_TE5 ((uint32_t)0x00080000)  #define: DMA1_FLAG_GL6 ((uint32_t)0x00100000)  #define: DMA1_FLAG_TC6 ((uint32_t)0x00200000)  #define: DMA1_FLAG_HT6 ((uint32_t)0x00400000)  #define: DMA1_FLAG_TE6 ((uint32_t)0x00800000)  #define: DMA1_FLAG_GL7 ((uint32_t)0x01000000) ...
  • Page 199 DMA controller (DMA) UM1581  #define: DMA2_FLAG_GL1 ((uint32_t)0x10000001)  #define: DMA2_FLAG_TC1 ((uint32_t)0x10000002)  #define: DMA2_FLAG_HT1 ((uint32_t)0x10000004)  #define: DMA2_FLAG_TE1 ((uint32_t)0x10000008)  #define: DMA2_FLAG_GL2 ((uint32_t)0x10000010)  #define: DMA2_FLAG_TC2 ((uint32_t)0x10000020)  #define: DMA2_FLAG_HT2 ((uint32_t)0x10000040)  #define: DMA2_FLAG_TE2 ((uint32_t)0x10000080)  #define: DMA2_FLAG_GL3 ((uint32_t)0x10000100) ...
  • Page 200 DMA controller (DMA) UM1581  #define: DMA2_FLAG_GL4 ((uint32_t)0x10001000)  #define: DMA2_FLAG_TC4 ((uint32_t)0x10002000)  #define: DMA2_FLAG_HT4 ((uint32_t)0x10004000)  #define: DMA2_FLAG_TE4 ((uint32_t)0x10008000)  #define: DMA2_FLAG_GL5 ((uint32_t)0x10010000)  #define: DMA2_FLAG_TC5 ((uint32_t)0x10020000)  #define: DMA2_FLAG_HT5 ((uint32_t)0x10040000)  #define: DMA2_FLAG_TE5 ((uint32_t)0x10080000) DMA_interrupts_definition  #define: DMA_IT_TC ((uint32_t)0x00000002) ...
  • Page 201 DMA controller (DMA) UM1581  #define: DMA1_IT_TC1 ((uint32_t)0x00000002)  #define: DMA1_IT_HT1 ((uint32_t)0x00000004)  #define: DMA1_IT_TE1 ((uint32_t)0x00000008)  #define: DMA1_IT_GL2 ((uint32_t)0x00000010)  #define: DMA1_IT_TC2 ((uint32_t)0x00000020)  #define: DMA1_IT_HT2 ((uint32_t)0x00000040)  #define: DMA1_IT_TE2 ((uint32_t)0x00000080)  #define: DMA1_IT_GL3 ((uint32_t)0x00000100)  #define: DMA1_IT_TC3 ((uint32_t)0x00000200) ...
  • Page 202 DMA controller (DMA) UM1581  #define: DMA1_IT_TC4 ((uint32_t)0x00002000)  #define: DMA1_IT_HT4 ((uint32_t)0x00004000)  #define: DMA1_IT_TE4 ((uint32_t)0x00008000)  #define: DMA1_IT_GL5 ((uint32_t)0x00010000)  #define: DMA1_IT_TC5 ((uint32_t)0x00020000)  #define: DMA1_IT_HT5 ((uint32_t)0x00040000)  #define: DMA1_IT_TE5 ((uint32_t)0x00080000)  #define: DMA1_IT_GL6 ((uint32_t)0x00100000)  #define: DMA1_IT_TC6 ((uint32_t)0x00200000) ...
  • Page 203 DMA controller (DMA) UM1581  #define: DMA1_IT_TC7 ((uint32_t)0x02000000)  #define: DMA1_IT_HT7 ((uint32_t)0x04000000)  #define: DMA1_IT_TE7 ((uint32_t)0x08000000)  #define: DMA2_IT_GL1 ((uint32_t)0x10000001)  #define: DMA2_IT_TC1 ((uint32_t)0x10000002)  #define: DMA2_IT_HT1 ((uint32_t)0x10000004)  #define: DMA2_IT_TE1 ((uint32_t)0x10000008)  #define: DMA2_IT_GL2 ((uint32_t)0x10000010)  #define: DMA2_IT_TC2 ((uint32_t)0x10000020) ...
  • Page 204 DMA controller (DMA) UM1581  #define: DMA2_IT_TC3 ((uint32_t)0x10000200)  #define: DMA2_IT_HT3 ((uint32_t)0x10000400)  #define: DMA2_IT_TE3 ((uint32_t)0x10000800)  #define: DMA2_IT_GL4 ((uint32_t)0x10001000)  #define: DMA2_IT_TC4 ((uint32_t)0x10002000)  #define: DMA2_IT_HT4 ((uint32_t)0x10004000)  #define: DMA2_IT_TE4 ((uint32_t)0x10008000)  #define: DMA2_IT_GL5 ((uint32_t)0x10010000)  #define: DMA2_IT_TC5 ((uint32_t)0x10020000) ...
  • Page 205 DMA controller (DMA) UM1581  #define: DMA_MemoryDataSize_Byte ((uint32_t)0x00000000)  #define: DMA_MemoryDataSize_HalfWord DMA_CCR_MSIZE_0  #define: DMA_MemoryDataSize_Word DMA_CCR_MSIZE_1 DMA_memory_incremented_mode  #define: DMA_MemoryInc_Disable ((uint32_t)0x00000000)  #define: DMA_MemoryInc_Enable DMA_CCR_MINC DMA_memory_to_memory  #define: DMA_M2M_Disable ((uint32_t)0x00000000)  #define: DMA_M2M_Enable DMA_CCR_MEM2MEM DMA_peripheral_data_size  #define: DMA_PeripheralDataSize_Byte ((uint32_t)0x00000000)  #define: DMA_PeripheralDataSize_HalfWord DMA_CCR_PSIZE_0 ...
  • Page 206 DMA controller (DMA) UM1581  #define: DMA_PeripheralInc_Enable DMA_CCR_PINC DMA_priority_level  #define: DMA_Priority_VeryHigh DMA_CCR_PL  #define: DMA_Priority_High DMA_CCR_PL_1  #define: DMA_Priority_Medium DMA_CCR_PL_0  #define: DMA_Priority_Low ((uint32_t)0x00000000) 206/584 DocID023800 Rev 1...
  • Page 207: External Interrupt/Event Controller (Exti)

    External interrupt/event controller (EXTI) UM1581 External interrupt/event controller (EXTI) 10.1 EXTI Firmware driver registers structures 10.1.1 EXTI_TypeDef EXTI_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t IMR  __IO uint32_t EMR  __IO uint32_t RTSR  __IO uint32_t FTSR ...
  • Page 208: Exti_Inittypedef

    External interrupt/event controller (EXTI) UM1581  __IO uint32_t EXTI_TypeDef::FTSR2  EXTI Falling trigger selection register, Address offset: 0x2C  __IO uint32_t EXTI_TypeDef::SWIER2  EXTI Software interrupt event register, Address offset: 0x30  __IO uint32_t EXTI_TypeDef::PR2  EXTI Pending register, Address offset: 0x34 10.1.2 EXTI_InitTypeDef EXTI_InitTypeDef is defined in the stm32f30x_exti.h...
  • Page 209: How To Use This Driver

    External interrupt/event controller (EXTI) UM1581 EXTI line 22 is connected to the Comparator 2 wakeup event EXTI line 23 is connected to the I2C1 wakeup event 10. EXTI line 24 is connected to the I2C2 wakeup event 11. EXTI line 25 is connected to the USART1 wakeup event 12.
  • Page 210: Initialization And Configuration Functions

    External interrupt/event controller (EXTI) UM1581 10.2.5 Initialization and Configuration functions 10.2.5.1 EXTI_DeInit Function Name void EXTI_DeInit ( void ) Function Description Deinitializes the EXTI peripheral registers to their default reset values.  Parameters None.  Return values None.  Notes None.
  • Page 211: Interrupts And Flags Management Functions

    External interrupt/event controller (EXTI) UM1581 10.2.5.4 EXTI_GenerateSWInterrupt Function Name void EXTI_GenerateSWInterrupt ( uint32_t EXTI_Line) Function Description Generates a Software interrupt on selected EXTI line.  Parameters EXTI_Line : specifies the EXTI line on which the software interrupt will be generated. This parameter can be any combination of EXTI_Linex where x can be (0..20).
  • Page 212: Exti Firmware Driver Defines

    External interrupt/event controller (EXTI) UM1581  Return values None.  Notes None. 10.2.6.3 EXTI_GetITStatus Function Name ITStatus EXTI_GetITStatus ( uint32_t EXTI_Line) Function Description Checks whether the specified EXTI line is asserted or not.  Parameters EXTI_Line : specifies the EXTI line to check. This parameter can be any combination of EXTI_Linex where x can be (0..20).
  • Page 213 External interrupt/event controller (EXTI) UM1581 External interrupt line 0  #define: EXTI_Line1 ((uint32_t)0x01) External interrupt line 1  #define: EXTI_Line2 ((uint32_t)0x02) External interrupt line 2  #define: EXTI_Line3 ((uint32_t)0x03) External interrupt line 3  #define: EXTI_Line4 ((uint32_t)0x04) External interrupt line 4 ...
  • Page 214 External interrupt/event controller (EXTI) UM1581 External interrupt line 12  #define: EXTI_Line13 ((uint32_t)0x0D) External interrupt line 13  #define: EXTI_Line14 ((uint32_t)0x0E) External interrupt line 14  #define: EXTI_Line15 ((uint32_t)0x0F) External interrupt line 15  #define: EXTI_Line16 ((uint32_t)0x10) External interrupt line 16 Connected to the PVD Output ...
  • Page 215 External interrupt/event controller (EXTI) UM1581 Internal interrupt line 24 Connected to the I2C2 wakeup event  #define: EXTI_Line25 ((uint32_t)0x19) Internal interrupt line 25 Connected to the USART1 wakeup event  #define: EXTI_Line26 ((uint32_t)0x1A) Internal interrupt line 26 Connected to the USART2 wakeup event ...
  • Page 216: Flash Memory (Flash)

    FLASH Memory (FLASH) UM1581 FLASH Memory (FLASH) 11.1 FLASH Firmware driver registers structures 11.1.1 FLASH_TypeDef FLASH_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t ACR  __IO uint32_t KEYR  __IO uint32_t OPTKEYR  __IO uint32_t SR  __IO uint32_t CR ...
  • Page 217: Flash Firmware Driver Api Description

    FLASH Memory (FLASH) UM1581  __IO uint16_t RDP  __IO uint16_t USER  uint16_t RESERVED0  uint16_t RESERVED1  __IO uint16_t WRP0  __IO uint16_t WRP1  __IO uint16_t WRP2  __IO uint16_t WRP3 Field Documentation  __IO uint16_t OB_TypeDef::RDP ...
  • Page 218: Flash Interface Configuration Functions

    FLASH Memory (FLASH) UM1581  Launch the Option Bytes loader  Erase the Option Bytes  Set/Reset the write protection  Set the Read protection Level  Program the user option Bytes  Set/Reset the BOOT1 bit  Enable/Disable the VDDA Analog Monitoring ...
  • Page 219: Option Bytes Programming Functions

    FLASH Memory (FLASH) UM1581  FLASH_EraseAllPages()  FLASH_ProgramWord()  FLASH_ProgramHalfWord() 11.2.4 Option Bytes Programming functions This group includes the following functions:  void FLASH_OB_Unlock(void);  void FLASH_OB_Lock(void);  void FLASH_OB_Erase(void);  FLASH_Status FLASH_OB_WRPConfig(uint32_t OB_WRP, FunctionalState NewState);  FLASH_Status FLASH_OB_RDPConfig(uint8_t OB_RDP); ...
  • Page 220: Interrupts And Flags Management Functions

    FLASH Memory (FLASH) UM1581  FLASH_OB_Launch()  FLASH_OB_Erase()  FLASH_OB_EnableWRP()  FLASH_OB_RDPConfig()  FLASH_OB_UserConfig()  FLASH_OB_BOOTConfig()  FLASH_OB_VDDAConfig()  FLASH_OB_SRAMParityConfig()  FLASH_OB_WriteUser()  FLASH_ProgramOptionByteData()  FLASH_OB_GetUser()  FLASH_OB_GetWRP()  FLASH_OB_GetRDP() 11.2.5 Interrupts and flags management functions  FLASH_ITConfig()  FLASH_GetFlagStatus() ...
  • Page 221: Flash Memory Programming Functions

    FLASH Memory (FLASH) UM1581 Function Description Enables or disables the Half cycle flash access.  Parameters FLASH_HalfCycleAccess : specifies the FLASH Half cycle Access mode. This parameter can be one of the following values:  FLASH_HalfCycleAccess_Enable : FLASH Half Cycle Enable ...
  • Page 222 FLASH Memory (FLASH) UM1581 11.2.7.2 FLASH_Lock Function Name void FLASH_Lock ( void ) Function Description Locks the FLASH control register access.  Parameters None.  Return values None.  Notes None. 11.2.7.3 FLASH_ErasePage Function Name FLASH_Status FLASH_ErasePage ( uint32_t Page_Address) Function Description Erases a specified page in program memory.
  • Page 223 FLASH Memory (FLASH) UM1581 FLASH_COMPLETE or FLASH_TIMEOUT.  Notes To correctly run this function, the FLASH_Unlock() function must be called before. all the FLASH_Lock() to disable the flash memory access (recommended to protect the FLASH memory against possible unwanted operation) 11.2.7.5 FLASH_ProgramWord Function Name...
  • Page 224: Option Bytes Programming Functions

    FLASH Memory (FLASH) UM1581 11.2.8 Option Bytes Programming functions 11.2.8.1 FLASH_OB_Unlock Function Name void FLASH_OB_Unlock ( void ) Function Description Unlocks the option bytes block access.  Parameters None.  Return values None.  Notes None. 11.2.8.2 FLASH_OB_Lock Function Name void FLASH_OB_Lock ( void ) Function Description Locks the option bytes block access.
  • Page 225 FLASH Memory (FLASH) UM1581 11.2.8.4 FLASH_OB_Erase Function Name FLASH_Status FLASH_OB_Erase ( void ) Function Description Erases the FLASH option bytes.  Parameters None.  Return values FLASH Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.  Notes This functions erases all option bytes except the Read protection (RDP).
  • Page 226 FLASH Memory (FLASH) UM1581 Function Description Enables or disables the read out protection.  Parameters FLASH_ReadProtection_Level : specifies the read protection level. This parameter can be:  OB_RDP_Level_0 : No protection  OB_RDP_Level_1 : Read protection of the memory  OB_RDP_Level_2 : Chip protection ...
  • Page 227 FLASH Memory (FLASH) UM1581 11.2.8.8 FLASH_OB_BOOTConfig Function Name FLASH_Status FLASH_OB_BOOTConfig ( uint8_t OB_BOOT1) Function Description Sets or resets the BOOT1.  Parameters OB_BOOT1 : Set or Reset the BOOT1. This parameter can be one of the following values:  OB_BOOT1_RESET : BOOT1 Reset ...
  • Page 228 FLASH Memory (FLASH) UM1581  Parameters OB_SRAM_Parity : Set or Reset the SRAM partiy enable bit. This parameter can be one of the following values:  OB_SRAM_PARITY_SET : Set SRAM partiy.  OB_SRAM_PARITY_RESET : Reset SRAM partiy.  Return values None.
  • Page 229 FLASH Memory (FLASH) UM1581 Function Description Programs a half word at a specified Option Byte Data address.  Parameters Address : specifies the address to be programmed. This parameter can be 0x1FFFF804 or 0x1FFFF806.  Data : specifies the data to be programmed. ...
  • Page 230: Interrupts And Flags Management Functions

    FLASH Memory (FLASH) UM1581 11.2.8.15 FLASH_OB_GetRDP Function Name FlagStatus FLASH_OB_GetRDP ( void ) Function Description Checks whether the FLASH Read out Protection Status is set or not.  Parameters None.  Return values FLASH ReadOut Protection Status(SET or RESET)  Notes None.
  • Page 231 FLASH Memory (FLASH) UM1581 flag flag  FLASH_FLAG_WRPERR : FLASH Write protected error flag  FLASH_FLAG_EOP : FLASH End of Programming flag  Return values The new state of FLASH_FLAG (SET or RESET).  Notes None. 11.2.9.3 FLASH_ClearFlag Function Name void FLASH_ClearFlag ( uint32_t FLASH_FLAG) Function Description Clears the FLASH's pending flags.
  • Page 232: Flash Firmware Driver Defines

    FLASH Memory (FLASH) UM1581 11.2.9.5 FLASH_WaitForLastOperation Function Name FLASH_Status FLASH_WaitForLastOperation ( uint32_t Timeout) Function Description Waits for a FLASH operation to complete or a TIMEOUT to occur.  Parameters Timeout : FLASH programming Timeout  Return values FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
  • Page 233 FLASH Memory (FLASH) UM1581 Flash_Latency  #define: FLASH_Latency_0 ((uint8_t)0x0000) FLASH Zero Latency cycle  #define: FLASH_Latency_1 FLASH_ACR_LATENCY_0 FLASH One Latency cycle  #define: FLASH_Latency_2 FLASH_ACR_LATENCY_1 FLASH Two Latency cycles FLASH_Option_Bytes_SRAM_Parity_Enable  #define: OB_SRAM_PARITY_SET ((uint8_t)0x00) SRAM parity enable Set  #define: OB_SRAM_PARITY_RESET ((uint8_t)0x40) SRAM parity enable reset DocID023800 Rev 1 233/584...
  • Page 234: General-Purpose I/Os (Gpio)

    General-purpose I/Os (GPIO) UM1581 General-purpose I/Os (GPIO) 12.1 GPIO Firmware driver registers structures 12.1.1 GPIO_TypeDef GPIO_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t MODER  __IO uint16_t OTYPER  uint16_t RESERVED0  __IO uint32_t OSPEEDR  __IO uint32_t PUPDR ...
  • Page 235: Gpio_Inittypedef

    General-purpose I/Os (GPIO) UM1581  __IO uint32_t GPIO_TypeDef::AFR[2]  GPIO alternate function low register, Address offset: 0x20-0x24  __IO uint16_t GPIO_TypeDef::BRR  GPIO bit reset register, Address offset: 0x28  uint16_t GPIO_TypeDef::RESERVED3  Reserved, 0x2A 12.1.2 GPIO_InitTypeDef GPIO_InitTypeDef is defined in the stm32f30x_gpio.h Data Fields ...
  • Page 236: Initialization And Configuration

    General-purpose I/Os (GPIO) UM1581  Input: Floating, Pull-up, Pull-down.  Output: Push-Pull (Pull-up, Pull-down or no Pull), Open Drain (Pull-up, Pull-down or no Pull). In output mode, the speed is configurable: Low, Medium, Fast or High.  Alternate Function: Push-Pull (Pull-up, Pull-down or no Pull), Open Drain (Pull- up, Pull-down or no Pull).
  • Page 237: Initialization And Configuration

    General-purpose I/Os (GPIO) UM1581  GPIO_PinAFConfig() 12.2.5 Initialization and Configuration 12.2.5.1 GPIO_DeInit Function Name void GPIO_DeInit ( GPIO_TypeDef * GPIOx) Function Description Deinitializes the GPIOx peripheral registers to their default reset values.  Parameters GPIOx : where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
  • Page 238: Gpio Read And Write Functions

    General-purpose I/Os (GPIO) UM1581 Function Description Fills each GPIO_InitStruct member with its default value.  Parameters GPIO_InitStruct : pointer to a GPIO_InitTypeDef structure which will be initialized.  Return values None.  Notes None. 12.2.5.4 GPIO_PinLockConfig Function Name void GPIO_PinLockConfig ( GPIO_TypeDef * GPIOx, uint16_t GPIO_Pin)
  • Page 239 General-purpose I/Os (GPIO) UM1581 12.2.6.2 GPIO_ReadInputData Function Name uint16_t GPIO_ReadInputData ( GPIO_TypeDef * GPIOx) Function Description Reads the specified input port pin.  Parameters GPIOx : where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
  • Page 240 General-purpose I/Os (GPIO) UM1581  Return values GPIO output data port value.  Notes None. 12.2.6.5 GPIO_SetBits Function Name void GPIO_SetBits ( GPIO_TypeDef * GPIOx, uint16_t GPIO_Pin) Function Description Sets the selected data port bits.  Parameters GPIOx : where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
  • Page 241: Gpio Alternate Functions Configuration Functions

    General-purpose I/Os (GPIO) UM1581 Function Name void GPIO_WriteBit ( GPIO_TypeDef * GPIOx, uint16_t GPIO_Pin, BitAction BitVal) Function Description Sets or clears the selected data port bit.  Parameters GPIOx : where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
  • Page 242: Gpio Firmware Driver Defines

    General-purpose I/Os (GPIO) UM1581 Function Description Writes data to the specified GPIO data port.  Parameters GPIOx : where x can be (A, B, C, D, E or F) to select the GPIO peripheral.  GPIO_PinSource : specifies the pin for the Alternate function.
  • Page 243 General-purpose I/Os (GPIO) UM1581  #define: GPIO_AF_1 ((uint8_t)0x01)  #define: GPIO_AF_2 ((uint8_t)0x02)  #define: GPIO_AF_3 ((uint8_t)0x03)  #define: GPIO_AF_4 ((uint8_t)0x04)  #define: GPIO_AF_5 ((uint8_t)0x05)  #define: GPIO_AF_6 ((uint8_t)0x06)  #define: GPIO_AF_7 ((uint8_t)0x07)  #define: GPIO_AF_8 ((uint8_t)0x08)  #define: GPIO_AF_9 ((uint8_t)0x09) ...
  • Page 244 General-purpose I/Os (GPIO) UM1581  #define: GPIO_AF_14 ((uint8_t)0x0E)  #define: GPIO_AF_15 ((uint8_t)0x0F) GPIO_pins_define  #define: GPIO_Pin_0 ((uint16_t)0x0001) Pin 0 selected  #define: GPIO_Pin_1 ((uint16_t)0x0002) Pin 1 selected  #define: GPIO_Pin_2 ((uint16_t)0x0004) Pin 2 selected  #define: GPIO_Pin_3 ((uint16_t)0x0008) Pin 3 selected ...
  • Page 245 General-purpose I/Os (GPIO) UM1581  #define: GPIO_Pin_9 ((uint16_t)0x0200) Pin 9 selected  #define: GPIO_Pin_10 ((uint16_t)0x0400) Pin 10 selected  #define: GPIO_Pin_11 ((uint16_t)0x0800) Pin 11 selected  #define: GPIO_Pin_12 ((uint16_t)0x1000) Pin 12 selected  #define: GPIO_Pin_13 ((uint16_t)0x2000) Pin 13 selected  #define: GPIO_Pin_14 ((uint16_t)0x4000) Pin 14 selected ...
  • Page 246 General-purpose I/Os (GPIO) UM1581  #define: GPIO_PinSource4 ((uint8_t)0x04)  #define: GPIO_PinSource5 ((uint8_t)0x05)  #define: GPIO_PinSource6 ((uint8_t)0x06)  #define: GPIO_PinSource7 ((uint8_t)0x07)  #define: GPIO_PinSource8 ((uint8_t)0x08)  #define: GPIO_PinSource9 ((uint8_t)0x09)  #define: GPIO_PinSource10 ((uint8_t)0x0A)  #define: GPIO_PinSource11 ((uint8_t)0x0B)  #define: GPIO_PinSource12 ((uint8_t)0x0C) ...
  • Page 247: Inter-Integrated Circuit Interface (I2C)

    Inter-integrated circuit interface (I2C) UM1581 Inter-integrated circuit interface (I2C) 13.1 I2C Firmware driver registers structures 13.1.1 I2C_TypeDef I2C_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t CR1  __IO uint32_t CR2  __IO uint32_t OAR1  __IO uint32_t OAR2 ...
  • Page 248: I2C_Inittypedef

    Inter-integrated circuit interface (I2C) UM1581 13.1.2 I2C_InitTypeDef I2C_InitTypeDef is defined in the stm32f30x_i2c.h Data Fields  uint32_t I2C_Timing  uint32_t I2C_AnalogFilter  uint32_t I2C_DigitalFilter  uint32_t I2C_Mode  uint32_t I2C_OwnAddress1  uint32_t I2C_Ack  uint32_t I2C_AcknowledgedAddress Field Documentation  uint32_t I2C_InitTypeDef::I2C_Timing ...
  • Page 249: Initialization And Configuration Functions

    Inter-integrated circuit interface (I2C) UM1581  Connect the pin to the desired peripherals' Alternate Function (AF) using GPIO_PinAFConfig() function.  Configure the desired pin in alternate function by: GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF  Select the type, OpenDrain and speed via GPIO_PuPd, GPIO_OType and GPIO_Speed members ...
  • Page 250: Communications Handling Functions

    Inter-integrated circuit interface (I2C) UM1581  I2C_Cmd()  I2C_SoftwareResetCmd()  I2C_ITConfig()  I2C_StretchClockCmd()  I2C_StopModeCmd()  I2C_DualAddressCmd()  I2C_OwnAddress2Config()  I2C_GeneralCallCmd()  I2C_SlaveByteControlCmd()  I2C_SlaveAddressConfig()  I2C_10BitAddressingModeCmd() 13.2.3 Communications handling functions This section provides a set of functions that handles I2C communication. Automatic End mode is enabled using I2C_AutoEndCmd() function.
  • Page 251: I2C Registers Management Functions

    Inter-integrated circuit interface (I2C) UM1581 The SMBus Host address (0b0001 000) is enabled by calling I2C_Init() function and setting I2C_Mode member of I2C_InitTypeDef() structure to I2C_Mode_SMBusHost. The Alert Response Address (0b0001 100) is enabled using I2C_SMBusAlertCmd() function. To detect cumulative SCL stretch in master and slave mode, TIMEOUTB should be configured (in accordance to SMBus specification) using I2C_TimeoutBConfig() function then I2C_ExtendedClockTimeoutCmd() function should be called to enable the detection.
  • Page 252: Interrupts And Flags Management Functions

    Inter-integrated circuit interface (I2C) UM1581 13.2.8 Interrupts and flags management functions This section provides functions allowing to configure the I2C Interrupts sources and check or clear the flags or pending bits status. The user should identify which mode will be used in his application to manage the communication: Polling mode, Interrupt mode or DMA mode(refer I2C_Group6) .
  • Page 253: Initialization And Configuration Functions

    Inter-integrated circuit interface (I2C) UM1581 I2C_IT_NACKF: to indicate the status of NACK received flag. I2C_IT_STOPF: to indicate the status of STOP detection flag. I2C_IT_TC: to indicate the status of Transfer complete flag (master mode). I2C_IT_TCR: to indicate the status of Transfer complete reload flag. I2C_IT_BERR: to indicate the status of Bus error flag.
  • Page 254 Inter-integrated circuit interface (I2C) UM1581  Notes None. 13.2.9.3 I2C_StructInit Function Name void I2C_StructInit ( I2C_InitTypeDef * I2C_InitStruct) Function Description Fills each I2C_InitStruct member with its default value.  Parameters I2C_InitStruct : pointer to an I2C_InitTypeDef structure which will be initialized. ...
  • Page 255 Inter-integrated circuit interface (I2C) UM1581  Return values None.  Notes None. 13.2.9.6 I2C_ITConfig Function Name void I2C_ITConfig ( I2C_TypeDef * I2Cx, uint32_t I2C_IT, FunctionalState NewState) Function Description Enables or disables the specified I2C interrupts.  Parameters I2Cx : where x can be 1 or 2 to select the I2C peripheral. ...
  • Page 256 Inter-integrated circuit interface (I2C) UM1581 13.2.9.8 I2C_StopModeCmd Function Name void I2C_StopModeCmd ( I2C_TypeDef * I2Cx, FunctionalState NewState) Function Description Enables or disables I2C wakeup from stop mode.  Parameters I2Cx : where x can be 1 or 2 to select the I2C peripheral. ...
  • Page 257 Inter-integrated circuit interface (I2C) UM1581  Address : specifies the slave address to be programmed.  Mask : specifies own address 2 mask to be programmed. This parameter can be one of the following values:  I2C_OA2_NoMask : no mask. ...
  • Page 258 Inter-integrated circuit interface (I2C) UM1581  Parameters I2Cx : where x can be 1 or 2 to select the I2C peripheral.  NewState : new state of the I2C slave byte control. This parameter can be: ENABLE or DISABLE.  Return values None.
  • Page 259: Communications Handling Functions

    Inter-integrated circuit interface (I2C) UM1581 13.2.10 Communications handling functions 13.2.10.1 I2C_AutoEndCmd Function Name void I2C_AutoEndCmd ( I2C_TypeDef * I2Cx, FunctionalState NewState) Function Description Enables or disables the I2C automatic end mode (stop condition is automatically sent when nbytes data are transferred). ...
  • Page 260 Inter-integrated circuit interface (I2C) UM1581 programmed.  Return values None.  Notes None. 13.2.10.4 I2C_MasterRequestConfig Function Name void I2C_MasterRequestConfig ( I2C_TypeDef * I2Cx, uint16_t I2C_Direction) Function Description Configures the type of transfer request for the master.  Parameters I2Cx : where x can be 1 or 2 to select the I2C peripheral. ...
  • Page 261 Inter-integrated circuit interface (I2C) UM1581 13.2.10.6 I2C_GenerateSTOP Function Name void I2C_GenerateSTOP ( I2C_TypeDef * I2Cx, FunctionalState NewState) Function Description Generates I2Cx communication STOP condition.  Parameters I2Cx : where x can be 1 or 2 to select the I2C peripheral. ...
  • Page 262 Inter-integrated circuit interface (I2C) UM1581  Return values None.  Notes None. 13.2.10.9 I2C_GetAddressMatched Function Name uint8_t I2C_GetAddressMatched ( I2C_TypeDef * I2Cx) Function Description Returns the I2C slave matched address .  Parameters I2Cx : where x can be 1 or 2 to select the I2C peripheral. ...
  • Page 263: Smbus Management Functions

    Inter-integrated circuit interface (I2C) UM1581  Number_Bytes : specifies the number of bytes to be programmed. This parameter must be a value between 0 and 255.  ReloadEndMode : new state of the I2C START condition generation. This parameter can be one of the following values: ...
  • Page 264 Inter-integrated circuit interface (I2C) UM1581 13.2.11.2 I2C_ClockTimeoutCmd Function Name void I2C_ClockTimeoutCmd ( I2C_TypeDef * I2Cx, FunctionalState NewState) Function Description Enables or disables I2C Clock Timeout (SCL Timeout detection).  Parameters I2Cx : where x can be 1 or 2 to select the I2C peripheral. ...
  • Page 265 Inter-integrated circuit interface (I2C) UM1581  Return values None.  Notes None. 13.2.11.5 I2C_TimeoutAConfig Function Name void I2C_TimeoutAConfig ( I2C_TypeDef * I2Cx, uint16_t Timeout) Function Description Configures the I2C Bus Timeout A (SCL Timeout when TIDLE = 0 or Bus idle SCL and SDA high when TIDLE = 1). ...
  • Page 266 Inter-integrated circuit interface (I2C) UM1581 13.2.11.7 I2C_CalculatePEC Function Name void I2C_CalculatePEC ( I2C_TypeDef * I2Cx, FunctionalState NewState) Function Description Enables or disables I2C PEC calculation.  Parameters I2Cx : where x can be 1 or 2 to select the I2C peripheral. ...
  • Page 267: I2C Registers Management Functions

    Inter-integrated circuit interface (I2C) UM1581 13.2.12 I2C registers management functions 13.2.12.1 I2C_ReadRegister Function Name uint32_t I2C_ReadRegister ( I2C_TypeDef * I2Cx, uint8_t I2C_Register) Function Description Reads the specified I2C register and returns its value.  Parameters I2Cx : where x can be 1 or 2 to select the I2C peripheral. ...
  • Page 268: Dma Transfers Management Functions

    Inter-integrated circuit interface (I2C) UM1581 13.2.13.2 I2C_ReceiveData Function Name uint8_t I2C_ReceiveData ( I2C_TypeDef * I2Cx) Function Description Returns the most recent received data by the I2Cx peripheral.  Parameters I2Cx : where x can be 1 or 2 to select the I2C peripheral. ...
  • Page 269 Inter-integrated circuit interface (I2C) UM1581  Parameters I2Cx : where x can be 1 or 2 to select the I2C peripheral.  I2C_FLAG : specifies the flag to check. This parameter can be one of the following values:  I2C_FLAG_TXE : Transmit data register empty ...
  • Page 270 Inter-integrated circuit interface (I2C) UM1581 13.2.15.3 I2C_GetITStatus Function Name ITStatus I2C_GetITStatus ( I2C_TypeDef * I2Cx, uint32_t I2C_IT) Function Description Checks whether the specified I2C interrupt has occurred or not.  Parameters I2Cx : where x can be 1 or 2 to select the I2C peripheral. ...
  • Page 271: I2C Firmware Driver Defines

    Inter-integrated circuit interface (I2C) UM1581  I2C_IT_ALERT : SMBus Alert  Return values The new state of I2C_IT (SET or RESET).  Notes None. 13.3 I2C Firmware driver defines 13.3.1 I2C_acknowledged_address  #define: I2C_AcknowledgedAddress_7bit ((uint32_t)0x00000000)  #define: I2C_AcknowledgedAddress_10bit I2C_OAR1_OA1MODE I2C_acknowledgement ...
  • Page 272 Inter-integrated circuit interface (I2C) UM1581 I2C_flags_definition  #define: I2C_FLAG_TXE I2C_ISR_TXE  #define: I2C_FLAG_TXIS I2C_ISR_TXIS  #define: I2C_FLAG_RXNE I2C_ISR_RXNE  #define: I2C_FLAG_ADDR I2C_ISR_ADDR  #define: I2C_FLAG_NACKF I2C_ISR_NACKF  #define: I2C_FLAG_STOPF I2C_ISR_STOPF  #define: I2C_FLAG_TC I2C_ISR_TC  #define: I2C_FLAG_TCR I2C_ISR_TCR  #define: I2C_FLAG_BERR I2C_ISR_BERR ...
  • Page 273 Inter-integrated circuit interface (I2C) UM1581  #define: I2C_FLAG_PECERR I2C_ISR_PECERR  #define: I2C_FLAG_TIMEOUT I2C_ISR_TIMEOUT  #define: I2C_FLAG_ALERT I2C_ISR_ALERT  #define: I2C_FLAG_BUSY I2C_ISR_BUSY I2C_interrupts_definition  #define: I2C_IT_ERRI I2C_CR1_ERRIE  #define: I2C_IT_TCI I2C_CR1_TCIE  #define: I2C_IT_STOPI I2C_CR1_STOPIE  #define: I2C_IT_NACKI I2C_CR1_NACKIE  #define: I2C_IT_ADDRI I2C_CR1_ADDRIE ...
  • Page 274 Inter-integrated circuit interface (I2C) UM1581  #define: I2C_IT_RXNE I2C_ISR_RXNE  #define: I2C_IT_ADDR I2C_ISR_ADDR  #define: I2C_IT_NACKF I2C_ISR_NACKF  #define: I2C_IT_STOPF I2C_ISR_STOPF  #define: I2C_IT_TC I2C_ISR_TC  #define: I2C_IT_TCR I2C_ISR_TCR  #define: I2C_IT_BERR I2C_ISR_BERR  #define: I2C_IT_ARLO I2C_ISR_ARLO  #define: I2C_IT_OVR I2C_ISR_OVR ...
  • Page 275 Inter-integrated circuit interface (I2C) UM1581 I2C_mode  #define: I2C_Mode_I2C ((uint32_t)0x00000000)  #define: I2C_Mode_SMBusDevice I2C_CR1_SMBDEN  #define: I2C_Mode_SMBusHost I2C_CR1_SMBHEN I2C_own_address2_mask  #define: I2C_OA2_NoMask ((uint8_t)0x00)  #define: I2C_OA2_Mask01 ((uint8_t)0x01)  #define: I2C_OA2_Mask02 ((uint8_t)0x02)  #define: I2C_OA2_Mask03 ((uint8_t)0x03)  #define: I2C_OA2_Mask04 ((uint8_t)0x04)  #define: I2C_OA2_Mask05 ((uint8_t)0x05) ...
  • Page 276 Inter-integrated circuit interface (I2C) UM1581 I2C_registers  #define: I2C_Register_CR1 ((uint8_t)0x00)  #define: I2C_Register_CR2 ((uint8_t)0x04)  #define: I2C_Register_OAR1 ((uint8_t)0x08)  #define: I2C_Register_OAR2 ((uint8_t)0x0C)  #define: I2C_Register_TIMINGR ((uint8_t)0x10)  #define: I2C_Register_TIMEOUTR ((uint8_t)0x14)  #define: I2C_Register_ISR ((uint8_t)0x18)  #define: I2C_Register_ICR ((uint8_t)0x1C)  #define: I2C_Register_PECR ((uint8_t)0x20) ...
  • Page 277 Inter-integrated circuit interface (I2C) UM1581  #define: I2C_AutoEnd_Mode I2C_CR2_AUTOEND  #define: I2C_SoftEnd_Mode ((uint32_t)0x00000000) I2C_StartStopMode_definition  #define: I2C_No_StartStop ((uint32_t)0x00000000)  #define: I2C_Generate_Stop I2C_CR2_STOP  #define: I2C_Generate_Start_Read (uint32_t)(I2C_CR2_START | I2C_CR2_RD_WRN)  #define: I2C_Generate_Start_Write I2C_CR2_START I2C_transfer_direction  #define: I2C_Direction_Transmitter ((uint16_t)0x0000)  #define: I2C_Direction_Receiver ((uint16_t)0x0400) DocID023800 Rev 1 277/584...
  • Page 278: Independent Watchdog (Iwdg)

    Independent watchdog (IWDG) UM1581 Independent watchdog (IWDG) 14.1 IWDG Firmware driver registers structures 14.1.1 IWDG_TypeDef IWDG_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t KR  __IO uint32_t PR  __IO uint32_t RLR  __IO uint32_t SR  __IO uint32_t WINR Field Documentation ...
  • Page 279: How To Use This Driver

    Independent watchdog (IWDG) UM1581 Min-max timeout value @41KHz (LSI): ~0.1ms / ~25.5s The IWDG timeout may vary due to LSI frequency dispersion. STM32F30x devices provide the capability to measure the LSI frequency (LSI clock connected internally to TIM16 CH1 input capture). The measured value can be used to have an IWDG timeout with an acceptable accuracy.
  • Page 280: Prescaler And Counter Configuration Functions

    Independent watchdog (IWDG) UM1581  IWDG_GetFlagStatus() 14.2.6 Prescaler and counter configuration functions 14.2.6.1 IWDG_WriteAccessCmd Function Name void IWDG_WriteAccessCmd ( uint16_t IWDG_WriteAccess) Function Description Enables or disables write access to IWDG_PR and IWDG_RLR registers.  Parameters IWDG_WriteAccess : new state of write access to IWDG_PR and IWDG_RLR registers.
  • Page 281 Independent watchdog (IWDG) UM1581 14.2.6.3 IWDG_SetReload Function Name void IWDG_SetReload ( uint16_t Reload) Function Description Sets IWDG Reload value.  Parameters Reload : specifies the IWDG Reload value. This parameter must be a number between 0 and 0x0FFF.  Return values None.
  • Page 282: Iwdg Activation Function

    Independent watchdog (IWDG) UM1581 14.2.7 IWDG activation function 14.2.7.1 IWDG_Enable Function Name void IWDG_Enable ( void ) Function Description Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled).  Parameters None.  Return values None.  Notes None. 14.2.8 Flag management function 14.2.8.1 IWDG_GetFlagStatus...
  • Page 283 Independent watchdog (IWDG) UM1581  #define: IWDG_FLAG_RVU ((uint16_t)0x0002)  #define: IWDG_FLAG_WVU ((uint16_t)0x0002) IWDG_prescaler  #define: IWDG_Prescaler_4 ((uint8_t)0x00)  #define: IWDG_Prescaler_8 ((uint8_t)0x01)  #define: IWDG_Prescaler_16 ((uint8_t)0x02)  #define: IWDG_Prescaler_32 ((uint8_t)0x03)  #define: IWDG_Prescaler_64 ((uint8_t)0x04)  #define: IWDG_Prescaler_128 ((uint8_t)0x05)  #define: IWDG_Prescaler_256 ((uint8_t)0x06) IWDG_WriteAccess ...
  • Page 284: Miscellaneous Add-On To Cmsis Functions(Misc)

    Miscellaneous add-on to CMSIS functions(misc) UM1581 Miscellaneous add-on to CMSIS functions(misc) 15.1 MISC Firmware driver registers structures 15.1.1 NVIC_InitTypeDef NVIC_InitTypeDef is defined in the stm32f30x_misc.h Data Fields  uint8_t NVIC_IRQChannel  uint8_t NVIC_IRQChannelPreemptionPriority  uint8_t NVIC_IRQChannelSubPriority  FunctionalState NVIC_IRQChannelCmd Field Documentation ...
  • Page 285: Misc Functions

    Miscellaneous add-on to CMSIS functions(misc) UM1581 When the NVIC_PriorityGroup_0 is selected, it will no any nested interrupt, the IRQ priority will be managed only by subpriority. The sub-priority is only used to sort pending exception priorities, and does not affect active exceptions. Lower priority values gives higher priority.
  • Page 286 Miscellaneous add-on to CMSIS functions(misc) UM1581 15.2.2.2 NVIC_Init Function Name void NVIC_Init ( NVIC_InitTypeDef * NVIC_InitStruct) Function Description Initializes the NVIC peripheral according to the specified parameters in the NVIC_InitStruct.  Parameters NVIC_InitStruct : pointer to a NVIC_InitTypeDef structure that contains the configuration information for the specified NVIC peripheral.
  • Page 287: Misc Firmware Driver Defines

    Miscellaneous add-on to CMSIS functions(misc) UM1581  Parameters LowPowerMode : Specifies the new mode for the system to enter low power mode. This parameter can be one of the following values:  NVIC_LP_SEVONPEND :  NVIC_LP_SLEEPDEEP :  NVIC_LP_SLEEPONEXIT : ...
  • Page 288 Miscellaneous add-on to CMSIS functions(misc) UM1581 MISC_Preemption_Priority_Group  #define: NVIC_PriorityGroup_0 ((uint32_t)0x700) 0 bits for pre-emption priority 4 bits for subpriority  #define: NVIC_PriorityGroup_1 ((uint32_t)0x600) 1 bits for pre-emption priority 3 bits for subpriority  #define: NVIC_PriorityGroup_2 ((uint32_t)0x500) 2 bits for pre-emption priority 2 bits for subpriority ...
  • Page 289: Operational Amplifier (Opamp)

    Operational amplifier (OPAMP) UM1581 Operational amplifier (OPAMP) 16.1 OPAMP Firmware driver registers structures 16.1.1 OPAMP_TypeDef OPAMP_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t CSR Field Documentation  __IO uint32_t OPAMP_TypeDef::CSR  OPAMP control and status register, Address offset: 0x00 16.1.2 OPAMP_InitTypeDef OPAMP_InitTypeDef is defined in the stm32f30x_opamp.h...
  • Page 290: How To Use This Driver

    Operational amplifier (OPAMP) UM1581  The OPAMPs non inverting input can be selected among the list shown by table below.  The OPAMPs inverting input can be selected among the list shown by table below.  The OPAMPs outputs can be internally connected to the inverting input (follower mode) ...
  • Page 291: Initialization And Configuration

    Operational amplifier (OPAMP) UM1581  OPAMP_Cmd()  OPAMP_GetOutputLevel()  OPAMP_OffsetTrimModeSelect()  OPAMP_OffsetTrimConfig()  OPAMP_StartCalibration() 16.2.4 Initialization and Configuration 16.2.4.1 OPAMP_DeInit Function Name void OPAMP_DeInit ( uint32_t OPAMP_Selection) Function Description Deinitializes OPAMP peripheral registers to their default reset values.  Parameters OPAMP_Selection.
  • Page 292 Operational amplifier (OPAMP) UM1581 16.2.4.3 OPAMP_StructInit Function Name void OPAMP_StructInit ( OPAMP_InitTypeDef * OPAMP_InitStruct) Function Description Fills each OPAMP_InitStruct member with its default value.  Parameters OPAMP_InitStruct : pointer to an OPAMP_InitTypeDef structure which will be initialized.  Return values None.
  • Page 293 Operational amplifier (OPAMP) UM1581 Function Description Configure the OPAMP's internal reference.  Parameters OPAMP_Selection : the selected OPAMP. This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4 to select the OPAMP peripheral.  OPAMP_Vref : This parameter can be: OPAMP_Vref_3VDDA: OPMAP Vref = 3.3% VDDA OPAMP_Vref_10VDDA: OPMAP Vref = 10% VDDA OPAMP_Vref_50VDDA: OPMAP Vref = 50% VDDA...
  • Page 294 Operational amplifier (OPAMP) UM1581 Function Description Enables or disables connecting the OPAMP's internal reference to ADC.  Parameters NewState : new state of the Vrefint output. This parameter can be: ENABLE or DISABLE.  Return values None.  Notes If the selected OPAMP is locked, Vref connection can't be performed.
  • Page 295 Operational amplifier (OPAMP) UM1581 Function Description Enable or disable the timer-controlled mux mode.  Parameters OPAMP_Selection : the selected OPAMP. This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4 to select the OPAMP peripheral.  NewState : new state of the OPAMP peripheral. This parameter can be: ENABLE or DISABLE.
  • Page 296 Operational amplifier (OPAMP) UM1581  OPAMP :  Return values Returns the selected OPAMP output level: low or high.  Notes OPAMP ouput level is provided only during calibration phase. 16.2.4.12 OPAMP_OffsetTrimModeSelect Function Name void OPAMP_OffsetTrimModeSelect ( uint32_t OPAMP_Selection, uint32_t OPAMP_Trimming) Function Description Select the trimming mode.
  • Page 297: Opamp Configuration Locking Function

    Operational amplifier (OPAMP) UM1581 can be any value lower or equal to 0x0000001F.  Return values None.  Notes None. 16.2.4.14 OPAMP_StartCalibration Function Name void OPAMP_StartCalibration ( uint32_t OPAMP_Selection, FunctionalState NewState) Function Description Start or stop the calibration of selected OPAMP peripheral. ...
  • Page 298: Opamp Firmware Driver Defines

    Operational amplifier (OPAMP) UM1581 16.3 OPAMP Firmware driver defines 16.3.1 OPAMP OPAMP OPAMP_Exported_Constants  #define: OPAMP_Trimming_Factory ((uint32_t)0x00000000) Factory trimming  #define: OPAMP_Trimming_User OPAMP_CSR_USERTRIM User trimming OPAMP_Input  #define: OPAMP_Input_Inverting ((uint32_t)0x00000018) Inverting input  #define: OPAMP_Input_NonInverting ((uint32_t)0x00000013) Non inverting input OPAMP_InvertingInput ...
  • Page 299 Operational amplifier (OPAMP) UM1581  #define: OPAMP_NonInvertingInput_IO1 ((uint32_t)0x00000000) IO1 (PA7 for OPAMP1, PD14 for OPAMP2, PB13 for OPAMP3, PD11 for OPAMP4) connected to OPAMPx non inverting input  #define: OPAMP_NonInvertingInput_IO2 OPAMP_CSR_VPSEL_0 IO2 (PA5 for OPAMP1, PB14 for OPAMP2, PA5 for OPAMP3, PB11 for OPAMP4) connected to OPAMPx non inverting input ...
  • Page 300 Operational amplifier (OPAMP) UM1581  #define: OPAMP_OPAMP_PGAGain_8 OPAMP_CSR_PGGAIN_1  #define: OPAMP_OPAMP_PGAGain_16 ((uint32_t)0x0000C000) OPAMP_Selection  #define: OPAMP_Selection_OPAMP1 ((uint32_t)0x00000000) OPAMP1 Selection  #define: OPAMP_Selection_OPAMP2 ((uint32_t)0x00000004) OPAMP2 Selection  #define: OPAMP_Selection_OPAMP3 ((uint32_t)0x00000008) OPAMP3 Selection  #define: OPAMP_Selection_OPAMP4 ((uint32_t)0x0000000C) OPAMP4 Selection OPAMP_Vref  #define: OPAMP_Vref_3VDDA ((uint32_t)0x00000000) OPMAP Vref = 3.3% VDDA ...
  • Page 301: Power Control (Pwr)

    Power control (PWR) UM1581 Power control (PWR) 17.1 PWR Firmware driver registers structures 17.1.1 PWR_TypeDef PWR_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t CR  __IO uint32_t CSR Field Documentation  __IO uint32_t PWR_TypeDef::CR  PWR power control register, Address offset: 0x00 ...
  • Page 302: Wakeup Pins Configuration Functions

    Power control (PWR) UM1581 17.2.3 WakeUp pins configuration functions  WakeUp pins are used to wakeup the system from Standby mode. These pins are forced in input pull down configuration and are active on rising edges.  There are three WakeUp pins: WakeUp Pin 1 on PA.00, WakeUp Pin 2 on PC.13 and WakeUp Pin 3 on PE.06.
  • Page 303: Flags Management Functions

    Power control (PWR) UM1581  WKUP pin rising edge, RTC alarm (Alarm A and Alarm B), RTC wakeup, tamper event, time-stamp event, external reset in NRST pin, IWDG reset. Auto-wakeup (AWU) from low-power mode The MCU can be woken up from low-power mode by an RTC Alarm event, a tamper event, a time-stamp event, or a comparator event, without depending on an external interrupt (Auto-wakeup mode).
  • Page 304: Backup Domain Access Function

    Power control (PWR) UM1581 17.2.6 Backup domain access function 17.2.6.1 PWR_DeInit Function Name void PWR_DeInit ( void ) Function Description Deinitializes the PWR peripheral registers to their default reset values.  Parameters None.  Return values None.  Notes None. 17.2.6.2 PWR_BackupAccessCmd Function Name...
  • Page 305: Wakeup Pins Configuration Functions

    Power control (PWR) UM1581  PWR_PVDLevel_3 : PVD detection level set to 2.48V  PWR_PVDLevel_4 : PVD detection level set to 2.58V  PWR_PVDLevel_5 : PVD detection level set to 2.68V  PWR_PVDLevel_6 : PVD detection level set to 2.78V ...
  • Page 306: Low Power Mode Configuration Functions

    Power control (PWR) UM1581 17.2.9 Low power mode configuration functions 17.2.9.1 PWR_EnterSleepMode Function Name void PWR_EnterSleepMode ( uint8_t PWR_SLEEPEntry) Function Description Enters Sleep mode.  Parameters PWR_SLEEPEntry : specifies if SLEEP mode in entered with WFI or WFE instruction. This parameter can be one of the following values: ...
  • Page 307: Flag Management Functions

    Power control (PWR) UM1581 mode. By keeping the internal regulator ON during Stop mode, the consumption is higher although the startup time is reduced. 17.2.9.3 PWR_EnterSTANDBYMode Function Name void PWR_EnterSTANDBYMode ( void ) Function Description Enters STANDBY mode.  Parameters None.
  • Page 308: Pwr Firmware Driver Defines

    Power control (PWR) UM1581 event, RTC TimeStamp event or RTC Wakeup.  PWR_FLAG_SB : StandBy flag. This flag indicates that the system was resumed from StandBy mode.  PWR_FLAG_PVDO : PVD Output. This flag is valid only if PVD is enabled by the PWR_PVDCmd() function. ...
  • Page 309 Power control (PWR) UM1581  #define: PWR_FLAG_VREFINTRDY PWR_CSR_VREFINTRDYF PWR_PVD_detection_level  #define: PWR_PVDLevel_0 PWR_CR_PLS_LEV0  #define: PWR_PVDLevel_1 PWR_CR_PLS_LEV1  #define: PWR_PVDLevel_2 PWR_CR_PLS_LEV2  #define: PWR_PVDLevel_3 PWR_CR_PLS_LEV3  #define: PWR_PVDLevel_4 PWR_CR_PLS_LEV4  #define: PWR_PVDLevel_5 PWR_CR_PLS_LEV5  #define: PWR_PVDLevel_6 PWR_CR_PLS_LEV6  #define: PWR_PVDLevel_7 PWR_CR_PLS_LEV7 PWR_Regulator_state_is_Sleep_STOP_mode ...
  • Page 310 Power control (PWR) UM1581 PWR_SLEEP_mode_entry  #define: PWR_SLEEPEntry_WFI ((uint8_t)0x01)  #define: PWR_SLEEPEntry_WFE ((uint8_t)0x02) PWR_STOP_mode_entry  #define: PWR_STOPEntry_WFI ((uint8_t)0x01)  #define: PWR_STOPEntry_WFE ((uint8_t)0x02) PWR_WakeUp_Pins  #define: PWR_WakeUpPin_1 PWR_CSR_EWUP1  #define: PWR_WakeUpPin_2 PWR_CSR_EWUP2  #define: PWR_WakeUpPin_3 PWR_CSR_EWUP3 310/584 DocID023800 Rev 1...
  • Page 311: Reset And Clock Control (Rcc)

    Reset and clock control (RCC) UM1581 Reset and clock control (RCC) 18.1 RCC Firmware driver registers structures 18.1.1 RCC_TypeDef RCC_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t CR  __IO uint32_t CFGR  __IO uint32_t CIR  __IO uint32_t APB2RSTR ...
  • Page 312: Rcc_Clockstypedef

    Reset and clock control (RCC) UM1581  RCC clock configuration register 2, Address offset: 0x2C  __IO uint32_t RCC_TypeDef::CFGR3  RCC clock configuration register 3, Address offset: 0x30 18.1.2 RCC_ClocksTypeDef RCC_ClocksTypeDef is defined in the stm32f30x_rcc.h Data Fields  uint32_t SYSCLK_Frequency ...
  • Page 313: Rcc Firmware Driver Api Description

    Reset and clock control (RCC) UM1581 18.2 RCC Firmware driver API description The following section lists the various functions of the RCC library. 18.2.1 RCC specific features After reset the device is running from HSI (8 MHz) with Flash 0 WS, all peripherals are off except internal SRAM, Flash and SWD.
  • Page 314: System, Ahb, Apb1 And Apb2 Busses Clocks Configuration Functions

    Reset and clock control (RCC) UM1581  RCC_PLLConfig()  RCC_PLLCmd()  RCC_PREDIV1Config()  RCC_ClockSecuritySystemCmd()  RCC_MCOConfig() 18.2.3 System, AHB, APB1 and APB2 busses clocks configuration functions This section provide functions allowing to configure the System, AHB, APB1 and APB2 busses clocks. Several clock sources can be used to drive the System clock (SYSCLK): HSI, HSE and PLL.
  • Page 315: Peripheral Clocks Configuration Functions

    Reset and clock control (RCC) UM1581  Check that the new number of WS is taken into account by reading FLASH_ACR  Modify the CPU clock source, using "RCC_SYSCLKConfig()" function  If needed, modify the CPU clock prescaler by using "RCC_HCLKConfig()" function ...
  • Page 316: Interrupts And Flags Management Functions

    Reset and clock control (RCC) UM1581 18.2.5 Interrupts and flags management functions  RCC_ITConfig()  RCC_GetFlagStatus()  RCC_ClearFlag()  RCC_GetITStatus()  RCC_ClearITPendingBit() 18.2.6 Internal and external clocks, PLL, CSS and MCO configuration functions 18.2.6.1 RCC_DeInit Function Name void RCC_DeInit ( void ) Function Description Resets the RCC clock configuration to the default reset state.
  • Page 317 Reset and clock control (RCC) UM1581  Return values None.  Notes After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application software should wait on HSERDY flag to be set indicating that HSE clock is stable and can be used to clock the PLL and/or system clock. ...
  • Page 318 Reset and clock control (RCC) UM1581 0x1F.  Return values None.  Notes The calibration is used to compensate for the variations in voltage and temperature that influence the frequency of the internal HSI RC. Refer to the Application Note AN3300 for more details on how to calibrate the HSI.
  • Page 319 Reset and clock control (RCC) UM1581  Return values None.  Notes As the LSE is in the Backup domain and write access is denied to this domain after reset, you have to enable write access using PWR_BackupAccessCmd(ENABLE) function before to configure the LSE (to be done once after reset). ...
  • Page 320 Reset and clock control (RCC) UM1581  Notes After enabling the LSI, the application software should wait on LSIRDY flag to be set indicating that LSI clock is stable and can be used to clock the IWDG and/or the RTC. ...
  • Page 321 Reset and clock control (RCC) UM1581  The PLL can not be disabled if it is used as system clock source  The PLL is disabled by hardware when entering STOP and STANDBY modes. 18.2.6.11 RCC_PREDIV1Config Function Name void RCC_PREDIV1Config ( uint32_t RCC_PREDIV1_Div) Function Description Configures the PREDIV1 division factor.
  • Page 322: System Ahb, Apb1 And Apb2 Busses Clocks Configuration Functions

    Reset and clock control (RCC) UM1581 Function Name void RCC_MCOConfig ( uint8_t RCC_MCOSource) Function Description Selects the clock source to output on MCO pin (PA8).  Parameters RCC_MCOSource : specifies the clock source to output. This parameter can be one of the following values: ...
  • Page 323 Reset and clock control (RCC) UM1581 selected, the switch will occur when the clock source will be ready. You can use RCC_GetSYSCLKSource() function to know which clock is currently used as system clock source. 18.2.7.2 RCC_GetSYSCLKSource Function Name uint8_t RCC_GetSYSCLKSource ( void ) Function Description Returns the clock source used as system clock.
  • Page 324 Reset and clock control (RCC) UM1581 details refer to section above "CPU, AHB and APB busses clocks configuration functions"). 18.2.7.4 RCC_PCLK1Config Function Name void RCC_PCLK1Config ( uint32_t RCC_HCLK) Function Description Configures the Low Speed APB clock (PCLK1).  Parameters RCC_HCLK : defines the APB1 clock divider. This clock is derived from the AHB clock (HCLK).
  • Page 325: Peripheral Clocks Configuration Functions

    Reset and clock control (RCC) UM1581 18.2.7.6 RCC_GetClocksFreq Function Name void RCC_GetClocksFreq ( RCC_ClocksTypeDef * RCC_Clocks) Function Description Returns the frequencies of the System, AHB, APB2 and APB1 busses clocks.  Parameters RCC_Clocks : pointer to a RCC_ClocksTypeDef structure which will hold the clocks frequencies. ...
  • Page 326 Reset and clock control (RCC) UM1581 Function Name void RCC_ADCCLKConfig ( uint32_t RCC_PLLCLK) Function Description Configures the ADC clock (ADCCLK).  Parameters RCC_PLLCLK : defines the ADC clock divider. This clock is derived from the PLL Clock. This parameter can be one of the following values: ...
  • Page 327 Reset and clock control (RCC) UM1581 18.2.8.2 RCC_I2CCLKConfig Function Name void RCC_I2CCLKConfig ( uint32_t RCC_I2CCLK) Function Description Configures the I2C clock (I2CCLK).  Parameters RCC_I2CCLK : defines the I2C clock source. This clock is derived from the HSI or System clock. This parameter can be one of the following values: ...
  • Page 328 Reset and clock control (RCC) UM1581 18.2.8.4 RCC_USARTCLKConfig Function Name void RCC_USARTCLKConfig ( uint32_t RCC_USARTCLK) Function Description Configures the USART clock (USARTCLK).  Parameters RCC_USARTCLK : defines the USART clock source. This clock is derived from the HSI or System clock. This parameter can be one of the following values: ...
  • Page 329 Reset and clock control (RCC) UM1581 18.2.8.6 RCC_RTCCLKConfig Function Name void RCC_RTCCLKConfig ( uint32_t RCC_RTCCLKSource) Function Description Configures the RTC clock (RTCCLK).  Parameters RCC_RTCCLKSource : specifies the RTC clock source. This parameter can be one of the following values: ...
  • Page 330 Reset and clock control (RCC) UM1581 18.2.8.8 RCC_RTCCLKCmd Function Name void RCC_RTCCLKCmd ( FunctionalState NewState) Function Description Enables or disables the RTC clock.  Parameters NewState : new state of the RTC clock. This parameter can be: ENABLE or DISABLE. ...
  • Page 331 Reset and clock control (RCC) UM1581  RCC_AHBPeriph_GPIOB :  RCC_AHBPeriph_GPIOC :  RCC_AHBPeriph_GPIOD :  RCC_AHBPeriph_GPIOE :  RCC_AHBPeriph_GPIOF :  RCC_AHBPeriph_TS :  RCC_AHBPeriph_CRC :  RCC_AHBPeriph_FLITF :  RCC_AHBPeriph_SRAM :  RCC_AHBPeriph_DMA2 :  RCC_AHBPeriph_DMA1 :  RCC_AHBPeriph_ADC34 : ...
  • Page 332 Reset and clock control (RCC) UM1581 18.2.8.12 RCC_APB1PeriphClockCmd Function Name void RCC_APB1PeriphClockCmd ( uint32_t RCC_APB1Periph, FunctionalState NewState) Function Description Enables or disables the Low Speed APB (APB1) peripheral clock.  Parameters RCC_APB1Periph : specifies the APB1 peripheral to gates its clock. This parameter can be any combination of the following values: ...
  • Page 333 Reset and clock control (RCC) UM1581  Parameters RCC_AHBPeriph : specifies the AHB peripheral to reset. This parameter can be any combination of the following values:  RCC_AHBPeriph_GPIOA :  RCC_AHBPeriph_GPIOB :  RCC_AHBPeriph_GPIOC :  RCC_AHBPeriph_GPIOD :  RCC_AHBPeriph_GPIOE : ...
  • Page 334: Interrupts And Flags Management Functions

    Reset and clock control (RCC) UM1581 18.2.8.15 RCC_APB1PeriphResetCmd Function Name void RCC_APB1PeriphResetCmd ( uint32_t RCC_APB1Periph, FunctionalState NewState) Function Description Forces or releases Low Speed APB (APB1) peripheral reset.  Parameters RCC_APB1Periph : specifies the APB1 peripheral to reset. This parameter can be any combination of the following values: ...
  • Page 335 Reset and clock control (RCC) UM1581  RCC_IT_LSIRDY : LSI ready interrupt  RCC_IT_LSERDY : LSE ready interrupt  RCC_IT_HSIRDY : HSI ready interrupt  RCC_IT_HSERDY : HSE ready interrupt  RCC_IT_PLLRDY : PLL ready interrupt  NewState : new state of the specified RCC interrupts. This parameter can be: ENABLE or DISABLE.
  • Page 336 Reset and clock control (RCC) UM1581 18.2.9.3 RCC_ClearFlag Function Name void RCC_ClearFlag ( void ) Function Description Clears the RCC reset flags.  Parameters None.  Return values None.  Notes None. 18.2.9.4 RCC_GetITStatus Function Name ITStatus RCC_GetITStatus ( uint8_t RCC_IT) Function Description Checks whether the specified RCC interrupt has occurred or not.
  • Page 337: Rcc Firmware Driver Defines

    Reset and clock control (RCC) UM1581  RCC_IT_HSERDY : HSE ready interrupt  RCC_IT_PLLRDY : PLL ready interrupt  RCC_IT_CSS : Clock Security System interrupt  Return values None.  Notes None. 18.3 RCC Firmware driver defines 18.3.1 RCC_ADC_clock_source  #define: RCC_ADC12PLLCLK_OFF ((uint32_t)0x00000000) ...
  • Page 338 Reset and clock control (RCC) UM1581  #define: RCC_ADC12PLLCLK_Div16 ((uint32_t)0x00000170)  #define: RCC_ADC12PLLCLK_Div32 ((uint32_t)0x00000180)  #define: RCC_ADC12PLLCLK_Div64 ((uint32_t)0x00000190)  #define: RCC_ADC12PLLCLK_Div128 ((uint32_t)0x000001A0)  #define: RCC_ADC12PLLCLK_Div256 ((uint32_t)0x000001B0)  #define: RCC_ADC34PLLCLK_OFF ((uint32_t)0x10000000)  #define: RCC_ADC34PLLCLK_Div1 ((uint32_t)0x10002000)  #define: RCC_ADC34PLLCLK_Div2 ((uint32_t)0x10002200)  #define: RCC_ADC34PLLCLK_Div4 ((uint32_t)0x10002400) ...
  • Page 339 Reset and clock control (RCC) UM1581  #define: RCC_ADC34PLLCLK_Div12 ((uint32_t)0x10002C00)  #define: RCC_ADC34PLLCLK_Div16 ((uint32_t)0x10002E00)  #define: RCC_ADC34PLLCLK_Div32 ((uint32_t)0x10003000)  #define: RCC_ADC34PLLCLK_Div64 ((uint32_t)0x10003200)  #define: RCC_ADC34PLLCLK_Div128 ((uint32_t)0x10003400)  #define: RCC_ADC34PLLCLK_Div256 ((uint32_t)0x10003600) RCC_AHB_Clock_Source  #define: RCC_SYSCLK_Div1 RCC_CFGR_HPRE_DIV1  #define: RCC_SYSCLK_Div2 RCC_CFGR_HPRE_DIV2  #define: RCC_SYSCLK_Div4 RCC_CFGR_HPRE_DIV4 ...
  • Page 340 Reset and clock control (RCC) UM1581  #define: RCC_SYSCLK_Div128 RCC_CFGR_HPRE_DIV128  #define: RCC_SYSCLK_Div256 RCC_CFGR_HPRE_DIV256  #define: RCC_SYSCLK_Div512 RCC_CFGR_HPRE_DIV512 RCC_AHB_Peripherals  #define: RCC_AHBPeriph_ADC34 RCC_AHBENR_ADC34EN  #define: RCC_AHBPeriph_ADC12 RCC_AHBENR_ADC12EN  #define: RCC_AHBPeriph_GPIOA RCC_AHBENR_GPIOAEN  #define: RCC_AHBPeriph_GPIOB RCC_AHBENR_GPIOBEN  #define: RCC_AHBPeriph_GPIOC RCC_AHBENR_GPIOCEN  #define: RCC_AHBPeriph_GPIOD RCC_AHBENR_GPIODEN ...
  • Page 341 Reset and clock control (RCC) UM1581  #define: RCC_AHBPeriph_CRC RCC_AHBENR_CRCEN  #define: RCC_AHBPeriph_FLITF RCC_AHBENR_FLITFEN  #define: RCC_AHBPeriph_SRAM RCC_AHBENR_SRAMEN  #define: RCC_AHBPeriph_DMA2 RCC_AHBENR_DMA2EN  #define: RCC_AHBPeriph_DMA1 RCC_AHBENR_DMA1EN RCC_APB1_APB2_clock_source  #define: RCC_HCLK_Div1 ((uint32_t)0x00000000)  #define: RCC_HCLK_Div2 ((uint32_t)0x00000400)  #define: RCC_HCLK_Div4 ((uint32_t)0x00000500)  #define: RCC_HCLK_Div8 ((uint32_t)0x00000600) ...
  • Page 342 Reset and clock control (RCC) UM1581  #define: RCC_APB1Periph_TIM3 ((uint32_t)0x00000002)  #define: RCC_APB1Periph_TIM4 ((uint32_t)0x00000004)  #define: RCC_APB1Periph_TIM6 ((uint32_t)0x00000010)  #define: RCC_APB1Periph_TIM7 ((uint32_t)0x00000020)  #define: RCC_APB1Periph_WWDG ((uint32_t)0x00000800)  #define: RCC_APB1Periph_SPI2 ((uint32_t)0x00004000)  #define: RCC_APB1Periph_SPI3 ((uint32_t)0x00008000)  #define: RCC_APB1Periph_USART2 ((uint32_t)0x00020000)  #define: RCC_APB1Periph_USART3 ((uint32_t)0x00040000) ...
  • Page 343 Reset and clock control (RCC) UM1581  #define: RCC_APB1Periph_I2C2 ((uint32_t)0x00400000)  #define: RCC_APB1Periph_USB ((uint32_t)0x00800000)  #define: RCC_APB1Periph_CAN1 ((uint32_t)0x02000000)  #define: RCC_APB1Periph_PWR ((uint32_t)0x10000000)  #define: RCC_APB1Periph_DAC ((uint32_t)0x20000000) RCC_APB2_Peripherals  #define: RCC_APB2Periph_SYSCFG ((uint32_t)0x00000001)  #define: RCC_APB2Periph_TIM1 ((uint32_t)0x00000800)  #define: RCC_APB2Periph_SPI1 ((uint32_t)0x00001000)  #define: RCC_APB2Periph_TIM8 ((uint32_t)0x00002000) ...
  • Page 344 Reset and clock control (RCC) UM1581  #define: RCC_APB2Periph_TIM17 ((uint32_t)0x00040000) RCC_Flag  #define: RCC_FLAG_HSIRDY ((uint8_t)0x01)  #define: RCC_FLAG_HSERDY ((uint8_t)0x11)  #define: RCC_FLAG_PLLRDY ((uint8_t)0x19)  #define: RCC_FLAG_MCOF ((uint8_t)0x9C)  #define: RCC_FLAG_LSERDY ((uint8_t)0x21)  #define: RCC_FLAG_LSIRDY ((uint8_t)0x41)  #define: RCC_FLAG_OBLRST ((uint8_t)0x59)  #define: RCC_FLAG_PINRST ((uint8_t)0x5A) ...
  • Page 345 Reset and clock control (RCC) UM1581  #define: RCC_FLAG_IWDGRST ((uint8_t)0x5D)  #define: RCC_FLAG_WWDGRST ((uint8_t)0x5E)  #define: RCC_FLAG_LPWRRST ((uint8_t)0x5F) RCC_HSE_configuration  #define: RCC_HSE_OFF ((uint8_t)0x00)  #define: RCC_HSE_ON ((uint8_t)0x01)  #define: RCC_HSE_Bypass ((uint8_t)0x05) RCC_I2C_clock_source  #define: RCC_I2C1CLK_HSI ((uint32_t)0x00000000)  #define: RCC_I2C1CLK_SYSCLK RCC_CFGR3_I2C1SW ...
  • Page 346 Reset and clock control (RCC) UM1581  #define: RCC_I2S2CLKSource_Ext ((uint8_t)0x01) RCC_Interrupt_Source  #define: RCC_IT_LSIRDY ((uint8_t)0x01)  #define: RCC_IT_LSERDY ((uint8_t)0x02)  #define: RCC_IT_HSIRDY ((uint8_t)0x04)  #define: RCC_IT_HSERDY ((uint8_t)0x08)  #define: RCC_IT_PLLRDY ((uint8_t)0x10)  #define: RCC_IT_CSS ((uint8_t)0x80) RCC_LSE_configuration  #define: RCC_LSE_OFF ((uint32_t)0x00000000) ...
  • Page 347 Reset and clock control (RCC) UM1581  #define: RCC_LSEDrive_MediumLow RCC_BDCR_LSEDRV_0  #define: RCC_LSEDrive_MediumHigh RCC_BDCR_LSEDRV_1  #define: RCC_LSEDrive_High RCC_BDCR_LSEDRV RCC_MCO_Clock_Source  #define: RCC_MCOSource_NoClock ((uint8_t)0x00)  #define: RCC_MCOSource_LSI ((uint8_t)0x02)  #define: RCC_MCOSource_LSE ((uint8_t)0x03)  #define: RCC_MCOSource_SYSCLK ((uint8_t)0x04)  #define: RCC_MCOSource_HSI ((uint8_t)0x05)  #define: RCC_MCOSource_HSE ((uint8_t)0x06) ...
  • Page 348 Reset and clock control (RCC) UM1581 RCC_PLL_Multiplication_Factor  #define: RCC_PLLMul_2 RCC_CFGR_PLLMULL2  #define: RCC_PLLMul_3 RCC_CFGR_PLLMULL3  #define: RCC_PLLMul_4 RCC_CFGR_PLLMULL4  #define: RCC_PLLMul_5 RCC_CFGR_PLLMULL5  #define: RCC_PLLMul_6 RCC_CFGR_PLLMULL6  #define: RCC_PLLMul_7 RCC_CFGR_PLLMULL7  #define: RCC_PLLMul_8 RCC_CFGR_PLLMULL8  #define: RCC_PLLMul_9 RCC_CFGR_PLLMULL9  #define: RCC_PLLMul_10 RCC_CFGR_PLLMULL10 ...
  • Page 349 Reset and clock control (RCC) UM1581  #define: RCC_PLLMul_13 RCC_CFGR_PLLMULL13  #define: RCC_PLLMul_14 RCC_CFGR_PLLMULL14  #define: RCC_PLLMul_15 RCC_CFGR_PLLMULL15  #define: RCC_PLLMul_16 RCC_CFGR_PLLMULL16 RCC_PREDIV1_division_factor  #define: RCC_PREDIV1_Div1 RCC_CFGR2_PREDIV1_DIV1  #define: RCC_PREDIV1_Div2 RCC_CFGR2_PREDIV1_DIV2  #define: RCC_PREDIV1_Div3 RCC_CFGR2_PREDIV1_DIV3  #define: RCC_PREDIV1_Div4 RCC_CFGR2_PREDIV1_DIV4  #define: RCC_PREDIV1_Div5 RCC_CFGR2_PREDIV1_DIV5 ...
  • Page 350 Reset and clock control (RCC) UM1581  #define: RCC_PREDIV1_Div9 RCC_CFGR2_PREDIV1_DIV9  #define: RCC_PREDIV1_Div10 RCC_CFGR2_PREDIV1_DIV10  #define: RCC_PREDIV1_Div11 RCC_CFGR2_PREDIV1_DIV11  #define: RCC_PREDIV1_Div12 RCC_CFGR2_PREDIV1_DIV12  #define: RCC_PREDIV1_Div13 RCC_CFGR2_PREDIV1_DIV13  #define: RCC_PREDIV1_Div14 RCC_CFGR2_PREDIV1_DIV14  #define: RCC_PREDIV1_Div15 RCC_CFGR2_PREDIV1_DIV15  #define: RCC_PREDIV1_Div16 RCC_CFGR2_PREDIV1_DIV16 RCC_RTC_Clock_Source  #define: RCC_RTCCLKSource_LSE RCC_BDCR_RTCSEL_LSE ...
  • Page 351 Reset and clock control (RCC) UM1581  #define: RCC_SYSCLKSource_HSI RCC_CFGR_SW_HSI  #define: RCC_SYSCLKSource_HSE RCC_CFGR_SW_HSE  #define: RCC_SYSCLKSource_PLLCLK RCC_CFGR_SW_PLL RCC_TIM_clock_source  #define: RCC_TIM1CLK_HCLK ((uint32_t)0x00000000)  #define: RCC_TIM1CLK_PLLCLK RCC_CFGR3_TIM1SW  #define: RCC_TIM8CLK_HCLK ((uint32_t)0x10000000)  #define: RCC_TIM8CLK_PLLCLK ((uint32_t)0x10000200) RCC_USART_clock_source  #define: RCC_USART1CLK_PCLK ((uint32_t)0x10000000) ...
  • Page 352 Reset and clock control (RCC) UM1581  #define: RCC_USART2CLK_SYSCLK ((uint32_t)0x20010000)  #define: RCC_USART2CLK_LSE ((uint32_t)0x20020000)  #define: RCC_USART2CLK_HSI ((uint32_t)0x20030000)  #define: RCC_USART3CLK_PCLK ((uint32_t)0x30000000)  #define: RCC_USART3CLK_SYSCLK ((uint32_t)0x30040000)  #define: RCC_USART3CLK_LSE ((uint32_t)0x30080000)  #define: RCC_USART3CLK_HSI ((uint32_t)0x300C0000)  #define: RCC_UART4CLK_PCLK ((uint32_t)0x40000000)  #define: RCC_UART4CLK_SYSCLK ((uint32_t)0x40100000) ...
  • Page 353 Reset and clock control (RCC) UM1581  #define: RCC_UART5CLK_SYSCLK ((uint32_t)0x50400000)  #define: RCC_UART5CLK_LSE ((uint32_t)0x50800000)  #define: RCC_UART5CLK_HSI ((uint32_t)0x50C00000) RCC_USB_Device_clock_source  #define: RCC_USBCLKSource_PLLCLK_1Div5 ((uint8_t)0x00)  #define: RCC_USBCLKSource_PLLCLK_Div1 ((uint8_t)0x01) DocID023800 Rev 1 353/584...
  • Page 354: Real-Time Clock (Rtc)

    Real-time clock (RTC) UM1581 Real-time clock (RTC) 19.1 RTC Firmware driver registers structures 19.1.1 RTC_TypeDef RTC_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t TR  __IO uint32_t DR  __IO uint32_t CR  __IO uint32_t ISR  __IO uint32_t PRER ...
  • Page 355 Real-time clock (RTC) UM1581  __IO uint32_t RTC_TypeDef::TR  RTC time register, Address offset: 0x00  __IO uint32_t RTC_TypeDef::DR  RTC date register, Address offset: 0x04  __IO uint32_t RTC_TypeDef::CR  RTC control register, Address offset: 0x08  __IO uint32_t RTC_TypeDef::ISR ...
  • Page 356: Rtc_Inittypedef

    Real-time clock (RTC) UM1581  __IO uint32_t RTC_TypeDef::BKP6R  RTC backup register 6, Address offset: 0x68  __IO uint32_t RTC_TypeDef::BKP7R  RTC backup register 7, Address offset: 0x6C  __IO uint32_t RTC_TypeDef::BKP8R  RTC backup register 8, Address offset: 0x70 ...
  • Page 357: Rtc_Datetypedef

    Real-time clock (RTC) UM1581  uint8_t RTC_Hours  uint8_t RTC_Minutes  uint8_t RTC_Seconds  uint8_t RTC_H12 Field Documentation  uint8_t RTC_TimeTypeDef::RTC_Hours  Specifies the RTC Time Hour. This parameter must be set to a value in the 0-12 range if the RTC_HourFormat_12 is selected or 0-23 range if the RTC_HourFormat_24 is selected.
  • Page 358: Rtc_Alarmtypedef

    Real-time clock (RTC) UM1581 19.1.5 RTC_AlarmTypeDef RTC_AlarmTypeDef is defined in the stm32f30x_rtc.h Data Fields  RTC_TimeTypeDef RTC_AlarmTime  uint32_t RTC_AlarmMask  uint32_t RTC_AlarmDateWeekDaySel  uint8_t RTC_AlarmDateWeekDay Field Documentation  RTC_TimeTypeDef RTC_AlarmTypeDef::RTC_AlarmTime  Specifies the RTC Alarm Time members.  uint32_t RTC_AlarmTypeDef::RTC_AlarmMask ...
  • Page 359: Backup Domain Reset

    Real-time clock (RTC) UM1581 PC14 and PC15 can be used as LSE pins only PC13 can be used as the RTC_AF pin 19.2.2 Backup Domain Reset The backup domain reset sets all RTC registers and the RCC_BDCR register to their reset values.
  • Page 360 Real-time clock (RTC) UM1581 RTC Wakeup configuration  Configure the RTC Wakeup Clock source use the RTC_WakeUpClockConfig() function.  Configure the RTC WakeUp Counter using the RTC_SetWakeUpCounter() function  Enable the RTC WakeUp using the RTC_WakeUpCmd() function  To read the RTC WakeUp Counter register, use the RTC_GetWakeUpCounter() function.
  • Page 361: Rtc And Low Power Modes

    UM1581 Real-time clock (RTC) 19.2.5 RTC and low power modes The MCU can be woken up from a low power mode by an RTC alternate function. The RTC alternate functions are the RTC alarms (Alarm A and Alarm B), RTC wakeup, RTC tamper event detection and RTC time stamp event detection.
  • Page 362: Initialization And Configuration Functions

    Real-time clock (RTC) UM1581 19.2.7 Initialization and Configuration functions This section provide functions allowing to initialize and configure the RTC Prescaler (Synchronous and Asynchronous), RTC Hour format, disable RTC registers Write protection, enter and exit the RTC initialization mode, RTC registers synchronization check and reference clock detection enable.
  • Page 363: Time And Date Configuration Functions

    Real-time clock (RTC) UM1581 All RTC interrupts are connected to the EXTI controller.  To enable the RTC Alarm interrupt, the following sequence is required:  Configure and enable the EXTI Line 17 in interrupt mode and select the rising edge sensitivity using the EXTI_Init() function.
  • Page 364: Wakeup Timer Configuration Functions

    Real-time clock (RTC) UM1581  RTC_SetAlarm()  RTC_AlarmStructInit()  RTC_GetAlarm()  RTC_AlarmCmd()  RTC_AlarmSubSecondConfig()  RTC_GetAlarmSubSecond() 19.2.14 WakeUp Timer configuration functions This section provide functions allowing to program and read the RTC WakeUp.  RTC_WakeUpClockConfig()  RTC_SetWakeUpCounter()  RTC_GetWakeUpCounter()  RTC_WakeUpCmd() 19.2.15 Daylight Saving configuration functions...
  • Page 365: Initialization And Configuration Functions

    Real-time clock (RTC) UM1581  RTC_TamperPinsPrechargeDuration()  RTC_TimeStampOnTamperDetectionCmd()  RTC_TamperPullUpCmd() 19.2.20 Initialization and Configuration functions 19.2.20.1 RTC_DeInit Function Name ErrorStatus RTC_DeInit ( void ) Function Description Deinitializes the RTC registers to their default reset values.  Parameters None.  Return values An ErrorStatus enumeration value: ...
  • Page 366 Real-time clock (RTC) UM1581 Function Name void RTC_StructInit ( RTC_InitTypeDef * RTC_InitStruct) Function Description Fills each RTC_InitStruct member with its default value.  Parameters RTC_InitStruct : pointer to a RTC_InitTypeDef structure which will be initialized.  Return values None.  Notes None.
  • Page 367 Real-time clock (RTC) UM1581 19.2.20.6 RTC_ExitInitMode Function Name void RTC_ExitInitMode ( void ) Function Description Exits the RTC Initialization mode.  Parameters None.  Return values None.  Notes When the initialization sequence is complete, the calendar restarts counting after 4 RTCCLK cycles. ...
  • Page 368: Backup Data Registers Configuration Functions

    Real-time clock (RTC) UM1581 19.2.20.8 RTC_RefClockCmd Function Name ErrorStatus RTC_RefClockCmd ( FunctionalState NewState) Function Description Enables or disables the RTC reference clock detection.  Parameters NewState : new state of the RTC reference clock. This parameter can be: ENABLE or DISABLE. ...
  • Page 369: Output Type Config Configuration Functions

    Real-time clock (RTC) UM1581  Data : Data to be written in the specified RTC Backup data register.  Return values None.  Notes None. 19.2.21.2 RTC_ReadBackupRegister Function Name uint32_t RTC_ReadBackupRegister ( uint32_t RTC_BKP_DR) Function Description Reads data from the specified RTC Backup data Register. ...
  • Page 370: Shift Control Synchronisation Functions

    Real-time clock (RTC) UM1581 19.2.23 Shift control synchronisation functions 19.2.23.1 RTC_SynchroShiftConfig Function Name ErrorStatus RTC_SynchroShiftConfig ( uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS) Function Description Configures the Synchronization Shift Control Settings.  Parameters RTC_ShiftAdd1S : : Select to add or not 1 second to the time Calendar.
  • Page 371 Real-time clock (RTC) UM1581 19.2.24.2 RTC_GetFlagStatus Function Name FlagStatus RTC_GetFlagStatus ( uint32_t RTC_FLAG) Function Description Checks whether the specified RTC flag is set or not.  Parameters RTC_FLAG : specifies the flag to check. This parameter can be one of the following values: ...
  • Page 372 Real-time clock (RTC) UM1581  RTC_FLAG_WUTF : WakeUp Timer flag  RTC_FLAG_ALRBF : Alarm B flag  RTC_FLAG_ALRAF : Alarm A flag  RTC_FLAG_RSF : Registers Synchronized flag  Return values None.  Notes None. 19.2.24.4 RTC_GetITStatus Function Name ITStatus RTC_GetITStatus ( uint32_t RTC_IT) Function Description Checks whether the specified RTC interrupt has occurred or not.
  • Page 373: Time And Date Configuration Functions

    Real-time clock (RTC) UM1581  RTC_IT_TAMP3 : Tamper3 event interrupt  Return values None.  Notes None. 19.2.25 Time and Date configuration functions 19.2.25.1 RTC_SetTime Function Name ErrorStatus RTC_SetTime ( uint32_t RTC_Format, RTC_TimeTypeDef * RTC_TimeStruct) Function Description Set the RTC current time. ...
  • Page 374 Real-time clock (RTC) UM1581 19.2.25.3 RTC_GetTime Function Name void RTC_GetTime ( uint32_t RTC_Format, RTC_TimeTypeDef RTC_TimeStruct) Function Description Get the RTC current Time.  Parameters RTC_Format : specifies the format of the returned parameters. This parameter can be one of the following values: ...
  • Page 375 Real-time clock (RTC) UM1581  Parameters RTC_Format : specifies the format of the entered parameters. This parameter can be one of the following values:  RTC_Format_BIN : Binary data format  RTC_Format_BCD : BCD data format  RTC_DateStruct : pointer to a RTC_DateTypeDef structure that contains the date configuration information for the RTC.
  • Page 376: Alarm Configuration Functions

    Real-time clock (RTC) UM1581  Return values None.  Notes None. 19.2.26 Alarm configuration functions 19.2.26.1 RTC_SetAlarm Function Name void RTC_SetAlarm ( uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef * RTC_AlarmStruct) Function Description Set the specified RTC Alarm.  Parameters RTC_Format : specifies the format of the returned parameters.
  • Page 377 Real-time clock (RTC) UM1581 19.2.26.3 RTC_GetAlarm Function Name void RTC_GetAlarm ( uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef * RTC_AlarmStruct) Function Description Get the RTC Alarm value and masks.  Parameters RTC_Format : specifies the format of the output parameters. This parameter can be one of the following values: ...
  • Page 378 Real-time clock (RTC) UM1581 19.2.26.5 RTC_AlarmSubSecondConfig Function Name void RTC_AlarmSubSecondConfig ( uint32_t RTC_Alarm, uint32_t RTC_AlarmSubSecondValue, uint32_t RTC_AlarmSubSecondMask) Function Description Configures the RTC AlarmA/B Subseconds value and mask.  Parameters RTC_Alarm : specifies the alarm to be configured. This parameter can be one of the following values: ...
  • Page 379: Wakeup Timer Configuration Functions

    Real-time clock (RTC) UM1581 are don't care in Alarm comparison. Only SS[11:0] are compared  RTC_AlarmSubSecondMask_SS14_13 : SS[14:13] are don't care in Alarm comparison. Only SS[12:0] are compared  RTC_AlarmSubSecondMask_SS14 : SS[14] is don't care in Alarm comparison. Only SS[13:0] are compared ...
  • Page 380 Real-time clock (RTC) UM1581  RTC_WakeUpClock_CK_SPRE_16bits : RTC Wakeup Counter Clock = CK_SPRE  RTC_WakeUpClock_CK_SPRE_17bits : RTC Wakeup Counter Clock = CK_SPRE  Return values None.  Notes The WakeUp Clock source can only be changed when the RTC WakeUp is disabled (Use the RTC_WakeUpCmd(DISABLE)).
  • Page 381: Daylight Saving Configuration Functions

    Real-time clock (RTC) UM1581 19.2.27.4 RTC_WakeUpCmd Function Name ErrorStatus RTC_WakeUpCmd ( FunctionalState NewState) Function Description Enables or Disables the RTC WakeUp timer.  Parameters NewState : new state of the WakeUp timer. This parameter can be: ENABLE or DISABLE.  Return values None.
  • Page 382: Output Pin Configuration Functions

    Real-time clock (RTC) UM1581 19.2.28.2 RTC_GetStoreOperation Function Name uint32_t RTC_GetStoreOperation ( void ) Function Description Returns the RTC Day Light Saving stored operation.  Parameters None.  Return values RTC Day Light Saving stored operation.  RTC_StoreOperation_Reset  RTC_StoreOperation_Set  Notes None.
  • Page 383: Digital Calibration Configuration Functions

    Real-time clock (RTC) UM1581 19.2.30 Digital calibration configuration functions 19.2.30.1 RTC_CalibOutputCmd Function Name void RTC_CalibOutputCmd ( FunctionalState NewState) Function Description Enables or disables the RTC clock to be output through the relative pin.  Parameters NewState : new state of the digital calibration Output. This parameter can be: ENABLE or DISABLE.
  • Page 384: Timestamp Configuration Functions

    Real-time clock (RTC) UM1581  Parameters RTC_SmoothCalibPeriod : : Select the Smooth Calibration Period. This parameter can be can be one of the following values:  RTC_SmoothCalibPeriod_32sec : The smooth calibration periode is 32s.  RTC_SmoothCalibPeriod_16sec : The smooth calibration periode is 16s. ...
  • Page 385: Tamper Configuration Functions

    Real-time clock (RTC) UM1581 19.2.31.2 RTC_GetTimeStamp Function Name void RTC_GetTimeStamp ( uint32_t RTC_Format, RTC_TimeTypeDef * RTC_StampTimeStruct, RTC_DateTypeDef * RTC_StampDateStruct) Function Description Gets the RTC TimeStamp value and masks.  Parameters RTC_Format : specifies the format of the output parameters. This parameter can be one of the following values: ...
  • Page 386 Real-time clock (RTC) UM1581 uint32_t RTC_TamperTrigger) Function Description Configures the select Tamper pin edge.  Parameters RTC_Tamper : Selected tamper pin. This parameter can be any combination of the following values:  RTC_Tamper_1 : Select Tamper 1.  RTC_Tamper_2 : Select Tamper 2.
  • Page 387 Real-time clock (RTC) UM1581 19.2.32.3 RTC_TamperFilterConfig Function Name void RTC_TamperFilterConfig ( uint32_t RTC_TamperFilter) Function Description Configures the Tampers Filter.  Parameters RTC_TamperFilter : Specifies the tampers filter. This parameter can be one of the following values:  RTC_TamperFilter_Disable : Tamper filter is disabled. ...
  • Page 388 Real-time clock (RTC) UM1581  RTC_TamperSamplingFreq_RTCCLK_Div512 : Each of the tamper inputs are sampled with a frequency = RTCCLK / 512  RTC_TamperSamplingFreq_RTCCLK_Div256 : Each of the tamper inputs are sampled with a frequency = RTCCLK / 256  Return values None.
  • Page 389: Rtc Firmware Driver Defines

    Real-time clock (RTC) UM1581  Parameters NewState : new state of the timestamp on tamper event. This parameter can be: ENABLE or DISABLE.  Return values None.  Notes The timestamp is valid even the TSE bit in tamper control register is reset.
  • Page 390 Real-time clock (RTC) UM1581 RTC_AlarmMask_Definitions  #define: RTC_AlarmMask_None ((uint32_t)0x00000000)  #define: RTC_AlarmMask_DateWeekDay ((uint32_t)0x80000000)  #define: RTC_AlarmMask_Hours ((uint32_t)0x00800000)  #define: RTC_AlarmMask_Minutes ((uint32_t)0x00008000)  #define: RTC_AlarmMask_Seconds ((uint32_t)0x00000080)  #define: RTC_AlarmMask_All ((uint32_t)0x80808080) RTC_Alarms_Definitions  #define: RTC_Alarm_A ((uint32_t)0x00000100)  #define: RTC_Alarm_B ((uint32_t)0x00000200) RTC_Alarm_Sub_Seconds_Masks_Definitions  #define: RTC_AlarmSubSecondMask_All ((uint32_t)0x00000000) All Alarm SS fields are masked.
  • Page 391 Real-time clock (RTC) UM1581  #define: RTC_AlarmSubSecondMask_SS14_3 ((uint32_t)0x03000000) SS[14:3] are don't care in Alarm comparison. Only SS[2:0] are compared  #define: RTC_AlarmSubSecondMask_SS14_4 ((uint32_t)0x04000000) SS[14:4] are don't care in Alarm comparison. Only SS[3:0] are compared  #define: RTC_AlarmSubSecondMask_SS14_5 ((uint32_t)0x05000000) SS[14:5] are don't care in Alarm comparison. Only SS[4:0] are compared ...
  • Page 392 Real-time clock (RTC) UM1581  #define: RTC_AlarmSubSecondMask_None ((uint32_t)0x0F000000) SS[14:0] are compared and must match to activate alarm. RTC_AM_PM_Definitions  #define: RTC_H12_AM ((uint8_t)0x00)  #define: RTC_H12_PM ((uint8_t)0x40) RTC_Backup_Registers_Definitions  #define: RTC_BKP_DR0 ((uint32_t)0x00000000)  #define: RTC_BKP_DR1 ((uint32_t)0x00000001)  #define: RTC_BKP_DR2 ((uint32_t)0x00000002)  #define: RTC_BKP_DR3 ((uint32_t)0x00000003) ...
  • Page 393 Real-time clock (RTC) UM1581  #define: RTC_BKP_DR8 ((uint32_t)0x00000008)  #define: RTC_BKP_DR9 ((uint32_t)0x00000009)  #define: RTC_BKP_DR10 ((uint32_t)0x0000000A)  #define: RTC_BKP_DR11 ((uint32_t)0x0000000B)  #define: RTC_BKP_DR12 ((uint32_t)0x0000000C)  #define: RTC_BKP_DR13 ((uint32_t)0x0000000D)  #define: RTC_BKP_DR14 ((uint32_t)0x0000000E)  #define: RTC_BKP_DR15 ((uint32_t)0x0000000F) RTC_Calib_Output_selection_Definitions  #define: RTC_CalibOutput_512Hz ((uint32_t)0x00000000) ...
  • Page 394 Real-time clock (RTC) UM1581  #define: RTC_StoreOperation_Reset ((uint32_t)0x00000000)  #define: RTC_StoreOperation_Set ((uint32_t)0x00040000) RTC_Digital_Calibration_Definitions  #define: RTC_CalibSign_Positive ((uint32_t)0x00000000)  #define: RTC_CalibSign_Negative ((uint32_t)0x00000080) RTC_Flags_Definitions  #define: RTC_FLAG_RECALPF ((uint32_t)0x00010000)  #define: RTC_FLAG_TAMP3F ((uint32_t)0x00008000)  #define: RTC_FLAG_TAMP2F ((uint32_t)0x00004000)  #define: RTC_FLAG_TAMP1F ((uint32_t)0x00002000)  #define: RTC_FLAG_TSOVF ((uint32_t)0x00001000) ...
  • Page 395 Real-time clock (RTC) UM1581  #define: RTC_FLAG_ALRBF ((uint32_t)0x00000200)  #define: RTC_FLAG_ALRAF ((uint32_t)0x00000100)  #define: RTC_FLAG_INITF ((uint32_t)0x00000040)  #define: RTC_FLAG_RSF ((uint32_t)0x00000020)  #define: RTC_FLAG_INITS ((uint32_t)0x00000010)  #define: RTC_FLAG_SHPF ((uint32_t)0x00000008)  #define: RTC_FLAG_WUTWF ((uint32_t)0x00000004)  #define: RTC_FLAG_ALRBWF ((uint32_t)0x00000002)  #define: RTC_FLAG_ALRAWF ((uint32_t)0x00000001) RTC_Hour_Formats ...
  • Page 396 Real-time clock (RTC) UM1581  #define: RTC_Format_BIN ((uint32_t)0x000000000)  #define: RTC_Format_BCD ((uint32_t)0x000000001) RTC_Interrupts_Definitions  #define: RTC_IT_TS ((uint32_t)0x00008000)  #define: RTC_IT_WUT ((uint32_t)0x00004000)  #define: RTC_IT_ALRB ((uint32_t)0x00002000)  #define: RTC_IT_ALRA ((uint32_t)0x00001000)  #define: RTC_IT_TAMP ((uint32_t)0x00000004)  #define: RTC_IT_TAMP1 ((uint32_t)0x00020000)  #define: RTC_IT_TAMP2 ((uint32_t)0x00040000) ...
  • Page 397 Real-time clock (RTC) UM1581  #define: RTC_Month_March ((uint8_t)0x03)  #define: RTC_Month_April ((uint8_t)0x04)  #define: RTC_Month_May ((uint8_t)0x05)  #define: RTC_Month_June ((uint8_t)0x06)  #define: RTC_Month_July ((uint8_t)0x07)  #define: RTC_Month_August ((uint8_t)0x08)  #define: RTC_Month_September ((uint8_t)0x09)  #define: RTC_Month_October ((uint8_t)0x10)  #define: RTC_Month_November ((uint8_t)0x11) ...
  • Page 398 Real-time clock (RTC) UM1581  #define: RTC_OutputPolarity_Low ((uint32_t)0x00100000) RTC_Output_selection_Definitions  #define: RTC_Output_Disable ((uint32_t)0x00000000)  #define: RTC_Output_AlarmA ((uint32_t)0x00200000)  #define: RTC_Output_AlarmB ((uint32_t)0x00400000)  #define: RTC_Output_WakeUp ((uint32_t)0x00600000) RTC_Output_Type_ALARM_OUT  #define: RTC_OutputType_OpenDrain ((uint32_t)0x00000000)  #define: RTC_OutputType_PushPull ((uint32_t)0x00040000) RTC_Smooth_calib_period_Definitions  #define: RTC_SmoothCalibPeriod_32sec ((uint32_t)0x00000000) if RTCCLK = 32768 Hz, Smooth calibation period is 32s, else 2exp20 RTCCLK seconds ...
  • Page 399 Real-time clock (RTC) UM1581  #define: RTC_SmoothCalibPlusPulses_Reset ((uint32_t)0x00000000) The number of RTCCLK pulses subbstited during a 32-second window = CALM[8:0]. RTC_Tamper_Filter_Definitions  #define: RTC_TamperFilter_Disable ((uint32_t)0x00000000) Tamper filter is disabled  #define: RTC_TamperFilter_2Sample ((uint32_t)0x00000800) Tamper is activated after 2 consecutive samples at the active level ...
  • Page 400 Real-time clock (RTC) UM1581  #define: RTC_TamperPrechargeDuration_8RTCCLK ((uint32_t)0x00006000) Tamper pins are pre-charged before sampling during 8 RTCCLK cycles RTC_Tamper_Sampling_Frequencies_Definitions  #define: RTC_TamperSamplingFreq_RTCCLK_Div32768 ((uint32_t)0x00000000) Each of the tamper inputs are sampled with a frequency = RTCCLK / 32768  #define: RTC_TamperSamplingFreq_RTCCLK_Div16384 ((uint32_t)0x000000100) Each of the tamper inputs are sampled with a frequency = RTCCLK / 16384 ...
  • Page 401 Real-time clock (RTC) UM1581  #define: RTC_TamperTrigger_LowLevel ((uint32_t)0x00000000)  #define: RTC_TamperTrigger_HighLevel ((uint32_t)0x00000001) RTC_Time_Stamp_Edges_definitions  #define: RTC_TimeStampEdge_Rising ((uint32_t)0x00000000)  #define: RTC_TimeStampEdge_Falling ((uint32_t)0x00000008) RTC_Wakeup_Timer_Definitions  #define: RTC_WakeUpClock_RTCCLK_Div16 ((uint32_t)0x00000000)  #define: RTC_WakeUpClock_RTCCLK_Div8 ((uint32_t)0x00000001)  #define: RTC_WakeUpClock_RTCCLK_Div4 ((uint32_t)0x00000002)  #define: RTC_WakeUpClock_RTCCLK_Div2 ((uint32_t)0x00000003)  #define: RTC_WakeUpClock_CK_SPRE_16bits ((uint32_t)0x00000004) ...
  • Page 402 Real-time clock (RTC) UM1581  #define: RTC_Weekday_Tuesday ((uint8_t)0x02)  #define: RTC_Weekday_Wednesday ((uint8_t)0x03)  #define: RTC_Weekday_Thursday ((uint8_t)0x04)  #define: RTC_Weekday_Friday ((uint8_t)0x05)  #define: RTC_Weekday_Saturday ((uint8_t)0x06)  #define: RTC_Weekday_Sunday ((uint8_t)0x07) 402/584 DocID023800 Rev 1...
  • Page 403: Serial Peripheral Interface (Spi)

    Serial peripheral interface (SPI) UM1581 Serial peripheral interface (SPI) 20.1 SPI Firmware driver registers structures 20.1.1 SPI_TypeDef SPI_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint16_t CR1  uint16_t RESERVED0  __IO uint16_t CR2  uint16_t RESERVED1  __IO uint16_t SR ...
  • Page 404: Spi_Inittypedef

    Serial peripheral interface (SPI) UM1581  uint16_t SPI_TypeDef::RESERVED4  Reserved, 0x12  __IO uint16_t SPI_TypeDef::RXCRCR  SPI Rx CRC register (not used in I2S mode), Address offset: 0x14  uint16_t SPI_TypeDef::RESERVED5  Reserved, 0x16  __IO uint16_t SPI_TypeDef::TXCRCR  SPI Tx CRC register (not used in I2S mode), Address offset: 0x18 ...
  • Page 405: I2S_Inittypedef

    Serial peripheral interface (SPI) UM1581  Specifies the clock active edge for the bit capture. This parameter can be a value SPI_Clock_Phase  uint16_t SPI_InitTypeDef::SPI_NSS  Specifies whether the NSS signal is managed by hardware (NSS pin) or by software using the SSI bit. This parameter can be a value of SPI_Slave_Select_management ...
  • Page 406: Spi Firmware Driver Api Description

    Serial peripheral interface (SPI) UM1581 20.2 SPI Firmware driver API description The following section lists the various functions of the SPI library. 20.2.1 How to use this driver Enable peripheral clock using RCC_APBPeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE) function for SPI1 or using RCC_APBPeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE) function for SPI2. Enable SCK, MOSI, MISO and NSS GPIO clocks using RCC_AHBPeriphClockCmd() function.
  • Page 407: Initialization And Configuration Functions

    Serial peripheral interface (SPI) UM1581 Configure SPIx in I2S mode (I2S_Init() function) as described above. Call the I2S_FullDuplexConfig() function using the same strucutre passed to I2S_Init() function. Call I2S_Cmd() for SPIx then for its extended block. Configure interrupts or DMA requests and to get/clear flag status, use I2Sxext instance for the extension block.
  • Page 408: Data Transfers Functions

    Serial peripheral interface (SPI) UM1581  I2S_StructInit()  I2S_Init()  SPI_Cmd()  SPI_TIModeCmd()  I2S_Cmd()  SPI_DataSizeConfig()  SPI_RxFIFOThresholdConfig()  SPI_BiDirectionalLineConfig()  SPI_NSSInternalSoftwareConfig()  I2S_FullDuplexConfig()  SPI_SSOutputCmd()  SPI_NSSPulseModeCmd() 20.2.3 Data transfers functions This section provides a set of functions allowing to manage the SPI or I2S data transfers. In reception, data are received and then stored into an internal Rx buffer while In transmission, data are first stored into an internal Tx buffer before being transmitted.
  • Page 409: Dma Transfers Management Functions

    Serial peripheral interface (SPI) UM1581 SCK slave input clock as soon as CRCEN is set, and this, whatever the value of the SPE bit.  With high bitrate frequencies, be careful when transmitting the CRC. As the number of used CPU cycles has to be as low as possible in the CRC transfer phase, it is forbidden to call software functions in the CRC transmission sequence to avoid errors in the last data and CRC reception.
  • Page 410 Serial peripheral interface (SPI) UM1581 SPI_I2S_FLAG_TXE : to indicate the status of the transmit buffer register. SPI_I2S_FLAG_RXNE : to indicate the status of the receive buffer register. SPI_I2S_FLAG_BSY : to indicate the state of the communication layer of the SPI. SPI_FLAG_CRCERR : to indicate if a CRC Calculation error occur.
  • Page 411: Initialization And Configuration Functions

    Serial peripheral interface (SPI) UM1581  void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState);  SPI_I2S_ITConfig()  SPI_GetTransmissionFIFOStatus()  SPI_GetReceptionFIFOStatus()  SPI_I2S_GetFlagStatus()  SPI_I2S_ClearFlag()  SPI_I2S_GetITStatus() 20.2.7 Initialization and configuration functions 20.2.7.1 SPI_I2S_DeInit Function Name void SPI_I2S_DeInit ( SPI_TypeDef * SPIx) Function Description Deinitializes the SPIx peripheral registers to their default reset values.
  • Page 412 Serial peripheral interface (SPI) UM1581 SPI_InitStruct) Function Description Initializes the SPIx peripheral according to the specified parameters in the SPI_InitStruct.  Parameters SPIx : where x can be 1, 2 or 3 to select the SPI peripheral.  SPI_InitStruct : pointer to a SPI_InitTypeDef structure that contains the configuration information for the specified SPI peripheral.
  • Page 413 Serial peripheral interface (SPI) UM1581 configuration). But in case the prescaler value is greater than 511, the default value (0x02) will be configured instead. 20.2.7.6 SPI_Cmd Function Name void SPI_Cmd ( SPI_TypeDef * SPIx, FunctionalState NewState) Function Description Enables or disables the specified SPI peripheral. ...
  • Page 414 Serial peripheral interface (SPI) UM1581 20.2.7.8 I2S_Cmd Function Name void I2S_Cmd ( SPI_TypeDef * SPIx, FunctionalState NewState) Function Description Enables or disables the specified SPI peripheral (in I2S mode).  Parameters SPIx:To : select the SPIx peripheral, where x can be: 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
  • Page 415 Serial peripheral interface (SPI) UM1581 20.2.7.10 SPI_RxFIFOThresholdConfig Function Name void SPI_RxFIFOThresholdConfig ( SPI_TypeDef * SPIx, uint16_t SPI_RxFIFOThreshold) Function Description Configures the FIFO reception threshold for the selected SPI.  Parameters SPIx : where x can be 1, 2 or 3 to select the SPI peripheral. ...
  • Page 416 Serial peripheral interface (SPI) UM1581 20.2.7.12 SPI_NSSInternalSoftwareConfig Function Name void SPI_NSSInternalSoftwareConfig ( SPI_TypeDef * SPIx, uint16_t SPI_NSSInternalSoft) Function Description Configures internally by software the NSS pin for the selected SPI.  Parameters SPIx : where x can be 1, 2 or 3 to select the SPI peripheral. ...
  • Page 417 Serial peripheral interface (SPI) UM1581 20.2.7.14 SPI_SSOutputCmd Function Name void SPI_SSOutputCmd ( SPI_TypeDef * SPIx, FunctionalState NewState) Function Description Enables or disables the SS output for the selected SPI.  Parameters SPIx : where x can be 1, 2 or 3 to select the SPI peripheral. ...
  • Page 418: Data Transfer Functions

    Serial peripheral interface (SPI) UM1581 20.2.8 Data transfer functions 20.2.8.1 SPI_SendData8 Function Name void SPI_SendData8 ( SPI_TypeDef * SPIx, uint8_t Data) Function Description Transmits a Data through the SPIx peripheral.  Parameters SPIx : where x can be 1, 2 or 3 to select the SPI peripheral. ...
  • Page 419: Hardware Crc Calculation Functions

    Serial peripheral interface (SPI) UM1581 20.2.8.4 SPI_I2S_ReceiveData16 Function Name uint16_t SPI_I2S_ReceiveData16 ( SPI_TypeDef * SPIx) Function Description Returns the most recent received data by the SPIx peripheral.  Parameters SPIx : To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
  • Page 420 Serial peripheral interface (SPI) UM1581 20.2.9.2 SPI_CalculateCRC Function Name void SPI_CalculateCRC ( SPI_TypeDef * SPIx, FunctionalState NewState) Function Description Enables or disables the CRC value calculation of the transferred bytes.  Parameters SPIx : where x can be 1, 2 or 3 to select the SPI peripheral. ...
  • Page 421: Dma Transfers Management Functions

    Serial peripheral interface (SPI) UM1581  Notes None. 20.2.9.5 SPI_GetCRCPolynomial Function Name uint16_t SPI_GetCRCPolynomial ( SPI_TypeDef * SPIx) Function Description Returns the CRC Polynomial register value for the specified SPI.  Parameters SPIx : where x can be 1, 2 or 3 to select the SPI peripheral. ...
  • Page 422: Interrupts And Flags Management Functions

    Serial peripheral interface (SPI) UM1581 20.2.10.2 SPI_LastDMATransferCmd Function Name void SPI_LastDMATransferCmd ( SPI_TypeDef * SPIx, uint16_t SPI_LastDMATransfer) Function Description Configures the number of data to transfer type(Even/Odd) for the DMA last transfers and for the selected SPI.  Parameters SPIx : where x can be 1, 2 or 3 to select the SPI peripheral. ...
  • Page 423 Serial peripheral interface (SPI) UM1581  SPI_I2S_IT_ERR : Error interrupt mask  NewState : new state of the specified SPI interrupt. This parameter can be: ENABLE or DISABLE.  Return values None.  Notes None. 20.2.11.2 SPI_GetTransmissionFIFOStatus Function Name uint16_t SPI_GetTransmissionFIFOStatus ( SPI_TypeDef * SPIx) Function Description...
  • Page 424 Serial peripheral interface (SPI) UM1581  Notes None. 20.2.11.4 SPI_I2S_GetFlagStatus Function Name FlagStatus SPI_I2S_GetFlagStatus ( SPI_TypeDef * SPIx, uint16_t SPI_I2S_FLAG) Function Description Checks whether the specified SPI flag is set or not.  Parameters SPIx : To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
  • Page 425: Spi Firmware Driver Defines

    Serial peripheral interface (SPI) UM1581 read operation to SPI_DR register (SPI_I2S_ReceiveData()) followed by a read operation to SPI_SR register (SPI_I2S_GetFlagStatus()).  MODF (Mode Fault) flag is cleared by software sequence: a read/write operation to SPI_SR register (SPI_I2S_GetFlagStatus()) followed by a write operation to SPI_CR1 register (SPI_Cmd() to enable the SPI).
  • Page 426 Serial peripheral interface (SPI) UM1581  #define: SPI_BaudRatePrescaler_8 ((uint16_t)0x0010)  #define: SPI_BaudRatePrescaler_16 ((uint16_t)0x0018)  #define: SPI_BaudRatePrescaler_32 ((uint16_t)0x0020)  #define: SPI_BaudRatePrescaler_64 ((uint16_t)0x0028)  #define: SPI_BaudRatePrescaler_128 ((uint16_t)0x0030)  #define: SPI_BaudRatePrescaler_256 ((uint16_t)0x0038) SPI_Clock_Phase  #define: SPI_CPHA_1Edge ((uint16_t)0x0000)  #define: SPI_CPHA_2Edge ((uint16_t)0x0001) SPI_Clock_Polarity  #define: SPI_CPOL_Low ((uint16_t)0x0000) ...
  • Page 427 Serial peripheral interface (SPI) UM1581  #define: SPI_CRCLength_16b ((uint16_t)0x0800) SPI_CRC_Transmit_Receive  #define: SPI_CRC_Tx ((uint8_t)0x00)  #define: SPI_CRC_Rx ((uint8_t)0x01) SPI_data_direction  #define: SPI_Direction_2Lines_FullDuplex ((uint16_t)0x0000)  #define: SPI_Direction_2Lines_RxOnly ((uint16_t)0x0400)  #define: SPI_Direction_1Line_Rx ((uint16_t)0x8000)  #define: SPI_Direction_1Line_Tx ((uint16_t)0xC000) SPI_data_size  #define: SPI_DataSize_4b ((uint16_t)0x0300) ...
  • Page 428 Serial peripheral interface (SPI) UM1581  #define: SPI_DataSize_8b ((uint16_t)0x0700)  #define: SPI_DataSize_9b ((uint16_t)0x0800)  #define: SPI_DataSize_10b ((uint16_t)0x0900)  #define: SPI_DataSize_11b ((uint16_t)0x0A00)  #define: SPI_DataSize_12b ((uint16_t)0x0B00)  #define: SPI_DataSize_13b ((uint16_t)0x0C00)  #define: SPI_DataSize_14b ((uint16_t)0x0D00)  #define: SPI_DataSize_15b ((uint16_t)0x0E00)  #define: SPI_DataSize_16b ((uint16_t)0x0F00) SPI_direction_transmit_receive ...
  • Page 429 Serial peripheral interface (SPI) UM1581 SPI_FIFO_reception_threshold  #define: SPI_RxFIFOThreshold_HF ((uint16_t)0x0000)  #define: SPI_RxFIFOThreshold_QF ((uint16_t)0x1000) SPI_I2S_DMA_transfer_requests  #define: SPI_I2S_DMAReq_Tx ((uint16_t)0x0002)  #define: SPI_I2S_DMAReq_Rx ((uint16_t)0x0001) SPI_I2S_flags_definition  #define: SPI_I2S_FLAG_RXNE ((uint16_t)0x0001)  #define: SPI_I2S_FLAG_TXE ((uint16_t)0x0002)  #define: I2S_FLAG_CHSIDE ((uint16_t)0x0004)  #define: I2S_FLAG_UDR ((uint16_t)0x0008) ...
  • Page 430 Serial peripheral interface (SPI) UM1581  #define: SPI_I2S_FLAG_BSY ((uint16_t)0x0080)  #define: SPI_I2S_FLAG_FRE ((uint16_t)0x0100) SPI_I2S_interrupts_definition  #define: SPI_I2S_IT_TXE ((uint8_t)0x71)  #define: SPI_I2S_IT_RXNE ((uint8_t)0x60)  #define: SPI_I2S_IT_ERR ((uint8_t)0x50)  #define: I2S_IT_UDR ((uint8_t)0x53)  #define: SPI_IT_MODF ((uint8_t)0x55)  #define: SPI_I2S_IT_OVR ((uint8_t)0x56)  #define: SPI_I2S_IT_FRE ((uint8_t)0x58) SPI_last_DMA_transfers ...
  • Page 431 Serial peripheral interface (SPI) UM1581  #define: SPI_LastDMATransfer_TxOddRxOdd ((uint16_t)0x6000) SPI_mode  #define: SPI_Mode_Master ((uint16_t)0x0104)  #define: SPI_Mode_Slave ((uint16_t)0x0000) SPI_MSB_LSB_transmission  #define: SPI_FirstBit_MSB ((uint16_t)0x0000)  #define: SPI_FirstBit_LSB ((uint16_t)0x0080) SPI_NSS_internal_software_management  #define: SPI_NSSInternalSoft_Set ((uint16_t)0x0100)  #define: SPI_NSSInternalSoft_Reset ((uint16_t)0xFEFF) SPI_reception_fifo_status_level  #define: SPI_ReceptionFIFOStatus_Empty ((uint16_t)0x0000) ...
  • Page 432 Serial peripheral interface (SPI) UM1581  #define: SPI_ReceptionFIFOStatus_Full ((uint16_t)0x0600) SPI_Slave_Select_management  #define: SPI_NSS_Soft ((uint16_t)0x0200)  #define: SPI_NSS_Hard ((uint16_t)0x0000) SPI_transmission_fifo_status_level  #define: SPI_TransmissionFIFOStatus_Empty ((uint16_t)0x0000)  #define: SPI_TransmissionFIFOStatus_1QuarterFull ((uint16_t)0x0800)  #define: SPI_TransmissionFIFOStatus_HalfFull ((uint16_t)0x1000)  #define: SPI_TransmissionFIFOStatus_Full ((uint16_t)0x1800) 432/584 DocID023800 Rev 1...
  • Page 433: System Configuration Controller (Syscfg)

    System configuration controller (SYSCFG) UM1581 System configuration controller (SYSCFG) 21.1 SYSCFG Firmware driver registers structures 21.1.1 SYSCFG_TypeDef SYSCFG_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t CFGR1  __IO uint32_t RCR  __IO uint32_t EXTICR  __IO uint32_t CFGR2 Field Documentation ...
  • Page 434: Syscfg Initialization And Configuration Functions

    System configuration controller (SYSCFG) UM1581  SYSCFG_I2CFastModePlusConfig()  SYSCFG_ITConfig()  SYSCFG_EXTILineConfig()  SYSCFG_BreakConfig()  SYSCFG_BypassParityCheckDisable()  SYSCFG_SRAMWRPEnable()  SYSCFG_GetFlagStatus()  SYSCFG_ClearFlag() 21.2.3 SYSCFG initialization and configuration functions 21.2.3.1 SYSCFG_DeInit Function Name void SYSCFG_DeInit ( void ) Function Description Deinitializes the SYSCFG registers to their default reset values. ...
  • Page 435 System configuration controller (SYSCFG) UM1581 21.2.3.3 SYSCFG_DMAChannelRemapConfig Function Name void SYSCFG_DMAChannelRemapConfig ( uint32_t SYSCFG_DMARemap, FunctionalState NewState) Function Configures the DMA channels remapping. Description  Parameters SYSCFG_DMARemap : selects the DMA channels remap. This parameter can be one of the following values: ...
  • Page 436 System configuration controller (SYSCFG) UM1581 trigger from TIM8 to TIM3  SYSCFG_TriggerRemap_TIM1TIM17 : Remap TIM1 ITR3 from TIM4 TRGO to TIM17 OC  NewState : new state of the trigger mapping. This parameter can be: ENABLE or DISABLE.  Return values None.
  • Page 437 System configuration controller (SYSCFG) UM1581  ENABLE : Remap the USB interrupt line as following:  USB :  USB :  USB :  DISABLE : Use the default USB interrupt line:  USB :  USB :  USB : ...
  • Page 438 System configuration controller (SYSCFG) UM1581 SYSCFG_I2CFastModePlus_I2C1 parameter.  For all I2C2 pins fast mode plus driving capability can be enabled only by using SYSCFG_I2CFastModePlus_I2C2 parameter. 21.2.3.8 SYSCFG_ITConfig Function Name void SYSCFG_ITConfig ( uint32_t SYSCFG_IT, FunctionalState NewState) Function Description Enables or disables the selected SYSCFG interrupts. ...
  • Page 439 System configuration controller (SYSCFG) UM1581 21.2.3.10 SYSCFG_BreakConfig Function Name void SYSCFG_BreakConfig ( uint32_t SYSCFG_Break) Function Description Connects the selected parameter to the break input of TIM1.  Parameters SYSCFG_Break : selects the configuration to be connected to break input of TIM1 This parameter can be any combination of the following values: ...
  • Page 440 System configuration controller (SYSCFG) UM1581 21.2.3.12 SYSCFG_SRAMWRPEnable Function Name void SYSCFG_SRAMWRPEnable ( uint32_t SYSCFG_SRAMWRP) Function Description Enables the ICODE SRAM write protection.  Parameters None.  Return values None.  Notes Enabling the ICODE SRAM write protection locks the configuration bit. To disable the ICODE SRAM write protection perform a system reset.
  • Page 441: Syscfg Firmware Driver Defines

    System configuration controller (SYSCFG) UM1581 21.3 SYSCFG Firmware driver defines 21.3.1 SYSCFG SYSCFG SYSCFG_DMA_Remap_Config  #define: SYSCFG_DMARemap_TIM17 SYSCFG_CFGR1_TIM17_DMA_RMP Remap TIM17 DMA requests from channel1 to channel2  #define: SYSCFG_DMARemap_TIM16 SYSCFG_CFGR1_TIM16_DMA_RMP Remap TIM16 DMA requests from channel3 to channel4  #define: SYSCFG_DMARemap_TIM6DAC1 SYSCFG_CFGR1_TIM6DAC1_DMA_RMP Remap TIM6/DAC1 DMA requests from DMA2 channel3 to DMA1 channel3 ...
  • Page 442 System configuration controller (SYSCFG) UM1581 SYSCFG_EXTI_Pin_sources  #define: EXTI_PinSource0 ((uint8_t)0x00)  #define: EXTI_PinSource1 ((uint8_t)0x01)  #define: EXTI_PinSource2 ((uint8_t)0x02)  #define: EXTI_PinSource3 ((uint8_t)0x03)  #define: EXTI_PinSource4 ((uint8_t)0x04)  #define: EXTI_PinSource5 ((uint8_t)0x05)  #define: EXTI_PinSource6 ((uint8_t)0x06)  #define: EXTI_PinSource7 ((uint8_t)0x07)  #define: EXTI_PinSource8 ((uint8_t)0x08) ...
  • Page 443 System configuration controller (SYSCFG) UM1581  #define: EXTI_PinSource12 ((uint8_t)0x0C)  #define: EXTI_PinSource13 ((uint8_t)0x0D)  #define: EXTI_PinSource14 ((uint8_t)0x0E)  #define: EXTI_PinSource15 ((uint8_t)0x0F) SYSCFG_EXTI_Port_Sources  #define: EXTI_PortSourceGPIOA ((uint8_t)0x00)  #define: EXTI_PortSourceGPIOB ((uint8_t)0x01)  #define: EXTI_PortSourceGPIOC ((uint8_t)0x02)  #define: EXTI_PortSourceGPIOD ((uint8_t)0x03)  #define: EXTI_PortSourceGPIOE ((uint8_t)0x04) ...
  • Page 444 System configuration controller (SYSCFG) UM1581 SYSCFG_FPU_Interrupt_Config  #define: SYSCFG_IT_IXC SYSCFG_CFGR1_FPU_IE_5 Inexact Interrupt enable (interrupt disabled by default)  #define: SYSCFG_IT_IDC SYSCFG_CFGR1_FPU_IE_4 Input denormal Interrupt enable  #define: SYSCFG_IT_OFC SYSCFG_CFGR1_FPU_IE_3 Overflow Interrupt enable  #define: SYSCFG_IT_UFC SYSCFG_CFGR1_FPU_IE_2 Underflow Interrupt enable  #define: SYSCFG_IT_DZC SYSCFG_CFGR1_FPU_IE_1 Divide-by-zero Interrupt enable ...
  • Page 445 System configuration controller (SYSCFG) UM1581  #define: SYSCFG_I2CFastModePlus_I2C2 SYSCFG_CFGR1_I2C2_FMP Enable Fast Mode Plus on I2C2 pins SYSCFG_Lock_Config  #define: SYSCFG_Break_PVD SYSCFG_CFGR2_PVD_LOCK Enables and locks the PVD connection with TIM1/8/15/16/17 Break Input and also the PVD_EN and PVDSEL[2:0] bits of the Power Control Interface ...
  • Page 446 System configuration controller (SYSCFG) UM1581  #define: SYSCFG_SRAMWRP_Page4 SYSCFG_RCR_PAGE4 ICODE SRAM Write protection page 4  #define: SYSCFG_SRAMWRP_Page5 SYSCFG_RCR_PAGE5 ICODE SRAM Write protection page 5  #define: SYSCFG_SRAMWRP_Page6 SYSCFG_RCR_PAGE6 ICODE SRAM Write protection page 6  #define: SYSCFG_SRAMWRP_Page7 SYSCFG_RCR_PAGE7 ICODE SRAM Write protection page 7 SYSCFG_Trigger_Remap_Config ...
  • Page 447: General-Purpose Timers (Tim)

    General-purpose timers (TIM) UM1581 General-purpose timers (TIM) 22.1 TIM Firmware driver registers structures 22.1.1 TIM_TypeDef TIM_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint16_t CR1  uint16_t RESERVED0  __IO uint32_t CR2  __IO uint32_t SMCR  __IO uint32_t DIER ...
  • Page 448 General-purpose timers (TIM) UM1581  TIM slave mode control register, Address offset: 0x08  __IO uint32_t TIM_TypeDef::DIER  TIM DMA/interrupt enable register, Address offset: 0x0C  __IO uint32_t TIM_TypeDef::SR  TIM status register, Address offset: 0x10  __IO uint32_t TIM_TypeDef::EGR ...
  • Page 449: Tim_Timebaseinittypedef

    General-purpose timers (TIM) UM1581 22.1.2 TIM_TimeBaseInitTypeDef TIM_TimeBaseInitTypeDef is defined in the stm32f30x_tim.h Data Fields  uint16_t TIM_Prescaler  uint16_t TIM_CounterMode  uint32_t TIM_Period  uint16_t TIM_ClockDivision  uint8_t TIM_RepetitionCounter Field Documentation  uint16_t TIM_TimeBaseInitTypeDef::TIM_Prescaler  Specifies the prescaler value used to divide the TIM clock. This parameter can be a number between 0x0000 and 0xFFFF ...
  • Page 450: Tim_Icinittypedef

    General-purpose timers (TIM) UM1581 Field Documentation  uint32_t TIM_OCInitTypeDef::TIM_OCMode  Specifies the TIM mode. This parameter can be a value of TIM_Output_Compare_and_PWM_modes  uint16_t TIM_OCInitTypeDef::TIM_OutputState  Specifies the TIM Output Compare state. This parameter can be a value of TIM_Output_Compare_State ...
  • Page 451: Tim_Bdtrinittypedef

    General-purpose timers (TIM) UM1581  uint16_t TIM_ICInitTypeDef::TIM_ICPrescaler  Specifies the Input Capture Prescaler. This parameter can be a value of TIM_Input_Capture_Prescaler  uint16_t TIM_ICInitTypeDef::TIM_ICFilter  Specifies the input capture filter. This parameter can be a number between 0x0 and 0xF 22.1.5 TIM_BDTRInitTypeDef TIM_BDTRInitTypeDef is defined in the stm32f30x_tim.h...
  • Page 452: Tim Firmware Driver Api Description

    General-purpose timers (TIM) UM1581 22.2 TIM Firmware driver API description The following section lists the various functions of the TIM library. 22.2.1 Output Compare management functions TIM Driver: how to use it in Output Compare Mode To use the Timer in Output Compare mode, the following steps are mandatory: Enable TIM clock using RCC_APBxPeriphClockCmd(RCC_APBxPeriph_TIMx, ENABLE) function Configure the TIM pins by configuring the corresponding GPIO pins...
  • Page 453: How To Use This Driver

    General-purpose timers (TIM) UM1581  TIM_SelectGC5C2()  TIM_SelectGC5C3()  TIM_OCStructInit()  TIM_SelectOCxM()  TIM_SetCompare1()  TIM_SetCompare2()  TIM_SetCompare3()  TIM_SetCompare4()  TIM_SetCompare5()  TIM_SetCompare6()  TIM_ForcedOC1Config()  TIM_ForcedOC2Config()  TIM_ForcedOC3Config()  TIM_ForcedOC4Config()  TIM_ForcedOC5Config()  TIM_ForcedOC6Config()  TIM_OC1PreloadConfig()  TIM_OC2PreloadConfig() ...
  • Page 454 General-purpose timers (TIM) UM1581  Set/Get Prescaler  Set/Get Autoreload  Counter modes configuration  Set Clock division  Select the One Pulse mode  Update Request Configuration  Update Disable Configuration  Auto-Preload Configuration  Enable/Disable the counter TIM Output Compare management: this group includes all needed functions to configure the Capture/Compare unit used in Output compare mode: ...
  • Page 455: Timebase Management Functions

    General-purpose timers (TIM) UM1581  Select Hall Sensor TIM specific remapping management includes the Remapping configuration of specific timers 22.2.3 TimeBase management functions TIM Driver: how to use it in Timing(Time base) Mode To use the Timer in Timing(Time base) mode, the following steps are mandatory: Enable TIM clock using RCC_APBxPeriphClockCmd(RCC_APBxPeriph_TIMx, ENABLE) function Fill the TIM_TimeBaseInitStruct with the desired parameters.
  • Page 456: Advanced-Control Timers (Tim1 And Tim8) Specific Features

    General-purpose timers (TIM) UM1581  Autoreload value = 0xFFFF  Prescaler value = 0x0000  Counter mode = Up counting  Clock Division = TIM_CKD_DIV1 Fill the TIM_ICInitStruct with the desired parameters including:  TIM Channel: TIM_Channel  TIM Input Capture polarity: TIM_ICPolarity ...
  • Page 457: Interrupts, Dma And Flags Management Functions

    General-purpose timers (TIM) UM1581  TIM_Break2Config()  TIM_Break1Cmd()  TIM_Break2Cmd()  TIM_BDTRStructInit()  TIM_CtrlPWMOutputs()  TIM_SelectCOM()  TIM_CCPreloadControl() 22.2.6 Interrupts, DMA and flags management functions  TIM_ITConfig()  TIM_GenerateEvent()  TIM_GetFlagStatus()  TIM_ClearFlag()  TIM_GetITStatus()  TIM_ClearITPendingBit()  TIM_DMAConfig()  TIM_DMACmd() ...
  • Page 458: Specific Interface Management Functions

    General-purpose timers (TIM) UM1581  void TIM_SelectSlaveMode(TIM_TypeDef* TIMx, uint16_t TIM_SlaveMode);  TIM_SelectInputTrigger()  TIM_SelectOutputTrigger()  TIM_SelectOutputTrigger2()  TIM_SelectSlaveMode()  TIM_SelectMasterSlaveMode()  TIM_ETRConfig() 22.2.9 Specific interface management functions  TIM_EncoderInterfaceConfig()  TIM_SelectHallSensor() 22.2.10 Specific remapping management function  TIM_RemapConfig() 22.2.11 TimeBase management functions 22.2.11.1 TIM_DeInit Function Name void TIM_DeInit (...
  • Page 459 General-purpose timers (TIM) UM1581 configuration information for the specified TIM peripheral.  Return values None.  Notes None. 22.2.11.3 TIM_TimeBaseStructInit Function Name void TIM_TimeBaseStructInit ( TIM_TimeBaseInitTypeDef * TIM_TimeBaseInitStruct) Function Description Fills each TIM_TimeBaseInitStruct member with its default value.  Parameters TIM_TimeBaseInitStruct : : pointer to a TIM_TimeBaseInitTypeDef structure which will be initialized.
  • Page 460 General-purpose timers (TIM) UM1581 22.2.11.5 TIM_CounterModeConfig Function Name void TIM_CounterModeConfig ( TIM_TypeDef * TIMx, uint16_t TIM_CounterMode) Function Description Specifies the TIMx Counter Mode to be used.  Parameters TIMx : where x can be 1, 2, 3, 4 or 8 to select the TIM peripheral.
  • Page 461 General-purpose timers (TIM) UM1581 Autoreload) Function Description Sets the TIMx Autoreload Register value.  Parameters TIMx : where x can be 1, 2, 3, 4, 6 ,7 ,8, 15, 16 or 17 to select the TIM peripheral.  Autoreload : specifies the Autoreload register new value. ...
  • Page 462 General-purpose timers (TIM) UM1581 22.2.11.10 TIM_UpdateDisableConfig Function Name void TIM_UpdateDisableConfig ( TIM_TypeDef * TIMx, FunctionalState NewState) Function Description Enables or Disables the TIMx Update event.  Parameters TIMx : where x can be 1, 2, 3, 4, 6 ,7 ,8, 15, 16 or 17 to select the TIM peripheral.
  • Page 463 General-purpose timers (TIM) UM1581 22.2.11.12 TIM_UIFRemap Function Name void TIM_UIFRemap ( TIM_TypeDef * TIMx, FunctionalState NewState) Function Description Sets or resets the update interrupt flag (UIF)status bit Remapping.  Parameters TIMx : where x can be 1, 2, 3, 4, 6 ,7 ,8, 15, 16 or 17 to select the TIM peripheral.
  • Page 464 General-purpose timers (TIM) UM1581  TIM_OPMode_Single :  TIM_OPMode_Repetitive :  Return values None.  Notes None. 22.2.11.15 TIM_SetClockDivision Function Name void TIM_SetClockDivision ( TIM_TypeDef * TIMx, uint16_t TIM_CKD) Function Description Sets the TIMx Clock Division value.  Parameters TIMx : where x can be 1, 2, 3, 4, 8, 15, 16 or 17, to select the TIM peripheral.
  • Page 465: Output Compare Management Functions

    General-purpose timers (TIM) UM1581 22.2.12 Output Compare management functions 22.2.12.1 TIM_OC1Init Function Name void TIM_OC1Init ( TIM_TypeDef * TIMx, TIM_OCInitTypeDef * TIM_OCInitStruct) Function Description Initializes the TIMx Channel1 according to the specified parameters in the TIM_OCInitStruct.  Parameters TIMx : where x can be 1, 2, 3, 4, 8, 15, 16 or 17, to select the TIM peripheral.
  • Page 466 General-purpose timers (TIM) UM1581 22.2.12.3 TIM_OC3Init Function Name void TIM_OC3Init ( TIM_TypeDef * TIMx, TIM_OCInitTypeDef * TIM_OCInitStruct) Function Description Initializes the TIMx Channel3 according to the specified parameters in the TIM_OCInitStruct.  Parameters TIMx : where x can be 1, 2, 3, 4 or 8 to select the TIM peripheral.
  • Page 467 General-purpose timers (TIM) UM1581 parameters in the TIM_OCInitStruct.  Parameters TIMx : where x can be 1 or 8 to select the TIM peripheral.  TIM_OCInitStruct : pointer to a TIM_OCInitTypeDef structure that contains the configuration information for the specified TIM peripheral. ...
  • Page 468 General-purpose timers (TIM) UM1581 22.2.12.8 TIM_SelectGC5C2 Function Name void TIM_SelectGC5C2 ( TIM_TypeDef * TIMx, FunctionalState NewState) Function Description Selects the TIM Group Channel 5 and Channel 2, OC2REFC is the logical AND of OC2REFC and OC5REF.  Parameters TIMx : where x can be 1 or 8 to select the TIMx peripheral ...
  • Page 469 General-purpose timers (TIM) UM1581  Return values None.  Notes None. 22.2.12.11 TIM_SelectOCxM Function Name void TIM_SelectOCxM ( TIM_TypeDef * TIMx, uint16_t TIM_Channel, uint32_t TIM_OCMode) Function Description Selects the TIM Output Compare Mode.  Parameters TIMx : where x can be 1, 2, 3, 4, 8, 15, 16 or 17 to select the TIM peripheral.
  • Page 470 General-purpose timers (TIM) UM1581 22.2.12.12 TIM_SetCompare1 Function Name void TIM_SetCompare1 ( TIM_TypeDef * TIMx, uint32_t Compare1) Function Description Sets the TIMx Capture Compare1 Register value.  Parameters TIMx : where x can be 1, 2, 3, 4, 8, 15, 16 or 17 to select the TIM peripheral.
  • Page 471 General-purpose timers (TIM) UM1581 value.  Return values None.  Notes None. 22.2.12.15 TIM_SetCompare4 Function Name void TIM_SetCompare4 ( TIM_TypeDef * TIMx, uint32_t Compare4) Function Description Sets the TIMx Capture Compare4 Register value.  Parameters TIMx : where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
  • Page 472 General-purpose timers (TIM) UM1581 22.2.12.17 TIM_SetCompare6 Function Name void TIM_SetCompare6 ( TIM_TypeDef * TIMx, uint32_t Compare6) Function Description Sets the TIMx Capture Compare6 Register value.  Parameters TIMx : where x can be 1 or 8 to select the TIM peripheral. ...
  • Page 473 General-purpose timers (TIM) UM1581  Parameters TIMx : where x can be 1, 2, 3, 4, 8 or 15 to select the TIM peripheral.  TIM_ForcedAction : specifies the forced Action to be set to the output waveform. This parameter can be one of the following values: ...
  • Page 474 General-purpose timers (TIM) UM1581  TIM_ForcedAction : specifies the forced Action to be set to the output waveform. This parameter can be one of the following values:  TIM_ForcedAction_Active : Force active level on OC4REF  TIM_ForcedAction_InActive : Force inactive level on OC4REF.
  • Page 475 General-purpose timers (TIM) UM1581 OC5REF  TIM_ForcedAction_InActive : Force inactive level on OC5REF.  Return values None.  Notes None. 22.2.12.24 TIM_OC1PreloadConfig Function Name void TIM_OC1PreloadConfig ( TIM_TypeDef * TIMx, uint16_t TIM_OCPreload) Function Description Enables or disables the TIMx peripheral Preload register on CCR1.
  • Page 476 General-purpose timers (TIM) UM1581 22.2.12.26 TIM_OC3PreloadConfig Function Name void TIM_OC3PreloadConfig ( TIM_TypeDef * TIMx, uint16_t TIM_OCPreload) Function Description Enables or disables the TIMx peripheral Preload register on CCR3.  Parameters TIMx : where x can be 1, 2, 3, 4 or 8 to select the TIM peripheral.
  • Page 477 General-purpose timers (TIM) UM1581 22.2.12.28 TIM_OC5PreloadConfig Function Name void TIM_OC5PreloadConfig ( TIM_TypeDef * TIMx, uint16_t TIM_OCPreload) Function Description Enables or disables the TIMx peripheral Preload register on CCR5.  Parameters TIMx : where x can be 1 or 8 to select the TIM peripheral. ...
  • Page 478 General-purpose timers (TIM) UM1581  Parameters TIMx : where x can be 1, 2, 3, 4, 8, 15, 16 or 17 to select the TIM peripheral.  TIM_OCFast : new state of the Output Compare Fast Enable Bit. This parameter can be one of the following values: ...
  • Page 479 General-purpose timers (TIM) UM1581 disable  Return values None.  Notes None. 22.2.12.33 TIM_OC4FastConfig Function Name void TIM_OC4FastConfig ( TIM_TypeDef * TIMx, uint16_t TIM_OCFast) Function Description Configures the TIMx Output Compare 4 Fast feature.  Parameters TIMx : where x can be 1, 2, 3, 4 or 8 to select the TIM peripheral.
  • Page 480 General-purpose timers (TIM) UM1581 22.2.12.35 TIM_ClearOC2Ref Function Name void TIM_ClearOC2Ref ( TIM_TypeDef * TIMx, uint16_t TIM_OCClear) Function Description Clears or safeguards the OCREF2 signal on an external event.  Parameters TIMx : where x can be 1, 2, 3, 4, 8 or 15 to select the TIM peripheral.
  • Page 481 General-purpose timers (TIM) UM1581 22.2.12.37 TIM_ClearOC4Ref Function Name void TIM_ClearOC4Ref ( TIM_TypeDef * TIMx, uint16_t TIM_OCClear) Function Description Clears or safeguards the OCREF4 signal on an external event.  Parameters TIMx : where x can be 1, 2, 3, 4 or 8 to select the TIM peripheral.
  • Page 482 General-purpose timers (TIM) UM1581  Parameters TIMx : where x can be 1 or 8 to select the TIM peripheral.  TIM_OCClear : new state of the Output Compare Clear Enable Bit. This parameter can be one of the following values: ...
  • Page 483 General-purpose timers (TIM) UM1581  Return values None.  Notes None. 22.2.12.42 TIM_OC1NPolarityConfig Function Name void TIM_OC1NPolarityConfig ( TIM_TypeDef * TIMx, uint16_t TIM_OCNPolarity) Function Description Configures the TIMx Channel 1N polarity.  Parameters TIMx : where x can be 1, 8, 15, 16 or 17 to select the TIM peripheral.
  • Page 484 General-purpose timers (TIM) UM1581 22.2.12.44 TIM_OC2NPolarityConfig Function Name void TIM_OC2NPolarityConfig ( TIM_TypeDef * TIMx, uint16_t TIM_OCNPolarity) Function Description Configures the TIMx Channel 2N polarity.  Parameters TIMx : where x can be 1 or 8 to select the TIM peripheral. ...
  • Page 485 General-purpose timers (TIM) UM1581  Parameters TIMx : where x can be 1 or 8 to select the TIM peripheral.  TIM_OCNPolarity : specifies the OC3N Polarity This parameter can be one of the following values:  TIM_OCNPolarity_High : Output Compare active high ...
  • Page 486 General-purpose timers (TIM) UM1581 22.2.12.49 TIM_OC6PolarityConfig Function Name void TIM_OC6PolarityConfig ( TIM_TypeDef * TIMx, uint16_t TIM_OCPolarity) Function Description Configures the TIMx channel 6 polarity.  Parameters TIMx : where x can be 1 or 8 to select the TIM peripheral. ...
  • Page 487: Input Capture Management Functions

    General-purpose timers (TIM) UM1581 22.2.12.51 TIM_CCxNCmd Function Name void TIM_CCxNCmd ( TIM_TypeDef * TIMx, uint16_t TIM_Channel, uint16_t TIM_CCxN) Function Description Enables or disables the TIM Capture Compare Channel xN.  Parameters TIMx : where x can be 1, 8, 15, 16 or 17 to select the TIM peripheral.
  • Page 488 General-purpose timers (TIM) UM1581 22.2.13.2 TIM_ICStructInit Function Name void TIM_ICStructInit ( TIM_ICInitTypeDef * TIM_ICInitStruct) Function Description Fills each TIM_ICInitStruct member with its default value.  Parameters TIM_ICInitStruct : pointer to a TIM_ICInitTypeDef structure which will be initialized.  Return values None.
  • Page 489 General-purpose timers (TIM) UM1581 22.2.13.5 TIM_GetCapture2 Function Name uint32_t TIM_GetCapture2 ( TIM_TypeDef * TIMx) Function Description Gets the TIMx Input Capture 2 value.  Parameters TIMx : where x can be 1, 2, 3, 4, 8 or 15 to select the TIM peripheral.
  • Page 490 General-purpose timers (TIM) UM1581 22.2.13.8 TIM_SetIC1Prescaler Function Name void TIM_SetIC1Prescaler ( TIM_TypeDef * TIMx, uint16_t TIM_ICPSC) Function Description Sets the TIMx Input Capture 1 prescaler.  Parameters TIMx : where x can be 1, 2, 3, 4, 8, 15, 16 or 17 to select the TIM peripheral.
  • Page 491 General-purpose timers (TIM) UM1581 22.2.13.10 TIM_SetIC3Prescaler Function Name void TIM_SetIC3Prescaler ( TIM_TypeDef * TIMx, uint16_t TIM_ICPSC) Function Description Sets the TIMx Input Capture 3 prescaler.  Parameters TIMx : where x can be 1, 2, 3, 4 or 8 to select the TIM peripheral.
  • Page 492: Advanced-Control Timers (Tim1, Tim8) Specific Features

    General-purpose timers (TIM) UM1581 22.2.14 Advanced-control timers (TIM1, TIM8) specific features 22.2.14.1 TIM_BDTRConfig Function Name void TIM_BDTRConfig ( TIM_TypeDef * TIMx, TIM_BDTRInitTypeDef * TIM_BDTRInitStruct) Function Description Configures the Break feature, dead time, Lock level, OSSI/OSSR State and the AOE(automatic output enable). ...
  • Page 493 General-purpose timers (TIM) UM1581 22.2.14.3 TIM_Break2Config Function Name void TIM_Break2Config ( TIM_TypeDef * TIMx, uint32_t TIM_Break2Polarity, uint8_t TIM_Break2Filter) Function Description Configures the Break2 feature.  Parameters TIMx : where x can be 1 or 8 to select the TIM  TIM_Break2Polarity : specifies the Break2 polarity.
  • Page 494 General-purpose timers (TIM) UM1581  Parameters TIMx : where x can be 1 or 8 to select the TIMx peripheral.  NewState : new state of the TIM Break2 input. This parameter can be: ENABLE or DISABLE.  Return values None.
  • Page 495: Interrupts Dma And Flags Management Functions

    General-purpose timers (TIM) UM1581 22.2.14.8 TIM_SelectCOM Function Name void TIM_SelectCOM ( TIM_TypeDef * TIMx, FunctionalState NewState) Function Description Selects the TIM peripheral Commutation event.  Parameters TIMx : where x can be 1, 8, 15, 16 or 17 to select the TIMx peripheral ...
  • Page 496 General-purpose timers (TIM) UM1581  TIM_IT : specifies the TIM interrupts sources to be enabled or disabled. This parameter can be any combination of the following values:  TIM_IT_Update : TIM update Interrupt source  TIM_IT_CC1 : TIM Capture Compare 1 Interrupt source ...
  • Page 497 General-purpose timers (TIM) UM1581  TIM_EventSource_Trigger : Timer Trigger Event source  TIM_EventSource_Break : Timer Break event source  Return values None.  Notes TIM6 and TIM7 can only generate an update event.  TIM_EventSource_COM and TIM_EventSource_Break are used only with TIM1 and TIM8. 22.2.15.3 TIM_GetFlagStatus Function Name FlagStatus TIM_GetFlagStatus (...
  • Page 498 General-purpose timers (TIM) UM1581 22.2.15.4 TIM_ClearFlag Function Name void TIM_ClearFlag ( TIM_TypeDef * TIMx, uint16_t TIM_FLAG) Function Description Clears the TIMx's pending flags.  Parameters TIMx : where x can be 1, 2, 3, 4, 6, 7, 8, 15, 16 or 17 to select the TIM peripheral.
  • Page 499 General-purpose timers (TIM) UM1581  TIM_IT_Update : TIM update Interrupt source  TIM_IT_CC1 : TIM Capture Compare 1 Interrupt source  TIM_IT_CC2 : TIM Capture Compare 2 Interrupt source  TIM_IT_CC3 : TIM Capture Compare 3 Interrupt source  TIM_IT_CC4 : TIM Capture Compare 4 Interrupt source ...
  • Page 500 General-purpose timers (TIM) UM1581 22.2.15.7 TIM_DMAConfig Function Name void TIM_DMAConfig ( TIM_TypeDef * TIMx, uint16_t TIM_DMABase, uint16_t TIM_DMABurstLength) Function Description Configures the TIMx's DMA interface.  Parameters TIMx : where x can be 1, 2, 3, 4 or 8 to select the TIM peripheral.
  • Page 501: Clock Management Functions

    General-purpose timers (TIM) UM1581  TIM_DMASource : specifies the DMA Request sources. This parameter can be any combination of the following values:  TIM_DMA_Update : TIM update Interrupt source  TIM_DMA_CC1 : TIM Capture Compare 1 DMA source  TIM_DMA_CC2 : TIM Capture Compare 2 DMA source ...
  • Page 502 General-purpose timers (TIM) UM1581 22.2.16.2 TIM_ITRxExternalClockConfig Function Name void TIM_ITRxExternalClockConfig ( TIM_TypeDef * TIMx, uint16_t TIM_InputTriggerSource) Function Description Configures the TIMx Internal Trigger as External Clock.  Parameters TIMx : where x can be 1, 2, 3, 4, 8 or 15 to select the TIM peripheral.
  • Page 503 General-purpose timers (TIM) UM1581 value between 0x0 and 0xF.  Return values None.  Notes None. 22.2.16.4 TIM_ETRClockMode1Config Function Name void TIM_ETRClockMode1Config ( TIM_TypeDef * TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter) Function Description Configures the External clock Mode1.  Parameters TIMx : where x can be 1, 2, 3, 4 or 8 to select the TIM peripheral.
  • Page 504: Synchronization Management Functions

    General-purpose timers (TIM) UM1581 peripheral.  TIM_ExtTRGPrescaler : The external Trigger Prescaler. This parameter can be one of the following values:  TIM_ExtTRGPSC_OFF : ETRP Prescaler OFF.  TIM_ExtTRGPSC_DIV2 : ETRP frequency divided by 2.  TIM_ExtTRGPSC_DIV4 : ETRP frequency divided by 4. ...
  • Page 505 General-purpose timers (TIM) UM1581 22.2.17.2 TIM_SelectOutputTrigger Function Name void TIM_SelectOutputTrigger ( TIM_TypeDef * TIMx, uint16_t TIM_TRGOSource) Function Description Selects the TIMx Trigger Output Mode.  Parameters TIMx : where x can be 1, 2, 3, 4, 5, 6, 7, 8 or 15 to select the TIM peripheral.
  • Page 506 General-purpose timers (TIM) UM1581 when the trigger signal (TRGI) is high  TIM_SlaveMode_Trigger : The counter starts at a rising edge of the trigger TRGI  TIM_SlaveMode_External1 : Rising edges of the selected trigger (TRGI) clock the counter  TIM_SlaveMode_Combined_ResetTrigger : Rising edge of the selected trigger input (TRGI) reinitializes the counter, generates an update of the registers and starts...
  • Page 507: Specific Interface Management Functions

    General-purpose timers (TIM) UM1581 This parameter can be one of the following values:  TIM_ExtTRGPSC_OFF : ETRP Prescaler OFF.  TIM_ExtTRGPSC_DIV2 : ETRP frequency divided by 2.  TIM_ExtTRGPSC_DIV4 : ETRP frequency divided by 4.  TIM_ExtTRGPSC_DIV8 : ETRP frequency divided by 8. ...
  • Page 508: Specific Remapping Management Functions

    General-purpose timers (TIM) UM1581  Notes None. 22.2.18.2 TIM_SelectHallSensor Function Name void TIM_SelectHallSensor ( TIM_TypeDef * TIMx, FunctionalState NewState) Function Description Enables or disables the TIMx's Hall sensor interface.  Parameters TIMx : where x can be 1, 2, 3, 4, 8 or 15 to select the TIM peripheral.
  • Page 509: Tim Firmware Driver Defines

    General-purpose timers (TIM) UM1581  TIM1_ADC4_AWDG1 : TIM1 ETR is connected to ADC4 AWDG1.  TIM1_ADC4_AWDG2 : TIM1 ETR is connected to ADC4 AWDG2.  TIM1_ADC4_AWDG3 : TIM1 ETR is connected to ADC4 AWDG3.  TIM8_ADC2_AWDG1 : TIM8 ETR is connected to ADC2 AWDG1.
  • Page 510 General-purpose timers (TIM) UM1581  #define: TIM_Break1Polarity_Low ((uint32_t)0x00000000)  #define: TIM_Break1Polarity_High ((uint32_t)0x00002000) TIM_Break2_Input_enable_disable  #define: TIM_Break2_Enable ((uint32_t)0x01000000)  #define: TIM_Break2_Disable ((uint32_t)0x00000000) TIM_Break2_Polarity  #define: TIM_Break2Polarity_Low ((uint32_t)0x00000000)  #define: TIM_Break2Polarity_High ((uint32_t)0x02000000) TIM_Break_Input_enable_disable  #define: TIM_Break_Enable ((uint16_t)0x1000)  #define: TIM_Break_Disable ((uint16_t)0x0000) TIM_Break_Polarity ...
  • Page 511 General-purpose timers (TIM) UM1581  #define: TIM_CCxN_Disable ((uint16_t)0x0000) TIM_Capture_Compare_State  #define: TIM_CCx_Enable ((uint16_t)0x0001)  #define: TIM_CCx_Disable ((uint16_t)0x0000) TIM_Channel  #define: TIM_Channel_1 ((uint16_t)0x0000)  #define: TIM_Channel_2 ((uint16_t)0x0004)  #define: TIM_Channel_3 ((uint16_t)0x0008)  #define: TIM_Channel_4 ((uint16_t)0x000C)  #define: TIM_Channel_5 ((uint16_t)0x0010)  #define: TIM_Channel_6 ((uint16_t)0x0014) TIM_Clock_Division_CKD ...
  • Page 512 General-purpose timers (TIM) UM1581  #define: TIM_CKD_DIV4 ((uint16_t)0x0200) TIM_Counter_Mode  #define: TIM_CounterMode_Up ((uint16_t)0x0000)  #define: TIM_CounterMode_Down ((uint16_t)0x0010)  #define: TIM_CounterMode_CenterAligned1 ((uint16_t)0x0020)  #define: TIM_CounterMode_CenterAligned2 ((uint16_t)0x0040)  #define: TIM_CounterMode_CenterAligned3 ((uint16_t)0x0060) TIM_DMA_Base_address  #define: TIM_DMABase_CR1 ((uint16_t)0x0000)  #define: TIM_DMABase_CR2 ((uint16_t)0x0001)  #define: TIM_DMABase_SMCR ((uint16_t)0x0002) ...
  • Page 513 General-purpose timers (TIM) UM1581  #define: TIM_DMABase_EGR ((uint16_t)0x0005)  #define: TIM_DMABase_CCMR1 ((uint16_t)0x0006)  #define: TIM_DMABase_CCMR2 ((uint16_t)0x0007)  #define: TIM_DMABase_CCER ((uint16_t)0x0008)  #define: TIM_DMABase_CNT ((uint16_t)0x0009)  #define: TIM_DMABase_PSC ((uint16_t)0x000A)  #define: TIM_DMABase_ARR ((uint16_t)0x000B)  #define: TIM_DMABase_RCR ((uint16_t)0x000C)  #define: TIM_DMABase_CCR1 ((uint16_t)0x000D) ...
  • Page 514 General-purpose timers (TIM) UM1581  #define: TIM_DMABase_BDTR ((uint16_t)0x0011)  #define: TIM_DMABase_DCR ((uint16_t)0x0012)  #define: TIM_DMABase_OR ((uint16_t)0x0013)  #define: TIM_DMABase_CCMR3 ((uint16_t)0x0014)  #define: TIM_DMABase_CCR5 ((uint16_t)0x0015)  #define: TIM_DMABase_CCR6 ((uint16_t)0x0016) TIM_DMA_Burst_Length  #define: TIM_DMABurstLength_1Transfer ((uint16_t)0x0000)  #define: TIM_DMABurstLength_2Transfers ((uint16_t)0x0100)  #define: TIM_DMABurstLength_3Transfers ((uint16_t)0x0200) ...
  • Page 515 General-purpose timers (TIM) UM1581  #define: TIM_DMABurstLength_7Transfers ((uint16_t)0x0600)  #define: TIM_DMABurstLength_8Transfers ((uint16_t)0x0700)  #define: TIM_DMABurstLength_9Transfers ((uint16_t)0x0800)  #define: TIM_DMABurstLength_10Transfers ((uint16_t)0x0900)  #define: TIM_DMABurstLength_11Transfers ((uint16_t)0x0A00)  #define: TIM_DMABurstLength_12Transfers ((uint16_t)0x0B00)  #define: TIM_DMABurstLength_13Transfers ((uint16_t)0x0C00)  #define: TIM_DMABurstLength_14Transfers ((uint16_t)0x0D00)  #define: TIM_DMABurstLength_15Transfers ((uint16_t)0x0E00) ...
  • Page 516 General-purpose timers (TIM) UM1581 TIM_DMA_sources  #define: TIM_DMA_Update ((uint16_t)0x0100)  #define: TIM_DMA_CC1 ((uint16_t)0x0200)  #define: TIM_DMA_CC2 ((uint16_t)0x0400)  #define: TIM_DMA_CC3 ((uint16_t)0x0800)  #define: TIM_DMA_CC4 ((uint16_t)0x1000)  #define: TIM_DMA_COM ((uint16_t)0x2000)  #define: TIM_DMA_Trigger ((uint16_t)0x4000) TIM_Encoder_Mode  #define: TIM_EncoderMode_TI1 ((uint16_t)0x0001)  #define: TIM_EncoderMode_TI2 ((uint16_t)0x0002) ...
  • Page 517 General-purpose timers (TIM) UM1581  #define: TIM_EventSource_CC1 ((uint16_t)0x0002)  #define: TIM_EventSource_CC2 ((uint16_t)0x0004)  #define: TIM_EventSource_CC3 ((uint16_t)0x0008)  #define: TIM_EventSource_CC4 ((uint16_t)0x0010)  #define: TIM_EventSource_COM ((uint16_t)0x0020)  #define: TIM_EventSource_Trigger ((uint16_t)0x0040)  #define: TIM_EventSource_Break ((uint16_t)0x0080)  #define: TIM_EventSource_Break2 ((uint16_t)0x0100) TIM_External_Trigger_Polarity  #define: TIM_ExtTRGPolarity_Inverted ((uint16_t)0x8000) ...
  • Page 518 General-purpose timers (TIM) UM1581  #define: TIM_ExtTRGPSC_DIV2 ((uint16_t)0x1000)  #define: TIM_ExtTRGPSC_DIV4 ((uint16_t)0x2000)  #define: TIM_ExtTRGPSC_DIV8 ((uint16_t)0x3000) TIM_Flags  #define: TIM_FLAG_Update ((uint32_t)0x00001)  #define: TIM_FLAG_CC1 ((uint32_t)0x00002)  #define: TIM_FLAG_CC2 ((uint32_t)0x00004)  #define: TIM_FLAG_CC3 ((uint32_t)0x00008)  #define: TIM_FLAG_CC4 ((uint32_t)0x00010)  #define: TIM_FLAG_COM ((uint32_t)0x00020) ...
  • Page 519 General-purpose timers (TIM) UM1581  #define: TIM_FLAG_CC1OF ((uint32_t)0x00200)  #define: TIM_FLAG_CC2OF ((uint32_t)0x00400)  #define: TIM_FLAG_CC3OF ((uint32_t)0x00800)  #define: TIM_FLAG_CC4OF ((uint32_t)0x01000)  #define: TIM_FLAG_CC5 ((uint32_t)0x10000)  #define: TIM_FLAG_CC6 ((uint32_t)0x20000) TIM_Forced_Action  #define: TIM_ForcedAction_Active ((uint16_t)0x0050)  #define: TIM_ForcedAction_InActive ((uint16_t)0x0040) TIM_Input_Capture_Polarity  #define: TIM_ICPolarity_Rising ((uint16_t)0x0000) ...
  • Page 520 General-purpose timers (TIM) UM1581 TIM_Input_Capture_Prescaler  #define: TIM_ICPSC_DIV1 ((uint16_t)0x0000) Capture performed each time an edge is detected on the capture input.  #define: TIM_ICPSC_DIV2 ((uint16_t)0x0004) Capture performed once every 2 events.  #define: TIM_ICPSC_DIV4 ((uint16_t)0x0008) Capture performed once every 4 events. ...
  • Page 521 General-purpose timers (TIM) UM1581  #define: TIM_TS_TI1F_ED ((uint16_t)0x0040)  #define: TIM_TS_TI1FP1 ((uint16_t)0x0050)  #define: TIM_TS_TI2FP2 ((uint16_t)0x0060)  #define: TIM_TS_ETRF ((uint16_t)0x0070) TIM_interrupt_sources  #define: TIM_IT_Update ((uint16_t)0x0001)  #define: TIM_IT_CC1 ((uint16_t)0x0002)  #define: TIM_IT_CC2 ((uint16_t)0x0004)  #define: TIM_IT_CC3 ((uint16_t)0x0008)  #define: TIM_IT_CC4 ((uint16_t)0x0010) ...
  • Page 522 General-purpose timers (TIM) UM1581 TIM_Legacy  #define: TIM_DMABurstLength_1Byte TIM_DMABurstLength_1Transfer  #define: TIM_DMABurstLength_2Bytes TIM_DMABurstLength_2Transfers  #define: TIM_DMABurstLength_3Bytes TIM_DMABurstLength_3Transfers  #define: TIM_DMABurstLength_4Bytes TIM_DMABurstLength_4Transfers  #define: TIM_DMABurstLength_5Bytes TIM_DMABurstLength_5Transfers  #define: TIM_DMABurstLength_6Bytes TIM_DMABurstLength_6Transfers  #define: TIM_DMABurstLength_7Bytes TIM_DMABurstLength_7Transfers  #define: TIM_DMABurstLength_8Bytes TIM_DMABurstLength_8Transfers  #define: TIM_DMABurstLength_9Bytes TIM_DMABurstLength_9Transfers ...
  • Page 523 General-purpose timers (TIM) UM1581  #define: TIM_DMABurstLength_12Bytes TIM_DMABurstLength_12Transfers  #define: TIM_DMABurstLength_13Bytes TIM_DMABurstLength_13Transfers  #define: TIM_DMABurstLength_14Bytes TIM_DMABurstLength_14Transfers  #define: TIM_DMABurstLength_15Bytes TIM_DMABurstLength_15Transfers  #define: TIM_DMABurstLength_16Bytes TIM_DMABurstLength_16Transfers  #define: TIM_DMABurstLength_17Bytes TIM_DMABurstLength_17Transfers  #define: TIM_DMABurstLength_18Bytes TIM_DMABurstLength_18Transfers TIM_Lock_level  #define: TIM_LOCKLevel_OFF ((uint16_t)0x0000)  #define: TIM_LOCKLevel_1 ((uint16_t)0x0100) ...
  • Page 524 General-purpose timers (TIM) UM1581  #define: TIM_MasterSlaveMode_Disable ((uint16_t)0x0000) TIM_OCReferenceClear  #define: TIM_OCReferenceClear_ETRF ((uint16_t)0x0008)  #define: TIM_OCReferenceClear_OCREFCLR ((uint16_t)0x0000) TIM_One_Pulse_Mode  #define: TIM_OPMode_Single ((uint16_t)0x0008)  #define: TIM_OPMode_Repetitive ((uint16_t)0x0000) TIM_OSSI_Off_State_Selection_for_Idle_mode_state  #define: TIM_OSSIState_Enable ((uint16_t)0x0400)  #define: TIM_OSSIState_Disable ((uint16_t)0x0000) TIM_OSSR_Off_State_Selection_for_Run_mode_state  #define: TIM_OSSRState_Enable ((uint16_t)0x0800) ...
  • Page 525 General-purpose timers (TIM) UM1581  #define: TIM_OCMode_Active ((uint32_t)0x00010)  #define: TIM_OCMode_Inactive ((uint32_t)0x00020)  #define: TIM_OCMode_Toggle ((uint32_t)0x00030)  #define: TIM_OCMode_PWM1 ((uint32_t)0x00060)  #define: TIM_OCMode_PWM2 ((uint32_t)0x00070)  #define: TIM_OCMode_Retrigerrable_OPM1 ((uint32_t)0x10000)  #define: TIM_OCMode_Retrigerrable_OPM2 ((uint32_t)0x10010)  #define: TIM_OCMode_Combined_PWM1 ((uint32_t)0x10040)  #define: TIM_OCMode_Combined_PWM2 ((uint32_t)0x10050) ...
  • Page 526 General-purpose timers (TIM) UM1581  #define: TIM_OCClear_Disable ((uint16_t)0x0000) TIM_Output_Compare_Fast_State  #define: TIM_OCFast_Enable ((uint16_t)0x0004)  #define: TIM_OCFast_Disable ((uint16_t)0x0000) TIM_Output_Compare_Idle_State  #define: TIM_OCIdleState_Set ((uint16_t)0x0100)  #define: TIM_OCIdleState_Reset ((uint16_t)0x0000) TIM_Output_Compare_N_Idle_State  #define: TIM_OCNIdleState_Set ((uint16_t)0x0200)  #define: TIM_OCNIdleState_Reset ((uint16_t)0x0000) TIM_Output_Compare_N_Polarity  #define: TIM_OCNPolarity_High ((uint16_t)0x0000) ...
  • Page 527 General-purpose timers (TIM) UM1581  #define: TIM_OutputNState_Enable ((uint16_t)0x0004) TIM_Output_Compare_Polarity  #define: TIM_OCPolarity_High ((uint16_t)0x0000)  #define: TIM_OCPolarity_Low ((uint16_t)0x0002) TIM_Output_Compare_Preload_State  #define: TIM_OCPreload_Enable ((uint16_t)0x0008)  #define: TIM_OCPreload_Disable ((uint16_t)0x0000) TIM_Output_Compare_State  #define: TIM_OutputState_Disable ((uint16_t)0x0000)  #define: TIM_OutputState_Enable ((uint16_t)0x0001) TIM_Prescaler_Reload_Mode  #define: TIM_PSCReloadMode_Update ((uint16_t)0x0000) ...
  • Page 528 General-purpose timers (TIM) UM1581  #define: TIM16_RTC_CLK ((uint16_t)0x0001)  #define: TIM16_HSEDiv32 ((uint16_t)0x0002)  #define: TIM16_MCO ((uint16_t)0x0003)  #define: TIM1_ADC1_AWDG1 ((uint16_t)0x0001)  #define: TIM1_ADC1_AWDG2 ((uint16_t)0x0002)  #define: TIM1_ADC1_AWDG3 ((uint16_t)0x0003)  #define: TIM1_ADC4_AWDG1 ((uint16_t)0x0004)  #define: TIM1_ADC4_AWDG2 ((uint16_t)0x0008)  #define: TIM1_ADC4_AWDG3 ((uint16_t)0x000C) ...
  • Page 529 General-purpose timers (TIM) UM1581  #define: TIM8_ADC3_AWDG1 ((uint16_t)0x0004)  #define: TIM8_ADC3_AWDG2 ((uint16_t)0x0008)  #define: TIM8_ADC3_AWDG3 ((uint16_t)0x000C) TIM_Slave_Mode  #define: TIM_SlaveMode_Reset ((uint32_t)0x00004)  #define: TIM_SlaveMode_Gated ((uint32_t)0x00005)  #define: TIM_SlaveMode_Trigger ((uint32_t)0x00006)  #define: TIM_SlaveMode_External1 ((uint32_t)0x00007)  #define: TIM_SlaveMode_Combined_ResetTrigger ((uint32_t)0x10000) TIM_TIx_External_Clock_Source  #define: TIM_TIxExternalCLK1Source_TI1 ((uint16_t)0x0050) ...
  • Page 530 General-purpose timers (TIM) UM1581  #define: TIM_TRGOSource_Reset ((uint16_t)0x0000)  #define: TIM_TRGOSource_Enable ((uint16_t)0x0010)  #define: TIM_TRGOSource_Update ((uint16_t)0x0020)  #define: TIM_TRGOSource_OC1 ((uint16_t)0x0030)  #define: TIM_TRGOSource_OC1Ref ((uint16_t)0x0040)  #define: TIM_TRGOSource_OC2Ref ((uint16_t)0x0050)  #define: TIM_TRGOSource_OC3Ref ((uint16_t)0x0060)  #define: TIM_TRGOSource_OC4Ref ((uint16_t)0x0070)  #define: TIM_TRGO2Source_Reset ((uint32_t)0x00000000) ...
  • Page 531 General-purpose timers (TIM) UM1581  #define: TIM_TRGO2Source_OC1Ref ((uint32_t)0x00400000)  #define: TIM_TRGO2Source_OC2Ref ((uint32_t)0x00500000)  #define: TIM_TRGO2Source_OC3Ref ((uint32_t)0x00600000)  #define: TIM_TRGO2Source_OC4Ref ((uint32_t)0x00700000)  #define: TIM_TRGO2Source_OC5Ref ((uint32_t)0x00800000)  #define: TIM_TRGO2Source_OC6Ref ((uint32_t)0x00900000)  #define: TIM_TRGO2Source_OC4Ref_RisingFalling ((uint32_t)0x00A00000)  #define: TIM_TRGO2Source_OC6Ref_RisingFalling ((uint32_t)0x00B00000)  #define: TIM_TRGO2Source_OC4RefRising_OC6RefRising ((uint32_t)0x00C00000) ...
  • Page 532 General-purpose timers (TIM) UM1581 TIM_Update_Source  #define: TIM_UpdateSource_Global ((uint16_t)0x0000) Source of update is the counter overflow/underflow or the setting of UG bit, or an update generation through the slave mode controller.  #define: TIM_UpdateSource_Regular ((uint16_t)0x0001) Source of update is counter overflow/underflow. 532/584 DocID023800 Rev 1...
  • Page 533: Universal Synchronous Asynchronous Receiver Transmitter (Usart)

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) Universal synchronous asynchronous receiver transmitter (USART) 23.1 USART Firmware driver registers structures 23.1.1 USART_TypeDef USART_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t CR1  __IO uint32_t CR2  __IO uint32_t CR3 ...
  • Page 534: Usart_Inittypedef

    Universal synchronous asynchronous receiver UM1581 transmitter (USART)  USART Request register, Address offset: 0x18  uint16_t USART_TypeDef::RESERVED3  Reserved, 0x1A  __IO uint32_t USART_TypeDef::ISR  USART Interrupt and status register, Address offset: 0x1C  __IO uint32_t USART_TypeDef::ICR  USART Interrupt flag Clear register, Address offset: 0x20 ...
  • Page 535: Usart_Clockinittypedef

    Universal synchronous asynchronous receiver UM1581 transmitter (USART)  Specifies wether the hardware flow control mode is enabled or disabled. This parameter can be a value of USART_Hardware_Flow_Control 23.1.3 USART_ClockInitTypeDef USART_ClockInitTypeDef is defined in the stm32f30x_usart.h Data Fields  uint32_t USART_Clock ...
  • Page 536: Initialization And Configuration Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART)  Configure the desired pin in alternate function by: GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF.  Select the type, pull-up/pull-down and output speed via GPIO_PuPd, GPIO_OType and GPIO_Speed members.  Call GPIO_Init() function. Program the Baud Rate, Word Length , Stop Bit, Parity, Hardware flow control and Mode(Receiver/Transmitter) using the SPI_Init() function.
  • Page 537: Rs485 Mode Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) These parameters can be configured using the USART_ClockInit() function.  USART_DeInit()  USART_Init()  USART_StructInit()  USART_ClockInit()  USART_ClockStructInit()  USART_Cmd()  USART_DirectionModeCmd()  USART_OverSampling8Cmd()  USART_OneBitMethodCmd()  USART_MSBFirstCmd()  USART_DataInvCmd()  USART_InvPinCmd() ...
  • Page 538: Interrupts And Flags Management Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) In this Mode it is advised to use the following function:  void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState).  USART_DMACmd()  USART_DMAReceptionErrorConfig() 23.2.5 Interrupts and flags management functions This subsection provides a set of functions allowing to configure the USART Interrupts sources, Requests and check or clear the flags or pending bits status.
  • Page 539: Stop Mode Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) USART_IT_CM: to indicate the status of Character match interrupt. USART_IT_EOB: to indicate the status of End of block interrupt. USART_IT_RTO: to indicate the status of Receive time out interrupt. USART_IT_CTS: to indicate the status of CTS change interrupt. USART_IT_LBD: to indicate the status of LIN Break detection interrupt.
  • Page 540: Autobaudrate Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) After configuring the source of WakeUp and before entering in Stop Mode USART_STOPModeCmd() function should be called to allow USART WakeUp.  USART_STOPModeCmd()  USART_StopModeWakeUpSourceConfig() 23.2.7 AutoBaudRate functions This subsection provides a set of functions allowing to manage the AutoBaudRate detections.
  • Page 541: Lin Mode Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) Program the Baud rate, Word length = 9 bits, Stop bits, Parity, Mode transmitter or Mode receiver and hardware flow control values using the USART_Init() function. Configures the USART address using the USART_SetAddress() function. Configures the wake up methode (USART_WakeUp_IdleLine or USART_WakeUp_AddressMark) using USART_WakeUpConfig() function only for the slaves.
  • Page 542: Half-Duplex Mode Function

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) 23.2.11 Half-duplex mode function This subsection provides a set of functions allowing to manage the USART Half-duplex communication. The USART can be configured to follow a single-wire half-duplex protocol where the TX and RX lines are internally connected. USART Half duplex communication is possible through the following procedure: Program the Baud rate, Word length, Stop bits, Parity, Mode transmitter or Mode receiver and hardware flow control values using the USART_Init() function.
  • Page 543: Irda Mode Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART)  Hardware flow control disabled (RTS and CTS signals).  Tx and Rx enabled Optionally you can enable the parity error interrupt using the USART_ITConfig() function. Enable the Smartcard NACK using the USART_SmartCardNACKCmd() function. Enable the Smartcard interface using the USART_SmartCardCmd() function.
  • Page 544: Initialization And Configuration Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) The receiver set up time should be managed by software. The IrDA physical layer specification specifies a minimum of 10 ms delay between transmission and reception (IrDA is a half duplex protocol). In IrDA mode, the following bits must be kept cleared: ...
  • Page 545 Universal synchronous asynchronous receiver UM1581 transmitter (USART)  Notes None. 23.2.14.3 USART_StructInit Function Name void USART_StructInit ( USART_InitTypeDef * USART_InitStruct) Function Description Fills each USART_InitStruct member with its default value.  Parameters USART_InitStruct : pointer to a USART_InitTypeDef structure which will be initialized. ...
  • Page 546 Universal synchronous asynchronous receiver UM1581 transmitter (USART) Function Name void USART_ClockStructInit ( USART_ClockInitTypeDef * USART_ClockInitStruct) Function Description Fills each USART_ClockInitStruct member with its default value.  Parameters USART_ClockInitStruct : pointer to a USART_ClockInitTypeDef structure which will be initialized.  Return values None.
  • Page 547 Universal synchronous asynchronous receiver UM1581 transmitter (USART)  NewState : new state of the USART transfer direction. This parameter can be: ENABLE or DISABLE.  Return values None.  Notes None. 23.2.14.8 USART_OverSampling8Cmd Function Name void USART_OverSampling8Cmd ( USART_TypeDef * USARTx, FunctionalState NewState)
  • Page 548 Universal synchronous asynchronous receiver UM1581 transmitter (USART) 23.2.14.10 USART_MSBFirstCmd Function Name void USART_MSBFirstCmd ( USART_TypeDef * USARTx, FunctionalState NewState) Function Description Enables or disables the USART's most significant bit first transmitted/received following the start bit.  Parameters USARTx : Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
  • Page 549 Universal synchronous asynchronous receiver UM1581 transmitter (USART) 23.2.14.12 USART_InvPinCmd Function Name void USART_InvPinCmd ( USART_TypeDef * USARTx, uint32_t USART_InvPin, FunctionalState NewState) Function Description Enables or disables the Pin(s) active level inversion.  Parameters USARTx : Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
  • Page 550 Universal synchronous asynchronous receiver UM1581 transmitter (USART)  Notes This function has to be called before calling USART_Cmd() function. 23.2.14.14 USART_ReceiverTimeOutCmd Function Name void USART_ReceiverTimeOutCmd ( USART_TypeDef * USARTx, FunctionalState NewState) Function Description Enables or disables the receiver Time Out feature. ...
  • Page 551: Rs485 Mode Function

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) 23.2.14.16 USART_SetPrescaler Function Name void USART_SetPrescaler ( USART_TypeDef * USARTx, uint8_t USART_Prescaler) Function Description Sets the system clock prescaler.  Parameters USARTx : Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
  • Page 552 Universal synchronous asynchronous receiver UM1581 transmitter (USART) Function Description Configures the USART's DE polarity.  Parameters USARTx : Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5. ...
  • Page 553: Dma Transfers Management Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) de-activation of the DE signal  Return values None.  Notes None. 23.2.16 DMA transfers management functions 23.2.16.1 USART_DMACmd Function Name void USART_DMACmd ( USART_TypeDef * USARTx, uint32_t USART_DMAReq, FunctionalState NewState) Function Description Enables or disables the USART's DMA interface.
  • Page 554: Interrupts And Flags Management Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART)  USART_DMAOnError_Enable : DMA receive request enabled when the USART DMA reception error is asserted.  USART_DMAOnError_Disable : DMA receive request disabled when the USART DMA reception error is asserted.  Return values None.
  • Page 555 Universal synchronous asynchronous receiver UM1581 transmitter (USART) 23.2.17.2 USART_RequestCmd Function Name void USART_RequestCmd ( USART_TypeDef * USARTx, uint32_t USART_Request, FunctionalState NewState) Function Description Enables the specified USART's Request.  Parameters USARTx : Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
  • Page 556 Universal synchronous asynchronous receiver UM1581 transmitter (USART)  Return values None.  Notes None. 23.2.17.4 USART_GetFlagStatus Function Name FlagStatus USART_GetFlagStatus ( USART_TypeDef * USARTx, uint32_t USART_FLAG) Function Description Checks whether the specified USART flag is set or not.  Parameters USARTx : Select the USART peripheral.
  • Page 557 Universal synchronous asynchronous receiver UM1581 transmitter (USART) 23.2.17.5 USART_ClearFlag Function Name void USART_ClearFlag ( USART_TypeDef * USARTx, uint32_t USART_FLAG) Function Description Clears the USARTx's pending flags.  Parameters USARTx : Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
  • Page 558 Universal synchronous asynchronous receiver UM1581 transmitter (USART) 23.2.17.6 USART_GetITStatus Function Name ITStatus USART_GetITStatus ( USART_TypeDef * USARTx, uint32_t USART_IT) Function Description Checks whether the specified USART interrupt has occurred or not.  Parameters USARTx : Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
  • Page 559: Stop Mode Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART)  USART_IT_WU : Wake up interrupt.  USART_IT_CM : Character match interrupt.  USART_IT_EOB : End of block interrupt.  USART_IT_RTO : Receive time out interrupt.  USART_IT_CTS : CTS change interrupt.  USART_IT_LBD : LIN Break detection interrupt.
  • Page 560: Data Transfer Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) 23.2.18.2 USART_StopModeWakeUpSourceConfig Function Name void USART_StopModeWakeUpSourceConfig ( USART_TypeDef * USARTx, uint32_t USART_WakeUpSource) Function Description Selects the USART WakeUp method form stop mode.  Parameters USARTx : Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
  • Page 561: Autobaudrate Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) 23.2.19.2 USART_ReceiveData Function Name uint16_t USART_ReceiveData ( USART_TypeDef * USARTx) Function Description Returns the most recent received data by the USARTx peripheral.  Parameters USARTx : Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
  • Page 562: Multiprocessor Communication Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) USART3 or UART4 or UART5.  USART_AutoBaudRate : specifies the selected USART auto baud rate method. This parameter can be one of the following values:  USART_AutoBaudRate_StartBit : Start Bit duration measurement.  USART_AutoBaudRate_FallingEdge : Falling edge to falling edge measurement.
  • Page 563 Universal synchronous asynchronous receiver UM1581 transmitter (USART) be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.  NewState : new state of the USART mute mode. This parameter can be: ENABLE or DISABLE.  Return values None.
  • Page 564: Lin Mode Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART)  USART_AddressLength_4b : 4-bit address length detection  USART_AddressLength_7b : 7-bit address length detection  Return values None.  Notes None. 23.2.22 LIN mode functions 23.2.22.1 USART_LINBreakDetectLengthConfig Function Name void USART_LINBreakDetectLengthConfig ( USART_TypeDef USARTx, uint32_t USART_LINBreakDetectLength) Function Description Sets the USART LIN Break detection length.
  • Page 565: Halfduplex Mode Function

    Universal synchronous asynchronous receiver UM1581 transmitter (USART)  NewState : new state of the USART LIN mode. This parameter can be: ENABLE or DISABLE.  Return values None.  Notes None. 23.2.23 Halfduplex mode function 23.2.23.1 USART_HalfDuplexCmd Function Name void USART_HalfDuplexCmd ( USART_TypeDef * USARTx, FunctionalState...
  • Page 566 Universal synchronous asynchronous receiver UM1581 transmitter (USART) 23.2.24.2 USART_SmartCardCmd Function Name void USART_SmartCardCmd ( USART_TypeDef * USARTx, FunctionalState NewState) Function Description Enables or disables the USART's Smart Card mode.  Parameters USARTx : Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3.
  • Page 567: Irda Mode Functions

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) 23.2.24.4 USART_SetAutoRetryCount Function Name void USART_SetAutoRetryCount ( USART_TypeDef * USARTx, uint8_t USART_AutoCount) Function Description Sets the Smart Card number of retries in transmit and receive.  Parameters USARTx : Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3.
  • Page 568: Usart Firmware Driver Defines

    Universal synchronous asynchronous receiver UM1581 transmitter (USART) Function Description Configures the USART's IrDA interface.  Parameters USARTx : Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5. ...
  • Page 569 Universal synchronous asynchronous receiver UM1581 transmitter (USART) USART_AutoBaudRate_Mode  #define: USART_AutoBaudRate_StartBit ((uint32_t)0x00000000)  #define: USART_AutoBaudRate_FallingEdge USART_CR2_ABRMODE_0  #define: USART_AutoBaudRate_0x7FFrame USART_CR2_ABRMODE_1  #define: USART_AutoBaudRate_0x55Frame (USART_CR2_ABRMODE_0 | USART_CR2_ABRMODE_1) USART_Clock  #define: USART_Clock_Disable ((uint32_t)0x00000000)  #define: USART_Clock_Enable USART_CR2_CLKEN USART_Clock_Phase  #define: USART_CPHA_1Edge ((uint32_t)0x00000000) ...
  • Page 570 Universal synchronous asynchronous receiver UM1581 transmitter (USART) USART_DE_Polarity  #define: USART_DEPolarity_High ((uint32_t)0x00000000)  #define: USART_DEPolarity_Low USART_CR3_DEP USART_DMA_Recception_Error  #define: USART_DMAOnError_Enable ((uint32_t)0x00000000)  #define: USART_DMAOnError_Disable USART_CR3_DDRE USART_DMA_Requests  #define: USART_DMAReq_Tx USART_CR3_DMAT  #define: USART_DMAReq_Rx USART_CR3_DMAR USART_Flags  #define: USART_FLAG_REACK USART_ISR_REACK  #define: USART_FLAG_TEACK USART_ISR_TEACK ...
  • Page 571 Universal synchronous asynchronous receiver UM1581 transmitter (USART)  #define: USART_FLAG_CM USART_ISR_CMF  #define: USART_FLAG_BUSY USART_ISR_BUSY  #define: USART_FLAG_ABRF USART_ISR_ABRF  #define: USART_FLAG_ABRE USART_ISR_ABRE  #define: USART_FLAG_EOB USART_ISR_EOBF  #define: USART_FLAG_RTO USART_ISR_RTOF  #define: USART_FLAG_nCTSS USART_ISR_CTS  #define: USART_FLAG_CTS USART_ISR_CTSIF  #define: USART_FLAG_LBD USART_ISR_LBD ...
  • Page 572 Universal synchronous asynchronous receiver UM1581 transmitter (USART)  #define: USART_FLAG_IDLE USART_ISR_IDLE  #define: USART_FLAG_ORE USART_ISR_ORE  #define: USART_FLAG_NE USART_ISR_NE  #define: USART_FLAG_FE USART_ISR_FE  #define: USART_FLAG_PE USART_ISR_PE USART_Hardware_Flow_Control  #define: USART_HardwareFlowControl_None ((uint32_t)0x00000000)  #define: USART_HardwareFlowControl_RTS USART_CR3_RTSE  #define: USART_HardwareFlowControl_CTS USART_CR3_CTSE ...
  • Page 573 Universal synchronous asynchronous receiver UM1581 transmitter (USART)  #define: USART_IT_EOB ((uint32_t)0x000C011B)  #define: USART_IT_RTO ((uint32_t)0x000B011A)  #define: USART_IT_PE ((uint32_t)0x00000108)  #define: USART_IT_TXE ((uint32_t)0x00070107)  #define: USART_IT_TC ((uint32_t)0x00060106)  #define: USART_IT_RXNE ((uint32_t)0x00050105)  #define: USART_IT_IDLE ((uint32_t)0x00040104)  #define: USART_IT_LBD ((uint32_t)0x00080206)  #define: USART_IT_CTS ((uint32_t)0x0009030A) ...
  • Page 574 Universal synchronous asynchronous receiver UM1581 transmitter (USART)  #define: USART_IT_FE ((uint32_t)0x00010300) USART_Inversion_Pins  #define: USART_InvPin_Tx USART_CR2_TXINV  #define: USART_InvPin_Rx USART_CR2_RXINV USART_IrDA_Low_Power  #define: USART_IrDAMode_LowPower USART_CR3_IRLP  #define: USART_IrDAMode_Normal ((uint32_t)0x00000000) USART_Last_Bit  #define: USART_LastBit_Disable ((uint32_t)0x00000000)  #define: USART_LastBit_Enable USART_CR2_LBCL USART_LIN_Break_Detection_Length  #define: USART_LINBreakDetectLength_10b ((uint32_t)0x00000000) ...
  • Page 575 Universal synchronous asynchronous receiver UM1581 transmitter (USART)  #define: USART_Mode_Tx USART_CR1_TE USART_MuteMode_WakeUp_methods  #define: USART_WakeUp_IdleLine ((uint32_t)0x00000000)  #define: USART_WakeUp_AddressMark USART_CR1_WAKE USART_OVR_DETECTION  #define: USART_OVRDetection_Enable ((uint32_t)0x00000000)  #define: USART_OVRDetection_Disable USART_CR3_OVRDIS USART_Parity  #define: USART_Parity_No ((uint32_t)0x00000000)  #define: USART_Parity_Even USART_CR1_PCE  #define: USART_Parity_Odd (USART_CR1_PCE | USART_CR1_PS) USART_Request ...
  • Page 576 Universal synchronous asynchronous receiver UM1581 transmitter (USART)  #define: USART_Request_RXFRQ USART_RQR_RXFRQ  #define: USART_Request_TXFRQ USART_RQR_TXFRQ USART_StopMode_WakeUp_methods  #define: USART_WakeUpSource_AddressMatch ((uint32_t)0x00000000)  #define: USART_WakeUpSource_StartBit USART_CR3_WUS_1  #define: USART_WakeUpSource_RXNE (uint32_t)(USART_CR3_WUS_0 | USART_CR3_WUS_1) USART_Stop_Bits  #define: USART_StopBits_1 ((uint32_t)0x00000000)  #define: USART_StopBits_2 USART_CR2_STOP_1  #define: USART_StopBits_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) USART_Word_Length ...
  • Page 577: Window Watchdog (Wwdg)

    Window watchdog (WWDG) UM1581 Window watchdog (WWDG) 24.1 WWDG Firmware driver registers structures 24.1.1 WWDG_TypeDef WWDG_TypeDef is defined in the stm32f30x.h Data Fields  __IO uint32_t CR  __IO uint32_t CFR  __IO uint32_t SR Field Documentation  __IO uint32_t WWDG_TypeDef::CR ...
  • Page 578: How To Use This Driver

    Window watchdog (WWDG) UM1581 24.2.2 How to use this driver Enable WWDG clock using RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, ENABLE) function. Configure the WWDG prescaler using WWDG_SetPrescaler() function. Configure the WWDG refresh window using WWDG_SetWindowValue() function. Set the WWDG counter value and start it using WWDG_Enable() function. When the WWDG is enabled the counter value should be configured to a value greater than 0x40 to prevent generating an immediate reset.
  • Page 579 Window watchdog (WWDG) UM1581 24.2.6.2 WWDG_SetPrescaler Function Name void WWDG_SetPrescaler ( uint32_t WWDG_Prescaler) Function Description Sets the WWDG Prescaler.  Parameters WWDG_Prescaler : specifies the WWDG Prescaler. This parameter can be one of the following values:  WWDG_Prescaler_1 : WWDG counter clock = (PCLK1/4096)/1 ...
  • Page 580: Wwdg Activation Functions

    Window watchdog (WWDG) UM1581 24.2.6.4 WWDG_EnableIT Function Name void WWDG_EnableIT ( void ) Function Description Enables the WWDG Early Wakeup interrupt(EWI).  Parameters None.  Return values None.  Notes Once enabled this interrupt cannot be disabled except by a system reset.
  • Page 581: Interrupts And Flags Management Functions

    Window watchdog (WWDG) UM1581 24.2.8 Interrupts and flags management functions 24.2.8.1 WWDG_GetFlagStatus Function Name FlagStatus WWDG_GetFlagStatus ( void ) Function Description Checks whether the Early Wakeup interrupt flag is set or not.  Parameters None.  Return values The new state of the Early Wakeup interrupt flag (SET or RESET).
  • Page 582 Window watchdog (WWDG) UM1581  #define: WWDG_Prescaler_4 ((uint32_t)0x00000100)  #define: WWDG_Prescaler_8 ((uint32_t)0x00000180) 582/584 DocID023800 Rev 1...
  • Page 583: Revision History

    Revision history UM1581 Revision history Table 16: Revision history Date Revision Changes 25-Oct-2012 Initial release. DocID023800 Rev 1 583/584...
  • Page 584 If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein.

This manual is also suitable for:

Stm32f30xx

Table of Contents